Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add clear session method #9

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/mailbox/mailbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ export class Mailbox {
return parseInt(messagesNumber, 10);
}

clearSession(url: string) {
const relay = this.relayFactory.getInstance(url);
relay.clearToken();
relay.clearSession();
}

private async encryptSignature(connection: RelayConnectionData) {
const privateKey = Utils.fromBase64(this.keyRing.getPrivateCommKey());
return await EncryptionHelper.encodeMessage(connection.h2Signature, connection.relayPublicKey, privateKey);
Expand Down
4 changes: 2 additions & 2 deletions src/relay/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class Relay {
this.tokenExpirationTimeoutHandle = setTimeout(() => this.clearToken(), config.RELAY_TOKEN_TIMEOUT);
}

private clearToken() {
clearToken() {
if (this.tokenExpirationTimeoutHandle) {
clearTimeout(this.tokenExpirationTimeoutHandle);
}
Expand All @@ -270,7 +270,7 @@ export class Relay {
}, config.RELAY_SESSION_TIMEOUT);
}

private clearSession() {
clearSession() {
if (this.sessionExpirationTimeoutHandle) {
clearTimeout(this.sessionExpirationTimeoutHandle);
}
Expand Down