From 14894a916e9f5e354633e3389250ed3a97e11e7e Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 2 Jul 2020 15:47:11 +1000 Subject: [PATCH] fix device mapping upload format --- js/modules/loki_file_server_api.js | 20 ++++++++++++++-- ts/test/session/utils/SyncMessage_test.ts | 28 ++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/js/modules/loki_file_server_api.js b/js/modules/loki_file_server_api.js index b6f87b175..8956c7f21 100644 --- a/js/modules/loki_file_server_api.js +++ b/js/modules/loki_file_server_api.js @@ -1,4 +1,4 @@ -/* global log, libloki, window */ +/* global log, libloki, window, dcodeIO */ /* global storage: false */ /* global log: false */ @@ -223,7 +223,23 @@ class LokiHomeServerInstance extends LokiFileServerInstance { this.ourKey ); - return this._setOurDeviceMapping(authorisations, isPrimary); + const authorisationsBase64 = authorisations.map(authorisation => { + const requestSignature = dcodeIO.ByteBuffer.wrap( + authorisation.requestSignature + ).toString('base64'); + const grantSignature = authorisation.grantSignature + ? dcodeIO.ByteBuffer.wrap(authorisation.grantSignature).toString( + 'base64' + ) + : null; + return { + ...authorisation, + requestSignature, + grantSignature, + }; + }); + + return this._setOurDeviceMapping(authorisationsBase64, isPrimary); } // you only upload to your own home server diff --git a/ts/test/session/utils/SyncMessage_test.ts b/ts/test/session/utils/SyncMessage_test.ts index df14f6627..ff6f168d9 100644 --- a/ts/test/session/utils/SyncMessage_test.ts +++ b/ts/test/session/utils/SyncMessage_test.ts @@ -21,22 +21,18 @@ describe('Sync Message Utils', () => { // Fill half with secondaries, half with primaries const numConversations = 20; - const primaryConversations = new Array(numConversations / 2) - .fill({}) - .map( - () => - new TestUtils.MockConversation({ - type: TestUtils.MockConversationType.Primary, - }) - ); - const secondaryConversations = new Array(numConversations / 2) - .fill({}) - .map( - () => - new TestUtils.MockConversation({ - type: TestUtils.MockConversationType.Secondary, - }) - ); + const primaryConversations = new Array(numConversations / 2).fill({}).map( + () => + new TestUtils.MockConversation({ + type: TestUtils.MockConversationType.Primary, + }) + ); + const secondaryConversations = new Array(numConversations / 2).fill({}).map( + () => + new TestUtils.MockConversation({ + type: TestUtils.MockConversationType.Secondary, + }) + ); const conversations = [...primaryConversations, ...secondaryConversations]; const sandbox = sinon.createSandbox();