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
window.getDefaultFileServer()
);
// use the anonymous access token
window.tokenlessFileServerAdnAPI.token = 'loki';
window.tokenlessFileServerAdnAPI.pubKey = window.Signal.Crypto.base64ToArrayBuffer(
LokiFileServerAPI.secureRpcPubKey
);

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

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

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

Loading…
Cancel
Save