Merge fixes

pull/1176/head
Mikunj 5 years ago
parent 27f4378de8
commit c027490d2f

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

@ -267,7 +267,12 @@ async function handleSecondaryDeviceFriendRequest(pubKey: string) {
if (!c || !(await c.isFriendWithAnyDevice())) { if (!c || !(await c.isFriendWithAnyDevice())) {
return false; 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; return true;
} }

@ -7,7 +7,6 @@ import {
} from '../../../js/modules/data'; } from '../../../js/modules/data';
import { PrimaryPubKey, PubKey, SecondaryPubKey } from '../types'; import { PrimaryPubKey, PubKey, SecondaryPubKey } from '../types';
import { UserUtil } from '../../util'; 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. 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( public static async fetchPairingAuthorisations(
device: PubKey device: PubKey
): Promise<Array<PairingAuthorisation>> { ): Promise<Array<PairingAuthorisation>> {
if (!lokiFileServerAPI) { if (!window.lokiFileServerAPI) {
throw new Error('lokiFileServerAPI is not initialised.'); 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 // TODO: Filter out invalid authorisations
return mapping.authorisations.map( return mapping.authorisations.map(

Loading…
Cancel
Save