Skip to content

Instantly share code, notes, and snippets.

@marcan2020
Created May 20, 2021 14:51
Show Gist options
  • Save marcan2020/94a1ff54783448c87768098b9d840c21 to your computer and use it in GitHub Desktop.
Save marcan2020/94a1ff54783448c87768098b9d840c21 to your computer and use it in GitHub Desktop.
SHC signJws
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