Merge pull request #829 from neuroscr/file-notoken

Make private attachments use generic token
pull/836/head
Ryan Tharp 5 years ago committed by GitHub
commit e6f5f4e718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,8 @@
'', // no pubkey needed '', // no pubkey needed
window.getDefaultFileServer() window.getDefaultFileServer()
); );
// use the anonymous access token
window.tokenlessFileServerAdnAPI.token = 'loki';
window.tokenlessFileServerAdnAPI.pubKey = window.Signal.Crypto.base64ToArrayBuffer( window.tokenlessFileServerAdnAPI.pubKey = window.Signal.Crypto.base64ToArrayBuffer(
LokiFileServerAPI.secureRpcPubKey LokiFileServerAPI.secureRpcPubKey
); );

@ -599,14 +599,14 @@ class LokiAppDotNetServerAPI {
`serverRequest ${mode} error`, `serverRequest ${mode} error`,
e.code, e.code,
e.message, e.message,
`json: ${txtResponse}` `json: ${txtResponse}`, 'attempting connection to', url
); );
} else { } else {
log.info( log.info(
`serverRequest ${mode} error`, `serverRequest ${mode} error`,
e.code, e.code,
e.message, e.message,
'atttempting connection to', 'attempting connection to',
url url
); );
} }

@ -245,6 +245,9 @@ class LokiHomeServerInstance extends LokiFileServerInstance {
isPrimary: isPrimary ? '1' : '0', isPrimary: isPrimary ? '1' : '0',
authorisations, authorisations,
}; };
if (!this.token) {
log.warn('_setOurDeviceMapping no token yet');
}
return this._server.setSelfAnnotation( return this._server.setSelfAnnotation(
DEVICE_MAPPING_USER_ANNOTATION_TYPE, DEVICE_MAPPING_USER_ANNOTATION_TYPE,
content content
@ -269,11 +272,14 @@ class LokiHomeServerInstance extends LokiFileServerInstance {
// you only upload to your own home server // you only upload to your own home server
// you can download from any server... // you can download from any server...
uploadAvatar(data) { uploadAvatar(data) {
if (!this.token) {
log.warn('uploadAvatar no token yet');
}
return this._server.uploadAvatar(data); return this._server.uploadAvatar(data);
} }
uploadPrivateAttachment(data) { static uploadPrivateAttachment(data) {
return this._server.uploadData(data); return window.tokenlessFileServerAdnAPI.uploadData(data);
} }
clearOurDeviceMappingAnnotations() { clearOurDeviceMappingAnnotations() {
@ -298,6 +304,7 @@ class LokiFileServerFactoryAPI {
if (!thisServer) { if (!thisServer) {
thisServer = new LokiHomeServerInstance(this.ourKey); thisServer = new LokiHomeServerInstance(this.ourKey);
log.info(`Registering HomeServer ${serverUrl}`); log.info(`Registering HomeServer ${serverUrl}`);
// not await, so a failure or slow connection doesn't hinder loading of the app
thisServer.establishConnection(serverUrl); thisServer.establishConnection(serverUrl);
this.servers.push(thisServer); this.servers.push(thisServer);
} }

@ -865,7 +865,7 @@ function initialize({
filename: 'attachment', filename: 'attachment',
}); });
return lokiFileServerAPI.uploadPrivateAttachment(formData); return lokiFileServerAPI.constructor.uploadPrivateAttachment(formData);
} }
function putAvatar(bin) { function putAvatar(bin) {

Loading…
Cancel
Save