Skip to content

Commit

Permalink
fixup! feat(backend): Add new method for signing jwt tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikpolik committed Oct 3, 2023
1 parent 0276fc5 commit 2016926
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/backend/src/tokens/jwt/signJwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {
publicJwks,
signingJwks,
} from '../fixtures';
import { hasValidSignature } from './hasValidSignature';
import { __unstable__signJwt } from './signJwt';
import { decodeJwt } from './verifyJwt';
import { decodeJwt, hasValidSignature } from './verifyJwt';

export default (QUnit: QUnit) => {
const { module, test } = QUnit;
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/tokens/jwt/signJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export async function __unstable__signJwt(

const cryptoKey = await importKey(secret, algorithm, 'sign');
const header = options.header || { typ: 'JWT' };

header.alg = options.algorithm;
payload.iat = Math.floor(Date.now() / 1000);

const encodedHeader = encodeJwtData(header);
const encodedPayload = encodeJwtData(payload);
Expand Down

0 comments on commit 2016926

Please sign in to comment.