UNPKG

@simulacrum/auth0-simulator

Version:

Run local instance of Auth0 API for local development and integration testing

1 lines 857 B
{"version":3,"file":"jwt.mjs","names":[],"sources":["../../src/auth/jwt.ts"],"sourcesContent":["import type { SignOptions } from \"jsonwebtoken\";\nimport * as jwt from \"jsonwebtoken\";\nimport { JWKS, PRIVATE_KEY } from \"./constants.ts\";\n\nexport const parseKey = (key: string): string => key.split(\"~~\").join(\"\\n\");\n\ntype SignPayload = Parameters<typeof jwt.sign>[0];\n\nexport function createJsonWebToken<P extends SignPayload>(\n payload: P,\n privateKey = parseKey(PRIVATE_KEY),\n options: SignOptions = {\n algorithm: \"RS256\",\n keyid: JWKS.keys[0].kid,\n }\n): string {\n return jwt.sign(payload, privateKey, options);\n}\n"],"mappings":";;;;AAIA,MAAa,YAAY,QAAwB,IAAI,MAAM,KAAK,CAAC,KAAK,KAAK;AAI3E,SAAgB,mBACd,SACA,aAAa,SAAS,YAAY,EAClC,UAAuB;CACrB,WAAW;CACX,OAAO,KAAK,KAAK,GAAG;CACrB,EACO;AACR,QAAO,IAAI,KAAK,SAAS,YAAY,QAAQ"}