From 0d403a0e1e0168fb2735fd6ba463ffb4303c646d Mon Sep 17 00:00:00 2001 From: Dmitry Fesenko Date: Thu, 13 May 2021 12:23:54 +0300 Subject: [PATCH] feat: issued claim includes only role info --- src/iam.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/iam.ts b/src/iam.ts index 7fdf0b6e..a1977e3c 100644 --- a/src/iam.ts +++ b/src/iam.ts @@ -1381,7 +1381,13 @@ export class IAM extends IAMBase { if (!this._did) { throw new Error(ERROR_MESSAGES.USER_NOT_LOGGED_IN); } - const issuedToken = await this.issuePublicClaim({ token }); + if (!this._jwt) { + throw new Error(ERROR_MESSAGES.JWT_NOT_INITIALIZED); + } + const { claimType, claimTypeVersion, sub } = this._jwt.decode(token) as { claimType: string; claimTypeVersion: string; sub: string }; + const issuedToken = await this.issuePublicClaim({ + token: await this._jwt.sign({ claimType, claimTypeVersion }, { subject: sub, issuer: this._did }) + }); const message: IClaimIssuance = { id, issuedToken,