Merge fixes

This commit is contained in:
Mikunj 2020-06-16 13:07:18 +10:00
parent 27f4378de8
commit c027490d2f
3 changed files with 12 additions and 5 deletions

View file

@ -1,5 +1,5 @@
interface DeviceMappingAnnotation {
isPrimary: boolean;
isPrimary: string;
authorisations: Array<{
primaryDevicePubKey: string;
secondaryDevicePubKey: string;
@ -10,4 +10,5 @@ interface DeviceMappingAnnotation {
interface LokiFileServerInstance {
getUserDeviceMapping(pubKey: string): Promise<DeviceMappingAnnotation>;
clearOurDeviceMappingAnnotations(): Promise<void>;
}

View file

@ -267,7 +267,12 @@ async function handleSecondaryDeviceFriendRequest(pubKey: string) {
if (!c || !(await c.isFriendWithAnyDevice())) {
return false;
}
await MultiDeviceProtocol.savePairingAuthorisation(authorisation);
await MultiDeviceProtocol.savePairingAuthorisation({
primaryDevicePubKey: authorisation.primaryDevicePubKey,
secondaryDevicePubKey: authorisation.secondaryDevicePubKey,
requestSignature: Buffer.from(authorisation.requestSignature).buffer,
grantSignature: Buffer.from(authorisation.grantSignature).buffer,
});
return true;
}

View file

@ -7,7 +7,6 @@ import {
} from '../../../js/modules/data';
import { PrimaryPubKey, PubKey, SecondaryPubKey } from '../types';
import { UserUtil } from '../../util';
import { lokiFileServerAPI } from '../../window';
/*
The reason we're exporing a class here instead of just exporting the functions directly is for the sake of testing.
@ -75,11 +74,13 @@ export class MultiDeviceProtocol {
public static async fetchPairingAuthorisations(
device: PubKey
): Promise<Array<PairingAuthorisation>> {
if (!lokiFileServerAPI) {
if (!window.lokiFileServerAPI) {
throw new Error('lokiFileServerAPI is not initialised.');
}
const mapping = await lokiFileServerAPI.getUserDeviceMapping(device.key);
const mapping = await window.lokiFileServerAPI.getUserDeviceMapping(
device.key
);
// TODO: Filter out invalid authorisations
return mapping.authorisations.map(