@rebasepro/server 0.16.0 → 0.16.1-canary.g2d1aec8

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 (160) hide show
  1. package/dist/api/contract-routes.d.ts +1 -1
  2. package/dist/api/errors.d.ts +1 -1
  3. package/dist/api/index.d.ts +3 -3
  4. package/dist/api/live-schema-routes.d.ts +111 -0
  5. package/dist/api/logs-routes.d.ts +1 -1
  6. package/dist/api/mount.d.ts +41 -0
  7. package/dist/api/rest/api-generator.d.ts +2 -2
  8. package/dist/api/rest/index.d.ts +1 -1
  9. package/dist/api/rest/query-parser.d.ts +1 -1
  10. package/dist/api/schema-editor-routes.d.ts +1 -1
  11. package/dist/api/types.d.ts +3 -4
  12. package/dist/{schema-editor-routes-CV9k0w3G.js → ast-schema-editor-BpFYpT38.js} +2 -39
  13. package/dist/ast-schema-editor-BpFYpT38.js.map +1 -0
  14. package/dist/auth/adapter-middleware.d.ts +2 -2
  15. package/dist/auth/admin-roles-route.d.ts +2 -2
  16. package/dist/auth/admin-user-ops.d.ts +3 -3
  17. package/dist/auth/admin-users-route.d.ts +4 -4
  18. package/dist/auth/api-keys/api-key-middleware.d.ts +2 -2
  19. package/dist/auth/api-keys/api-key-permission-guard.d.ts +1 -1
  20. package/dist/auth/api-keys/api-key-routes.d.ts +2 -2
  21. package/dist/auth/api-keys/api-key-store.d.ts +1 -1
  22. package/dist/auth/api-keys/index.d.ts +9 -9
  23. package/dist/auth/apple-oauth.d.ts +2 -2
  24. package/dist/auth/auth-hooks.d.ts +3 -3
  25. package/dist/auth/bitbucket-oauth.d.ts +2 -2
  26. package/dist/auth/builtin-auth-adapter.d.ts +7 -4
  27. package/dist/auth/captcha.d.ts +86 -0
  28. package/dist/auth/cookie-utils.d.ts +2 -2
  29. package/dist/auth/discord-oauth.d.ts +2 -2
  30. package/dist/auth/facebook-oauth.d.ts +2 -2
  31. package/dist/auth/github-oauth.d.ts +2 -2
  32. package/dist/auth/gitlab-oauth.d.ts +2 -2
  33. package/dist/auth/google-oauth.d.ts +1 -1
  34. package/dist/auth/index.d.ts +56 -54
  35. package/dist/auth/jwks-routes.d.ts +1 -1
  36. package/dist/auth/jwt.d.ts +1 -1
  37. package/dist/auth/linkedin-oauth.d.ts +2 -2
  38. package/dist/auth/magic-link-routes.d.ts +10 -3
  39. package/dist/auth/mfa-gate.d.ts +1 -1
  40. package/dist/auth/mfa-routes.d.ts +3 -3
  41. package/dist/auth/microsoft-oauth.d.ts +2 -2
  42. package/dist/auth/middleware.d.ts +5 -5
  43. package/dist/auth/rate-limiter.d.ts +2 -2
  44. package/dist/auth/require-auth.d.ts +1 -1
  45. package/dist/auth/reset-password-admin.d.ts +4 -4
  46. package/dist/auth/routes.d.ts +13 -4
  47. package/dist/auth/session-routes.d.ts +3 -3
  48. package/dist/auth/slack-oauth.d.ts +2 -2
  49. package/dist/auth/spotify-oauth.d.ts +2 -2
  50. package/dist/auth/token-revocation.d.ts +2 -2
  51. package/dist/auth/twitter-oauth.d.ts +2 -2
  52. package/dist/{auth-5Et5mnUA.js → auth-C74dqR2B.js} +250 -15
  53. package/dist/auth-C74dqR2B.js.map +1 -0
  54. package/dist/backup/backup-common.d.ts +1 -1
  55. package/dist/backup/backup-routes.d.ts +3 -3
  56. package/dist/backup/index.d.ts +3 -3
  57. package/dist/{backup-C6ljYVTp.js → backup-BJ86ah4T.js} +2 -2
  58. package/dist/{backup-C6ljYVTp.js.map → backup-BJ86ah4T.js.map} +1 -1
  59. package/dist/boot/boot.d.ts +5 -5
  60. package/dist/boot/bundle.d.ts +1 -1
  61. package/dist/boot/driver.d.ts +1 -1
  62. package/dist/boot/env.d.ts +13 -1
  63. package/dist/boot/options.d.ts +30 -6
  64. package/dist/boot/role.d.ts +3 -2
  65. package/dist/boot/sources.d.ts +1 -1
  66. package/dist/collections/BackendCollectionRegistry.d.ts +1 -1
  67. package/dist/collections/loader.d.ts +1 -1
  68. package/dist/{contract-routes-DZ-LBpSL.js → contract-routes-BEq7euZg.js} +2 -2
  69. package/dist/contract-routes-BEq7euZg.js.map +1 -0
  70. package/dist/cron/cron-routes.d.ts +2 -2
  71. package/dist/cron/cron-scheduler.d.ts +2 -2
  72. package/dist/cron/index.d.ts +8 -8
  73. package/dist/{cron-loader-YhhQeVBM.js → cron-loader-BMvtW6-J.js} +2 -2
  74. package/dist/{cron-loader-YhhQeVBM.js.map → cron-loader-BMvtW6-J.js.map} +1 -1
  75. package/dist/{cron-routes-maM_RlUu.js → cron-routes-BvYk-Kmi.js} +2 -2
  76. package/dist/{cron-routes-maM_RlUu.js.map → cron-routes-BvYk-Kmi.js.map} +1 -1
  77. package/dist/{cron-scheduler-DIpYBmZP.js → cron-scheduler-Buf-uVam.js} +2 -2
  78. package/dist/{cron-scheduler-DIpYBmZP.js.map → cron-scheduler-Buf-uVam.js.map} +1 -1
  79. package/dist/{cron-store-DfH_4Cd9.js → cron-store-CyF-oInV.js} +3 -3
  80. package/dist/{cron-store-DfH_4Cd9.js.map → cron-store-CyF-oInV.js.map} +1 -1
  81. package/dist/{ddl-bootstrap-Cywoj8Ta.js → ddl-bootstrap-DgSnERYN.js} +17 -3
  82. package/dist/ddl-bootstrap-DgSnERYN.js.map +1 -0
  83. package/dist/dev-secrets.d.ts +52 -0
  84. package/dist/email/dev-sink.d.ts +67 -0
  85. package/dist/email/index.d.ts +9 -7
  86. package/dist/email/link-base.d.ts +1 -1
  87. package/dist/email/smtp-email-service.d.ts +1 -1
  88. package/dist/env.d.ts +1 -1
  89. package/dist/{errors-EBYiaJ2E.js → errors-D_LwNKRM.js} +5 -5
  90. package/dist/errors-D_LwNKRM.js.map +1 -0
  91. package/dist/{function-loader-DDS1v7YX.js → function-loader-BrLmC_-y.js} +3 -3
  92. package/dist/{function-loader-DDS1v7YX.js.map → function-loader-BrLmC_-y.js.map} +1 -1
  93. package/dist/functions/context.d.ts +141 -0
  94. package/dist/functions/define-function.d.ts +1 -1
  95. package/dist/functions/function-routes.d.ts +2 -2
  96. package/dist/functions/guards.d.ts +76 -0
  97. package/dist/functions/index.d.ts +96 -5
  98. package/dist/functions/index.js +919 -0
  99. package/dist/functions/index.js.map +1 -0
  100. package/dist/functions/internal.d.ts +26 -0
  101. package/dist/functions/proxy.d.ts +1 -1
  102. package/dist/functions/request-timeout.d.ts +9 -1
  103. package/dist/functions/runtime-env.d.ts +92 -0
  104. package/dist/functions/wait-until.d.ts +74 -0
  105. package/dist/history/history-routes.d.ts +2 -2
  106. package/dist/history/index.d.ts +1 -1
  107. package/dist/index.d.ts +63 -54
  108. package/dist/index.es.js +2183 -164
  109. package/dist/index.es.js.map +1 -1
  110. package/dist/init/docs.d.ts +1 -1
  111. package/dist/init/middlewares.d.ts +1 -1
  112. package/dist/init/shutdown.d.ts +4 -0
  113. package/dist/init/storage.d.ts +1 -1
  114. package/dist/init/surfaces.d.ts +10 -0
  115. package/dist/init.d.ts +104 -18
  116. package/dist/jobs/index.d.ts +5 -5
  117. package/dist/{jobs-CyOKXXlu.js → jobs-Bn6nhY8J.js} +3 -3
  118. package/dist/{jobs-CyOKXXlu.js.map → jobs-Bn6nhY8J.js.map} +1 -1
  119. package/dist/{jwt-DxH9fLPt.js → jwt-BbJi0TR0.js} +2 -2
  120. package/dist/{jwt-DxH9fLPt.js.map → jwt-BbJi0TR0.js.map} +1 -1
  121. package/dist/{logger-DfvF_8r-.js → logger-TdvXIGqR.js} +101 -8
  122. package/dist/logger-TdvXIGqR.js.map +1 -0
  123. package/dist/metrics/index.d.ts +1 -1
  124. package/dist/{proxy-Bj5DVllb.js → proxy-QJKSS-CV.js} +5 -3
  125. package/dist/{proxy-Bj5DVllb.js.map → proxy-QJKSS-CV.js.map} +1 -1
  126. package/dist/{request-timeout-BuFoEKwT.js → request-timeout-OofPCHQT.js} +17 -3
  127. package/dist/request-timeout-OofPCHQT.js.map +1 -0
  128. package/dist/rls-audit/index.d.ts +111 -0
  129. package/dist/schema-edit/apply-schema-change.d.ts +141 -0
  130. package/dist/schema-edit/github-repository.d.ts +67 -0
  131. package/dist/schema-edit/local-git-repository.d.ts +28 -0
  132. package/dist/schema-edit/project-root.d.ts +29 -0
  133. package/dist/schema-edit/remote-source.d.ts +25 -0
  134. package/dist/schema-edit/schema-edit-permissions.d.ts +129 -0
  135. package/dist/schema-editor-routes-yh2cQcdJ.js +44 -0
  136. package/dist/schema-editor-routes-yh2cQcdJ.js.map +1 -0
  137. package/dist/services/webhook-service.d.ts +1 -1
  138. package/dist/singleton.d.ts +7 -0
  139. package/dist/storage/GCSStorageController.d.ts +1 -1
  140. package/dist/storage/LocalStorageController.d.ts +1 -1
  141. package/dist/storage/S3StorageController.d.ts +1 -1
  142. package/dist/storage/cache-headers.d.ts +87 -0
  143. package/dist/storage/index.d.ts +11 -11
  144. package/dist/storage/policies.d.ts +88 -0
  145. package/dist/storage/range.d.ts +63 -0
  146. package/dist/storage/routes.d.ts +3 -3
  147. package/dist/storage/storage-registry.d.ts +1 -1
  148. package/dist/storage/tus-handler.d.ts +2 -2
  149. package/dist/utils/host.d.ts +58 -0
  150. package/dist/utils/logger.d.ts +0 -15
  151. package/dist/utils/request-id.d.ts +1 -1
  152. package/functions/package.json +24 -0
  153. package/package.json +13 -7
  154. package/dist/auth-5Et5mnUA.js.map +0 -1
  155. package/dist/contract-routes-DZ-LBpSL.js.map +0 -1
  156. package/dist/ddl-bootstrap-Cywoj8Ta.js.map +0 -1
  157. package/dist/errors-EBYiaJ2E.js.map +0 -1
  158. package/dist/logger-DfvF_8r-.js.map +0 -1
  159. package/dist/request-timeout-BuFoEKwT.js.map +0 -1
  160. package/dist/schema-editor-routes-CV9k0w3G.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import { HonoEnv } from "../api/types.js";
3
+ /** The two providers whose verify endpoints share this exact shape. */
4
+ export type CaptchaProvider = "turnstile" | "hcaptcha";
5
+ export interface CaptchaVerifyRequest {
6
+ token: string;
7
+ /** The caller's address, which both providers accept as a cross-check. */
8
+ remoteIp?: string;
9
+ }
10
+ export interface CaptchaVerifyResult {
11
+ success: boolean;
12
+ /** Provider error codes, for the log line. Never returned to the caller. */
13
+ errorCodes?: string[];
14
+ }
15
+ export type CaptchaVerifier = (request: CaptchaVerifyRequest) => Promise<CaptchaVerifyResult>;
16
+ export interface CaptchaConfig {
17
+ /** Off unless set. */
18
+ enabled?: boolean;
19
+ provider?: CaptchaProvider;
20
+ /** The provider's secret. Required when enabled, unless `verify` is given. */
21
+ secret?: string;
22
+ /**
23
+ * Which routes to protect. Defaults to the three that send mail or create
24
+ * accounts: `register`, `forgotPassword`, `magicLink`.
25
+ *
26
+ * `login` is deliberately not on by default. A challenge on every sign-in is
27
+ * a tax on every real user, and credential stuffing is what the rate limiter
28
+ * and account lockout are for.
29
+ */
30
+ routes?: CaptchaRoute[];
31
+ /**
32
+ * Where the token is read from. Defaults to the `captchaToken` field of the
33
+ * JSON body, with the `cf-turnstile-response` / `h-captcha-response` header
34
+ * accepted as a fallback.
35
+ */
36
+ tokenField?: string;
37
+ /** Override the verifier. Supplying it makes `secret` unnecessary. */
38
+ verify?: CaptchaVerifier;
39
+ /** Milliseconds before a verification attempt is abandoned. Default 5000. */
40
+ timeoutMs?: number;
41
+ }
42
+ export type CaptchaRoute = "register" | "login" | "forgotPassword" | "magicLink";
43
+ export declare const DEFAULT_CAPTCHA_ROUTES: CaptchaRoute[];
44
+ /**
45
+ * The built-in verifier: a form post, which is the whole protocol.
46
+ *
47
+ * A non-200, a timeout or a malformed body are all "not verified" rather than
48
+ * exceptions — the caller cannot distinguish them and should not be told which
49
+ * one happened.
50
+ */
51
+ export declare function createHttpCaptchaVerifier(options: {
52
+ provider: CaptchaProvider;
53
+ secret: string;
54
+ timeoutMs?: number;
55
+ fetchImpl?: typeof fetch;
56
+ }): CaptchaVerifier;
57
+ /**
58
+ * Resolve a config into a verifier, or explain why it cannot be used.
59
+ *
60
+ * Returns `undefined` when the feature is off. Throws when it is on but
61
+ * unusable — a misconfigured challenge must not boot as an absent one, because
62
+ * the whole point is that it is there.
63
+ */
64
+ export declare function resolveCaptchaVerifier(config: CaptchaConfig | undefined): CaptchaVerifier | undefined;
65
+ /** Read the challenge token out of a request, body field first, then headers. */
66
+ export declare function extractCaptchaToken(c: Parameters<MiddlewareHandler<HonoEnv>>[0], field: string): Promise<string | undefined>;
67
+ /**
68
+ * Middleware refusing a request whose challenge is missing or unverified.
69
+ *
70
+ * The response says only that the challenge failed. Which of "absent",
71
+ * "malformed", "already used" or "provider unreachable" it was is a log line,
72
+ * because telling a script which one it hit is telling it how to get closer.
73
+ */
74
+ export declare function createCaptchaMiddleware(options: {
75
+ verify: CaptchaVerifier;
76
+ tokenField?: string;
77
+ /** Named in the log so a failure says which route refused. */
78
+ route: CaptchaRoute;
79
+ }): MiddlewareHandler<HonoEnv>;
80
+ /**
81
+ * A middleware per protected route, or an empty map when the feature is off.
82
+ *
83
+ * Routes not named get nothing at all rather than a pass-through, so an unnamed
84
+ * route costs exactly what it did before.
85
+ */
86
+ export declare function buildCaptchaMiddlewares(config: CaptchaConfig | undefined): Partial<Record<CaptchaRoute, MiddlewareHandler<HonoEnv>>>;
@@ -1,7 +1,7 @@
1
1
  import type { Context } from "hono";
2
2
  import type { AuthResponsePayload } from "@rebasepro/types";
3
- import type { HonoEnv } from "../api/types";
4
- import type { CookieAuthConfig } from "./routes";
3
+ import type { HonoEnv } from "../api/types.js";
4
+ import type { CookieAuthConfig } from "./routes.js";
5
5
  /**
6
6
  * Cookie auth helpers for httpOnly refresh tokens.
7
7
  */
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Discord OAuth2 Provider integration.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Facebook / Meta OAuth Provider integration.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a GitHub OAuth Provider integration.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a GitLab OAuth Provider integration.
5
5
  * Works with both GitLab.com and self-hosted instances.
@@ -1,4 +1,4 @@
1
- import type { OAuthProvider } from "./interfaces";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
2
  export interface GoogleUserInfo {
3
3
  googleId: string;
4
4
  email: string;
@@ -1,54 +1,56 @@
1
- export * from "./interfaces";
2
- export { configureJwt, isJwtConfigured, generateAccessToken, verifyAccessToken, generateRefreshToken, hashRefreshToken, getRefreshTokenExpiry, getAccessTokenExpiry, generateDownloadToken, verifyDownloadToken, getJwks, hasAsymmetricSigningKey } from "./jwt";
3
- export type { JwtConfig, AccessTokenPayload, DownloadTokenPayload } from "./jwt";
4
- export { createJwksRoutes } from "./jwks-routes";
5
- export type { JwtSigningKeyConfig, JwtSigningAlgorithm, PublicJwk } from "./jwt-keys";
6
- export { hashPassword, verifyPassword, validatePasswordStrength } from "./password";
7
- export { safeCompare } from "./crypto-utils";
8
- export type { PasswordValidationResult } from "./password";
9
- export type { AuthHooks, AuthMethod, ResolvedAuthHooks } from "./auth-hooks";
10
- export { resolveAuthHooks } from "./auth-hooks";
11
- export { generateSecurePassword, generateSecureToken, hashToken, prepareAdminUserValues, finalizeAdminUserCreation } from "./admin-user-ops";
12
- export type { AdminUserContext, AdminUserPrepareResult } from "./admin-user-ops";
13
- export { createGoogleProvider } from "./google-oauth";
14
- export type { GoogleProviderConfig } from "./google-oauth";
15
- export { createLinkedinProvider } from "./linkedin-oauth";
16
- export { createGitHubProvider } from "./github-oauth";
17
- export { createMicrosoftProvider } from "./microsoft-oauth";
18
- export { createAppleProvider } from "./apple-oauth";
19
- export { createFacebookProvider } from "./facebook-oauth";
20
- export { createTwitterProvider } from "./twitter-oauth";
21
- export { createDiscordProvider } from "./discord-oauth";
22
- export { createGitLabProvider } from "./gitlab-oauth";
23
- export { createBitbucketProvider } from "./bitbucket-oauth";
24
- export { createSlackProvider } from "./slack-oauth";
25
- export { createSpotifyProvider } from "./spotify-oauth";
26
- export type { AppleCodeFlowPayload } from "./apple-oauth";
27
- export { oauthCodeFlowSchema, pkceTokenParams, providerVerifiedEmail } from "./oauth-code-flow";
28
- export type { OAuthCodeFlowPayload } from "./oauth-code-flow";
29
- export { verifyOidcIdToken, tryVerifyOidcIdToken } from "./oidc-id-token";
30
- export type { OidcIdTokenClaims, VerifyOidcIdTokenOptions } from "./oidc-id-token";
31
- export { decideOAuthAutoLink, isRedirectUriAllowed } from "./oauth-signin-policy";
32
- export type { AutoLinkDecision, AutoLinkRefusal } from "./oauth-signin-policy";
33
- export { requireAuth, requireAdmin, optionalAuth, extractUserFromToken, createAuthMiddleware, queryTokenAuth, fileTokenAuth } from "./middleware";
34
- export type { AuthMiddlewareOptions, AuthResult } from "./middleware";
35
- export { createAuthRoutes } from "./routes";
36
- export type { AuthModuleConfig, CookieAuthConfig } from "./routes";
37
- export { mountMagicLinkRoutes } from "./magic-link-routes";
38
- export { createResetPasswordRoute } from "./reset-password-admin";
39
- export type { ResetPasswordRouteConfig } from "./reset-password-admin";
40
- export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter, createDataRateLimiter, apiKeyKeyGenerator } from "./rate-limiter";
41
- export type { DataRateLimitConfig } from "./rate-limiter";
42
- export { MemoryRateLimitStore } from "./rate-limit-store";
43
- export type { RateLimitStore, RateLimitDecision } from "./rate-limit-store";
44
- export { createSqlRateLimitStore } from "./sql-rate-limit-store";
45
- export type { SqlRateLimitStoreOptions } from "./sql-rate-limit-store";
46
- export { resolveRateLimitStoreKind, RateLimitStoreConfigurationError } from "./resolve-rate-limit-store";
47
- export type { RateLimitStoreKind, RateLimitStoreEnv } from "./resolve-rate-limit-store";
48
- export { createApiKeyStore, createApiKeyRoutes, isApiKeyToken, validateApiKey, httpMethodToOperation, isOperationAllowed } from "./api-keys";
49
- export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest, ApiKeyStore, ApiKeyOperation } from "./api-keys";
50
- export { createBuiltinAuthAdapter } from "./builtin-auth-adapter";
51
- export type { BuiltinAuthAdapterConfig } from "./builtin-auth-adapter";
52
- export { createCustomAuthAdapter } from "./custom-auth-adapter";
53
- export { createAdapterAuthMiddleware } from "./adapter-middleware";
54
- export type { AdapterAuthMiddlewareOptions } from "./adapter-middleware";
1
+ export * from "./interfaces.js";
2
+ export { configureJwt, isJwtConfigured, generateAccessToken, verifyAccessToken, generateRefreshToken, hashRefreshToken, getRefreshTokenExpiry, getAccessTokenExpiry, generateDownloadToken, verifyDownloadToken, getJwks, hasAsymmetricSigningKey } from "./jwt.js";
3
+ export type { JwtConfig, AccessTokenPayload, DownloadTokenPayload } from "./jwt.js";
4
+ export { createJwksRoutes } from "./jwks-routes.js";
5
+ export type { JwtSigningKeyConfig, JwtSigningAlgorithm, PublicJwk } from "./jwt-keys.js";
6
+ export { hashPassword, verifyPassword, validatePasswordStrength } from "./password.js";
7
+ export { safeCompare } from "./crypto-utils.js";
8
+ export type { PasswordValidationResult } from "./password.js";
9
+ export type { AuthHooks, AuthMethod, ResolvedAuthHooks } from "./auth-hooks.js";
10
+ export { resolveAuthHooks } from "./auth-hooks.js";
11
+ export { generateSecurePassword, generateSecureToken, hashToken, prepareAdminUserValues, finalizeAdminUserCreation } from "./admin-user-ops.js";
12
+ export type { AdminUserContext, AdminUserPrepareResult } from "./admin-user-ops.js";
13
+ export { createGoogleProvider } from "./google-oauth.js";
14
+ export type { GoogleProviderConfig } from "./google-oauth.js";
15
+ export { createLinkedinProvider } from "./linkedin-oauth.js";
16
+ export { createGitHubProvider } from "./github-oauth.js";
17
+ export { createMicrosoftProvider } from "./microsoft-oauth.js";
18
+ export { createAppleProvider } from "./apple-oauth.js";
19
+ export { createFacebookProvider } from "./facebook-oauth.js";
20
+ export { createTwitterProvider } from "./twitter-oauth.js";
21
+ export { createDiscordProvider } from "./discord-oauth.js";
22
+ export { createGitLabProvider } from "./gitlab-oauth.js";
23
+ export { createBitbucketProvider } from "./bitbucket-oauth.js";
24
+ export { createSlackProvider } from "./slack-oauth.js";
25
+ export { createSpotifyProvider } from "./spotify-oauth.js";
26
+ export type { AppleCodeFlowPayload } from "./apple-oauth.js";
27
+ export { oauthCodeFlowSchema, pkceTokenParams, providerVerifiedEmail } from "./oauth-code-flow.js";
28
+ export type { OAuthCodeFlowPayload } from "./oauth-code-flow.js";
29
+ export { verifyOidcIdToken, tryVerifyOidcIdToken } from "./oidc-id-token.js";
30
+ export type { OidcIdTokenClaims, VerifyOidcIdTokenOptions } from "./oidc-id-token.js";
31
+ export { decideOAuthAutoLink, isRedirectUriAllowed } from "./oauth-signin-policy.js";
32
+ export type { AutoLinkDecision, AutoLinkRefusal } from "./oauth-signin-policy.js";
33
+ export { requireAuth, requireAdmin, optionalAuth, extractUserFromToken, createAuthMiddleware, queryTokenAuth, fileTokenAuth } from "./middleware.js";
34
+ export type { AuthMiddlewareOptions, AuthResult } from "./middleware.js";
35
+ export { createAuthRoutes } from "./routes.js";
36
+ export type { AuthModuleConfig, CookieAuthConfig } from "./routes.js";
37
+ export { mountMagicLinkRoutes } from "./magic-link-routes.js";
38
+ export { buildCaptchaMiddlewares, createCaptchaMiddleware, createHttpCaptchaVerifier, resolveCaptchaVerifier, DEFAULT_CAPTCHA_ROUTES } from "./captcha.js";
39
+ export type { CaptchaConfig, CaptchaProvider, CaptchaRoute, CaptchaVerifier, CaptchaVerifyRequest, CaptchaVerifyResult } from "./captcha.js";
40
+ export { createResetPasswordRoute } from "./reset-password-admin.js";
41
+ export type { ResetPasswordRouteConfig } from "./reset-password-admin.js";
42
+ export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter, createDataRateLimiter, apiKeyKeyGenerator } from "./rate-limiter.js";
43
+ export type { DataRateLimitConfig } from "./rate-limiter.js";
44
+ export { MemoryRateLimitStore } from "./rate-limit-store.js";
45
+ export type { RateLimitStore, RateLimitDecision } from "./rate-limit-store.js";
46
+ export { createSqlRateLimitStore } from "./sql-rate-limit-store.js";
47
+ export type { SqlRateLimitStoreOptions } from "./sql-rate-limit-store.js";
48
+ export { resolveRateLimitStoreKind, RateLimitStoreConfigurationError } from "./resolve-rate-limit-store.js";
49
+ export type { RateLimitStoreKind, RateLimitStoreEnv } from "./resolve-rate-limit-store.js";
50
+ export { createApiKeyStore, createApiKeyRoutes, isApiKeyToken, validateApiKey, httpMethodToOperation, isOperationAllowed } from "./api-keys/index.js";
51
+ export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest, ApiKeyStore, ApiKeyOperation } from "./api-keys/index.js";
52
+ export { createBuiltinAuthAdapter } from "./builtin-auth-adapter.js";
53
+ export type { BuiltinAuthAdapterConfig } from "./builtin-auth-adapter.js";
54
+ export { createCustomAuthAdapter } from "./custom-auth-adapter.js";
55
+ export { createAdapterAuthMiddleware } from "./adapter-middleware.js";
56
+ export type { AdapterAuthMiddlewareOptions } from "./adapter-middleware.js";
@@ -1,5 +1,5 @@
1
1
  import { Hono } from "hono";
2
- import type { HonoEnv } from "../api/types";
2
+ import type { HonoEnv } from "../api/types.js";
3
3
  /**
4
4
  * `GET /.well-known/jwks.json` — the public keys that verify this issuer's
5
5
  * access tokens.
@@ -1,4 +1,4 @@
1
- import { type JwtSigningKeyConfig, type PublicJwk } from "./jwt-keys";
1
+ import { type JwtSigningKeyConfig, type PublicJwk } from "./jwt-keys.js";
2
2
  export interface JwtConfig {
3
3
  secret: string;
4
4
  accessExpiresIn?: string;
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  export interface LinkedinUserInfo {
4
4
  linkedinId: string;
5
5
  email: string;
@@ -1,7 +1,8 @@
1
1
  import { Hono } from "hono";
2
- import type { AuthModuleConfig } from "./routes";
3
- import type { ResolvedAuthHooks } from "./auth-hooks";
4
- import type { HonoEnv } from "../api/types";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import type { AuthModuleConfig } from "./routes.js";
4
+ import type { ResolvedAuthHooks } from "./auth-hooks.js";
5
+ import type { HonoEnv } from "../api/types.js";
5
6
  import { z } from "zod";
6
7
  import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
7
8
  /**
@@ -29,4 +30,10 @@ export declare function mountMagicLinkRoutes(deps: {
29
30
  refreshToken: string;
30
31
  }>;
31
32
  applyTransformHook: (response: AuthResponsePayload, method: TransformAuthResponseContext["method"], request: Request, uid: string) => Promise<AuthResponsePayload>;
33
+ /**
34
+ * Built by the caller so a misconfiguration fails the boot once, rather
35
+ * than being resolved again here. Absent when captcha is off, or when
36
+ * `magicLink` is not among the protected routes.
37
+ */
38
+ captchaMiddleware?: MiddlewareHandler<HonoEnv>;
32
39
  }): void;
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @module
14
14
  */
15
- import type { AuthRepository } from "./interfaces";
15
+ import type { AuthRepository } from "./interfaces.js";
16
16
  /** Error code a client watches for to switch a sign-in into its second step. */
17
17
  export declare const MFA_REQUIRED_CODE = "MFA_REQUIRED";
18
18
  /** Shape carried in `error.details` of an {@link MFA_REQUIRED_CODE} response. */
@@ -1,8 +1,8 @@
1
1
  import { Hono } from "hono";
2
2
  import { z } from "zod";
3
- import { HonoEnv } from "../api/types";
4
- import type { AuthModuleConfig } from "./routes";
5
- import { resolveAuthHooks } from "./auth-hooks";
3
+ import { HonoEnv } from "../api/types.js";
4
+ import type { AuthModuleConfig } from "./routes.js";
5
+ import { resolveAuthHooks } from "./auth-hooks.js";
6
6
  import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
7
7
  interface MfaRoutesConfig {
8
8
  router: Hono<HonoEnv>;
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Microsoft / Entra ID (Azure AD) OAuth Provider integration.
5
5
  *
@@ -1,10 +1,10 @@
1
1
  import { MiddlewareHandler, Context } from "hono";
2
- import type { AuthRepository } from "./interfaces";
2
+ import type { AuthRepository } from "./interfaces.js";
3
3
  import { DataDriver } from "@rebasepro/types";
4
- import { AccessTokenPayload } from "./jwt";
5
- import type { HonoEnv } from "../api/types";
6
- import type { ApiKeyStore } from "./api-keys/api-key-store";
7
- import { extractBearerToken } from "./bearer-token";
4
+ import { AccessTokenPayload } from "./jwt.js";
5
+ import type { HonoEnv } from "../api/types.js";
6
+ import type { ApiKeyStore } from "./api-keys/api-key-store.js";
7
+ import { extractBearerToken } from "./bearer-token.js";
8
8
  export { extractBearerToken };
9
9
  /**
10
10
  * Result from a custom auth validator.
@@ -1,6 +1,6 @@
1
1
  import { MiddlewareHandler } from "hono";
2
- import { HonoEnv } from "../api/types";
3
- import { RateLimitStore } from "./rate-limit-store";
2
+ import { HonoEnv } from "../api/types.js";
3
+ import { RateLimitStore } from "./rate-limit-store.js";
4
4
  /**
5
5
  * Sliding-window rate limiting for Hono.
6
6
  *
@@ -1,5 +1,5 @@
1
1
  import type { AuthAdapter } from "@rebasepro/types";
2
- import type { RebaseAuthConfig } from "../init";
2
+ import type { RebaseAuthConfig } from "../init.js";
3
3
  /**
4
4
  * Whether the `auth` config is an `AuthAdapter` (it can verify a request) or a
5
5
  * plain `RebaseAuthConfig`. Lives here rather than in `init.ts` so this module
@@ -7,10 +7,10 @@
7
7
  * 3. Built-in default (send reset email, or generate temp password)
8
8
  */
9
9
  import { Hono } from "hono";
10
- import type { AuthRepository } from "./interfaces";
11
- import type { AuthHooks } from "./auth-hooks";
12
- import type { EmailService, EmailConfig } from "../email";
13
- import type { HonoEnv } from "../api/types";
10
+ import type { AuthRepository } from "./interfaces.js";
11
+ import type { AuthHooks } from "./auth-hooks.js";
12
+ import type { EmailService, EmailConfig } from "../email/index.js";
13
+ import type { HonoEnv } from "../api/types.js";
14
14
  import type { AuthCollectionConfig } from "@rebasepro/types";
15
15
  export interface ResetPasswordRouteConfig {
16
16
  authRepo: AuthRepository;
@@ -1,13 +1,22 @@
1
1
  import { Hono } from "hono";
2
- import type { AuthRepository, OAuthProvider } from "./interfaces";
3
- import type { AuthHooks } from "./auth-hooks";
4
- import { EmailService, EmailConfig } from "../email";
5
- import { HonoEnv } from "../api/types";
2
+ import type { AuthRepository, OAuthProvider } from "./interfaces.js";
3
+ import type { AuthHooks } from "./auth-hooks.js";
4
+ import { EmailService, EmailConfig } from "../email/index.js";
5
+ import { HonoEnv } from "../api/types.js";
6
+ import { type CaptchaConfig } from "./captcha.js";
6
7
  /**
7
8
  * Shared configuration for auth and admin route factories.
8
9
  */
9
10
  export interface AuthModuleConfig {
10
11
  authRepo: AuthRepository;
12
+ /**
13
+ * Bot protection. Off unless `enabled`.
14
+ *
15
+ * Rate limiting bounds one caller; a botnet of a thousand addresses sending
16
+ * one request each never touches a per-IP window, and `/register` and
17
+ * `/forgot-password` both send mail. See `captcha.ts`.
18
+ */
19
+ captcha?: CaptchaConfig;
11
20
  emailService?: EmailService;
12
21
  emailConfig?: EmailConfig;
13
22
  /** Allow new user registration (default: false). */
@@ -1,9 +1,9 @@
1
1
  import { Hono } from "hono";
2
2
  import { z } from "zod";
3
- import { HonoEnv } from "../api/types";
4
- import type { AuthModuleConfig } from "./routes";
3
+ import { HonoEnv } from "../api/types.js";
4
+ import type { AuthModuleConfig } from "./routes.js";
5
5
  import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
6
- import type { resolveAuthHooks } from "./auth-hooks";
6
+ import type { resolveAuthHooks } from "./auth-hooks.js";
7
7
  interface SessionRoutesConfig {
8
8
  router: Hono<HonoEnv>;
9
9
  config: AuthModuleConfig;
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Slack OAuth Provider integration (OAuth 2.0 / "Sign in with Slack").
5
5
  * Uses the OpenID Connect flow with the "openid,email,profile" scopes.
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Spotify OAuth Provider integration.
5
5
  * Uses the authorization code flow with the "user-read-email" scope.
@@ -1,5 +1,5 @@
1
- import type { AuthRepository } from "./interfaces";
2
- import type { AccessTokenPayload } from "./jwt";
1
+ import type { AuthRepository } from "./interfaces.js";
2
+ import type { AccessTokenPayload } from "./jwt.js";
3
3
  /**
4
4
  * Has this access token been revoked?
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { OAuthProvider } from "./interfaces";
2
- import { type OAuthCodeFlowPayload } from "./oauth-code-flow";
1
+ import type { OAuthProvider } from "./interfaces.js";
2
+ import { type OAuthCodeFlowPayload } from "./oauth-code-flow.js";
3
3
  /**
4
4
  * Creates a Twitter/X OAuth 2.0 Provider integration.
5
5
  *