@warlock.js/auth 5.30.0 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/esm/commands/auth-cleanup-command.d.mts +1 -2
  3. package/esm/commands/auth-cleanup-command.d.mts.map +1 -1
  4. package/esm/commands/auth-purge-never-expiring-command.d.mts +1 -2
  5. package/esm/commands/auth-purge-never-expiring-command.d.mts.map +1 -1
  6. package/esm/commands/auth-purge-never-expiring-command.mjs.map +1 -1
  7. package/esm/commands/jwt-secret-generator-command.d.mts +1 -2
  8. package/esm/commands/jwt-secret-generator-command.d.mts.map +1 -1
  9. package/esm/commands/jwt-secret-generator-command.mjs.map +1 -1
  10. package/esm/contracts/auth-contract.d.mts +1 -3
  11. package/esm/contracts/auth-contract.d.mts.map +1 -1
  12. package/esm/contracts/index.d.mts +2 -1
  13. package/esm/contracts/providers.d.mts +82 -50
  14. package/esm/contracts/providers.d.mts.map +1 -1
  15. package/esm/contracts/request-locals.d.mts +2 -3
  16. package/esm/contracts/request-locals.d.mts.map +1 -1
  17. package/esm/contracts/types.d.mts +59 -43
  18. package/esm/contracts/types.d.mts.map +1 -1
  19. package/esm/errors/auth-provider-sdk-missing.error.d.mts +1 -3
  20. package/esm/errors/auth-provider-sdk-missing.error.d.mts.map +1 -1
  21. package/esm/errors/email-not-verified.error.d.mts +1 -3
  22. package/esm/errors/email-not-verified.error.d.mts.map +1 -1
  23. package/esm/errors/index.d.mts +2 -1
  24. package/esm/errors/index.mjs +1 -1
  25. package/esm/errors/invalid-one-time-token.error.d.mts +1 -3
  26. package/esm/errors/invalid-one-time-token.error.d.mts.map +1 -1
  27. package/esm/errors/invalid-passkey.error.d.mts +1 -3
  28. package/esm/errors/invalid-passkey.error.d.mts.map +1 -1
  29. package/esm/errors/invalid-provider-callback.error.d.mts +1 -3
  30. package/esm/errors/invalid-provider-callback.error.d.mts.map +1 -1
  31. package/esm/errors/notifications-unavailable.error.d.mts +1 -3
  32. package/esm/errors/notifications-unavailable.error.d.mts.map +1 -1
  33. package/esm/errors/provider-email-not-verified.error.d.mts +1 -3
  34. package/esm/errors/provider-email-not-verified.error.d.mts.map +1 -1
  35. package/esm/index.d.mts +8 -0
  36. package/esm/localization/auth-default-translations.d.mts +1 -3
  37. package/esm/localization/auth-default-translations.d.mts.map +1 -1
  38. package/esm/localization/auth-translations.type.d.mts +11 -7
  39. package/esm/localization/auth-translations.type.d.mts.map +1 -1
  40. package/esm/localization/index.mjs +1 -1
  41. package/esm/localization/register-auth-translations.d.mts +1 -2
  42. package/esm/localization/register-auth-translations.d.mts.map +1 -1
  43. package/esm/middleware/auth.middleware.d.mts +10 -10
  44. package/esm/middleware/auth.middleware.d.mts.map +1 -1
  45. package/esm/middleware/auth.middleware.mjs +2 -2
  46. package/esm/middleware/auth.middleware.mjs.map +1 -1
  47. package/esm/middleware/csrf-origin-check.d.mts +4 -6
  48. package/esm/middleware/csrf-origin-check.d.mts.map +1 -1
  49. package/esm/middleware/csrf-origin-check.mjs +1 -1
  50. package/esm/middleware/csrf-origin-check.mjs.map +1 -1
  51. package/esm/middleware/index.d.mts +2 -1
  52. package/esm/middleware/index.mjs +1 -1
  53. package/esm/middleware/login-throttle.middleware.d.mts +4 -6
  54. package/esm/middleware/login-throttle.middleware.d.mts.map +1 -1
  55. package/esm/middleware/login-throttle.middleware.mjs +1 -1
  56. package/esm/middleware/login-throttle.middleware.mjs.map +1 -1
  57. package/esm/middleware/one-time-token-throttle.middleware.d.mts +2 -4
  58. package/esm/middleware/one-time-token-throttle.middleware.d.mts.map +1 -1
  59. package/esm/middleware/otp-throttle.middleware.d.mts +2 -4
  60. package/esm/middleware/otp-throttle.middleware.d.mts.map +1 -1
  61. package/esm/middleware/require-verified-email.middleware.d.mts +1 -3
  62. package/esm/middleware/require-verified-email.middleware.d.mts.map +1 -1
  63. package/esm/models/access-token/access-token.model.d.mts +6 -30
  64. package/esm/models/access-token/access-token.model.d.mts.map +1 -1
  65. package/esm/models/access-token/index.d.mts +2 -1
  66. package/esm/models/access-token/index.mjs +1 -1
  67. package/esm/models/auth-token-family/auth-token-family.model.d.mts +2 -28
  68. package/esm/models/auth-token-family/auth-token-family.model.d.mts.map +1 -1
  69. package/esm/models/auth-token-family/index.d.mts +2 -1
  70. package/esm/models/auth-token-family/index.mjs +1 -1
  71. package/esm/models/auth.model.d.mts +1 -3
  72. package/esm/models/auth.model.d.mts.map +1 -1
  73. package/esm/models/index.d.mts +8 -2
  74. package/esm/models/index.d.mts.map +1 -1
  75. package/esm/models/index.mjs +1 -1
  76. package/esm/models/one-time-token/index.d.mts +2 -1
  77. package/esm/models/one-time-token/index.mjs +1 -1
  78. package/esm/models/one-time-token/one-time-token.model.d.mts +3 -37
  79. package/esm/models/one-time-token/one-time-token.model.d.mts.map +1 -1
  80. package/esm/models/passkey-credential/index.d.mts +2 -1
  81. package/esm/models/passkey-credential/index.mjs +1 -1
  82. package/esm/models/passkey-credential/passkey-credential.model.d.mts +2 -32
  83. package/esm/models/passkey-credential/passkey-credential.model.d.mts.map +1 -1
  84. package/esm/models/provider-account/index.d.mts +2 -1
  85. package/esm/models/provider-account/index.mjs +1 -1
  86. package/esm/models/provider-account/provider-account.model.d.mts +2 -28
  87. package/esm/models/provider-account/provider-account.model.d.mts.map +1 -1
  88. package/esm/models/refresh-token/index.d.mts +2 -1
  89. package/esm/models/refresh-token/index.mjs +1 -1
  90. package/esm/models/refresh-token/refresh-token.model.d.mts +11 -55
  91. package/esm/models/refresh-token/refresh-token.model.d.mts.map +1 -1
  92. package/esm/otp/index.d.mts +2 -1
  93. package/esm/otp/index.mjs +1 -1
  94. package/esm/otp/otp.d.mts +2 -4
  95. package/esm/otp/otp.d.mts.map +1 -1
  96. package/esm/otp/otp.mjs +2 -1
  97. package/esm/otp/otp.mjs.map +1 -1
  98. package/esm/passkeys/index.d.mts +2 -1
  99. package/esm/passkeys/index.mjs +1 -1
  100. package/esm/passkeys/passkey-authentication.d.mts +2 -4
  101. package/esm/passkeys/passkey-authentication.d.mts.map +1 -1
  102. package/esm/passkeys/passkey-authentication.mjs +2 -1
  103. package/esm/passkeys/passkey-authentication.mjs.map +1 -1
  104. package/esm/passkeys/passkey-registration.d.mts +3 -4
  105. package/esm/passkeys/passkey-registration.d.mts.map +1 -1
  106. package/esm/passkeys/simplewebauthn.d.mts +2 -3
  107. package/esm/passkeys/simplewebauthn.d.mts.map +1 -1
  108. package/esm/passkeys/simplewebauthn.mjs +1 -1
  109. package/esm/providers/apple-provider.d.mts +5 -9
  110. package/esm/providers/apple-provider.d.mts.map +1 -1
  111. package/esm/providers/discord-provider.d.mts +2 -7
  112. package/esm/providers/discord-provider.d.mts.map +1 -1
  113. package/esm/providers/facebook-provider.d.mts +2 -7
  114. package/esm/providers/facebook-provider.d.mts.map +1 -1
  115. package/esm/providers/github-provider.d.mts +2 -7
  116. package/esm/providers/github-provider.d.mts.map +1 -1
  117. package/esm/providers/google-provider.d.mts +5 -10
  118. package/esm/providers/google-provider.d.mts.map +1 -1
  119. package/esm/providers/index.d.mts +2 -1
  120. package/esm/providers/index.mjs +1 -1
  121. package/esm/providers/linkedin-provider.d.mts +3 -8
  122. package/esm/providers/linkedin-provider.d.mts.map +1 -1
  123. package/esm/providers/provider-login.d.mts +3 -5
  124. package/esm/providers/provider-login.d.mts.map +1 -1
  125. package/esm/providers/provider-login.mjs +3 -2
  126. package/esm/providers/provider-login.mjs.map +1 -1
  127. package/esm/providers/provider-state-cookie.mjs +3 -2
  128. package/esm/providers/provider-state-cookie.mjs.map +1 -1
  129. package/esm/providers/x-provider.d.mts +2 -7
  130. package/esm/providers/x-provider.d.mts.map +1 -1
  131. package/esm/services/auth-events.d.mts +5 -6
  132. package/esm/services/auth-events.d.mts.map +1 -1
  133. package/esm/services/auth.service.d.mts +10 -9
  134. package/esm/services/auth.service.d.mts.map +1 -1
  135. package/esm/services/current-user.d.mts +1 -3
  136. package/esm/services/current-user.d.mts.map +1 -1
  137. package/esm/services/email-verification.d.mts +3 -5
  138. package/esm/services/email-verification.d.mts.map +1 -1
  139. package/esm/services/generate-jwt-secret.d.mts +1 -2
  140. package/esm/services/generate-jwt-secret.d.mts.map +1 -1
  141. package/esm/services/index.d.mts +2 -1
  142. package/esm/services/index.mjs +1 -1
  143. package/esm/services/jwt.d.mts +8 -29
  144. package/esm/services/jwt.d.mts.map +1 -1
  145. package/esm/services/jwt.mjs +2 -2
  146. package/esm/services/jwt.mjs.map +1 -1
  147. package/esm/services/one-time-tokens.d.mts +6 -6
  148. package/esm/services/one-time-tokens.d.mts.map +1 -1
  149. package/esm/services/password-reset.d.mts +2 -4
  150. package/esm/services/password-reset.d.mts.map +1 -1
  151. package/esm/services/resolve-request-user.d.mts +19 -14
  152. package/esm/services/resolve-request-user.d.mts.map +1 -1
  153. package/esm/services/resolve-request-user.mjs.map +1 -1
  154. package/esm/services/token-family-operation.mjs +1 -1
  155. package/esm/session/index.d.mts +2 -1
  156. package/esm/session/index.mjs +1 -1
  157. package/esm/session/page-session.d.mts +26 -18
  158. package/esm/session/page-session.d.mts.map +1 -1
  159. package/esm/utils/auth-error-codes.d.mts +11 -22
  160. package/esm/utils/auth-error-codes.d.mts.map +1 -1
  161. package/esm/utils/index.mjs +1 -1
  162. package/esm/utils/safe-equal.d.mts +1 -2
  163. package/esm/utils/safe-equal.d.mts.map +1 -1
  164. package/esm/utils/token-expiry.d.mts +3 -4
  165. package/esm/utils/token-expiry.d.mts.map +1 -1
  166. package/llms-full.txt +189 -111
  167. package/package.json +8 -8
  168. package/skills/auth-basics/SKILL.md +10 -13
  169. package/skills/customize-token-storage/SKILL.md +24 -19
  170. package/skills/customize-user-type/SKILL.md +3 -1
  171. package/skills/index.md +4 -1
  172. package/skills/login-with-providers/SKILL.md +54 -29
  173. package/skills/manage-tokens/SKILL.md +2 -2
  174. package/skills/overview/SKILL.md +10 -1
  175. package/skills/protect-routes/SKILL.md +23 -14
  176. package/skills/register-user/SKILL.md +4 -4
  177. package/skills/run-auth-commands/SKILL.md +1 -1
  178. package/skills/throttle-login-attempts/SKILL.md +51 -22
  179. package/skills/verify-email-and-reset-password/SKILL.md +7 -5
@@ -1 +1 @@
1
- {"version":3,"file":"provider-state-cookie.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/providers/provider-state-cookie.ts"],"sourcesContent":["import type { Request, Response } from \"@warlock.js/core\";\nimport { createHmac, randomBytes } from \"node:crypto\";\nimport type { ProviderAuthorizationState } from \"../contracts/providers\";\nimport { authConfig } from \"../services/auth-config\";\nimport { safeEqual } from \"../utils/safe-equal\";\n\n/** Cookie carrying a redirect login's state from the start to the callback. */\nexport const PROVIDER_STATE_COOKIE = \"auth_provider_state\";\n\n/** How long a started provider login stays completable. */\nconst PROVIDER_STATE_TTL_SECONDS = 600;\n\n/** What the signed cookie holds. */\nexport type StoredProviderState = ProviderAuthorizationState & {\n provider: string;\n expiresAt: number;\n callbackMode: \"query\" | \"form_post\";\n};\n\n/** 32 random bytes, base64url — used for `state`, `nonce` and the PKCE verifier. */\nexport function randomUrlSafe(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/**\n * HMAC over the payload with a key DERIVED from the access-token secret, so\n * the state cookie never shares a MAC key with the JWTs themselves.\n */\nfunction sign(payload: string): string {\n const key = createHmac(\"sha256\", authConfig.accessToken.secret())\n .update(\"@warlock.js/auth:provider-state\")\n .digest();\n\n return createHmac(\"sha256\", key).update(payload).digest(\"base64url\");\n}\n\n/**\n * Write the signed, 10-minute state cookie for a provider login. `HttpOnly`\n * comes from the `response.cookie()` secure defaults. `callbackMode` picks\n * the `SameSite`/`Secure` pair: `\"query\"` (default) keeps the framework's\n * `SameSite=Lax`, which still rides a top-level GET redirect back to the app;\n * `\"form_post\"` (Apple) overrides to `SameSite=None; Secure`, since a browser\n * drops a `Lax` cookie on the provider's cross-site POST callback. Either\n * way, the signed `state`/`nonce`/PKCE values — not the cookie's SameSite\n * attribute — are what actually defend against CSRF here.\n */\nexport function writeProviderState(\n response: Response,\n provider: string,\n state: ProviderAuthorizationState,\n callbackMode: \"query\" | \"form_post\" = \"query\",\n): void {\n const stored: StoredProviderState = {\n ...state,\n provider,\n expiresAt: Date.now() + PROVIDER_STATE_TTL_SECONDS * 1000,\n callbackMode,\n };\n const payload = Buffer.from(JSON.stringify(stored)).toString(\"base64url\");\n\n response.cookie(PROVIDER_STATE_COOKIE, `${payload}.${sign(payload)}`, {\n raw: true,\n path: \"/\",\n maxAge: PROVIDER_STATE_TTL_SECONDS,\n ...(callbackMode === \"form_post\" ? { sameSite: \"none\", secure: true } : {}),\n });\n}\n\n/**\n * Read AND clear the state cookie, so a started login completes at most once.\n * Resolves `undefined` for an absent, forged (bad MAC), malformed or expired\n * cookie. The clearing `Set-Cookie` repeats whatever `SameSite`/`Secure` pair\n * the cookie was WRITTEN with (recovered from the decoded payload itself, so\n * this needs no mode passed in) — a browser only honours a clearing cookie\n * when it matches the original's attributes, and for a `form_post` (Apple)\n * cookie that means `SameSite=None; Secure` too, or the original survives.\n */\nexport function takeProviderState(\n request: Request,\n response: Response,\n): StoredProviderState | undefined {\n const raw: unknown = request.cookie(PROVIDER_STATE_COOKIE);\n\n let stored: Partial<StoredProviderState> | undefined;\n\n if (typeof raw === \"string\") {\n const [payload, signature, ...rest] = raw.split(\".\");\n\n if (payload && signature && rest.length === 0 && safeEqual(signature, sign(payload))) {\n try {\n stored = JSON.parse(Buffer.from(payload, \"base64url\").toString(\"utf8\"));\n } catch {\n stored = undefined;\n }\n }\n }\n\n response.clearCookie(PROVIDER_STATE_COOKIE, {\n path: \"/\",\n ...(stored?.callbackMode === \"form_post\" ? { sameSite: \"none\", secure: true } : {}),\n });\n\n if (\n typeof stored?.state !== \"string\" ||\n typeof stored.nonce !== \"string\" ||\n typeof stored.codeVerifier !== \"string\" ||\n typeof stored.provider !== \"string\" ||\n typeof stored.expiresAt !== \"number\" ||\n stored.expiresAt <= Date.now()\n ) {\n return undefined;\n }\n\n return stored as StoredProviderState;\n}\n"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,IAAI,CAAC;CACnF,CAAC;CAED,IACE,OAAO,QAAQ,UAAU,YACzB,OAAO,OAAO,UAAU,YACxB,OAAO,OAAO,iBAAiB,YAC/B,OAAO,OAAO,aAAa,YAC3B,OAAO,OAAO,cAAc,YAC5B,OAAO,aAAa,KAAK,IAAI,GAE7B;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"provider-state-cookie.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/providers/provider-state-cookie.ts"],"sourcesContent":["import type { Request, Response } from \"@warlock.js/core\";\nimport { createHmac, randomBytes } from \"node:crypto\";\nimport type { ProviderAuthorizationState } from \"../contracts/providers\";\nimport { authConfig } from \"../services/auth-config\";\nimport { safeEqual } from \"../utils/safe-equal\";\n\n/** Cookie carrying a redirect login's state from the start to the callback. */\nexport const PROVIDER_STATE_COOKIE = \"auth_provider_state\";\n\n/** How long a started provider login stays completable. */\nconst PROVIDER_STATE_TTL_SECONDS = 600;\n\n/** What the signed cookie holds. */\nexport type StoredProviderState = ProviderAuthorizationState & {\n provider: string;\n expiresAt: number;\n callbackMode: \"query\" | \"form_post\";\n};\n\n/** 32 random bytes, base64url — used for `state`, `nonce` and the PKCE verifier. */\nexport function randomUrlSafe(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/**\n * HMAC over the payload with a key DERIVED from the access-token secret, so\n * the state cookie never shares a MAC key with the JWTs themselves.\n */\nfunction sign(payload: string): string {\n const key = createHmac(\"sha256\", authConfig.accessToken.secret())\n .update(\"@warlock.js/auth:provider-state\")\n .digest();\n\n return createHmac(\"sha256\", key).update(payload).digest(\"base64url\");\n}\n\n/**\n * Write the signed, 10-minute state cookie for a provider login. `HttpOnly`\n * comes from the `response.cookie()` secure defaults. `callbackMode` picks\n * the `SameSite`/`Secure` pair: `\"query\"` (default) keeps the framework's\n * `SameSite=Lax`, which still rides a top-level GET redirect back to the app;\n * `\"form_post\"` (Apple) overrides to `SameSite=None; Secure`, since a browser\n * drops a `Lax` cookie on the provider's cross-site POST callback. Either\n * way, the signed `state`/`nonce`/PKCE values — not the cookie's SameSite\n * attribute — are what actually defend against CSRF here.\n */\nexport function writeProviderState(\n response: Response,\n provider: string,\n state: ProviderAuthorizationState,\n callbackMode: \"query\" | \"form_post\" = \"query\",\n): void {\n const stored: StoredProviderState = {\n ...state,\n provider,\n expiresAt: Date.now() + PROVIDER_STATE_TTL_SECONDS * 1000,\n callbackMode,\n };\n const payload = Buffer.from(JSON.stringify(stored)).toString(\"base64url\");\n\n response.cookie(PROVIDER_STATE_COOKIE, `${payload}.${sign(payload)}`, {\n raw: true,\n path: \"/\",\n maxAge: PROVIDER_STATE_TTL_SECONDS,\n ...(callbackMode === \"form_post\" ? { sameSite: \"none\", secure: true } : {}),\n });\n}\n\n/**\n * Read AND clear the state cookie, so a started login completes at most once.\n * Resolves `undefined` for an absent, forged (bad MAC), malformed or expired\n * cookie. The clearing `Set-Cookie` repeats whatever `SameSite`/`Secure` pair\n * the cookie was WRITTEN with (recovered from the decoded payload itself, so\n * this needs no mode passed in) — a browser only honours a clearing cookie\n * when it matches the original's attributes, and for a `form_post` (Apple)\n * cookie that means `SameSite=None; Secure` too, or the original survives.\n */\nexport function takeProviderState(\n request: Request,\n response: Response,\n): StoredProviderState | undefined {\n const raw: unknown = request.cookie(PROVIDER_STATE_COOKIE);\n\n let stored: Partial<StoredProviderState> | undefined;\n\n if (typeof raw === \"string\") {\n const [payload, signature, ...rest] = raw.split(\".\");\n\n if (payload && signature && rest.length === 0 && safeEqual(signature, sign(payload))) {\n try {\n stored = JSON.parse(Buffer.from(payload, \"base64url\").toString(\"utf8\"));\n } catch {\n stored = undefined;\n }\n }\n }\n\n response.clearCookie(PROVIDER_STATE_COOKIE, {\n path: \"/\",\n ...(stored?.callbackMode === \"form_post\" ? { sameSite: \"none\", secure: true } : {}),\n });\n\n if (\n typeof stored?.state !== \"string\" ||\n typeof stored.nonce !== \"string\" ||\n typeof stored.codeVerifier !== \"string\" ||\n typeof stored.provider !== \"string\" ||\n typeof stored.expiresAt !== \"number\" ||\n stored.expiresAt <= Date.now()\n ) {\n return undefined;\n }\n\n return stored as StoredProviderState;\n}\n"],"mappings":";;;;;;AAOA,MAAa,wBAAwB;;AAGrC,MAAM,6BAA6B;;AAUnC,SAAgB,gBAAwB;CACtC,OAAO,YAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;;;;;AAMA,SAAS,KAAK,SAAyB;CACrC,MAAM,MAAM,WAAW,UAAU,WAAW,YAAY,OAAO,CAAC,CAAC,CAC9D,OAAO,iCAAiC,CAAC,CACzC,OAAO;CAEV,OAAO,WAAW,UAAU,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,WAAW;AACrE;;;;;;;;;;;AAYA,SAAgB,mBACd,UACA,UACA,OACA,eAAsC,SAChC;CACN,MAAM,SAA8B;EAClC,GAAG;EACH;EACA,WAAW,KAAK,IAAI,IAAI,6BAA6B;EACrD;CACF;CACA,MAAM,UAAU,OAAO,KAAK,KAAK,UAAU,MAAM,CAAC,CAAC,CAAC,SAAS,WAAW;CAExE,SAAS,OAAO,uBAAuB,GAAG,QAAQ,GAAG,KAAK,OAAO,KAAK;EACpE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,GAAI,iBAAiB,cAAc;GAAE,UAAU;GAAQ,QAAQ;EAAK,IAAI,CAAC;CAC3E,CAAC;AACH;;;;;;;;;;AAWA,SAAgB,kBACd,SACA,UACiC;CACjC,MAAM,MAAe,QAAQ,OAAO,qBAAqB;CAEzD,IAAI;CAEJ,IAAI,OAAO,QAAQ,UAAU;EAC3B,MAAM,CAAC,SAAS,WAAW,GAAG,QAAQ,IAAI,MAAM,GAAG;EAEnD,IAAI,WAAW,aAAa,KAAK,WAAW,KAAK,UAAU,WAAW,KAAK,OAAO,CAAC,GACjF,IAAI;GACF,SAAS,KAAK,MAAM,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC;EACxE,QAAQ;GACN,SAAS;EACX;CAEJ;CAEA,SAAS,YAAY,uBAAuB;EAC1C,MAAM;EACN,GAAI,QAAQ,iBAAiB,cAAc;GAAE,UAAU;GAAQ,QAAQ;EAAK,IAAI,CAAC;CACnF,CAAC;CAED,IACE,OAAO,QAAQ,UAAU,YACzB,OAAO,OAAO,UAAU,YACxB,OAAO,OAAO,iBAAiB,YAC/B,OAAO,OAAO,aAAa,YAC3B,OAAO,OAAO,cAAc,YAC5B,OAAO,aAAa,KAAK,IAAI,GAE7B;CAGF,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  import { AuthProvider, ProviderAuthorizationState, ProviderCallbackParams, ProviderProfile, XProviderConfig } from "../contracts/providers.mjs";
2
-
3
2
  //#region ../../packages/auth/src/providers/x-provider.d.ts
4
3
  /**
5
4
  * X (Twitter) sign-in: OAuth 2.0 authorization code flow with PKCE (S256). X
@@ -15,15 +14,12 @@ import { AuthProvider, ProviderAuthorizationState, ProviderCallbackParams, Provi
15
14
  * rather than invented, and `resolveProviderUser` rejects it the same way it
16
15
  * rejects any other missing email.
17
16
  */
18
- declare class XProvider implements AuthProvider {
17
+ export declare class XProvider implements AuthProvider {
19
18
  private readonly settings;
20
19
  readonly name = "x";
21
20
  constructor(settings: XProviderConfig);
22
21
  authorizationUrl(state: ProviderAuthorizationState): string;
23
- handleCallback({
24
- query,
25
- expected
26
- }: ProviderCallbackParams): Promise<ProviderProfile>;
22
+ handleCallback({ query, expected }: ProviderCallbackParams): Promise<ProviderProfile>;
27
23
  /** Basic-auth credential for the confidential-client token request. */
28
24
  private basicAuth;
29
25
  /** Redeem the authorization code (with the PKCE verifier) for an access token. */
@@ -31,5 +27,4 @@ declare class XProvider implements AuthProvider {
31
27
  private fetchUser;
32
28
  }
33
29
  //#endregion
34
- export { XProvider };
35
30
  //# sourceMappingURL=x-provider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-provider.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/providers/x-provider.ts"],"mappings":";;;;;AAoCA;;;;;;;;;;;;cAAa,SAAA,YAAqB,YAAA;EAAA,iBAGI,QAAA;EAAA,SAFpB,IAAA;cAEoB,QAAA,EAAU,eAAA;EAEvC,gBAAA,CAAiB,KAAA,EAAO,0BAAA;EAclB,cAAA;IACX,KAAA;IACA;EAAA,GACC,sBAAA,GAAyB,OAAA,CAAQ,eAAA;EAnBA;EAAA,QA8C5B,SAAA;EA5CuB;EAAA,QAmDjB,YAAA;EAAA,QAuCA,SAAA;AAAA"}
1
+ {"version":3,"file":"x-provider.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/providers/x-provider.ts"],"mappings":";;;;;;;;;;;;;;;;qBAoCa,qBAAqB;mBAGI;WAFpB;EAEhB,YAAoC,UAAU;EAEvC,iBAAiB,OAAO;EAclB,iBACX,OACA,YACC,yBAAyB,QAAQ;;UA2B5B;;UAOM;UAuCA"}
@@ -1,13 +1,13 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
+ import "../models/refresh-token/index.mjs";
2
3
  import { DeviceInfo, TokenPair } from "../contracts/types.mjs";
3
4
  import { RefreshToken } from "../models/refresh-token/refresh-token.model.mjs";
4
5
  import { EventSubscription } from "@mongez/events";
5
-
6
6
  //#region ../../packages/auth/src/services/auth-events.d.ts
7
7
  /**
8
8
  * Auth event payload types
9
9
  */
10
- type AuthEventPayloads = {
10
+ export type AuthEventPayloads = {
11
11
  "login.success": [user: Auth, tokenPair: TokenPair, deviceInfo?: DeviceInfo];
12
12
  "login.failed": [credentials: {
13
13
  email?: string;
@@ -35,11 +35,11 @@ type AuthEventPayloads = {
35
35
  /**
36
36
  * Auth event names
37
37
  */
38
- type AuthEventName = keyof AuthEventPayloads;
38
+ export type AuthEventName = keyof AuthEventPayloads;
39
39
  /**
40
40
  * Callback type for a specific event
41
41
  */
42
- type AuthEventCallback<T extends AuthEventName> = (...args: AuthEventPayloads[T]) => void | Promise<void>;
42
+ export type AuthEventCallback<T extends AuthEventName> = (...args: AuthEventPayloads[T]) => void | Promise<void>;
43
43
  /**
44
44
  * Type-safe auth events manager
45
45
  *
@@ -58,7 +58,7 @@ type AuthEventCallback<T extends AuthEventName> = (...args: AuthEventPayloads[T]
58
58
  * authEvents.emit("login.success", user, tokenPair, deviceInfo);
59
59
  * ```
60
60
  */
61
- declare const authEvents: {
61
+ export declare const authEvents: {
62
62
  /**
63
63
  * Subscribe to an auth event
64
64
  */
@@ -85,5 +85,4 @@ declare const authEvents: {
85
85
  off(event?: AuthEventName): void;
86
86
  };
87
87
  //#endregion
88
- export { AuthEventCallback, AuthEventName, AuthEventPayloads, authEvents };
89
88
  //# sourceMappingURL=auth-events.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-events.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth-events.ts"],"mappings":";;;;;;;;;KASY,iBAAA;EAEV,eAAA,GAAkB,IAAA,EAAM,IAAA,EAAM,SAAA,EAAW,SAAA,EAAW,UAAA,GAAa,UAAA;EACjE,cAAA,GAAiB,WAAA;IAAe,KAAA;IAAgB,QAAA;EAAA,GAAqB,MAAA;EACrE,eAAA,GAAkB,WAAA;IAAe,KAAA;IAAgB,QAAA;EAAA;EAGjD,MAAA,GAAS,IAAA,EAAM,IAAA;EACf,YAAA,GAAe,IAAA,EAAM,IAAA;EACrB,iBAAA,GAAoB,IAAA,EAAM,IAAA;EAG1B,eAAA,GAAkB,IAAA,EAAM,IAAA,EAAM,SAAA,EAAW,SAAA;EACzC,iBAAA,GAAoB,IAAA,EAAM,IAAA,EAAM,YAAA,EAAc,SAAA,EAAW,eAAA,EAAiB,YAAA;EAC1E,eAAA,GAAkB,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,YAAA;EACrC,eAAA,GAAkB,KAAA,EAAO,YAAA;EACzB,qBAAA,GAAwB,QAAA,UAAkB,MAAA,EAAQ,YAAA;EAGlD,kBAAA,GAAqB,IAAA,EAAM,IAAA;EAC3B,yBAAA,GAA4B,IAAA,EAAM,IAAA,EAAM,UAAA;EACxC,gBAAA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A4B,MAAM,MAAM;EACxC,mBAAmB,MAAM;EAGzB,oBAAoB,MAAM,MAAM,cAAc,cAAc,aAAa;EACzE,sBAAsB,MAAM,MAAM,cAAc;EAGhD,sBAAsB;;;;;YAMZ,sBAAsB;;;;YAKtB,kBAAkB,UAAU,qBACnC,MAAM,kBAAkB,cACjB;;;;;;;;;;;;;;;;;;;qBAyBC;;;;EAIX,GAAG,UAAU,eAAa,OAAS,GAAC,UAAY,kBAAkB,KAAK;;;;EAOvE,UAAU,UAAU,eAAa,OAAS,GAAC,UAAY,kBAAkB,KAAK;;;;EAO9E,KAAK,UAAU,eAAa,OAAS,MAAC,MAAW,kBAAkB;;;;EAgBnE,QAAQ,UAAU,eAAa,OAAS,MAAC,MAAW,kBAAkB;;;;EAOtE;;;;EAOA,IAAG,QAAS"}
@@ -1,13 +1,14 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
2
  import { AccessToken } from "../models/access-token/access-token.model.mjs";
3
+ import "../models/access-token/index.mjs";
4
+ import "../models/refresh-token/index.mjs";
3
5
  import { AccessTokenOutput, AuthCredentials, ClearAuthCookieOptions, DeviceInfo, LoginResult, SetAuthCookieOptions, TokenPair } from "../contracts/types.mjs";
4
6
  import { RefreshToken } from "../models/refresh-token/refresh-token.model.mjs";
5
7
  import { Request, Response } from "@warlock.js/core";
6
8
  import { ChildModel } from "@warlock.js/cascade";
7
-
8
9
  //#region ../../packages/auth/src/services/auth.service.d.ts
9
10
  /** Thrown when a request-scoped cookie Domain cannot be resolved safely. */
10
- declare class CookieDomainRequestRequiredError extends Error {
11
+ export declare class CookieDomainRequestRequiredError extends Error {
11
12
  constructor(method: string);
12
13
  }
13
14
  declare class AuthService {
@@ -120,7 +121,7 @@ declare class AuthService {
120
121
  * cross-site Origin/Referer throws `CsrfOriginMismatchError` before any
121
122
  * credential is looked at. Returns `null` on bad credentials.
122
123
  */
123
- loginWithSessionCookies<T extends Auth>(request: Request, response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown }, Model: ChildModel<T>, credentials: AuthCredentials, deviceInfo?: DeviceInfo): Promise<LoginResult<T> | null>;
124
+ loginWithSessionCookies<T extends Auth>(request: Request, response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown; }, Model: ChildModel<T>, credentials: AuthCredentials, deviceInfo?: DeviceInfo): Promise<LoginResult<T> | null>;
124
125
  /** The one token-issuing tail every login method shares. */
125
126
  private finalizeLogin;
126
127
  /**
@@ -221,7 +222,7 @@ declare class AuthService {
221
222
  * const { user, tokens } = await authService.login(User, credentials);
222
223
  * authService.setAuthCookie(response, tokens.accessToken);
223
224
  */
224
- setAuthCookie(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown }, token: string | AccessTokenOutput, options?: SetAuthCookieOptions): void;
225
+ setAuthCookie(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown; }, token: string | AccessTokenOutput, options?: SetAuthCookieOptions): void;
225
226
  /**
226
227
  * Clear the auth cookie {@link setAuthCookie} wrote. An explicit
227
228
  * app-controller call — pair it with {@link logout} after the token row is
@@ -232,7 +233,7 @@ declare class AuthService {
232
233
  * await authService.logout(user, accessToken, refreshToken);
233
234
  * authService.clearAuthCookie(response);
234
235
  */
235
- clearAuthCookie(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown }, options?: ClearAuthCookieOptions, request?: Request): void;
236
+ clearAuthCookie(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown; }, options?: ClearAuthCookieOptions, request?: Request): void;
236
237
  /**
237
238
  * Write the access and refresh cookies of a browser session. Both are
238
239
  * `HttpOnly`, `SameSite=Lax`, `Path=/` (the refresh cookie must reach every
@@ -244,7 +245,7 @@ declare class AuthService {
244
245
  * const { tokens } = await authService.login(User, credentials);
245
246
  * authService.setSessionCookies(response, tokens);
246
247
  */
247
- setSessionCookies(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown }, tokens: {
248
+ setSessionCookies(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown; }, tokens: {
248
249
  accessToken: AccessTokenOutput;
249
250
  refreshToken: AccessTokenOutput;
250
251
  }, request?: Request): void;
@@ -252,9 +253,9 @@ declare class AuthService {
252
253
  * Clear both session cookies {@link setSessionCookies} wrote, on `Path=/`.
253
254
  * Pair it with {@link logout} after the token rows are revoked.
254
255
  */
255
- clearSessionCookies(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown }, request?: Request): void;
256
+ clearSessionCookies(response: { [K in "cookie" | "clearCookie"]: (...args: Parameters<Response[K]>) => unknown; }, request?: Request): void;
256
257
  }
257
- declare const authService: AuthService;
258
+ export declare const authService: AuthService;
258
259
  //#endregion
259
- export { CookieDomainRequestRequiredError, authService };
260
+ export {};
260
261
  //# sourceMappingURL=auth.service.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/auth.service.ts"],"mappings":";;;;;;;;;cAoCa,gCAAA,SAAyC,KAAK;cACtC,MAAA;AAAA;AAAA,cAQf,WAAA;EATwC;;;;;;EAAA,YAgBhC,gBAAA;EAfqB;AAMlC;;EANkC,YAsBrB,iBAAA;EAcyB;;;EAAA,YAPzB,iBAAA;EAqDJ;;;EA9CD,uBAAA,CAAwB,IAAA,EAAM,IAAA,GAAO,MAAA;EAiIpC;EAxHK,eAAA,CAAgB,IAAA,EAAM,IAAA,GAAO,OAAA;EAAA,QAI5B,qBAAA;EAAA,QAMA,gBAAA;EAmLqB;;;;;EAzJtB,mBAAA,CACX,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,MAAA,oBACT,OAAA,CAAQ,iBAAA;EAAA,QAMG,iBAAA;EAiQgC;;;;;;EAAA,QAvNhC,qBAAA;EA6aL;;;;EA7YI,kBAAA,CACX,IAAA,EAAM,IAAA,EACN,UAAA,GAAa,UAAA,GAC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,aAAa,iBACb,aAAa,aACZ,QAAQ,YAAY;;UA0BT;;;;;;;;;;;EA2BD,OAAO,MAAM,MAAM,sBAAsB,wBAAwB;;;;EA6BjE,kBAAkB,MAAM,MAAM,gBAAgB;;;;EAO9C,sBAAsB,MAAM,OAAO;;;;EAOnC,mBAAmB,MAAM,MAAM,gBAAgB;;;;;;EAS/C,gBAAgB,MAAM,OAAO;;;;EA+B7B,kBAAkB,mBAAmB;;;;;;;EAyErC,wBAAwB;;;;;;;;;;;EAyBxB,2BAA2B;IACtC,cAAc;IACd,eAAe;;;;;;;;;;EAgBJ,4BAA4B;IACvC;IACA;;;;;EAkBW,kBAAkB,MAAM,OAAO,QAAQ;;;;;;UAS5C;UAUA;;;;;;;;;;;;;;;;;;;;;;EAmCD,cACL,aAAa,oCAAoC,MAAM,WAAW,SAAS,oBAC3E,gBAAgB,mBAChB,UAAS;;;;;;;;;;;EAyBJ,gBACL,aAAa,oCAAoC,MAAM,WAAW,SAAS,oBAC3E,UAAS,wBACT,UAAU;;;;;;;;;;;;EAwBL,kBACL,aAAa,oCAAoC,MAAM,WAAW,SAAS,oBAC3E;IAAU,aAAa;IAAmB,cAAc;KACxD,UAAU;;;;;EA0BL,oBACL,aAAa,oCAAoC,MAAM,WAAW,SAAS,oBAC3E,UAAU;;qBAcD,aAAW"}
@@ -1,5 +1,4 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
-
3
2
  //#region ../../packages/auth/src/services/current-user.d.ts
4
3
  /**
5
4
  * Typed accessor over the request-scoped current user, for callers that want
@@ -15,7 +14,6 @@ import { Auth } from "../models/auth.model.mjs";
15
14
  * @example
16
15
  * const user = currentUser<AdminUser>();
17
16
  */
18
- declare function currentUser<UserType extends Auth = Auth>(): UserType | undefined;
17
+ export declare function currentUser<UserType extends Auth = Auth>(): UserType | undefined;
19
18
  //#endregion
20
- export { currentUser };
21
19
  //# sourceMappingURL=current-user.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-user.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/current-user.ts"],"mappings":";;;;;AAiBA;;;;;;;;;;;;iBAAgB,WAAA,kBAA6B,IAAA,GAAO,IAAA,KAAS,QAAA"}
1
+ {"version":3,"file":"current-user.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/current-user.ts"],"mappings":";;;;;;;;;;;;;;;;wBAiBgB,YAAY,iBAAiB,OAAO,SAAS"}
@@ -1,11 +1,10 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
-
3
2
  //#region ../../packages/auth/src/services/email-verification.d.ts
4
3
  /**
5
4
  * Whether the user has verified their email — the configured
6
5
  * `auth.verification.field` (default `emailVerifiedAt`) holds a value.
7
6
  */
8
- declare function isEmailVerified(user: Pick<Auth, "get">): boolean;
7
+ export declare function isEmailVerified(user: Pick<Auth, "get">): boolean;
9
8
  /**
10
9
  * Issue an email-verification token for the user and send it through the
11
10
  * verification notification (`auth.verification.notification`, else auth's
@@ -19,7 +18,7 @@ declare function isEmailVerified(user: Pick<Auth, "get">): boolean;
19
18
  * const user = await User.create(data);
20
19
  * await sendEmailVerification(user);
21
20
  */
22
- declare function sendEmailVerification(user: Auth): Promise<void>;
21
+ export declare function sendEmailVerification(user: Auth): Promise<void>;
23
22
  /**
24
23
  * Consume a verification token and stamp the user's verified field with the
25
24
  * current date. Resolves to the verified user.
@@ -29,7 +28,6 @@ declare function sendEmailVerification(user: Auth): Promise<void>;
29
28
  * @throws Error when the save did not keep the field — the user schema must
30
29
  * declare it (e.g. `emailVerifiedAt: v.date().optional()`).
31
30
  */
32
- declare function verifyEmail(token: string): Promise<Auth>;
31
+ export declare function verifyEmail(token: string): Promise<Auth>;
33
32
  //#endregion
34
- export { isEmailVerified, sendEmailVerification, verifyEmail };
35
33
  //# sourceMappingURL=email-verification.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-verification.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/email-verification.ts"],"mappings":";;;;;AASA;;iBAAgB,eAAA,CAAgB,IAAA,EAAM,IAAI,CAAC,IAAA;;;;;;AAAY;AAiBvD;;;;;;;iBAAsB,qBAAA,CAAsB,IAAA,EAAM,IAAA,GAAO,OAAO;AAAA;AAuBhE;;;;;;;;AAvBgE,iBAuB1C,WAAA,CAAY,KAAA,WAAgB,OAAO,CAAC,IAAA"}
1
+ {"version":3,"file":"email-verification.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/email-verification.ts"],"mappings":";;;;;;wBASgB,gBAAgB,MAAM,KAAK;;;;;;;;;;;;;;wBAiBrB,sBAAsB,MAAM,OAAO;;;;;;;;;;wBAuBnC,YAAY,gBAAgB,QAAQ"}
@@ -1,5 +1,4 @@
1
1
  //#region ../../packages/auth/src/services/generate-jwt-secret.d.ts
2
- declare function generateJWTSecret(): Promise<void>;
2
+ export declare function generateJWTSecret(): Promise<void>;
3
3
  //#endregion
4
- export { generateJWTSecret };
5
4
  //# sourceMappingURL=generate-jwt-secret.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-jwt-secret.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/generate-jwt-secret.ts"],"mappings":";iBAKsB,iBAAA,IAAiB,OAAA"}
1
+ {"version":3,"file":"generate-jwt-secret.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/generate-jwt-secret.ts"],"mappings":";wBAKsB,qBAAiB"}
@@ -6,4 +6,5 @@ import { TokenType, TokenTypeError, isInvalidCredentialError, jwt } from "./jwt.
6
6
  import { isEmailVerified, sendEmailVerification, verifyEmail } from "./email-verification.mjs";
7
7
  import { IssuedOneTimeToken, consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenModel } from "./one-time-tokens.mjs";
8
8
  import { requestPasswordReset, resetPassword } from "./password-reset.mjs";
9
- import { RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, readCredential, resolveRequestUser, resolveRequestUserOutcome } from "./resolve-request-user.mjs";
9
+ import { RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, readCredential, resolveRequestUser, resolveRequestUserOutcome } from "./resolve-request-user.mjs";
10
+ export { AuthEventCallback, AuthEventName, AuthEventPayloads, CookieDomainRequestRequiredError, IssuedOneTimeToken, RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, TokenType, TokenTypeError, authEvents, authService, consumeOneTimeToken, currentUser, generateJWTSecret, hashOneTimeToken, isEmailVerified, isInvalidCredentialError, issueOneTimeToken, jwt, oneTimeTokenModel, readCredential, requestPasswordReset, resetPassword, resolveRequestUser, resolveRequestUserOutcome, sendEmailVerification, verifyEmail };
@@ -8,4 +8,4 @@ import { consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenM
8
8
  import { isEmailVerified, sendEmailVerification, verifyEmail } from "./email-verification.mjs";
9
9
  import { requestPasswordReset, resetPassword } from "./password-reset.mjs";
10
10
 
11
- export { };
11
+ export { CookieDomainRequestRequiredError, TokenTypeError, authEvents, authService, consumeOneTimeToken, currentUser, generateJWTSecret, hashOneTimeToken, isEmailVerified, isInvalidCredentialError, issueOneTimeToken, jwt, oneTimeTokenModel, readCredential, requestPasswordReset, resetPassword, resolveRequestUser, resolveRequestUserOutcome, sendEmailVerification, verifyEmail };
@@ -1,6 +1,5 @@
1
1
  import { AuthErrorCodes } from "../utils/auth-error-codes.mjs";
2
2
  import { SignerOptions, VerifierOptions } from "fast-jwt";
3
-
4
3
  //#region ../../packages/auth/src/services/jwt.d.ts
5
4
  /**
6
5
  * Token class. Stamped as the `tokenType` claim on every signed token and
@@ -10,13 +9,13 @@ import { SignerOptions, VerifierOptions } from "fast-jwt";
10
9
  * this claim existed carry no `tokenType` and remain accepted; a *mismatched*
11
10
  * type is always rejected.
12
11
  */
13
- type TokenType = "access" | "refresh";
12
+ export type TokenType = "access" | "refresh";
14
13
  /**
15
14
  * Only coded credential failures become authentication misses. Plain errors,
16
15
  * including missing-secret configuration failures, propagate to the central
17
16
  * server-error path instead of reading as "everyone's token is bad".
18
17
  */
19
- declare function isInvalidCredentialError(error: unknown): boolean;
18
+ export declare function isInvalidCredentialError(error: unknown): boolean;
20
19
  /**
21
20
  * A `tokenType` claim that does not match what the caller expects. This IS a
22
21
  * bad credential (an access-token cookie can only hold a refresh token
@@ -26,20 +25,16 @@ declare function isInvalidCredentialError(error: unknown): boolean;
26
25
  * `code` mirrors how `fast-jwt`'s `TokenError` carries its own code, so a
27
26
  * caller can classify both through `isInvalidCredentialError` above.
28
27
  */
29
- declare class TokenTypeError extends Error {
28
+ export declare class TokenTypeError extends Error {
30
29
  readonly code = AuthErrorCodes.InvalidTokenType;
31
30
  constructor(expected: TokenType, actual: string);
32
31
  }
33
- declare const jwt: {
32
+ export declare const jwt: {
34
33
  /**
35
34
  * Generate a new JWT token for the user.
36
35
  * @param payload The payload to encode in the JWT token.
37
36
  */
38
- generate(payload: any, {
39
- key,
40
- algorithm,
41
- ...options
42
- }?: SignerOptions & {
37
+ generate(payload: any, { key, algorithm, ...options }?: SignerOptions & {
43
38
  key?: string;
44
39
  }): Promise<string>;
45
40
  /**
@@ -47,37 +42,21 @@ declare const jwt: {
47
42
  * @param token The JWT token to verify.
48
43
  * @returns The decoded token payload if verification is successful.
49
44
  */
50
- verify<T = unknown>(token: string, {
51
- key,
52
- algorithms,
53
- requiredClaims,
54
- ...options
55
- }?: VerifierOptions & {
45
+ verify<T = unknown>(token: string, { key, algorithms, requiredClaims, ...options }?: VerifierOptions & {
56
46
  key?: string;
57
47
  }): Promise<T>;
58
48
  /**
59
49
  * Generate a new refresh token for the user.
60
50
  */
61
- generateRefreshToken(payload: any, {
62
- key,
63
- expiresIn,
64
- algorithm,
65
- ...options
66
- }?: SignerOptions & {
51
+ generateRefreshToken(payload: any, { key, expiresIn, algorithm, ...options }?: SignerOptions & {
67
52
  key?: string;
68
53
  }): Promise<string>;
69
54
  /**
70
55
  * Verify the given refresh token.
71
56
  */
72
- verifyRefreshToken<T = unknown>(token: string, {
73
- key,
74
- algorithms,
75
- requiredClaims,
76
- ...options
77
- }?: VerifierOptions & {
57
+ verifyRefreshToken<T = unknown>(token: string, { key, algorithms, requiredClaims, ...options }?: VerifierOptions & {
78
58
  key?: string;
79
59
  }): Promise<T>;
80
60
  };
81
61
  //#endregion
82
- export { TokenType, TokenTypeError, isInvalidCredentialError, jwt };
83
62
  //# sourceMappingURL=jwt.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/jwt.ts"],"mappings":";;;;;;AAoBA;;;;AAAqB;AAoCrB;KApCY,SAAA;;;AAoC2C;AAevD;;iBAfgB,wBAAA,CAAyB,KAAc;;;;;;;;;;cAe1C,cAAA,SAAuB,KAAA;EAAA,SACzB,IAAA,GAAI,cAAA,CAAA,gBAAA;cAED,QAAA,EAAU,SAAA,EAAW,MAAA;AAAA;AAAA,cA+CtB,GAAA;EA/CoC;AA+CjD;;;;IAMgB,GAAA;IAAA,SAAA;IAAA,GAAA;EAAA,IAKT,aAAA;IAAkB,GAAA;EAAA,IACpB,OAAA;EAAA;;;;;sBAaW,KAAA;IACC,GAAA;IAAA,UAAA;IAAA,cAAA;IAAA,GAAA;EAAA,IAMV,eAAA;IAAoB,GAAA;EAAA,IACtB,OAAA,CAAQ,CAAA;EAmBG;;;;IAAA,GAAA;IAAA,SAAA;IAAA,SAAA;IAAA,GAAA;EAAA,IAMT,aAAA;IAAkB,GAAA;EAAA,IACpB,OAAA;EASY;;;kCADW,KAAA;IACX,GAAA;IAAA,UAAA;IAAA,cAAA;IAAA,GAAA;EAAA,IAMV,eAAA;IAAoB,GAAA;EAAA,IACtB,OAAA,CAAQ,CAAA;AAAA"}
1
+ {"version":3,"file":"jwt.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/jwt.ts"],"mappings":";;;;;;;;;;;YAoBY;;;;;;wBAoCI,yBAAyB;;;;;;;;;;qBAe5B,uBAAuB;WACzB,OAAI,eAAA;EAEb,YAAY,UAAU,WAAW;;qBA+CtB;;;;;EAKL,SAAQ,gBACA,KAAA,cAAA,YAKT;IAAkB;MACpB;;;;;;EAaG,OAAO,aAAW,iBACT,KAAA,YAAA,mBAAA,YAMV;IAAoB;MACtB,QAAQ;;;;EAkBL,qBAAoB,gBACZ,KAAA,WAAA,cAAA,YAMT;IAAkB;MACpB;;;;EAQG,mBAAmB,aAAW,iBACrB,KAAA,YAAA,mBAAA,YAMV;IAAoB;MACtB,QAAQ"}
@@ -17,7 +17,7 @@ const REFRESH_TOKEN_TYPE = "refresh";
17
17
  * `FAST_JWT_VERIFY_ERROR`, and `FAST_JWT_SIGN_ERROR` — describe a broken
18
18
  * server, not a broken token, and so does every unknown future code.
19
19
  */
20
- const INVALID_CREDENTIAL_ERROR_CODES = new Set([
20
+ const INVALID_CREDENTIAL_ERROR_CODES = /* @__PURE__ */ new Set([
21
21
  "FAST_JWT_MALFORMED",
22
22
  "FAST_JWT_INVALID_SIGNATURE",
23
23
  "FAST_JWT_MISSING_SIGNATURE",
@@ -89,7 +89,7 @@ const REQUIRED_CLAIMS = ["exp"];
89
89
  */
90
90
  function withRequiredClaims(callerClaims) {
91
91
  if (!callerClaims?.length) return REQUIRED_CLAIMS;
92
- return [...new Set([...callerClaims, ...REQUIRED_CLAIMS])];
92
+ return [.../* @__PURE__ */ new Set([...callerClaims, ...REQUIRED_CLAIMS])];
93
93
  }
94
94
  const jwt = {
95
95
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/jwt.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { createSigner, createVerifier, type SignerOptions, type VerifierOptions } from \"fast-jwt\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\nimport { authConfig } from \"./auth-config\";\n\nconst getSecretKey = () => authConfig.accessToken.secret();\nconst getAlgorithm = () => authConfig.accessToken.algorithm();\n\n// Refresh tokens may declare their own secret; when unset/empty we fall back to\n// the access-token secret (the documented optional behavior).\nconst getRefreshSecretKey = () => authConfig.refreshToken.secret() || getSecretKey();\n\n/**\n * Token class. Stamped as the `tokenType` claim on every signed token and\n * checked on verify so an access token can never be accepted where a refresh\n * token is expected (and vice versa) — even when both share the same secret\n * under the documented refresh-secret fallback. Legacy tokens minted before\n * this claim existed carry no `tokenType` and remain accepted; a *mismatched*\n * type is always rejected.\n */\nexport type TokenType = \"access\" | \"refresh\";\n\nconst ACCESS_TOKEN_TYPE: TokenType = \"access\";\nconst REFRESH_TOKEN_TYPE: TokenType = \"refresh\";\n\n/**\n * Error codes that mean \"the credential itself is bad\", as opposed to \"this\n * server could not check it\". This is an ALLOWLIST and must stay one. The codes\n * deliberately left out — `FAST_JWT_INVALID_KEY`, `FAST_JWT_MISSING_KEY`,\n * `FAST_JWT_KEY_FETCHING_ERROR`, `FAST_JWT_INVALID_OPTION`,\n * `FAST_JWT_VERIFY_ERROR`, and `FAST_JWT_SIGN_ERROR` — describe a broken\n * server, not a broken token, and so does every unknown future code.\n */\nconst INVALID_CREDENTIAL_ERROR_CODES = new Set<string>([\n \"FAST_JWT_MALFORMED\",\n \"FAST_JWT_INVALID_SIGNATURE\",\n \"FAST_JWT_MISSING_SIGNATURE\",\n \"FAST_JWT_INVALID_ALGORITHM\",\n \"FAST_JWT_EXPIRED\",\n \"FAST_JWT_INACTIVE\",\n // How a token carrying no `exp` is rejected — `jwt.verify` forces `exp` into\n // `requiredClaims`, so this code IS the missing-deadline guard firing.\n \"FAST_JWT_MISSING_REQUIRED_CLAIM\",\n \"FAST_JWT_INVALID_CLAIM_VALUE\",\n \"FAST_JWT_INVALID_CLAIM_TYPE\",\n \"FAST_JWT_INVALID_CRIT_HEADER\",\n \"FAST_JWT_INVALID_TYPE\",\n \"FAST_JWT_INVALID_PAYLOAD\",\n AuthErrorCodes.InvalidTokenType,\n]);\n\n/**\n * Only coded credential failures become authentication misses. Plain errors,\n * including missing-secret configuration failures, propagate to the central\n * server-error path instead of reading as \"everyone's token is bad\".\n */\nexport function isInvalidCredentialError(error: unknown): boolean {\n const code = (error as { code?: unknown } | null | undefined)?.code;\n\n return typeof code === \"string\" && INVALID_CREDENTIAL_ERROR_CODES.has(code);\n}\n\n/**\n * A `tokenType` claim that does not match what the caller expects. This IS a\n * bad credential (an access-token cookie can only hold a refresh token\n * through an app bug) — but unlike `fast-jwt`'s own rejections it was\n * previously a plain `Error`, unclassifiable by a caller that wants to answer\n * 401 without string-matching a message that could reword on any release.\n * `code` mirrors how `fast-jwt`'s `TokenError` carries its own code, so a\n * caller can classify both through `isInvalidCredentialError` above.\n */\nexport class TokenTypeError extends Error {\n readonly code = AuthErrorCodes.InvalidTokenType;\n\n constructor(expected: TokenType, actual: string) {\n super(`Invalid token type: expected \"${expected}\", received \"${actual}\".`);\n this.name = \"TokenTypeError\";\n }\n}\n\n/**\n * Reject the token when its `tokenType` claim is present and does not match the\n * expected class. Absent claim ⇒ legacy token, accepted (backward compatible).\n */\nfunction assertTokenType(decoded: unknown, expected: TokenType): void {\n const actual = (decoded as { tokenType?: unknown } | null | undefined)?.tokenType;\n\n if (typeof actual === \"string\" && actual !== expected) {\n throw new TokenTypeError(expected, actual);\n }\n}\n\n/**\n * Claims no token may be missing, whatever the caller asks for.\n *\n * A JWT with no `exp` is not \"a token with a long life\" — it is a credential\n * with *no* life, because a verifier with no deadline to check simply succeeds,\n * forever (measured against `fast-jwt@6.2.4`: a token with no `exp` verifies\n * unchanged at `clockTimestamp` + 100 years). Nothing in this package can mint\n * one as of 4.12.0, but tokens minted by an earlier version are already in the\n * wild, so the rejection lives on the *verify* side where it catches a token\n * from any version, including one signed by a service this package never ran.\n *\n * There is no legitimate source to preserve: an app that wants a token that\n * effectively never expires sets `expiresIn: NO_EXPIRATION` (`\"100y\"`), which\n * mints a real `exp` roughly a century out (measured: `ms(\"100y\")` ⇒\n * `3155760000000`, `exp - iat` ⇒ `3155760000` seconds). \"No deadline\" and \"a\n * distant deadline\" are different things, and only the second one is asked for.\n */\nconst REQUIRED_CLAIMS = [\"exp\"];\n\n/**\n * Union the caller's `requiredClaims` with the mandatory ones — a caller may\n * add requirements, never drop them.\n */\nfunction withRequiredClaims(callerClaims?: string[]): string[] {\n if (!callerClaims?.length) return REQUIRED_CLAIMS;\n\n return [...new Set([...callerClaims, ...REQUIRED_CLAIMS])];\n}\n\nexport const jwt = {\n /**\n * Generate a new JWT token for the user.\n * @param payload The payload to encode in the JWT token.\n */\n async generate(\n payload: any,\n {\n key = getSecretKey(),\n algorithm = getAlgorithm(),\n ...options\n }: SignerOptions & { key?: string } = {},\n ): Promise<string> {\n // Create a signer function with predefined options\n const sign = createSigner({ key, ...options, algorithm });\n\n const token = await sign({ jti: randomUUID(), ...payload, tokenType: ACCESS_TOKEN_TYPE });\n return token;\n },\n\n /**\n * Verify the given token.\n * @param token The JWT token to verify.\n * @returns The decoded token payload if verification is successful.\n */\n async verify<T = unknown>(\n token: string,\n {\n key = getSecretKey(),\n algorithms = [getAlgorithm()],\n requiredClaims,\n ...options\n }: VerifierOptions & { key?: string } = {},\n ): Promise<T> {\n const verify = createVerifier({\n key,\n ...options,\n algorithms,\n requiredClaims: withRequiredClaims(requiredClaims),\n });\n\n const decoded = await verify(token as string);\n\n assertTokenType(decoded, ACCESS_TOKEN_TYPE);\n\n return decoded;\n },\n\n /**\n * Generate a new refresh token for the user.\n */\n async generateRefreshToken(\n payload: any,\n {\n key = getRefreshSecretKey(),\n expiresIn,\n algorithm = getAlgorithm(),\n ...options\n }: SignerOptions & { key?: string } = {},\n ): Promise<string> {\n const sign = createSigner({ key, expiresIn, algorithm, ...options });\n return sign({ jti: randomUUID(), ...payload, tokenType: REFRESH_TOKEN_TYPE });\n },\n\n /**\n * Verify the given refresh token.\n */\n async verifyRefreshToken<T = unknown>(\n token: string,\n {\n key = getRefreshSecretKey(),\n algorithms = [getAlgorithm()],\n requiredClaims,\n ...options\n }: VerifierOptions & { key?: string } = {},\n ): Promise<T> {\n const verify = createVerifier({\n key,\n algorithms,\n ...options,\n requiredClaims: withRequiredClaims(requiredClaims),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AW;EAAkB,CAAC;CAE1F;;;;;;CAOA,MAAM,OACJ,OACA,EACE,MAAM,aAAa,GACnB,aAAa,CAAC,aAAa,CAAC,GAC5B,gBACA,GAAG,YACmC,CAAC,GAC7B;EAQZ,MAAM,UAAU,MAPD,eAAe;GAC5B;GACA,GAAG;GACH;GACA,gBAAgB,mBAAmB,cAAc;EACnD,CAE2B,CAAC,CAAC,KAAe;EAE5C,gBAAgB,SAAS,iBAAiB;EAE1C,OAAO;CACT;;;;CAKA,MAAM,qBACJ,SACA,EACE,MAAM,oBAAoB,GAC1B,WACA,YAAY,aAAa,GACzB,GAAG,YACiC,CAAC,GACtB;EAEjB,OADa,aAAa;GAAE;GAAK;GAAW;GAAW,GAAG;EAAQ,CACxD,CAAC,CAAC;GAAE,KAAK,WAAW;GAAG,GAAG;GAAS,WAAW;EAAmB,CAAC;CAC9E;;;;CAKA,MAAM,mBACJ,OACA,EACE,MAAM,oBAAoB,GAC1B,aAAa,CAAC,aAAa,CAAC,GAC5B,gBACA,GAAG,YACmC,CAAC,GAC7B;EAQZ,MAAM,UAAU,MAPD,eAAe;GAC5B;GACA;GACA,GAAG;GACH,gBAAgB,mBAAmB,cAAc;EACnD,CAE2B,CAAC,CAAC,KAAK;EAElC,gBAAgB,SAAS,kBAAkB;EAE3C,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"jwt.mjs","names":[],"sources":["../../../../../../../../packages/auth/src/services/jwt.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { createSigner, createVerifier, type SignerOptions, type VerifierOptions } from \"fast-jwt\";\nimport { AuthErrorCodes } from \"../utils/auth-error-codes\";\nimport { authConfig } from \"./auth-config\";\n\nconst getSecretKey = () => authConfig.accessToken.secret();\nconst getAlgorithm = () => authConfig.accessToken.algorithm();\n\n// Refresh tokens may declare their own secret; when unset/empty we fall back to\n// the access-token secret (the documented optional behavior).\nconst getRefreshSecretKey = () => authConfig.refreshToken.secret() || getSecretKey();\n\n/**\n * Token class. Stamped as the `tokenType` claim on every signed token and\n * checked on verify so an access token can never be accepted where a refresh\n * token is expected (and vice versa) — even when both share the same secret\n * under the documented refresh-secret fallback. Legacy tokens minted before\n * this claim existed carry no `tokenType` and remain accepted; a *mismatched*\n * type is always rejected.\n */\nexport type TokenType = \"access\" | \"refresh\";\n\nconst ACCESS_TOKEN_TYPE: TokenType = \"access\";\nconst REFRESH_TOKEN_TYPE: TokenType = \"refresh\";\n\n/**\n * Error codes that mean \"the credential itself is bad\", as opposed to \"this\n * server could not check it\". This is an ALLOWLIST and must stay one. The codes\n * deliberately left out — `FAST_JWT_INVALID_KEY`, `FAST_JWT_MISSING_KEY`,\n * `FAST_JWT_KEY_FETCHING_ERROR`, `FAST_JWT_INVALID_OPTION`,\n * `FAST_JWT_VERIFY_ERROR`, and `FAST_JWT_SIGN_ERROR` — describe a broken\n * server, not a broken token, and so does every unknown future code.\n */\nconst INVALID_CREDENTIAL_ERROR_CODES = new Set<string>([\n \"FAST_JWT_MALFORMED\",\n \"FAST_JWT_INVALID_SIGNATURE\",\n \"FAST_JWT_MISSING_SIGNATURE\",\n \"FAST_JWT_INVALID_ALGORITHM\",\n \"FAST_JWT_EXPIRED\",\n \"FAST_JWT_INACTIVE\",\n // How a token carrying no `exp` is rejected — `jwt.verify` forces `exp` into\n // `requiredClaims`, so this code IS the missing-deadline guard firing.\n \"FAST_JWT_MISSING_REQUIRED_CLAIM\",\n \"FAST_JWT_INVALID_CLAIM_VALUE\",\n \"FAST_JWT_INVALID_CLAIM_TYPE\",\n \"FAST_JWT_INVALID_CRIT_HEADER\",\n \"FAST_JWT_INVALID_TYPE\",\n \"FAST_JWT_INVALID_PAYLOAD\",\n AuthErrorCodes.InvalidTokenType,\n]);\n\n/**\n * Only coded credential failures become authentication misses. Plain errors,\n * including missing-secret configuration failures, propagate to the central\n * server-error path instead of reading as \"everyone's token is bad\".\n */\nexport function isInvalidCredentialError(error: unknown): boolean {\n const code = (error as { code?: unknown } | null | undefined)?.code;\n\n return typeof code === \"string\" && INVALID_CREDENTIAL_ERROR_CODES.has(code);\n}\n\n/**\n * A `tokenType` claim that does not match what the caller expects. This IS a\n * bad credential (an access-token cookie can only hold a refresh token\n * through an app bug) — but unlike `fast-jwt`'s own rejections it was\n * previously a plain `Error`, unclassifiable by a caller that wants to answer\n * 401 without string-matching a message that could reword on any release.\n * `code` mirrors how `fast-jwt`'s `TokenError` carries its own code, so a\n * caller can classify both through `isInvalidCredentialError` above.\n */\nexport class TokenTypeError extends Error {\n readonly code = AuthErrorCodes.InvalidTokenType;\n\n constructor(expected: TokenType, actual: string) {\n super(`Invalid token type: expected \"${expected}\", received \"${actual}\".`);\n this.name = \"TokenTypeError\";\n }\n}\n\n/**\n * Reject the token when its `tokenType` claim is present and does not match the\n * expected class. Absent claim ⇒ legacy token, accepted (backward compatible).\n */\nfunction assertTokenType(decoded: unknown, expected: TokenType): void {\n const actual = (decoded as { tokenType?: unknown } | null | undefined)?.tokenType;\n\n if (typeof actual === \"string\" && actual !== expected) {\n throw new TokenTypeError(expected, actual);\n }\n}\n\n/**\n * Claims no token may be missing, whatever the caller asks for.\n *\n * A JWT with no `exp` is not \"a token with a long life\" — it is a credential\n * with *no* life, because a verifier with no deadline to check simply succeeds,\n * forever (measured against `fast-jwt@6.2.4`: a token with no `exp` verifies\n * unchanged at `clockTimestamp` + 100 years). Nothing in this package can mint\n * one as of 4.12.0, but tokens minted by an earlier version are already in the\n * wild, so the rejection lives on the *verify* side where it catches a token\n * from any version, including one signed by a service this package never ran.\n *\n * There is no legitimate source to preserve: an app that wants a token that\n * effectively never expires sets `expiresIn: NO_EXPIRATION` (`\"100y\"`), which\n * mints a real `exp` roughly a century out (measured: `ms(\"100y\")` ⇒\n * `3155760000000`, `exp - iat` ⇒ `3155760000` seconds). \"No deadline\" and \"a\n * distant deadline\" are different things, and only the second one is asked for.\n */\nconst REQUIRED_CLAIMS = [\"exp\"];\n\n/**\n * Union the caller's `requiredClaims` with the mandatory ones — a caller may\n * add requirements, never drop them.\n */\nfunction withRequiredClaims(callerClaims?: string[]): string[] {\n if (!callerClaims?.length) return REQUIRED_CLAIMS;\n\n return [...new Set([...callerClaims, ...REQUIRED_CLAIMS])];\n}\n\nexport const jwt = {\n /**\n * Generate a new JWT token for the user.\n * @param payload The payload to encode in the JWT token.\n */\n async generate(\n payload: any,\n {\n key = getSecretKey(),\n algorithm = getAlgorithm(),\n ...options\n }: SignerOptions & { key?: string } = {},\n ): Promise<string> {\n // Create a signer function with predefined options\n const sign = createSigner({ key, ...options, algorithm });\n\n const token = await sign({ jti: randomUUID(), ...payload, tokenType: ACCESS_TOKEN_TYPE });\n return token;\n },\n\n /**\n * Verify the given token.\n * @param token The JWT token to verify.\n * @returns The decoded token payload if verification is successful.\n */\n async verify<T = unknown>(\n token: string,\n {\n key = getSecretKey(),\n algorithms = [getAlgorithm()],\n requiredClaims,\n ...options\n }: VerifierOptions & { key?: string } = {},\n ): Promise<T> {\n const verify = createVerifier({\n key,\n ...options,\n algorithms,\n requiredClaims: withRequiredClaims(requiredClaims),\n });\n\n const decoded = await verify(token as string);\n\n assertTokenType(decoded, ACCESS_TOKEN_TYPE);\n\n return decoded;\n },\n\n /**\n * Generate a new refresh token for the user.\n */\n async generateRefreshToken(\n payload: any,\n {\n key = getRefreshSecretKey(),\n expiresIn,\n algorithm = getAlgorithm(),\n ...options\n }: SignerOptions & { key?: string } = {},\n ): Promise<string> {\n const sign = createSigner({ key, expiresIn, algorithm, ...options });\n return sign({ jti: randomUUID(), ...payload, tokenType: REFRESH_TOKEN_TYPE });\n },\n\n /**\n * Verify the given refresh token.\n */\n async verifyRefreshToken<T = unknown>(\n token: string,\n {\n key = getRefreshSecretKey(),\n algorithms = [getAlgorithm()],\n requiredClaims,\n ...options\n }: VerifierOptions & { key?: string } = {},\n ): Promise<T> {\n const verify = createVerifier({\n key,\n algorithms,\n ...options,\n requiredClaims: withRequiredClaims(requiredClaims),\n });\n\n const decoded = await verify(token);\n\n assertTokenType(decoded, REFRESH_TOKE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A,EACE,MAAM,aAAa,GACnB,aAAa,CAAC,aAAa,CAAC,GAC5B,gBACA,GAAG,YACmC,CAAC,GAC7B;EAQZ,MAAM,UAAU,MAPD,eAAe;GAC5B;GACA,GAAG;GACH;GACA,gBAAgB,mBAAmB,cAAc;EACnD,CAE2B,CAAC,CAAC,KAAe;EAE5C,gBAAgB,SAAS,iBAAiB;EAE1C,OAAO;CACT;;;;CAKA,MAAM,qBACJ,SACA,EACE,MAAM,oBAAoB,GAC1B,WACA,YAAY,aAAa,GACzB,GAAG,YACiC,CAAC,GACtB;EAEjB,OADa,aAAa;GAAE;GAAK;GAAW;GAAW,GAAG;EAAQ,CACxD,CAAC,CAAC;GAAE,KAAK,WAAW;GAAG,GAAG;GAAS,WAAW;EAAmB,CAAC;CAC9E;;;;CAKA,MAAM,mBACJ,OACA,EACE,MAAM,oBAAoB,GAC1B,aAAa,CAAC,aAAa,CAAC,GAC5B,gBACA,GAAG,YACmC,CAAC,GAC7B;EAQZ,MAAM,UAAU,MAPD,eAAe;GAC5B;GACA;GACA,GAAG;GACH,gBAAgB,mBAAmB,cAAc;EACnD,CAE2B,CAAC,CAAC,KAAK;EAElC,gBAAgB,SAAS,kBAAkB;EAE3C,OAAO;CACT;AACF"}
@@ -1,15 +1,16 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
2
  import { OneTimeToken, OneTimeTokenPurpose } from "../models/one-time-token/one-time-token.model.mjs";
3
+ import "../models/one-time-token/index.mjs";
3
4
  //#region ../../packages/auth/src/services/one-time-tokens.d.ts
4
5
  /** The raw token handed to the notification, with its expiry. */
5
- type IssuedOneTimeToken = {
6
+ export type IssuedOneTimeToken = {
6
7
  token: string;
7
8
  expiresAt: Date;
8
9
  };
9
10
  /** Resolve the active one-time-token model — the default or `auth.oneTimeToken.model`. */
10
- declare function oneTimeTokenModel(): typeof OneTimeToken;
11
+ export declare function oneTimeTokenModel(): typeof OneTimeToken;
11
12
  /** SHA-256 hex digest of a raw one-time token — the only form ever persisted. */
12
- declare function hashOneTimeToken(token: string): string;
13
+ export declare function hashOneTimeToken(token: string): string;
13
14
  /**
14
15
  * Create and persist a one-time token for the user: 32 random bytes,
15
16
  * base64url-encoded. Only the hash reaches storage.
@@ -17,7 +18,7 @@ declare function hashOneTimeToken(token: string): string;
17
18
  * @param invalidatePrevious - consume the user's still-unused tokens of the
18
19
  * same purpose first (password reset: only the newest link works).
19
20
  */
20
- declare function issueOneTimeToken(user: Auth, purpose: OneTimeTokenPurpose, expiresInMs: number, invalidatePrevious?: boolean): Promise<IssuedOneTimeToken>;
21
+ export declare function issueOneTimeToken(user: Auth, purpose: OneTimeTokenPurpose, expiresInMs: number, invalidatePrevious?: boolean): Promise<IssuedOneTimeToken>;
21
22
  /**
22
23
  * Consume a raw one-time token of the given purpose and resolve its user.
23
24
  *
@@ -26,7 +27,6 @@ declare function issueOneTimeToken(user: Auth, purpose: OneTimeTokenPurpose, exp
26
27
  * The consume is a conditional update, so of N concurrent callers exactly one
27
28
  * proceeds.
28
29
  */
29
- declare function consumeOneTimeToken(rawToken: string, purpose: OneTimeTokenPurpose): Promise<Auth>;
30
+ export declare function consumeOneTimeToken(rawToken: string, purpose: OneTimeTokenPurpose): Promise<Auth>;
30
31
  //#endregion
31
- export { IssuedOneTimeToken, consumeOneTimeToken, hashOneTimeToken, issueOneTimeToken, oneTimeTokenModel };
32
32
  //# sourceMappingURL=one-time-tokens.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"one-time-tokens.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/one-time-tokens.ts"],"mappings":";;;;KAOY,kBAAA;EACV,KAAA;EACA,SAAA,EAAW,IAAI;AAAA;;iBAID,iBAAA,WAA4B,YAAY;;iBAKxC,gBAAA,CAAiB,KAAa;;;AAT7B;AAIjB;;;;iBAgBsB,iBAAA,CACpB,IAAA,EAAM,IAAA,EACN,OAAA,EAAS,mBAAA,EACT,WAAA,UACA,kBAAA,aACC,OAAA,CAAQ,kBAAA;AAhBX;;;;AAA8C;AAW9C;;;AAXA,iBAuCsB,mBAAA,CACpB,QAAA,UACA,OAAA,EAAS,mBAAA,GACR,OAAA,CAAQ,IAAA"}
1
+ {"version":3,"file":"one-time-tokens.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/one-time-tokens.ts"],"mappings":";;;;;YAOY;EACV;EACA,WAAW;;;wBAIG,4BAA4B;;wBAK5B,iBAAiB;;;;;;;;wBAWX,kBACpB,MAAM,MACN,SAAS,qBACT,qBACA,+BACC,QAAQ;;;;;;;;;wBAuBW,oBACpB,kBACA,SAAS,sBACR,QAAQ"}
@@ -1,6 +1,5 @@
1
1
  import { Auth } from "../models/auth.model.mjs";
2
2
  import { ChildModel } from "@warlock.js/cascade";
3
-
4
3
  //#region ../../packages/auth/src/services/password-reset.d.ts
5
4
  /**
6
5
  * Start a password reset for the account whose `auth.passwordReset.identifierField`
@@ -17,7 +16,7 @@ import { ChildModel } from "@warlock.js/cascade";
17
16
  * await requestPasswordReset(User, request.input("email"));
18
17
  * return response.success({ message: "If the account exists, we sent a reset link." });
19
18
  */
20
- declare function requestPasswordReset<T extends Auth>(Model: ChildModel<T>, identifier: string): Promise<void>;
19
+ export declare function requestPasswordReset<T extends Auth>(Model: ChildModel<T>, identifier: string): Promise<void>;
21
20
  /**
22
21
  * Complete a password reset: consume the token, store the new password, then
23
22
  * revoke every access token, refresh token and cookie session the user holds
@@ -28,7 +27,6 @@ declare function requestPasswordReset<T extends Auth>(Model: ChildModel<T>, iden
28
27
  * @throws InvalidOneTimeTokenError for an unknown, verification-purpose,
29
28
  * expired, superseded or already-used token.
30
29
  */
31
- declare function resetPassword(token: string, newPassword: string): Promise<Auth>;
30
+ export declare function resetPassword(token: string, newPassword: string): Promise<Auth>;
32
31
  //#endregion
33
- export { requestPasswordReset, resetPassword };
34
32
  //# sourceMappingURL=password-reset.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"password-reset.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/password-reset.ts"],"mappings":";;;;;;AAwDA;;;;;;;;;;;;;iBAAsB,oBAAA,WAA+B,IAAA,EACnD,KAAA,EAAO,UAAA,CAAW,CAAA,GAClB,UAAA,WACC,OAAA;;;;AAAO;AAmCV;;;;;;iBAAsB,aAAA,CAAc,KAAA,UAAe,WAAA,WAAsB,OAAO,CAAC,IAAA"}
1
+ {"version":3,"file":"password-reset.d.mts","names":[],"sources":["../../../../../../../../packages/auth/src/services/password-reset.ts"],"mappings":";;;;;;;;;;;;;;;;;;wBAwDsB,qBAAqB,UAAU,MACnD,OAAO,WAAW,IAClB,qBACC;;;;;;;;;;;wBAmCmB,cAAc,eAAe,sBAAsB,QAAQ"}
@@ -1,22 +1,28 @@
1
1
  import { CookieDomainResolver, TokenFrom } from "../contracts/types.mjs";
2
2
  import { Request, Response } from "@warlock.js/core";
3
-
4
3
  //#region ../../packages/auth/src/services/resolve-request-user.d.ts
5
- type ResolveRequestUserOptions = {
6
- /** Where the access token is read from. Defaults to `"header"`. */tokenFrom?: TokenFrom; /** Refresh credential source; enables one automatic renewal per call. */
7
- refreshCredential?: TokenFrom; /** Refresh overlap window forwarded to `authService.renewAutomaticSession`. */
8
- overlapMs?: number; /** User types allowed to pass. Empty means any authenticated type. */
9
- allowedTypes?: string[]; /** Absolute family lifetime in ms; rotation never extends a family past it. */
10
- maxAgeMs?: number; /** The single user type a renewal mints for. Required for renewal. */
11
- renewalUserType?: string; /** Select a request-scoped Domain for renewed cookies. */
4
+ export type ResolveRequestUserOptions = {
5
+ /** Where the access token is read from. Defaults to `"header"`. */
6
+ tokenFrom?: TokenFrom;
7
+ /** Refresh credential source; enables one automatic renewal per call. */
8
+ refreshCredential?: TokenFrom;
9
+ /** Refresh overlap window forwarded to `authService.renewAutomaticSession`. */
10
+ overlapMs?: number;
11
+ /** User types allowed to pass. Empty means any authenticated type. */
12
+ allowedTypes?: string[];
13
+ /** Absolute family lifetime in ms; rotation never extends a family past it. */
14
+ maxAgeMs?: number;
15
+ /** The single user type a renewal mints for. Required for renewal. */
16
+ renewalUserType?: string;
17
+ /** Select a request-scoped Domain for renewed cookies. */
12
18
  cookieDomain?: CookieDomainResolver;
13
19
  };
14
20
  /**
15
21
  * Why a request did not resolve to a user. The middleware maps each reason to
16
22
  * its own response; `resolveRequestUser` collapses them all to `null`.
17
23
  */
18
- type RequestUserFailure = "missing" | "invalid" | "forbidden" | "unauthorized";
19
- type RequestUserOutcome<TUser = any> = {
24
+ export type RequestUserFailure = "missing" | "invalid" | "forbidden" | "unauthorized";
25
+ export type RequestUserOutcome<TUser = any> = {
20
26
  user: TUser;
21
27
  failure?: undefined;
22
28
  } | {
@@ -24,7 +30,7 @@ type RequestUserOutcome<TUser = any> = {
24
30
  failure: RequestUserFailure;
25
31
  };
26
32
  /** Read one credential (access or refresh) from the header or a cookie. */
27
- declare function readCredential(request: Request, tokenFrom: TokenFrom): string;
33
+ export declare function readCredential(request: Request, tokenFrom: TokenFrom): string;
28
34
  /**
29
35
  * Resolve a request's credential to a user, reporting WHY it failed.
30
36
  *
@@ -36,7 +42,7 @@ declare function readCredential(request: Request, tokenFrom: TokenFrom): string;
36
42
  * At most one renewal is attempted per call. The renewed access token is
37
43
  * checked through the same path; no handler or unsafe request replay happens.
38
44
  */
39
- declare function resolveRequestUserOutcome(request: Request, response: Response, options?: ResolveRequestUserOptions): Promise<RequestUserOutcome>;
45
+ export declare function resolveRequestUserOutcome(request: Request, response: Response, options?: ResolveRequestUserOptions): Promise<RequestUserOutcome>;
40
46
  /**
41
47
  * Resolve the request's credential to its user model, or `null` when there is
42
48
  * none (missing, invalid, expired, wrong type, or not allowed to authenticate).
@@ -44,7 +50,6 @@ declare function resolveRequestUserOutcome(request: Request, response: Response,
44
50
  * Includes the middleware's automatic renewal when `options.refreshCredential`
45
51
  * is set. Use `resolveRequestUserOutcome` when the failure reason matters.
46
52
  */
47
- declare function resolveRequestUser(request: Request, response: Response, options?: ResolveRequestUserOptions): Promise<any>;
53
+ export declare function resolveRequestUser(request: Request, response: Response, options?: ResolveRequestUserOptions): Promise<any>;
48
54
  //#endregion
49
- export { RequestUserFailure, RequestUserOutcome, ResolveRequestUserOptions, readCredential, resolveRequestUser, resolveRequestUserOutcome };
50
55
  //# sourceMappingURL=resolve-request-user.d.mts.map