|
@@ -259,6 +259,10 @@ export class WebClientService {
|
|
|
private batteryStatusTimeout: ng.IPromise<void> = null;
|
|
|
|
|
|
// Other
|
|
|
+ private initParameters: {
|
|
|
+ keyStore?: saltyrtc.KeyStore,
|
|
|
+ peerTrustedKey?: Uint8Array,
|
|
|
+ } = {};
|
|
|
private config: threema.Config;
|
|
|
private container: threema.Container.Factory;
|
|
|
private typingInstance: threema.Container.Typing;
|
|
@@ -451,12 +455,26 @@ export class WebClientService {
|
|
|
public init(flags: {
|
|
|
keyStore?: saltyrtc.KeyStore,
|
|
|
peerTrustedKey?: Uint8Array,
|
|
|
+ reuseKeyStoreAndTrustedKey?: boolean,
|
|
|
resume: boolean,
|
|
|
}): void {
|
|
|
let keyStore = flags.keyStore;
|
|
|
+ let peerTrustedKey = flags.peerTrustedKey;
|
|
|
let resumeSession = flags.resume;
|
|
|
+
|
|
|
+ // Reuse
|
|
|
+ if (flags.reuseKeyStoreAndTrustedKey) {
|
|
|
+ keyStore = this.initParameters.keyStore;
|
|
|
+ peerTrustedKey = this.initParameters.peerTrustedKey;
|
|
|
+ } else {
|
|
|
+ this.initParameters = {
|
|
|
+ keyStore: keyStore,
|
|
|
+ peerTrustedKey: peerTrustedKey,
|
|
|
+ };
|
|
|
+ }
|
|
|
this.log.info(`Initializing (keyStore=${keyStore !== undefined ? 'yes' : 'no'}, peerTrustedKey=` +
|
|
|
- `${flags.peerTrustedKey !== undefined ? 'yes' : 'no'}, resume=${resumeSession})`);
|
|
|
+ `${peerTrustedKey !== undefined ? 'yes' : 'no'}, reuseKeyStoreAndTrustedKey=` +
|
|
|
+ `${flags.reuseKeyStoreAndTrustedKey}, resume=${resumeSession})`);
|
|
|
|
|
|
// Reset fields, blob cache, pending requests and pending timeouts in case the session
|
|
|
// should explicitly not be resumed
|
|
@@ -539,8 +557,8 @@ export class WebClientService {
|
|
|
.withKeyStore(keyStore)
|
|
|
.usingTasks(tasks)
|
|
|
.withPingInterval(30);
|
|
|
- if (flags.peerTrustedKey !== undefined) {
|
|
|
- builder = builder.withTrustedPeerKey(flags.peerTrustedKey);
|
|
|
+ if (peerTrustedKey !== undefined) {
|
|
|
+ builder = builder.withTrustedPeerKey(peerTrustedKey);
|
|
|
}
|
|
|
this.salty = builder.asInitiator();
|
|
|
this.arpLog.info('Public key:', this.salty.permanentKeyHex);
|