Add version number to user-agent header on outgoing requests
This commit is contained in:
parent
be6ae038dc
commit
a271fe0eee
3 changed files with 20 additions and 4 deletions
|
@ -210,7 +210,7 @@ function _promiseAjax(providedUrl, options) {
|
||||||
method: options.type,
|
method: options.type,
|
||||||
body: options.data || null,
|
body: options.data || null,
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Signal Desktop (+https://signal.org/download)',
|
'User-Agent': `Signal Desktop ${options.version}`,
|
||||||
'X-Signal-Agent': 'OWD',
|
'X-Signal-Agent': 'OWD',
|
||||||
...options.headers,
|
...options.headers,
|
||||||
},
|
},
|
||||||
|
@ -413,6 +413,7 @@ function initialize({
|
||||||
certificateAuthority,
|
certificateAuthority,
|
||||||
contentProxyUrl,
|
contentProxyUrl,
|
||||||
proxyUrl,
|
proxyUrl,
|
||||||
|
version,
|
||||||
}) {
|
}) {
|
||||||
if (!is.string(url)) {
|
if (!is.string(url)) {
|
||||||
throw new Error('WebAPI.initialize: Invalid server url');
|
throw new Error('WebAPI.initialize: Invalid server url');
|
||||||
|
@ -426,6 +427,9 @@ function initialize({
|
||||||
if (!is.string(contentProxyUrl)) {
|
if (!is.string(contentProxyUrl)) {
|
||||||
throw new Error('WebAPI.initialize: Invalid contentProxyUrl');
|
throw new Error('WebAPI.initialize: Invalid contentProxyUrl');
|
||||||
}
|
}
|
||||||
|
if (!is.string(version)) {
|
||||||
|
throw new Error('WebAPI.initialize: Invalid version');
|
||||||
|
}
|
||||||
|
|
||||||
// Thanks to function-hoisting, we can put this return statement before all of the
|
// Thanks to function-hoisting, we can put this return statement before all of the
|
||||||
// below function definitions.
|
// below function definitions.
|
||||||
|
@ -489,6 +493,7 @@ function initialize({
|
||||||
type: param.httpType,
|
type: param.httpType,
|
||||||
user: username,
|
user: username,
|
||||||
validateResponse: param.validateResponse,
|
validateResponse: param.validateResponse,
|
||||||
|
version,
|
||||||
unauthenticated: param.unauthenticated,
|
unauthenticated: param.unauthenticated,
|
||||||
accessKey: param.accessKey,
|
accessKey: param.accessKey,
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
@ -576,6 +581,7 @@ function initialize({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,6 +861,7 @@ function initialize({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
redactUrl: redactStickerUrl,
|
redactUrl: redactStickerUrl,
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,6 +872,7 @@ function initialize({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
redactUrl: redactStickerUrl,
|
redactUrl: redactStickerUrl,
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -942,6 +950,7 @@ function initialize({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
processData: false,
|
processData: false,
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Upload stickers
|
// Upload stickers
|
||||||
|
@ -957,6 +966,7 @@ function initialize({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
processData: false,
|
processData: false,
|
||||||
|
version,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (onProgress) {
|
if (onProgress) {
|
||||||
|
@ -977,6 +987,7 @@ function initialize({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,6 +1010,7 @@ function initialize({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
processData: false,
|
processData: false,
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
|
|
||||||
return attachmentIdString;
|
return attachmentIdString;
|
||||||
|
@ -1036,6 +1048,7 @@ function initialize({
|
||||||
redirect: 'follow',
|
redirect: 'follow',
|
||||||
redactUrl: () => '[REDACTED_URL]',
|
redactUrl: () => '[REDACTED_URL]',
|
||||||
headers,
|
headers,
|
||||||
|
version,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!returnArrayBuffer) {
|
if (!returnArrayBuffer) {
|
||||||
|
@ -1071,9 +1084,10 @@ function initialize({
|
||||||
.replace('http://', 'ws://');
|
.replace('http://', 'ws://');
|
||||||
const login = encodeURIComponent(username);
|
const login = encodeURIComponent(username);
|
||||||
const pass = encodeURIComponent(password);
|
const pass = encodeURIComponent(password);
|
||||||
|
const clientVersion = encodeURIComponent(version);
|
||||||
|
|
||||||
return _createSocket(
|
return _createSocket(
|
||||||
`${fixedScheme}/v1/websocket/?login=${login}&password=${pass}&agent=OWD`,
|
`${fixedScheme}/v1/websocket/?login=${login}&password=${pass}&agent=OWD&version=${clientVersion}`,
|
||||||
{ certificateAuthority, proxyUrl }
|
{ certificateAuthority, proxyUrl }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1083,9 +1097,10 @@ function initialize({
|
||||||
const fixedScheme = url
|
const fixedScheme = url
|
||||||
.replace('https://', 'wss://')
|
.replace('https://', 'wss://')
|
||||||
.replace('http://', 'ws://');
|
.replace('http://', 'ws://');
|
||||||
|
const clientVersion = encodeURIComponent(version);
|
||||||
|
|
||||||
return _createSocket(
|
return _createSocket(
|
||||||
`${fixedScheme}/v1/websocket/provisioning/?agent=OWD`,
|
`${fixedScheme}/v1/websocket/provisioning/?agent=OWD&version=${clientVersion}`,
|
||||||
{ certificateAuthority, proxyUrl }
|
{ certificateAuthority, proxyUrl }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ window.WebAPI = initializeWebAPI({
|
||||||
certificateAuthority: config.certificateAuthority,
|
certificateAuthority: config.certificateAuthority,
|
||||||
contentProxyUrl: config.contentProxyUrl,
|
contentProxyUrl: config.contentProxyUrl,
|
||||||
proxyUrl: config.proxyUrl,
|
proxyUrl: config.proxyUrl,
|
||||||
|
version: config.version,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
||||||
|
|
|
@ -273,7 +273,7 @@ function getGotOptions(): GotOptions<null> {
|
||||||
ca,
|
ca,
|
||||||
headers: {
|
headers: {
|
||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache',
|
||||||
'User-Agent': 'Signal Desktop (+https://signal.org/download)',
|
'User-Agent': `Signal Desktop ${packageJson.version}`,
|
||||||
},
|
},
|
||||||
useElectronNet: false,
|
useElectronNet: false,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue