UNPKG

@simulacrum/auth0-simulator

Version:

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

1 lines 1.13 kB
{"version":3,"file":"refresh-token.mjs","names":[],"sources":["../../src/auth/refresh-token.ts"],"sourcesContent":["import type { GrantType, RefreshToken } from \"../types.ts\";\nimport { epochTime } from \"./date.ts\";\nimport { encode } from \"base64-url\";\nimport { assert } from \"assert-ts\";\n\nexport function issueRefreshToken(\n scope: string,\n grantType: GrantType\n): boolean {\n return grantType === \"refresh_token\" || scope.includes(\"offline_access\");\n}\n\nexport function createRefreshToken({\n exp,\n rotations = 0,\n scope,\n user,\n nonce,\n}: Omit<RefreshToken, \"iat\">): string {\n assert(!!user.id, `no identifier for user`);\n\n return encode(\n JSON.stringify({\n exp,\n iat: epochTime(),\n rotations,\n scope,\n user: { id: user.id },\n nonce,\n })\n );\n}\n"],"mappings":";;;;;AAKA,SAAgB,kBACd,OACA,WACS;AACT,QAAO,cAAc,mBAAmB,MAAM,SAAS,iBAAiB;;AAG1E,SAAgB,mBAAmB,EACjC,KACA,YAAY,GACZ,OACA,MACA,SACoC;AACpC,QAAO,CAAC,CAAC,KAAK,IAAI,yBAAyB;AAE3C,QAAO,OACL,KAAK,UAAU;EACb;EACA,KAAK,WAAW;EAChB;EACA;EACA,MAAM,EAAE,IAAI,KAAK,IAAI;EACrB;EACD,CAAC,CACH"}