Created
May 20, 2021 14:51
-
-
Save marcan2020/94a1ff54783448c87768098b9d840c21 to your computer and use it in GitHub Desktop.
SHC signJws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async signJws(idTokenPayload: Record<string, unknown>, deflate = true): Promise<string> { | |
const bodyString = JSON.stringify(idTokenPayload); | |
const fields = deflate ? { zip: 'DEF' } : {}; | |
const body = deflate ? pako.deflateRaw(bodyString) : bodyString; | |
const signed = await jose.JWS.createSign({ format: 'compact', fields }, this.signingKey) | |
.update(Buffer.from(body)) | |
.final(); | |
return (signed as unknown) as string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment