@rebasepro/server 0.16.0 → 0.16.1-canary.g701140a
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.
- package/dist/api/contract-routes.d.ts +1 -1
- package/dist/api/errors.d.ts +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/logs-routes.d.ts +1 -1
- package/dist/api/rest/api-generator.d.ts +2 -2
- package/dist/api/rest/index.d.ts +1 -1
- package/dist/api/rest/query-parser.d.ts +1 -1
- package/dist/api/schema-editor-routes.d.ts +1 -1
- package/dist/api/types.d.ts +3 -4
- package/dist/auth/adapter-middleware.d.ts +2 -2
- package/dist/auth/admin-roles-route.d.ts +2 -2
- package/dist/auth/admin-user-ops.d.ts +3 -3
- package/dist/auth/admin-users-route.d.ts +4 -4
- package/dist/auth/api-keys/api-key-middleware.d.ts +2 -2
- package/dist/auth/api-keys/api-key-permission-guard.d.ts +1 -1
- package/dist/auth/api-keys/api-key-routes.d.ts +2 -2
- package/dist/auth/api-keys/api-key-store.d.ts +1 -1
- package/dist/auth/api-keys/index.d.ts +9 -9
- package/dist/auth/apple-oauth.d.ts +2 -2
- package/dist/auth/auth-hooks.d.ts +3 -3
- package/dist/auth/bitbucket-oauth.d.ts +2 -2
- package/dist/auth/builtin-auth-adapter.d.ts +7 -4
- package/dist/auth/captcha.d.ts +86 -0
- package/dist/auth/cookie-utils.d.ts +2 -2
- package/dist/auth/discord-oauth.d.ts +2 -2
- package/dist/auth/facebook-oauth.d.ts +2 -2
- package/dist/auth/github-oauth.d.ts +2 -2
- package/dist/auth/gitlab-oauth.d.ts +2 -2
- package/dist/auth/google-oauth.d.ts +1 -1
- package/dist/auth/index.d.ts +56 -54
- package/dist/auth/jwks-routes.d.ts +1 -1
- package/dist/auth/jwt.d.ts +1 -1
- package/dist/auth/linkedin-oauth.d.ts +2 -2
- package/dist/auth/magic-link-routes.d.ts +10 -3
- package/dist/auth/mfa-gate.d.ts +1 -1
- package/dist/auth/mfa-routes.d.ts +3 -3
- package/dist/auth/microsoft-oauth.d.ts +2 -2
- package/dist/auth/middleware.d.ts +5 -5
- package/dist/auth/rate-limiter.d.ts +2 -2
- package/dist/auth/require-auth.d.ts +1 -1
- package/dist/auth/reset-password-admin.d.ts +4 -4
- package/dist/auth/routes.d.ts +13 -4
- package/dist/auth/session-routes.d.ts +3 -3
- package/dist/auth/slack-oauth.d.ts +2 -2
- package/dist/auth/spotify-oauth.d.ts +2 -2
- package/dist/auth/token-revocation.d.ts +2 -2
- package/dist/auth/twitter-oauth.d.ts +2 -2
- package/dist/{auth-5Et5mnUA.js → auth-B0IV-irB.js} +250 -15
- package/dist/auth-B0IV-irB.js.map +1 -0
- package/dist/backup/backup-common.d.ts +1 -1
- package/dist/backup/backup-routes.d.ts +3 -3
- package/dist/backup/index.d.ts +3 -3
- package/dist/{backup-C6ljYVTp.js → backup-BJ86ah4T.js} +2 -2
- package/dist/{backup-C6ljYVTp.js.map → backup-BJ86ah4T.js.map} +1 -1
- package/dist/boot/boot.d.ts +5 -5
- package/dist/boot/bundle.d.ts +1 -1
- package/dist/boot/driver.d.ts +1 -1
- package/dist/boot/env.d.ts +13 -1
- package/dist/boot/options.d.ts +30 -6
- package/dist/boot/role.d.ts +3 -2
- package/dist/boot/sources.d.ts +1 -1
- package/dist/collections/BackendCollectionRegistry.d.ts +1 -1
- package/dist/collections/loader.d.ts +1 -1
- package/dist/{contract-routes-DZ-LBpSL.js → contract-routes-BEq7euZg.js} +2 -2
- package/dist/contract-routes-BEq7euZg.js.map +1 -0
- package/dist/cron/cron-routes.d.ts +2 -2
- package/dist/cron/cron-scheduler.d.ts +2 -2
- package/dist/cron/index.d.ts +8 -8
- package/dist/{cron-loader-YhhQeVBM.js → cron-loader-BMvtW6-J.js} +2 -2
- package/dist/{cron-loader-YhhQeVBM.js.map → cron-loader-BMvtW6-J.js.map} +1 -1
- package/dist/{cron-routes-maM_RlUu.js → cron-routes-BvYk-Kmi.js} +2 -2
- package/dist/{cron-routes-maM_RlUu.js.map → cron-routes-BvYk-Kmi.js.map} +1 -1
- package/dist/{cron-scheduler-DIpYBmZP.js → cron-scheduler-Buf-uVam.js} +2 -2
- package/dist/{cron-scheduler-DIpYBmZP.js.map → cron-scheduler-Buf-uVam.js.map} +1 -1
- package/dist/{cron-store-DfH_4Cd9.js → cron-store-CpfttP4f.js} +3 -3
- package/dist/{cron-store-DfH_4Cd9.js.map → cron-store-CpfttP4f.js.map} +1 -1
- package/dist/{ddl-bootstrap-Cywoj8Ta.js → ddl-bootstrap-CFLhcvfQ.js} +2 -2
- package/dist/{ddl-bootstrap-Cywoj8Ta.js.map → ddl-bootstrap-CFLhcvfQ.js.map} +1 -1
- package/dist/dev-secrets.d.ts +52 -0
- package/dist/email/dev-sink.d.ts +67 -0
- package/dist/email/index.d.ts +9 -7
- package/dist/email/link-base.d.ts +1 -1
- package/dist/email/smtp-email-service.d.ts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/{errors-EBYiaJ2E.js → errors-D_LwNKRM.js} +5 -5
- package/dist/errors-D_LwNKRM.js.map +1 -0
- package/dist/{function-loader-DDS1v7YX.js → function-loader-BrLmC_-y.js} +3 -3
- package/dist/{function-loader-DDS1v7YX.js.map → function-loader-BrLmC_-y.js.map} +1 -1
- package/dist/functions/context.d.ts +141 -0
- package/dist/functions/define-function.d.ts +1 -1
- package/dist/functions/function-routes.d.ts +2 -2
- package/dist/functions/guards.d.ts +76 -0
- package/dist/functions/index.d.ts +96 -5
- package/dist/functions/index.js +919 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/internal.d.ts +26 -0
- package/dist/functions/proxy.d.ts +1 -1
- package/dist/functions/request-timeout.d.ts +9 -1
- package/dist/functions/runtime-env.d.ts +92 -0
- package/dist/functions/wait-until.d.ts +74 -0
- package/dist/history/history-routes.d.ts +2 -2
- package/dist/history/index.d.ts +1 -1
- package/dist/index.d.ts +63 -54
- package/dist/index.es.js +1126 -53
- package/dist/index.es.js.map +1 -1
- package/dist/init/docs.d.ts +1 -1
- package/dist/init/middlewares.d.ts +1 -1
- package/dist/init/shutdown.d.ts +4 -0
- package/dist/init/storage.d.ts +1 -1
- package/dist/init/surfaces.d.ts +10 -0
- package/dist/init.d.ts +72 -18
- package/dist/jobs/index.d.ts +5 -5
- package/dist/{jobs-CyOKXXlu.js → jobs-CSlBZ8dn.js} +3 -3
- package/dist/{jobs-CyOKXXlu.js.map → jobs-CSlBZ8dn.js.map} +1 -1
- package/dist/{jwt-DxH9fLPt.js → jwt-BbJi0TR0.js} +2 -2
- package/dist/{jwt-DxH9fLPt.js.map → jwt-BbJi0TR0.js.map} +1 -1
- package/dist/{logger-DfvF_8r-.js → logger-TdvXIGqR.js} +101 -8
- package/dist/logger-TdvXIGqR.js.map +1 -0
- package/dist/metrics/index.d.ts +1 -1
- package/dist/{proxy-Bj5DVllb.js → proxy-QJKSS-CV.js} +5 -3
- package/dist/{proxy-Bj5DVllb.js.map → proxy-QJKSS-CV.js.map} +1 -1
- package/dist/{request-timeout-BuFoEKwT.js → request-timeout-OofPCHQT.js} +17 -3
- package/dist/request-timeout-OofPCHQT.js.map +1 -0
- package/dist/rls-audit/index.d.ts +111 -0
- package/dist/{schema-editor-routes-CV9k0w3G.js → schema-editor-routes-Cax2XTRj.js} +2 -2
- package/dist/{schema-editor-routes-CV9k0w3G.js.map → schema-editor-routes-Cax2XTRj.js.map} +1 -1
- package/dist/services/webhook-service.d.ts +1 -1
- package/dist/singleton.d.ts +7 -0
- package/dist/storage/GCSStorageController.d.ts +1 -1
- package/dist/storage/LocalStorageController.d.ts +1 -1
- package/dist/storage/S3StorageController.d.ts +1 -1
- package/dist/storage/cache-headers.d.ts +87 -0
- package/dist/storage/index.d.ts +11 -11
- package/dist/storage/policies.d.ts +88 -0
- package/dist/storage/range.d.ts +63 -0
- package/dist/storage/routes.d.ts +3 -3
- package/dist/storage/storage-registry.d.ts +1 -1
- package/dist/storage/tus-handler.d.ts +2 -2
- package/dist/utils/host.d.ts +58 -0
- package/dist/utils/logger.d.ts +0 -15
- package/dist/utils/request-id.d.ts +1 -1
- package/functions/package.json +24 -0
- package/package.json +13 -7
- package/dist/auth-5Et5mnUA.js.map +0 -1
- package/dist/contract-routes-DZ-LBpSL.js.map +0 -1
- package/dist/errors-EBYiaJ2E.js.map +0 -1
- package/dist/logger-DfvF_8r-.js.map +0 -1
- package/dist/request-timeout-BuFoEKwT.js.map +0 -1
package/dist/api/errors.d.ts
CHANGED
package/dist/api/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* API generation infrastructure for Rebase
|
|
3
3
|
* Automatically generates REST APIs from CollectionConfig definitions
|
|
4
4
|
*/
|
|
5
|
-
export * from "./rest";
|
|
6
|
-
export * from "./types";
|
|
7
|
-
export * from "./errors";
|
|
5
|
+
export * from "./rest/index.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * from "./errors.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { AuthAdapter, DataDriver, CollectionConfig } from "@rebasepro/types";
|
|
3
|
-
import { HonoEnv } from "../types";
|
|
4
|
-
import { type ListLimitOptions } from "./query-parser";
|
|
3
|
+
import { HonoEnv } from "../types.js";
|
|
4
|
+
import { type ListLimitOptions } from "./query-parser.js";
|
|
5
5
|
/**
|
|
6
6
|
* Lightweight REST API generator that leverages existing Rebase DataDriver.
|
|
7
7
|
* Supports `include` query parameter for eager-loading relations via Drizzle.
|
package/dist/api/rest/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./api-generator";
|
|
1
|
+
export * from "./api-generator.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ListLimitBounds, OrderByTuple } from "@rebasepro/types";
|
|
2
|
-
import { QueryOptions } from "../types";
|
|
2
|
+
import { QueryOptions } from "../types.js";
|
|
3
3
|
export declare const mapOperator: (op: string) => import("@rebasepro/types").WhereFilterOp | null;
|
|
4
4
|
type OrderByEntry = {
|
|
5
5
|
field: string;
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { VectorSearchParams, LogicalCondition, FilterValues } from "@rebasepro/types";
|
|
2
|
-
import type { AuthResult } from "../auth/middleware";
|
|
3
|
-
import {
|
|
4
|
-
import type { ApiKeyMasked } from "../auth/api-keys/api-key-types";
|
|
1
|
+
import type { VectorSearchParams, LogicalCondition, FilterValues, DataDriver } from "@rebasepro/types";
|
|
2
|
+
import type { AuthResult } from "../auth/middleware.js";
|
|
3
|
+
import type { ApiKeyMasked } from "../auth/api-keys/api-key-types.js";
|
|
5
4
|
/**
|
|
6
5
|
* Hono Environment Variables
|
|
7
6
|
* Passed to generic Hono<HonoEnv> to type `c.get()`
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { MiddlewareHandler, Context } from "hono";
|
|
20
20
|
import type { DataDriver, AuthAdapter } from "@rebasepro/types";
|
|
21
|
-
import type { HonoEnv } from "../api/types";
|
|
22
|
-
import type { ApiKeyStore } from "./api-keys/api-key-store";
|
|
21
|
+
import type { HonoEnv } from "../api/types.js";
|
|
22
|
+
import type { ApiKeyStore } from "./api-keys/api-key-store.js";
|
|
23
23
|
export interface AdapterAuthMiddlewareOptions {
|
|
24
24
|
/** The auth adapter to delegate verification to. */
|
|
25
25
|
adapter: AuthAdapter;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Mounts: GET /roles
|
|
5
5
|
*/
|
|
6
6
|
import { Hono } from "hono";
|
|
7
|
-
import type { AuthRepository } from "./interfaces";
|
|
8
|
-
import type { HonoEnv } from "../api/types";
|
|
7
|
+
import type { AuthRepository } from "./interfaces.js";
|
|
8
|
+
import type { HonoEnv } from "../api/types.js";
|
|
9
9
|
export interface AdminRolesRouteConfig {
|
|
10
10
|
authRepo: AuthRepository;
|
|
11
11
|
serviceKey?: string;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* 2. Backend-level hook (`AuthHooks.onAdminCreateUser`) — global override
|
|
10
10
|
* 3. Built-in default — framework fallback
|
|
11
11
|
*/
|
|
12
|
-
import type { AuthRepository } from "./interfaces";
|
|
13
|
-
import type { EmailService, EmailConfig } from "../email";
|
|
14
|
-
import type { ResolvedAuthHooks } from "./auth-hooks";
|
|
12
|
+
import type { AuthRepository } from "./interfaces.js";
|
|
13
|
+
import type { EmailService, EmailConfig } from "../email/index.js";
|
|
14
|
+
import type { ResolvedAuthHooks } from "./auth-hooks.js";
|
|
15
15
|
import type { AuthCollectionConfig } from "@rebasepro/types";
|
|
16
16
|
/**
|
|
17
17
|
* Generate a cryptographically secure random password that meets strength requirements.
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* POST /bootstrap
|
|
11
11
|
*/
|
|
12
12
|
import { Hono } from "hono";
|
|
13
|
-
import type { AuthRepository } from "./interfaces";
|
|
14
|
-
import type { AuthHooks } from "./auth-hooks";
|
|
15
|
-
import type { EmailService, EmailConfig } from "../email";
|
|
16
|
-
import type { HonoEnv } from "../api/types";
|
|
13
|
+
import type { AuthRepository } from "./interfaces.js";
|
|
14
|
+
import type { AuthHooks } from "./auth-hooks.js";
|
|
15
|
+
import type { EmailService, EmailConfig } from "../email/index.js";
|
|
16
|
+
import type { HonoEnv } from "../api/types.js";
|
|
17
17
|
import type { AuthCollectionConfig } from "@rebasepro/types";
|
|
18
18
|
export interface AdminUsersRouteConfig {
|
|
19
19
|
authRepo: AuthRepository;
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import type { Context, MiddlewareHandler } from "hono";
|
|
25
25
|
import type { DataDriver } from "@rebasepro/types";
|
|
26
|
-
import type { HonoEnv } from "../../api/types";
|
|
27
|
-
import type { ApiKeyStore } from "./api-key-store";
|
|
26
|
+
import type { HonoEnv } from "../../api/types.js";
|
|
27
|
+
import type { ApiKeyStore } from "./api-key-store.js";
|
|
28
28
|
/**
|
|
29
29
|
* Check whether a token looks like a Rebase API key.
|
|
30
30
|
*/
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { Hono } from "hono";
|
|
11
|
-
import type { HonoEnv } from "../../api/types";
|
|
12
|
-
import type { ApiKeyStore } from "./api-key-store";
|
|
11
|
+
import type { HonoEnv } from "../../api/types.js";
|
|
12
|
+
import type { ApiKeyStore } from "./api-key-store.js";
|
|
13
13
|
export interface ApiKeyRouteOptions {
|
|
14
14
|
store: ApiKeyStore;
|
|
15
15
|
serviceKey?: string;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import type { DataDriver } from "@rebasepro/types";
|
|
11
|
-
import type { ApiKey, ApiKeyMasked, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest } from "./api-key-types";
|
|
11
|
+
import type { ApiKey, ApiKeyMasked, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest } from "./api-key-types.js";
|
|
12
12
|
export interface ApiKeyStore {
|
|
13
13
|
/** Ensure the `rebase.api_keys` table exists. Called once on startup. */
|
|
14
14
|
ensureTable(): Promise<void>;
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest } from "./api-key-types";
|
|
10
|
-
export { createApiKeyStore } from "./api-key-store";
|
|
11
|
-
export type { ApiKeyStore } from "./api-key-store";
|
|
12
|
-
export { isApiKeyToken, validateApiKey, createApiKeyPreAuth, createFunctionApiKeyGuard, createStorageApiKeyGuard } from "./api-key-middleware";
|
|
13
|
-
export type { ApiKeyAuthOptions } from "./api-key-middleware";
|
|
14
|
-
export { httpMethodToOperation, isOperationAllowed, isFunctionAllowed, isStorageAllowed } from "./api-key-permission-guard";
|
|
15
|
-
export type { ApiKeyOperation } from "./api-key-permission-guard";
|
|
16
|
-
export { createApiKeyRoutes } from "./api-key-routes";
|
|
17
|
-
export type { ApiKeyRouteOptions } from "./api-key-routes";
|
|
9
|
+
export type { ApiKey, ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, UpdateApiKeyRequest } from "./api-key-types.js";
|
|
10
|
+
export { createApiKeyStore } from "./api-key-store.js";
|
|
11
|
+
export type { ApiKeyStore } from "./api-key-store.js";
|
|
12
|
+
export { isApiKeyToken, validateApiKey, createApiKeyPreAuth, createFunctionApiKeyGuard, createStorageApiKeyGuard } from "./api-key-middleware.js";
|
|
13
|
+
export type { ApiKeyAuthOptions } from "./api-key-middleware.js";
|
|
14
|
+
export { httpMethodToOperation, isOperationAllowed, isFunctionAllowed, isStorageAllowed } from "./api-key-permission-guard.js";
|
|
15
|
+
export type { ApiKeyOperation } from "./api-key-permission-guard.js";
|
|
16
|
+
export { createApiKeyRoutes } from "./api-key-routes.js";
|
|
17
|
+
export type { ApiKeyRouteOptions } from "./api-key-routes.js";
|
|
@@ -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
|
/** Extra field Apple's client sends that no other provider has. */
|
|
4
4
|
export interface AppleCodeFlowPayload extends OAuthCodeFlowPayload {
|
|
5
5
|
/**
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
* };
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
import type { PasswordValidationResult } from "./password";
|
|
40
|
-
import type { AuthRepository, UserData, CreateUserData } from "./interfaces";
|
|
41
|
-
import type { EmailService, EmailConfig } from "../email";
|
|
39
|
+
import type { PasswordValidationResult } from "./password.js";
|
|
40
|
+
import type { AuthRepository, UserData, CreateUserData } from "./interfaces.js";
|
|
41
|
+
import type { EmailService, EmailConfig } from "../email/index.js";
|
|
42
42
|
import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
|
|
43
43
|
/**
|
|
44
44
|
* Authentication method identifier for lifecycle hooks.
|
|
@@ -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 Bitbucket OAuth Provider integration (OAuth 2.0 consumer).
|
|
5
5
|
*/
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* present the same functionality through the pluggable `AuthAdapter` contract.
|
|
11
11
|
*/
|
|
12
12
|
import type { AuthAdapter } from "@rebasepro/types";
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
13
|
+
import type { CaptchaConfig } from "./captcha.js";
|
|
14
|
+
import type { AuthRepository, OAuthProvider } from "./interfaces.js";
|
|
15
|
+
import type { AuthHooks } from "./auth-hooks.js";
|
|
16
|
+
import type { EmailService, EmailConfig } from "../email/index.js";
|
|
16
17
|
/**
|
|
17
18
|
* Configuration for the built-in Rebase auth adapter.
|
|
18
19
|
*
|
|
@@ -50,6 +51,8 @@ export interface BuiltinAuthAdapterConfig {
|
|
|
50
51
|
allowAnonymous?: boolean;
|
|
51
52
|
/** Whether to expose the authenticated email→minimal-profile lookup route. */
|
|
52
53
|
allowUserLookup?: boolean;
|
|
54
|
+
/** Bot protection for the auth routes. See `captcha.ts`. */
|
|
55
|
+
captcha?: CaptchaConfig;
|
|
53
56
|
/** Default role to assign to new users. */
|
|
54
57
|
defaultRole?: string;
|
|
55
58
|
/** OAuth providers to register. */
|
|
@@ -65,7 +68,7 @@ export interface BuiltinAuthAdapterConfig {
|
|
|
65
68
|
/** Enable magic link (passwordless email) login. Requires email service. */
|
|
66
69
|
enableMagicLink?: boolean;
|
|
67
70
|
/** Opt-in httpOnly cookie mode for refresh tokens. */
|
|
68
|
-
cookieAuth?: import("./routes").CookieAuthConfig;
|
|
71
|
+
cookieAuth?: import("./routes.js").CookieAuthConfig;
|
|
69
72
|
}
|
|
70
73
|
/**
|
|
71
74
|
* Create the built-in Rebase auth adapter.
|
|
@@ -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.
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -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 {
|
|
39
|
-
export type {
|
|
40
|
-
export {
|
|
41
|
-
export type {
|
|
42
|
-
export {
|
|
43
|
-
export type {
|
|
44
|
-
export {
|
|
45
|
-
export type {
|
|
46
|
-
export {
|
|
47
|
-
export type {
|
|
48
|
-
export {
|
|
49
|
-
export type {
|
|
50
|
-
export {
|
|
51
|
-
export type {
|
|
52
|
-
export {
|
|
53
|
-
export {
|
|
54
|
-
export
|
|
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";
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -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 {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
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;
|
package/dist/auth/mfa-gate.d.ts
CHANGED
|
@@ -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
|
*
|