Skip to content

Commit

Permalink
fix(trustchain): invalid jwt token if trustchain/memberCredentials ch…
Browse files Browse the repository at this point in the history
…anges (#7358)
  • Loading branch information
gre committed Jul 18, 2024
1 parent 53e9dd4 commit 40da39d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/trustchain/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,26 @@ import { TrustchainEjected, TrustchainNotAllowed } from "./errors";

export class SDK implements TrustchainSDK {
private context: TrustchainSDKContext;
private jwt: JWT | undefined = undefined;
private deviceJwt: JWT | undefined = undefined;
private lifecycle?: TrustchainLifecycle;

constructor(context: TrustchainSDKContext, lifecyle?: TrustchainLifecycle) {
this.context = context;
this.lifecycle = lifecyle;
}

private jwt: JWT | undefined = undefined;
private jwtHash = "";
withAuth<T>(
trustchain: Trustchain,
memberCredentials: MemberCredentials,
job: (jwt: JWT) => Promise<T>,
policy?: AuthCachePolicy,
): Promise<T> {
const hash = trustchain.rootId + " " + memberCredentials.pubkey;
if (this.jwtHash !== hash) {
this.jwt = undefined;
this.jwtHash = hash;
}
return genericWithJWT(
jwt => {
this.jwt = jwt;
Expand All @@ -64,6 +69,7 @@ export class SDK implements TrustchainSDK {
);
}

private deviceJwt: JWT | undefined = undefined;
withDeviceAuth<T>(
transport: Transport,
job: (jwt: JWT) => Promise<T>,
Expand Down

0 comments on commit 40da39d

Please sign in to comment.