Skip to content

Commit

Permalink
cmments
Browse files Browse the repository at this point in the history
  • Loading branch information
acharb committed Apr 9, 2024
1 parent 3b8c5f1 commit 72c98d0
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ export class DefaultAuthHeaderSigner implements AuthHeaderSigner {
const issuedAt = Math.floor(Date.now() / 1000);
const timeExp = Math.floor(Date.now() / 1000) + this.expiration;

// turn stellar kp into nacl kp for creating JWT
const rawSeed = StrKey.decodeEd25519SecretSeed(issuer.secretKey);
const naclKP = nacl.sign.keyPair.fromSeed(rawSeed);

// encode JWT message
const header = { alg: "EdDSA", typ: "JWT" };
const encodedHeader = base64url(JSON.stringify(header));
const encodedPayload = base64url(
JSON.stringify({ ...claims, exp: timeExp, iat: issuedAt }),
);

// sign JWT and create siganture
const signature = nacl.sign.detached(
naclUtil.decodeUTF8(`${encodedHeader}.${encodedPayload}`),
naclKP.secretKey,
Expand Down

0 comments on commit 72c98d0

Please sign in to comment.