@pureq/auth 0.2.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 (198) hide show
  1. package/README.md +293 -0
  2. package/dist/adapter/capabilities.d.ts +23 -0
  3. package/dist/adapter/capabilities.d.ts.map +1 -0
  4. package/dist/adapter/capabilities.js +77 -0
  5. package/dist/adapter/capabilities.js.map +1 -0
  6. package/dist/adapter/index.d.ts +12 -0
  7. package/dist/adapter/index.d.ts.map +1 -0
  8. package/dist/adapter/index.js +121 -0
  9. package/dist/adapter/index.js.map +1 -0
  10. package/dist/adapter/sql.d.ts +36 -0
  11. package/dist/adapter/sql.d.ts.map +1 -0
  12. package/dist/adapter/sql.js +268 -0
  13. package/dist/adapter/sql.js.map +1 -0
  14. package/dist/adapters/index.d.ts +4 -0
  15. package/dist/adapters/index.d.ts.map +1 -0
  16. package/dist/adapters/index.js +42 -0
  17. package/dist/adapters/index.js.map +1 -0
  18. package/dist/authorization/index.d.ts +8 -0
  19. package/dist/authorization/index.d.ts.map +1 -0
  20. package/dist/authorization/index.js +49 -0
  21. package/dist/authorization/index.js.map +1 -0
  22. package/dist/bridge/index.d.ts +23 -0
  23. package/dist/bridge/index.d.ts.map +1 -0
  24. package/dist/bridge/index.js +124 -0
  25. package/dist/bridge/index.js.map +1 -0
  26. package/dist/callbacks/index.d.ts +8 -0
  27. package/dist/callbacks/index.d.ts.map +1 -0
  28. package/dist/callbacks/index.js +53 -0
  29. package/dist/callbacks/index.js.map +1 -0
  30. package/dist/core/index.d.ts +12 -0
  31. package/dist/core/index.d.ts.map +1 -0
  32. package/dist/core/index.js +481 -0
  33. package/dist/core/index.js.map +1 -0
  34. package/dist/core/kit.d.ts +7 -0
  35. package/dist/core/kit.d.ts.map +1 -0
  36. package/dist/core/kit.js +145 -0
  37. package/dist/core/kit.js.map +1 -0
  38. package/dist/core/starter.d.ts +28 -0
  39. package/dist/core/starter.d.ts.map +1 -0
  40. package/dist/core/starter.js +67 -0
  41. package/dist/core/starter.js.map +1 -0
  42. package/dist/csrf/index.d.ts +7 -0
  43. package/dist/csrf/index.d.ts.map +1 -0
  44. package/dist/csrf/index.js +126 -0
  45. package/dist/csrf/index.js.map +1 -0
  46. package/dist/debug/index.d.ts +8 -0
  47. package/dist/debug/index.d.ts.map +1 -0
  48. package/dist/debug/index.js +21 -0
  49. package/dist/debug/index.js.map +1 -0
  50. package/dist/encryption/index.d.ts +8 -0
  51. package/dist/encryption/index.d.ts.map +1 -0
  52. package/dist/encryption/index.js +43 -0
  53. package/dist/encryption/index.js.map +1 -0
  54. package/dist/events/index.d.ts +22 -0
  55. package/dist/events/index.d.ts.map +1 -0
  56. package/dist/events/index.js +53 -0
  57. package/dist/events/index.js.map +1 -0
  58. package/dist/framework/index.d.ts +10 -0
  59. package/dist/framework/index.d.ts.map +1 -0
  60. package/dist/framework/index.js +68 -0
  61. package/dist/framework/index.js.map +1 -0
  62. package/dist/framework/packs.d.ts +54 -0
  63. package/dist/framework/packs.d.ts.map +1 -0
  64. package/dist/framework/packs.js +124 -0
  65. package/dist/framework/packs.js.map +1 -0
  66. package/dist/framework/recipes.d.ts +6 -0
  67. package/dist/framework/recipes.d.ts.map +1 -0
  68. package/dist/framework/recipes.js +108 -0
  69. package/dist/framework/recipes.js.map +1 -0
  70. package/dist/hooks/index.d.ts +11 -0
  71. package/dist/hooks/index.d.ts.map +1 -0
  72. package/dist/hooks/index.js +95 -0
  73. package/dist/hooks/index.js.map +1 -0
  74. package/dist/hooks/react.d.ts +9 -0
  75. package/dist/hooks/react.d.ts.map +1 -0
  76. package/dist/hooks/react.js +24 -0
  77. package/dist/hooks/react.js.map +1 -0
  78. package/dist/hooks/vue.d.ts +4 -0
  79. package/dist/hooks/vue.d.ts.map +1 -0
  80. package/dist/hooks/vue.js +32 -0
  81. package/dist/hooks/vue.js.map +1 -0
  82. package/dist/index.d.ts +36 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +31 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/jwt/index.d.ts +13 -0
  87. package/dist/jwt/index.d.ts.map +1 -0
  88. package/dist/jwt/index.js +82 -0
  89. package/dist/jwt/index.js.map +1 -0
  90. package/dist/middleware/authBasic.d.ts +5 -0
  91. package/dist/middleware/authBasic.d.ts.map +1 -0
  92. package/dist/middleware/authBasic.js +25 -0
  93. package/dist/middleware/authBasic.js.map +1 -0
  94. package/dist/middleware/authBearer.d.ts +4 -0
  95. package/dist/middleware/authBearer.d.ts.map +1 -0
  96. package/dist/middleware/authBearer.js +26 -0
  97. package/dist/middleware/authBearer.js.map +1 -0
  98. package/dist/middleware/authCustom.d.ts +4 -0
  99. package/dist/middleware/authCustom.d.ts.map +1 -0
  100. package/dist/middleware/authCustom.js +22 -0
  101. package/dist/middleware/authCustom.js.map +1 -0
  102. package/dist/middleware/authRefresh.d.ts +4 -0
  103. package/dist/middleware/authRefresh.d.ts.map +1 -0
  104. package/dist/middleware/authRefresh.js +68 -0
  105. package/dist/middleware/authRefresh.js.map +1 -0
  106. package/dist/middleware/authSession.d.ts +5 -0
  107. package/dist/middleware/authSession.d.ts.map +1 -0
  108. package/dist/middleware/authSession.js +35 -0
  109. package/dist/middleware/authSession.js.map +1 -0
  110. package/dist/middleware/broadcastSync.d.ts +7 -0
  111. package/dist/middleware/broadcastSync.d.ts.map +1 -0
  112. package/dist/middleware/broadcastSync.js +36 -0
  113. package/dist/middleware/broadcastSync.js.map +1 -0
  114. package/dist/middleware/common.d.ts +3 -0
  115. package/dist/middleware/common.d.ts.map +1 -0
  116. package/dist/middleware/common.js +10 -0
  117. package/dist/middleware/common.js.map +1 -0
  118. package/dist/middleware/index.d.ts +8 -0
  119. package/dist/middleware/index.d.ts.map +1 -0
  120. package/dist/middleware/index.js +8 -0
  121. package/dist/middleware/index.js.map +1 -0
  122. package/dist/middleware/tokenLifecycle.d.ts +4 -0
  123. package/dist/middleware/tokenLifecycle.d.ts.map +1 -0
  124. package/dist/middleware/tokenLifecycle.js +52 -0
  125. package/dist/middleware/tokenLifecycle.js.map +1 -0
  126. package/dist/migration/index.d.ts +40 -0
  127. package/dist/migration/index.d.ts.map +1 -0
  128. package/dist/migration/index.js +136 -0
  129. package/dist/migration/index.js.map +1 -0
  130. package/dist/oidc/index.d.ts +25 -0
  131. package/dist/oidc/index.d.ts.map +1 -0
  132. package/dist/oidc/index.js +392 -0
  133. package/dist/oidc/index.js.map +1 -0
  134. package/dist/oidc/providers.d.ts +21 -0
  135. package/dist/oidc/providers.d.ts.map +1 -0
  136. package/dist/oidc/providers.js +51 -0
  137. package/dist/oidc/providers.js.map +1 -0
  138. package/dist/presets/index.d.ts +13 -0
  139. package/dist/presets/index.d.ts.map +1 -0
  140. package/dist/presets/index.js +12 -0
  141. package/dist/presets/index.js.map +1 -0
  142. package/dist/providers/callbackContracts.d.ts +14 -0
  143. package/dist/providers/callbackContracts.d.ts.map +1 -0
  144. package/dist/providers/callbackContracts.js +14 -0
  145. package/dist/providers/callbackContracts.js.map +1 -0
  146. package/dist/providers/errors.d.ts +9 -0
  147. package/dist/providers/errors.d.ts.map +1 -0
  148. package/dist/providers/errors.js +66 -0
  149. package/dist/providers/errors.js.map +1 -0
  150. package/dist/providers/index.d.ts +28 -0
  151. package/dist/providers/index.d.ts.map +1 -0
  152. package/dist/providers/index.js +29 -0
  153. package/dist/providers/index.js.map +1 -0
  154. package/dist/providers/presets.d.ts +17 -0
  155. package/dist/providers/presets.d.ts.map +1 -0
  156. package/dist/providers/presets.js +84 -0
  157. package/dist/providers/presets.js.map +1 -0
  158. package/dist/revocation/index.d.ts +10 -0
  159. package/dist/revocation/index.d.ts.map +1 -0
  160. package/dist/revocation/index.js +182 -0
  161. package/dist/revocation/index.js.map +1 -0
  162. package/dist/session/exporters.d.ts +15 -0
  163. package/dist/session/exporters.d.ts.map +1 -0
  164. package/dist/session/exporters.js +62 -0
  165. package/dist/session/exporters.js.map +1 -0
  166. package/dist/session/index.d.ts +11 -0
  167. package/dist/session/index.d.ts.map +1 -0
  168. package/dist/session/index.js +324 -0
  169. package/dist/session/index.js.map +1 -0
  170. package/dist/shared/encoding.d.ts +5 -0
  171. package/dist/shared/encoding.d.ts.map +1 -0
  172. package/dist/shared/encoding.js +27 -0
  173. package/dist/shared/encoding.js.map +1 -0
  174. package/dist/shared/errors.d.ts +13 -0
  175. package/dist/shared/errors.d.ts.map +1 -0
  176. package/dist/shared/errors.js +12 -0
  177. package/dist/shared/errors.js.map +1 -0
  178. package/dist/shared/index.d.ts +5 -0
  179. package/dist/shared/index.d.ts.map +1 -0
  180. package/dist/shared/index.js +5 -0
  181. package/dist/shared/index.js.map +1 -0
  182. package/dist/shared/types.d.ts +585 -0
  183. package/dist/shared/types.d.ts.map +1 -0
  184. package/dist/shared/types.js +2 -0
  185. package/dist/shared/types.js.map +1 -0
  186. package/dist/shared/values.d.ts +3 -0
  187. package/dist/shared/values.d.ts.map +1 -0
  188. package/dist/shared/values.js +23 -0
  189. package/dist/shared/values.js.map +1 -0
  190. package/dist/storage/index.d.ts +44 -0
  191. package/dist/storage/index.d.ts.map +1 -0
  192. package/dist/storage/index.js +318 -0
  193. package/dist/storage/index.js.map +1 -0
  194. package/dist/templates/index.d.ts +9 -0
  195. package/dist/templates/index.d.ts.map +1 -0
  196. package/dist/templates/index.js +146 -0
  197. package/dist/templates/index.js.map +1 -0
  198. package/package.json +173 -0
@@ -0,0 +1,36 @@
1
+ export type { AuthStore, AuthBearerOptions, AuthRefreshOptions, TokenLifecycleOptions, AuthBasicOptions, AuthCustomOptions, BroadcastSyncOptions, OIDCFlow, OIDCFlowOptions, OIDCAuthorizationOptions, OIDCAuthorizationResult, OIDCTokenEndpointAuthMethod, OIDCProviderDefinition, OIDCCallbackParams, TokenResponse, AuthTokens, AuthSessionState, AuthSessionStatus, AuthSessionHookResult, AuthSessionManager, AuthSessionManagerOptions, AuthSessionEvent, AuthSessionEventAudit, AuthSessionEventExporter, AuthSessionEventListener, AuthTokenRotationPolicy, AuthSessionMiddlewareOptions, AuthCsrfOptions, AuthCsrfProtection, AuthRevocationClaims, AuthRevocationRegistry, AuthRevocationRegistryBackend, AuthRevocationGuardOptions, AuthBridge, AuthBridgeCookieOptions, AuthBridgeRequestLike, AuthFrameworkContext, AuthFrameworkContextOptions, AuthMappedHttpError, AuthRouteHandlerRecipe, AuthRouteHandlerRecipeOptions, AuthRequestAdapter, AuthRequestAdapterOptions, AuthServerActionFailure, AuthServerActionRecipe, AuthServerActionResult, AuthServerActionSuccess, AuthPreset, AuthPresetOptions, AuthSessionStore, AuthSessionStoreOptions, ReactAuthHooks, ReactUseSyncExternalStore, VueAuthSessionComposable, VueRuntimeBindings, AuthTemplateThreatModel, MultiTenantAuthPresetFactory, MultiTenantAuthPresetFactoryOptions, MultiTenantAuthTemplatePack, MultiTenantAuthTemplatePackOptions, SingleTenantAuthTemplate, SingleTenantAuthTemplateOptions, AuthLegacyTokenSnapshot, AuthMigrationResult, AuthUser, AuthAccount, AuthPersistedSession, AuthVerificationToken, AuthDatabaseAdapter, AuthProvider, AuthCredentialsProviderOptions, AuthEmailProviderOptions, AuthCallbacks, AuthEncryption, AuthAuthorization, AuthAuthorizationOptions, AuthDebugLogger, AuthConfig, AuthInstance, AuthKit, AuthKitConfig, AuthRouteHandlers, } from "./shared";
2
+ export { authMemoryStore, authLocalStorage, authSessionStorage, authCookieStore, authCustomStore, authHybridStore, authEncryptedStore, } from "./storage/index";
3
+ export { authBearer, authRefresh, authSession, withTokenLifecycle, authBasic, authCustom, withBroadcastSync } from "./middleware/index";
4
+ export { decodeJwt, verifyJwt } from "./jwt/index";
5
+ export { createOIDCFlow, createOIDCFlowFromProvider, createOIDCflow, createOIDCflowFromProvider, parseOIDCCallbackParams, oidcProviders } from "./oidc/index";
6
+ export { createAuthError, buildAuthError } from "./shared";
7
+ export { createAuthCsrfProtection, withCsrfProtection } from "./csrf/index";
8
+ export { createAuthRevocationRegistry, withRevocationGuard } from "./revocation/index";
9
+ export { createAuthEventAdapter, composeAuthEventListeners } from "./events/index";
10
+ export { createAuthBridge } from "./bridge/index";
11
+ export { createAuthPreset } from "./presets/index";
12
+ export { createAuthRequestAdapter } from "./adapters/index";
13
+ export { createAuthFrameworkContext } from "./framework/index";
14
+ export { createAuthRouteHandlerRecipe, createAuthServerActionRecipe, mapAuthErrorToHttp } from "./framework/recipes";
15
+ export { createExpressAuthKitPack, createFastifyAuthKitPack, createNextAuthKitPack, createReactAuthKitBootstrapPack, } from "./framework/packs";
16
+ export { createAuthSessionStore } from "./hooks/index";
17
+ export { createReactAuthHooks, createVueAuthSessionComposable } from "./hooks/index";
18
+ export { createMultiTenantAuthPresetFactory } from "./templates/index";
19
+ export { createSingleTenantAuthTemplate, createMultiTenantAuthTemplatePack } from "./templates/index";
20
+ export { normalizeLegacyAuthTokens, migrateLegacyTokensToStore, hydrateSessionManagerFromLegacy, analyzeAuthMigration, formatMigrationParityReport, generateMigrationChecklists, } from "./migration/index";
21
+ export { createAuthSessionManager, composeSessionEventAudits, createConsoleSessionEventAudit, createBufferedSessionEventExporter, } from "./session/index";
22
+ export type { SessionEventBufferedExporter, SessionEventExporterOptions } from "./session/index";
23
+ export type { AuthEventAdapter, AuthEventAdapterOptions } from "./events/index";
24
+ export { createInMemoryAdapter, createMySqlAdapter, createMySqlExecutor, createPostgresAdapter, createPostgresExecutor, createSqlAdapter, getSqlSchemaStatements, probeAdapterCapabilities, assessAdapterReadiness, } from "./adapter/index";
25
+ export type { AdapterCapabilityReport, AdapterReadinessOptions, AdapterReadinessReport, MySqlClientLike, PostgresClientLike, SqlAdapterOptions, SqlDialect, SqlExecutor, SqlRow, SqlValue, TableNames, } from "./adapter/index";
26
+ export { credentialsProvider, emailProvider, createTopProviderPreset, listTopProviderPresets, validateProviderCallbackContract, normalizeProviderError, PROVIDER_ERROR_NORMALIZATION_TABLE, } from "./providers/index";
27
+ export type { TopProviderPreset, TopProviderPresetOptions, ProviderCallbackContractInput, ProviderCallbackContractResult, ProviderNormalizedError, } from "./providers/index";
28
+ export { composeAuthCallbacks } from "./callbacks/index";
29
+ export { createAuthEncryption } from "./encryption/index";
30
+ export { createAuthorization } from "./authorization/index";
31
+ export { createAuthDebugLogger } from "./debug/index";
32
+ export { createAuth } from "./core/index";
33
+ export { createAuthKit } from "./core/kit";
34
+ export { createAuthStarter } from "./core/starter";
35
+ export type { AuthStarter, AuthStarterConfig } from "./core/starter";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,0BAA0B,EAC1B,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,mCAAmC,EACnC,2BAA2B,EAC3B,kCAAkC,EAClC,wBAAwB,EACxB,+BAA+B,EAC/B,u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jB,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ export { authMemoryStore, authLocalStorage, authSessionStorage, authCookieStore, authCustomStore, authHybridStore, authEncryptedStore, } from "./storage/index";
2
+ export { authBearer, authRefresh, authSession, withTokenLifecycle, authBasic, authCustom, withBroadcastSync } from "./middleware/index";
3
+ export { decodeJwt, verifyJwt } from "./jwt/index";
4
+ export { createOIDCFlow, createOIDCFlowFromProvider, createOIDCflow, createOIDCflowFromProvider, parseOIDCCallbackParams, oidcProviders } from "./oidc/index";
5
+ export { createAuthError, buildAuthError } from "./shared";
6
+ export { createAuthCsrfProtection, withCsrfProtection } from "./csrf/index";
7
+ export { createAuthRevocationRegistry, withRevocationGuard } from "./revocation/index";
8
+ export { createAuthEventAdapter, composeAuthEventListeners } from "./events/index";
9
+ export { createAuthBridge } from "./bridge/index";
10
+ export { createAuthPreset } from "./presets/index";
11
+ export { createAuthRequestAdapter } from "./adapters/index";
12
+ export { createAuthFrameworkContext } from "./framework/index";
13
+ export { createAuthRouteHandlerRecipe, createAuthServerActionRecipe, mapAuthErrorToHttp } from "./framework/recipes";
14
+ export { createExpressAuthKitPack, createFastifyAuthKitPack, createNextAuthKitPack, createReactAuthKitBootstrapPack, } from "./framework/packs";
15
+ export { createAuthSessionStore } from "./hooks/index";
16
+ export { createReactAuthHooks, createVueAuthSessionComposable } from "./hooks/index";
17
+ export { createMultiTenantAuthPresetFactory } from "./templates/index";
18
+ export { createSingleTenantAuthTemplate, createMultiTenantAuthTemplatePack } from "./templates/index";
19
+ export { normalizeLegacyAuthTokens, migrateLegacyTokensToStore, hydrateSessionManagerFromLegacy, analyzeAuthMigration, formatMigrationParityReport, generateMigrationChecklists, } from "./migration/index";
20
+ export { createAuthSessionManager, composeSessionEventAudits, createConsoleSessionEventAudit, createBufferedSessionEventExporter, } from "./session/index";
21
+ // New module exports
22
+ export { createInMemoryAdapter, createMySqlAdapter, createMySqlExecutor, createPostgresAdapter, createPostgresExecutor, createSqlAdapter, getSqlSchemaStatements, probeAdapterCapabilities, assessAdapterReadiness, } from "./adapter/index";
23
+ export { credentialsProvider, emailProvider, createTopProviderPreset, listTopProviderPresets, validateProviderCallbackContract, normalizeProviderError, PROVIDER_ERROR_NORMALIZATION_TABLE, } from "./providers/index";
24
+ export { composeAuthCallbacks } from "./callbacks/index";
25
+ export { createAuthEncryption } from "./encryption/index";
26
+ export { createAuthorization } from "./authorization/index";
27
+ export { createAuthDebugLogger } from "./debug/index";
28
+ export { createAuth } from "./core/index";
29
+ export { createAuthKit } from "./core/kit";
30
+ export { createAuthStarter } from "./core/starter";
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqFA,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,kBAAkB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC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BAAyB,EACzB,8BAA8B,EAC9B,kCAAkC,GAClC,MAAM,iBAAiB,CAAC;AAIzB,qBAAqB;AACrB,OAAO,EACN,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AAczB,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,EACtB,kCAAkC,GAClC,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Decode a JWT payload without signature verification. */
2
+ export declare function decodeJwt<T = unknown>(token: string): T;
3
+ /**
4
+ * Verify a JWT signature and return the decoded payload.
5
+ *
6
+ * @param token - The JWT string to verify.
7
+ * @param keyOrSecret - HMAC secret string, CryptoKey, or raw key bytes.
8
+ * @param options - Must include `algorithms` to prevent algorithm confusion attacks.
9
+ */
10
+ export declare function verifyJwt<T = unknown>(token: string, keyOrSecret: string | CryptoKey | ArrayBuffer | Uint8Array, options: {
11
+ readonly algorithms: readonly string[];
12
+ }): Promise<T>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jwt/index.ts"],"names":[],"mappings":"AAOA,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAOvD;AA2BD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACzC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,EAC1D,OAAO,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAClD,OAAO,CAAC,CAAC,CAAC,CAkEZ"}
@@ -0,0 +1,82 @@
1
+ import { base64UrlDecode } from "../shared";
2
+ function parseSegment(segment) {
3
+ const text = new TextDecoder().decode(base64UrlDecode(segment));
4
+ return JSON.parse(text);
5
+ }
6
+ /** Decode a JWT payload without signature verification. */
7
+ export function decodeJwt(token) {
8
+ const segments = token.split(".");
9
+ if (segments.length < 2 || !segments[1]) {
10
+ throw new Error("pureq: invalid JWT format");
11
+ }
12
+ return parseSegment(segments[1]);
13
+ }
14
+ const SUPPORTED_ALGORITHMS = ["HS256", "RS256", "ES256"];
15
+ function isSupportedAlgorithm(alg) {
16
+ return SUPPORTED_ALGORITHMS.includes(alg);
17
+ }
18
+ function algorithmParams(alg) {
19
+ switch (alg) {
20
+ case "HS256":
21
+ return { name: "HMAC", hash: "SHA-256" };
22
+ case "RS256":
23
+ return { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" };
24
+ case "ES256":
25
+ return { name: "ECDSA", namedCurve: "P-256" };
26
+ }
27
+ }
28
+ function verifyAlgorithmParams(alg) {
29
+ if (alg === "ES256") {
30
+ return { name: "ECDSA", hash: "SHA-256" };
31
+ }
32
+ return algorithmParams(alg);
33
+ }
34
+ /**
35
+ * Verify a JWT signature and return the decoded payload.
36
+ *
37
+ * @param token - The JWT string to verify.
38
+ * @param keyOrSecret - HMAC secret string, CryptoKey, or raw key bytes.
39
+ * @param options - Must include `algorithms` to prevent algorithm confusion attacks.
40
+ */
41
+ export async function verifyJwt(token, keyOrSecret, options) {
42
+ const [headerSegment, payloadSegment, signatureSegment] = token.split(".");
43
+ if (!headerSegment || !payloadSegment) {
44
+ throw new Error("pureq: invalid JWT format");
45
+ }
46
+ const header = parseSegment(headerSegment);
47
+ const alg = header.alg ?? "";
48
+ // SEC-C1: Reject alg: "none" unconditionally
49
+ if (alg === "none" || alg === "") {
50
+ throw new Error("pureq: JWT algorithm \"none\" is not permitted");
51
+ }
52
+ if (!signatureSegment) {
53
+ throw new Error("pureq: invalid JWT format");
54
+ }
55
+ // SEC-C2: Reject algorithms not in the caller's allowlist
56
+ if (!options.algorithms.includes(alg)) {
57
+ throw new Error(`pureq: unsupported JWT algorithm ${alg}`);
58
+ }
59
+ if (!isSupportedAlgorithm(alg)) {
60
+ throw new Error(`pureq: JWT verification is not implemented for algorithm ${alg}`);
61
+ }
62
+ const unsigned = `${headerSegment}.${payloadSegment}`;
63
+ const encoder = new TextEncoder();
64
+ const signature = base64UrlDecode(signatureSegment);
65
+ let key;
66
+ if (keyOrSecret instanceof CryptoKey) {
67
+ key = keyOrSecret;
68
+ }
69
+ else if (typeof keyOrSecret === "string") {
70
+ key = await crypto.subtle.importKey("raw", encoder.encode(keyOrSecret), algorithmParams(alg), false, ["verify"]);
71
+ }
72
+ else {
73
+ const rawBytes = keyOrSecret instanceof ArrayBuffer ? new Uint8Array(keyOrSecret) : keyOrSecret;
74
+ key = await crypto.subtle.importKey("raw", rawBytes, algorithmParams(alg), false, ["verify"]);
75
+ }
76
+ const verified = await crypto.subtle.verify(verifyAlgorithmParams(alg), key, signature, encoder.encode(unsigned));
77
+ if (!verified) {
78
+ throw new Error("pureq: JWT signature verification failed");
79
+ }
80
+ return parseSegment(payloadSegment);
81
+ }
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jwt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,M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AI,GAAc,CAAC;IAEnB,IAAI,WAAW,YAAY,SAAS,EAAE,CAAC;QACrC,GAAG,GAAG,WAAW,CAAC;IACpB,CAAC;SAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC3C,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACjC,KAAK,EACL,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAC3B,eAAe,CAAC,GAAG,CAAC,EACpB,KAAK,EACL,CAAC,QAAQ,CAAC,CACX,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,WAAW,YAAY,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAChG,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACjC,KAAK,EACL,QAAe,EACf,eAAe,CAAC,GAAG,CAAC,EACpB,KAAK,EACL,CAAC,QAAQ,CAAC,CACX,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CACzC,qBAAqB,CAAC,GAAG,CAAC,EAC1B,GAAG,EACH,SAAgB,EAChB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAQ,CAChC,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,YAAY,CAAI,cAAc,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { AuthBasicOptions } from "../shared";
3
+ /** HTTP Basic authentication middleware. SEC-H4: validates credentials for injection safety. */
4
+ export declare function authBasic(options: AuthBasicOptions): Middleware;
5
+ //# sourceMappingURL=authBasic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authBasic.d.ts","sourceRoot":"","sources":["../../src/middleware/authBasic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQlD,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,CAqB/D"}
@@ -0,0 +1,25 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ import { base64Encode, resolveStringValue, createAuthError } from "../shared";
3
+ import { mergeHeaders } from "./common";
4
+ function hasUnsafeChars(value) {
5
+ return /[\r\n\0]/u.test(value);
6
+ }
7
+ /** HTTP Basic authentication middleware. SEC-H4: validates credentials for injection safety. */
8
+ export function authBasic(options) {
9
+ const headerName = options.header ?? "Authorization";
10
+ const middleware = async (req, next) => {
11
+ const username = await resolveStringValue(options.username);
12
+ const password = await resolveStringValue(options.password);
13
+ // SEC-H4: Reject username containing ':' and unsafe header chars
14
+ if (username.includes(":")) {
15
+ throw createAuthError("PUREQ_AUTH_INVALID_CREDENTIALS", "pureq: Basic auth username must not contain ':'");
16
+ }
17
+ if (hasUnsafeChars(username) || hasUnsafeChars(password)) {
18
+ throw createAuthError("PUREQ_AUTH_INVALID_CREDENTIALS", "pureq: Basic auth credentials contain unsafe characters");
19
+ }
20
+ const encoded = base64Encode(`${username}:${password}`);
21
+ return next(mergeHeaders(req, { [headerName]: `Basic ${encoded}` }));
22
+ };
23
+ return markPolicyMiddleware(middleware, { name: "authBasic", kind: "auth" });
24
+ }
25
+ //# sourceMappingURL=authBasic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authBasic.js","sourceRoot":"","sources":["../../src/middleware/authBasic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC;IAErD,MAAM,UAAU,GAAe,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE5D,iEAAiE;QACjE,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,eAAe,CAAC,gCAAgC,EAAE,iDAAiD,CAAC,CAAC;QAC7G,CAAC;QACD,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzD,MAAM,eAAe,CAAC,gCAAgC,EAAE,yDAAyD,CAAC,CAAC;QACrH,CAAC;QAED,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC;QAExD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { AuthBearerOptions } from "../shared";
3
+ export declare function authBearer(options: AuthBearerOptions): Middleware;
4
+ //# sourceMappingURL=authBearer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authBearer.d.ts","sourceRoot":"","sources":["../../src/middleware/authBearer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAUnD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAoBjE"}
@@ -0,0 +1,26 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ import { buildAuthError } from "../shared";
3
+ import { mergeHeaders } from "./common";
4
+ const MAX_BEARER_TOKEN_LENGTH = 8192;
5
+ function hasUnsafeHeaderChars(token) {
6
+ return /[\r\n\0]/u.test(token);
7
+ }
8
+ export function authBearer(options) {
9
+ const headerName = options.header ?? "Authorization";
10
+ const formatValue = options.formatValue ?? ((token) => `Bearer ${token}`);
11
+ const middleware = async (req, next) => {
12
+ const token = await options.getToken(req);
13
+ if (!token || !token.trim()) {
14
+ throw buildAuthError("PUREQ_AUTH_MISSING_TOKEN", "pureq: no authentication token available");
15
+ }
16
+ if (token.length > MAX_BEARER_TOKEN_LENGTH || hasUnsafeHeaderChars(token)) {
17
+ throw buildAuthError("PUREQ_AUTH_INVALID_TOKEN", "pureq: authentication token contains unsafe header value");
18
+ }
19
+ if (options.validate && !(await options.validate(token))) {
20
+ throw buildAuthError("PUREQ_AUTH_INVALID_TOKEN", "pureq: authentication token validation failed");
21
+ }
22
+ return next(mergeHeaders(req, { [headerName]: formatValue(token) }));
23
+ };
24
+ return markPolicyMiddleware(middleware, { name: "authBearer", kind: "auth" });
25
+ }
26
+ //# sourceMappingURL=authBearer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authBearer.js","sourceRoot":"","sources":["../../src/middleware/authBearer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,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AAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { AuthCustomOptions } from "../shared";
3
+ export declare function authCustom(options: AuthCustomOptions): Middleware;
4
+ //# sourceMappingURL=authCustom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authCustom.d.ts","sourceRoot":"","sources":["../../src/middleware/authCustom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAInD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAqBjE"}
@@ -0,0 +1,22 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ import { appendQueryParam, resolveStringValue } from "../shared";
3
+ import { mergeHeaders } from "./common";
4
+ export function authCustom(options) {
5
+ const middleware = async (req, next) => {
6
+ let nextReq = req;
7
+ if (options.header) {
8
+ nextReq = mergeHeaders(nextReq, {
9
+ [options.header.name]: await resolveStringValue(options.header.value),
10
+ });
11
+ }
12
+ if (options.queryParam) {
13
+ nextReq = {
14
+ ...nextReq,
15
+ url: appendQueryParam(nextReq.url, options.queryParam.name, await resolveStringValue(options.queryParam.value)),
16
+ };
17
+ }
18
+ return next(nextReq);
19
+ };
20
+ return markPolicyMiddleware(middleware, { name: "authCustom", kind: "auth" });
21
+ }
22
+ //# sourceMappingURL=authCustom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authCustom.js","sourceRoot":"","sources":["../../src/middleware/authCustom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,UAAU,GAAe,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjD,IAAI,OAAO,GAAG,GAAG,CAAC;QAElB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE;gBAC9B,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;aACtE,CAAC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,GAAG;gBACR,GAAG,OAAO;gBACV,GAAG,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aAChH,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { AuthRefreshOptions } from "../shared";
3
+ export declare function authRefresh(options: AuthRefreshOptions): Middleware;
4
+ //# sourceMappingURL=authRefresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authRefresh.d.ts","sourceRoot":"","sources":["../../src/middleware/authRefresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAmBpD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU,CA6DnE"}
@@ -0,0 +1,68 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ import { buildAuthError } from "../shared";
3
+ import { mergeHeaders } from "./common";
4
+ function readHeader(headers, name) {
5
+ if (!headers) {
6
+ return null;
7
+ }
8
+ const normalized = name.toLowerCase();
9
+ for (const [key, value] of Object.entries(headers)) {
10
+ if (key.toLowerCase() === normalized) {
11
+ return typeof value === "string" ? value : null;
12
+ }
13
+ }
14
+ return null;
15
+ }
16
+ export function authRefresh(options) {
17
+ const triggerStatus = options.triggerStatus ?? 401;
18
+ const maxAttempts = options.maxAttempts ?? 1;
19
+ const updateRequest = options.updateRequest ??
20
+ ((req, newToken) => mergeHeaders(req, { Authorization: `Bearer ${newToken}` }));
21
+ const getRefreshScopeKey = options.getRefreshScopeKey ??
22
+ ((req) => readHeader(req.headers, "authorization") ?? "__global_refresh_scope__");
23
+ const refreshByScope = new Map();
24
+ const getOrStartRefresh = (req) => {
25
+ const scopeKey = getRefreshScopeKey(req) || "__global_refresh_scope__";
26
+ const existing = refreshByScope.get(scopeKey);
27
+ if (existing) {
28
+ return existing;
29
+ }
30
+ const refreshPromise = options
31
+ .refresh(req)
32
+ .then(async (newToken) => {
33
+ await options.onSuccess?.(newToken);
34
+ return newToken;
35
+ })
36
+ .catch(async (error) => {
37
+ const normalized = error instanceof Error ? error : new Error(String(error));
38
+ await options.onFailure?.(normalized);
39
+ throw normalized;
40
+ })
41
+ .finally(() => {
42
+ refreshByScope.delete(scopeKey);
43
+ });
44
+ refreshByScope.set(scopeKey, refreshPromise);
45
+ return refreshPromise;
46
+ };
47
+ const middleware = async (req, next) => {
48
+ let attempts = 0;
49
+ let currentReq = req;
50
+ while (attempts <= maxAttempts) {
51
+ const response = await next(currentReq);
52
+ if (response.status !== triggerStatus || attempts >= maxAttempts) {
53
+ return response;
54
+ }
55
+ attempts += 1;
56
+ try {
57
+ const newToken = await getOrStartRefresh(currentReq);
58
+ currentReq = updateRequest(currentReq, newToken);
59
+ }
60
+ catch (error) {
61
+ throw buildAuthError("PUREQ_AUTH_REFRESH_FAILED", "pureq: token refresh failed", error);
62
+ }
63
+ }
64
+ throw buildAuthError("PUREQ_AUTH_UNAUTHORIZED", "pureq: authentication refresh loop exited unexpectedly");
65
+ };
66
+ return markPolicyMiddleware(middleware, { name: "authRefresh", kind: "auth" });
67
+ }
68
+ //# sourceMappingURL=authRefresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authRefresh.js","sourceRoot":"","sources":["../../src/middleware/authRefresh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,SAAS,UAAU,CAAC,OAAiC,EAAE,IAAY;IACjE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC;YACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,GAAG,CAAC;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC7C,MAAM,aAAa,GACjB,OAAO,CAAC,aAAa;QACrB,CAAC,CAAC,GAAkB,EAAE,QAAgB,EAAE,EAAE,CAAC,YAAY,CAA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AAO,cAAc,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAe,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjD,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,UAAU,GAAG,GAAG,CAAC;QAErB,OAAO,QAAQ,IAAI,WAAW,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;YACxC,IAAI,QAAQ,CAAC,MAAM,KAAK,aAAa,IAAI,QAAQ,IAAI,WAAW,EAAE,CAAC;gBACjE,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,QAAQ,IAAI,CAAC,CAAC;YAEd,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBACrD,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,cAAc,CAAC,2BAA2B,EAAE,6BAA6B,EAAE,KAAK,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;QAED,MAAM,cAAc,CAAC,yBAAyB,EAAE,wDAAwD,CAAC,CAAC;IAC5G,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACjF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { AuthSessionMiddlewareOptions } from "../shared";
3
+ /** Session middleware — refreshes tokens as needed and injects the access token into the request (DX-L2). */
4
+ export declare function authSession(options: AuthSessionMiddlewareOptions): Middleware;
5
+ //# sourceMappingURL=authSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authSession.d.ts","sourceRoot":"","sources":["../../src/middleware/authSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,4BAA4B,EAAoB,MAAM,WAAW,CAAC;AAchF,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,OAAO,EAAE,4BAA4B,GAAG,UAAU,CAwB7E"}
@@ -0,0 +1,35 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ import { buildAuthError } from "../shared";
3
+ import { mergeHeaders } from "./common";
4
+ async function ensureAuthState(options) {
5
+ try {
6
+ return await options.session.refreshIfNeeded(options.refresh, options.refreshThresholdMs ?? 60000);
7
+ }
8
+ catch (error) {
9
+ const normalized = error instanceof Error ? error : new Error(String(error));
10
+ await options.onRefreshError?.(normalized);
11
+ throw buildAuthError("PUREQ_AUTH_REFRESH_FAILED", "pureq: failed to refresh session token", error);
12
+ }
13
+ }
14
+ /** Session middleware — refreshes tokens as needed and injects the access token into the request (DX-L2). */
15
+ export function authSession(options) {
16
+ const middleware = async (req, next) => {
17
+ const before = await options.session.getState();
18
+ const state = await ensureAuthState(options);
19
+ const refreshed = before.accessToken !== state.accessToken;
20
+ if (refreshed) {
21
+ await options.onRefreshed?.(state);
22
+ }
23
+ if ((options.requireAccessToken ?? true) && !state.accessToken) {
24
+ throw buildAuthError("PUREQ_AUTH_MISSING_TOKEN", "pureq: no active session access token");
25
+ }
26
+ // DX-L2: Inject the current access token into the request
27
+ let nextReq = req;
28
+ if (state.accessToken) {
29
+ nextReq = mergeHeaders(req, { Authorization: `Bearer ${state.accessToken}` });
30
+ }
31
+ return next(nextReq);
32
+ };
33
+ return markPolicyMiddleware(middleware, { name: "authSession", kind: "auth" });
34
+ }
35
+ //# sourceMappingURL=authSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authSession.js","sourceRoot":"","sources":["../../src/middleware/authSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAA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CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,GAAG,YAAY,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACjF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { BroadcastSyncOptions } from "../shared";
3
+ /** DX-L1: BroadcastSync with dispose support. */
4
+ export declare function withBroadcastSync(options: BroadcastSyncOptions): Middleware & {
5
+ dispose(): void;
6
+ };
7
+ //# sourceMappingURL=broadcastSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcastSync.d.ts","sourceRoot":"","sources":["../../src/middleware/broadcastSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,iDAAiD;AACjD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,UAAU,GAAG;IAAE,OAAO,IAAI,IAAI,CAAA;CAAE,CAqCjG"}
@@ -0,0 +1,36 @@
1
+ import { markPolicyMiddleware } from "@pureq/pureq";
2
+ /** DX-L1: BroadcastSync with dispose support. */
3
+ export function withBroadcastSync(options) {
4
+ const channelName = options.channel ?? "auth:token";
5
+ let initialized = false;
6
+ let channel = null;
7
+ const initialize = () => {
8
+ if (initialized || typeof BroadcastChannel !== "function") {
9
+ initialized = true;
10
+ return;
11
+ }
12
+ channel = new BroadcastChannel(channelName);
13
+ channel.onmessage = (event) => {
14
+ const token = typeof event.data === "string" ? event.data : event.data?.token;
15
+ if (typeof token === "string" && token.length > 0) {
16
+ void options.onRemoteRefresh(token);
17
+ }
18
+ };
19
+ initialized = true;
20
+ };
21
+ const middleware = async (req, next) => {
22
+ initialize();
23
+ return next(req);
24
+ };
25
+ const marked = markPolicyMiddleware(middleware, { name: "withBroadcastSync", kind: "auth" });
26
+ return Object.assign(marked, {
27
+ dispose() {
28
+ if (channel) {
29
+ channel.onmessage = null;
30
+ channel.close();
31
+ channel = null;
32
+ }
33
+ },
34
+ });
35
+ }
36
+ //# sourceMappingURL=broadcastSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcastSync.js","sourceRoot":"","sources":["../../src/middleware/broadcastSync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,iDAAiD;AACjD,MAAM,UAAU,iBAAiB,CAAC,OAA6B;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC;IACpD,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,OAAO,GAA4B,IAAI,CAAC;IAE5C,MAAM,UAAU,GAAG,GAAS,EAAE;QAC5B,IAAI,WAAW,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAC1D,WAAW,GAAG,IAAI,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,GAAG,IAAI,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC5C,OAAO,CAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;YAC5B,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;YAC9E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClD,KAAK,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC;QACF,WAAW,GAAG,IAAI,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAe,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjD,UAAU,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,oBAAoB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,OAAO;YACL,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;gBACzB,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RequestConfig } from "@pureq/pureq";
2
+ export declare function mergeHeaders(req: RequestConfig, headers: Readonly<Record<string, string>>): RequestConfig;
3
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/middleware/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,aAAa,CAQzG"}
@@ -0,0 +1,10 @@
1
+ export function mergeHeaders(req, headers) {
2
+ return {
3
+ ...req,
4
+ headers: {
5
+ ...req.headers,
6
+ ...headers,
7
+ },
8
+ };
9
+ }
10
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/middleware/common.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAkB,EAAE,OAAyC;IACxF,OAAO;QACL,GAAG,GAAG;QACN,OAAO,EAAE;YACP,GAAG,GAAG,CAAC,OAAO;YACd,GAAG,OAAO;SACX;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { authBearer } from "./authBearer";
2
+ export { authRefresh } from "./authRefresh";
3
+ export { authSession } from "./authSession";
4
+ export { withTokenLifecycle } from "./tokenLifecycle";
5
+ export { authBasic } from "./authBasic";
6
+ export { authCustom } from "./authCustom";
7
+ export { withBroadcastSync } from "./broadcastSync";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { authBearer } from "./authBearer";
2
+ export { authRefresh } from "./authRefresh";
3
+ export { authSession } from "./authSession";
4
+ export { withTokenLifecycle } from "./tokenLifecycle";
5
+ export { authBasic } from "./authBasic";
6
+ export { authCustom } from "./authCustom";
7
+ export { withBroadcastSync } from "./broadcastSync";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@pureq/pureq";
2
+ import type { TokenLifecycleOptions } from "../shared";
3
+ export declare function withTokenLifecycle(options: TokenLifecycleOptions): Middleware;
4
+ //# sourceMappingURL=tokenLifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenLifecycle.d.ts","sourceRoot":"","sources":["../../src/middleware/tokenLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAIvD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAiD7E"}