@rebasepro/server 0.23.0 → 0.24.1-canary.g19596ef
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/README.md +28 -3
- package/bin/rebase-server.js +4 -2
- package/dist/GCSStorageController-DEga1ULx.js +402 -0
- package/dist/GCSStorageController-DEga1ULx.js.map +1 -0
- package/dist/S3StorageController-Btx-6bJ5.js +480 -0
- package/dist/S3StorageController-Btx-6bJ5.js.map +1 -0
- package/dist/api/ast-schema-editor.d.ts +92 -1
- package/dist/api/errors.d.ts +41 -0
- package/dist/api/live-schema-routes.d.ts +64 -10
- package/dist/api/logs-routes.d.ts +39 -1
- package/dist/api/mount-path.d.ts +30 -0
- package/dist/api/mount.d.ts +6 -13
- package/dist/api/openapi-generator.d.ts +17 -0
- package/dist/api/rest/api-generator.d.ts +97 -11
- package/dist/api/rest/auth-collection-writes.d.ts +28 -21
- package/dist/api/rest/field-access-query.d.ts +28 -8
- package/dist/api/rest/field-ops.d.ts +19 -7
- package/dist/api/rest/query-body.d.ts +10 -0
- package/dist/api/rest/write-validation.d.ts +9 -7
- package/dist/api/schema-editor-routes.d.ts +10 -1
- package/dist/api/sql-export-routes.d.ts +8 -0
- package/dist/api/types.d.ts +52 -1
- package/dist/{ast-schema-editor-Mvr50v_S.js → ast-schema-editor-mCeSC03x.js} +310 -12
- package/dist/ast-schema-editor-mCeSC03x.js.map +1 -0
- package/dist/auth/access.d.ts +156 -0
- package/dist/auth/adapter-middleware.d.ts +2 -1
- package/dist/auth/address-ownership.d.ts +16 -1
- package/dist/auth/admin-roles-route.d.ts +4 -2
- package/dist/auth/admin-roles.d.ts +17 -20
- package/dist/auth/admin-user-ops.d.ts +24 -2
- package/dist/auth/admin-users-route.d.ts +2 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +64 -56
- package/dist/auth/api-keys/api-key-routes.d.ts +44 -11
- package/dist/auth/api-keys/api-key-store.d.ts +31 -8
- package/dist/auth/api-keys/api-key-types.d.ts +14 -16
- package/dist/auth/api-keys/http-operation.d.ts +19 -0
- package/dist/auth/api-keys/index.d.ts +11 -11
- package/dist/auth/api-keys/key-grant.d.ts +41 -0
- package/dist/auth/api-keys/legacy-permissions.d.ts +33 -0
- package/dist/auth/auth-hooks.d.ts +46 -7
- package/dist/auth/builtin-auth-adapter.d.ts +21 -0
- package/dist/auth/cookie-utils.d.ts +7 -0
- package/dist/auth/deliverable-address.d.ts +6 -0
- package/dist/auth/email-change-routes.d.ts +44 -0
- package/dist/auth/expired-token-sweep.d.ts +71 -0
- package/dist/auth/impersonation.d.ts +110 -0
- package/dist/auth/index.d.ts +4 -2
- package/dist/auth/interfaces.d.ts +120 -59
- package/dist/auth/jwks-routes.d.ts +5 -1
- package/dist/auth/jwt-crypto.d.ts +7 -0
- package/dist/auth/jwt-keys.d.ts +4 -0
- package/dist/auth/jwt.d.ts +319 -157
- package/dist/auth/magic-link-routes.d.ts +5 -6
- package/dist/auth/mfa-crypto.d.ts +9 -3
- package/dist/auth/mfa-gate.d.ts +4 -2
- package/dist/auth/mfa-routes.d.ts +8 -9
- package/dist/auth/middleware.d.ts +26 -7
- package/dist/auth/otp-routes.d.ts +5 -6
- package/dist/auth/passwordless-signup.d.ts +27 -0
- package/dist/auth/platform-token.d.ts +122 -0
- package/dist/auth/rate-limiter.d.ts +99 -31
- package/dist/auth/registration-policy.d.ts +17 -0
- package/dist/auth/require-auth.d.ts +1 -1
- package/dist/auth/routes.d.ts +61 -0
- package/dist/auth/scope-routes.d.ts +22 -0
- package/dist/auth/session-routes.d.ts +17 -6
- package/dist/auth/token-revocation.d.ts +56 -1
- package/dist/auth/user-picking.d.ts +37 -0
- package/dist/auth/verify-credential.d.ts +49 -0
- package/dist/{auth-B-GIMpDG.js → auth-CSBky1mt.js} +4564 -1929
- package/dist/auth-CSBky1mt.js.map +1 -0
- package/dist/auth_adapter-CIItCTc8.js +21 -0
- package/dist/auth_adapter-CIItCTc8.js.map +1 -0
- package/dist/backend/create-backend.d.ts +281 -0
- package/dist/backend/default-backend.d.ts +35 -0
- package/dist/backend/no-collections.d.ts +19 -0
- package/dist/backend/options.d.ts +912 -0
- package/dist/backend/scope.d.ts +23 -0
- package/dist/backend/services.d.ts +54 -0
- package/dist/backend-DTAOsLQc.js.map +1 -1
- package/dist/backup/backup-common.d.ts +24 -3
- package/dist/backup/backup-routes.d.ts +46 -5
- package/dist/backup/backup-schedule.d.ts +33 -0
- package/dist/backup/backup-storage.d.ts +16 -0
- package/dist/backup/index.d.ts +5 -1
- package/dist/backup-DBGRUVTS.js +585 -0
- package/dist/backup-DBGRUVTS.js.map +1 -0
- package/dist/boot/boot.d.ts +2 -2
- package/dist/boot/bundle.d.ts +19 -0
- package/dist/boot/driver.d.ts +3 -0
- package/dist/boot/env.d.ts +58 -6
- package/dist/boot/http-server.d.ts +22 -0
- package/dist/boot/options.d.ts +16 -1
- package/dist/boot/provision.d.ts +4 -2
- package/dist/boot/resource-adapters.d.ts +11 -14
- package/dist/boot/runtime-cors.d.ts +17 -0
- package/dist/boot/security-headers.d.ts +26 -0
- package/dist/boot/sources.d.ts +9 -0
- package/dist/boot/static-routing.d.ts +65 -0
- package/dist/collection_patch-BRu-BvDv.js +472 -0
- package/dist/collection_patch-BRu-BvDv.js.map +1 -0
- package/dist/{contract-routes-CbFjuBwa.js → contract-routes-DiFwiLg2.js} +5 -8
- package/dist/contract-routes-DiFwiLg2.js.map +1 -0
- package/dist/cron/cron-loader.d.ts +77 -18
- package/dist/cron/cron-routes.d.ts +1 -1
- package/dist/cron/cron-scheduler.d.ts +94 -23
- package/dist/cron/cron-store.d.ts +37 -5
- package/dist/cron/define-cron.d.ts +6 -2
- package/dist/cron/index.d.ts +3 -3
- package/dist/cron-loader-NHqRfKF0.js +202 -0
- package/dist/cron-loader-NHqRfKF0.js.map +1 -0
- package/dist/{cron-routes-eE8nif_b.js → cron-routes-DsH8Jwn5.js} +34 -8
- package/dist/cron-routes-DsH8Jwn5.js.map +1 -0
- package/dist/{cron-scheduler-B0pLfAix.js → cron-scheduler-D1DT0nw5.js} +349 -65
- package/dist/cron-scheduler-D1DT0nw5.js.map +1 -0
- package/dist/cron-store-DEpVstUU.js +577 -0
- package/dist/cron-store-DEpVstUU.js.map +1 -0
- package/dist/{ddl-bootstrap-C6mo0Kmz.js → ddl-bootstrap-BNqi2NZe.js} +2 -2
- package/dist/{ddl-bootstrap-C6mo0Kmz.js.map → ddl-bootstrap-BNqi2NZe.js.map} +1 -1
- package/dist/email/index.d.ts +2 -2
- package/dist/email/smtp-email-service.d.ts +23 -0
- package/dist/email/templates.d.ts +22 -0
- package/dist/email/types.d.ts +44 -0
- package/dist/env.d.ts +1 -39
- package/dist/{errors-DWsX4yTd.js → errors-Cqp86KnA.js} +263 -10
- package/dist/errors-Cqp86KnA.js.map +1 -0
- package/dist/filter-dialect-O1HK6Nvr.js +1628 -0
- package/dist/filter-dialect-O1HK6Nvr.js.map +1 -0
- package/dist/{function-loader-xnbDAPfa.js → function-loader-DbCSoNJj.js} +69 -39
- package/dist/function-loader-DbCSoNJj.js.map +1 -0
- package/dist/{function-routes-Chet4-lB.js → function-routes-BSTClQNa.js} +28 -15
- package/dist/function-routes-BSTClQNa.js.map +1 -0
- package/dist/functions/context.d.ts +26 -6
- package/dist/functions/define-function.d.ts +10 -6
- package/dist/functions/function-loader.d.ts +75 -18
- package/dist/functions/function-routes.d.ts +2 -1
- package/dist/functions/guards.d.ts +22 -5
- package/dist/functions/index.d.ts +6 -5
- package/dist/functions/index.js +148 -50
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/internal.d.ts +2 -2
- package/dist/functions/proxy.d.ts +6 -2
- package/dist/functions/request-timeout.d.ts +7 -5
- package/dist/history/history-routes.d.ts +9 -0
- package/dist/history/retention-sweep.d.ts +81 -0
- package/dist/{history-recorder-B4MpJfJK.js → history-recorder-RZ1Ow4YY.js} +4 -4
- package/dist/{history-recorder-B4MpJfJK.js.map → history-recorder-RZ1Ow4YY.js.map} +1 -1
- package/dist/{history-store-BhxWOuz9.js → history-store-DPofGVDp.js} +2 -2
- package/dist/{history-store-BhxWOuz9.js.map → history-store-DPofGVDp.js.map} +1 -1
- package/dist/index.d.ts +32 -13
- package/dist/index.es.js +25329 -18393
- package/dist/index.es.js.map +1 -1
- package/dist/init/docs.d.ts +35 -10
- package/dist/init/health.d.ts +17 -2
- package/dist/init/process-safety.d.ts +7 -2
- package/dist/init/shutdown.d.ts +26 -1
- package/dist/init.d.ts +49 -811
- package/dist/internal-tables-L2t39RdT.js +136 -0
- package/dist/internal-tables-L2t39RdT.js.map +1 -0
- package/dist/jobs/job-queue.d.ts +8 -0
- package/dist/jobs/job-store.d.ts +24 -0
- package/dist/jobs/types.d.ts +25 -4
- package/dist/{jobs-CazMYhyy.js → jobs-8G-_agld.js} +235 -25
- package/dist/jobs-8G-_agld.js.map +1 -0
- package/dist/{jwt-DnQHNFCl.js → jwt-CBaFc34Y.js} +546 -447
- package/dist/jwt-CBaFc34Y.js.map +1 -0
- package/dist/{keys-CogCQpxG.js → keys-COzQ2aE8.js} +3 -17
- package/dist/{keys-CogCQpxG.js.map → keys-COzQ2aE8.js.map} +1 -1
- package/dist/load-failure-L5hvfDoG.js +80 -0
- package/dist/load-failure-L5hvfDoG.js.map +1 -0
- package/dist/{logger-DO2PZc4i.js → logger-Bt32sHFw.js} +41 -5
- package/dist/logger-Bt32sHFw.js.map +1 -0
- package/dist/{logs-routes-Bj4TYYUl.js → logs-routes-DQJhrf-b.js} +48 -8
- package/dist/logs-routes-DQJhrf-b.js.map +1 -0
- package/dist/mcp/consent-page.d.ts +1 -1
- package/dist/mcp/mcp-routes.d.ts +13 -0
- package/dist/mcp/mcp-tools.d.ts +23 -9
- package/dist/mcp/oauth-metadata.d.ts +21 -16
- package/dist/mcp/oauth-routes.d.ts +14 -1
- package/dist/metrics/index.d.ts +18 -0
- package/dist/metrics/pool-wait.d.ts +50 -0
- package/dist/offline-QNQgsPOq-B2yGeXkn.js +3305 -0
- package/dist/offline-QNQgsPOq-B2yGeXkn.js.map +1 -0
- package/dist/offline-store-Cm5sAX81-CALiO4Gn.js +1915 -0
- package/dist/offline-store-Cm5sAX81-CALiO4Gn.js.map +1 -0
- package/dist/{openapi-generator-O_O24MAT.js → openapi-generator-CeGW2dLC.js} +455 -80
- package/dist/openapi-generator-CeGW2dLC.js.map +1 -0
- package/dist/policy-PdzX-Opd.js +121 -0
- package/dist/policy-PdzX-Opd.js.map +1 -0
- package/dist/project_manifest-R6y_KHms.js +59 -0
- package/dist/project_manifest-R6y_KHms.js.map +1 -0
- package/dist/{proxy-Czngl3p9.js → proxy-BEKbsil6.js} +5 -4
- package/dist/proxy-BEKbsil6.js.map +1 -0
- package/dist/{query-parser-DGRVFNM3.js → query-parser-ECxP0nDw.js} +497 -52
- package/dist/query-parser-ECxP0nDw.js.map +1 -0
- package/dist/{request-timeout-C_4C2BeR.js → request-timeout-BiRelY-U.js} +17 -10
- package/dist/request-timeout-BiRelY-U.js.map +1 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js +24 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js.map +1 -0
- package/dist/schema-edit/apply-schema-change.d.ts +73 -3
- package/dist/schema-edit/local-source.d.ts +29 -0
- package/dist/schema-edit/project-root.d.ts +3 -2
- package/dist/schema-edit/remote-source.d.ts +20 -5
- package/dist/schema-edit/source-editor.d.ts +28 -0
- package/dist/schema-editor-routes-DRXBAbZy.js +136 -0
- package/dist/schema-editor-routes-DRXBAbZy.js.map +1 -0
- package/dist/serve-spa.d.ts +58 -0
- package/dist/services/outbound-post.d.ts +50 -0
- package/dist/services/outbound-url-guard.d.ts +34 -5
- package/dist/services/routed-realtime-service.d.ts +16 -0
- package/dist/services/webhook-service.d.ts +66 -14
- package/dist/singleton.d.ts +9 -5
- package/dist/soft-delete-params-CBryZXMq.js +668 -0
- package/dist/soft-delete-params-CBryZXMq.js.map +1 -0
- package/dist/sql-export-routes-D8ZaRvoR.js +240 -0
- package/dist/sql-export-routes-D8ZaRvoR.js.map +1 -0
- package/dist/{src-vkcwKXbT.js → src-D5Y3N-S4.js} +440 -20
- package/dist/src-D5Y3N-S4.js.map +1 -0
- package/dist/storage/GCSStorageController.d.ts +48 -2
- package/dist/storage/LocalStorageController.d.ts +69 -2
- package/dist/storage/S3StorageController.d.ts +39 -3
- package/dist/storage/image-transform.d.ts +15 -0
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/maintenance-routes.d.ts +23 -0
- package/dist/storage/maintenance.d.ts +126 -0
- package/dist/storage/property-limits.d.ts +41 -6
- package/dist/storage/rendition-cache.d.ts +9 -11
- package/dist/storage/request-keys.d.ts +15 -0
- package/dist/storage/request-principals.d.ts +30 -0
- package/dist/storage/requested-object.d.ts +74 -0
- package/dist/storage/routes.d.ts +52 -14
- package/dist/storage/source-variables.d.ts +10 -0
- package/dist/storage/streams.d.ts +42 -0
- package/dist/storage/tus-handler.d.ts +76 -7
- package/dist/storage/types.d.ts +101 -7
- package/dist/storage/upload-validation.d.ts +13 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js +125 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js.map +1 -0
- package/dist/strings.es-BeZWAodn.js +256 -0
- package/dist/strings.es-BeZWAodn.js.map +1 -0
- package/dist/upload-validation-CVobI5xO.js +172 -0
- package/dist/upload-validation-CVobI5xO.js.map +1 -0
- package/dist/utils/byte-size.d.ts +10 -0
- package/dist/utils/compression.d.ts +6 -0
- package/dist/utils/load-failure.d.ts +14 -0
- package/dist/utils/logger.d.ts +21 -0
- package/package.json +5 -5
- package/dist/GCSStorageController-CjrA4PMo.js +0 -242
- package/dist/GCSStorageController-CjrA4PMo.js.map +0 -1
- package/dist/S3StorageController-B6pKDNVj.js +0 -264
- package/dist/S3StorageController-B6pKDNVj.js.map +0 -1
- package/dist/admin-roles-vYdp_Pil.js +0 -36
- package/dist/admin-roles-vYdp_Pil.js.map +0 -1
- package/dist/admin_block-DxKLmdiv.js +0 -206
- package/dist/admin_block-DxKLmdiv.js.map +0 -1
- package/dist/ast-schema-editor-Mvr50v_S.js.map +0 -1
- package/dist/auth/api-keys/api-key-permission-guard.d.ts +0 -65
- package/dist/auth-B-GIMpDG.js.map +0 -1
- package/dist/backup-D7YR94N3.js +0 -253
- package/dist/backup-D7YR94N3.js.map +0 -1
- package/dist/contract-routes-CbFjuBwa.js.map +0 -1
- package/dist/cron-loader-DfTj2Hbi.js +0 -118
- package/dist/cron-loader-DfTj2Hbi.js.map +0 -1
- package/dist/cron-routes-eE8nif_b.js.map +0 -1
- package/dist/cron-scheduler-B0pLfAix.js.map +0 -1
- package/dist/cron-store-TcoGz-xS.js +0 -305
- package/dist/cron-store-TcoGz-xS.js.map +0 -1
- package/dist/dynamic-import-X40pTZUQ.js +0 -23
- package/dist/dynamic-import-X40pTZUQ.js.map +0 -1
- package/dist/errors-DWsX4yTd.js.map +0 -1
- package/dist/function-loader-xnbDAPfa.js.map +0 -1
- package/dist/function-routes-Chet4-lB.js.map +0 -1
- package/dist/jobs-CazMYhyy.js.map +0 -1
- package/dist/jwt-DnQHNFCl.js.map +0 -1
- package/dist/logger-DO2PZc4i.js.map +0 -1
- package/dist/logs-routes-Bj4TYYUl.js.map +0 -1
- package/dist/openapi-generator-O_O24MAT.js.map +0 -1
- package/dist/proxy-Czngl3p9.js.map +0 -1
- package/dist/query-parser-DGRVFNM3.js.map +0 -1
- package/dist/request-timeout-C_4C2BeR.js.map +0 -1
- package/dist/schema-editor-routes-C5-lh_jO.js +0 -87
- package/dist/schema-editor-routes-C5-lh_jO.js.map +0 -1
- package/dist/src-pmvW7BFx.js +0 -6688
- package/dist/src-pmvW7BFx.js.map +0 -1
- package/dist/src-vkcwKXbT.js.map +0 -1
- package/dist/types-BfKcm9do.js +0 -39
- package/dist/types-BfKcm9do.js.map +0 -1
|
@@ -2,11 +2,17 @@ import { Hono } from "hono";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { HonoEnv } from "../api/types.js";
|
|
4
4
|
import type { MiddlewareHandler } from "hono";
|
|
5
|
-
import type
|
|
5
|
+
import { type AuthLimiters } from "./rate-limiter.js";
|
|
6
|
+
import { type JwtService } from "./jwt.js";
|
|
7
|
+
import type { AuthModuleConfig, CreateSessionAndTokens } from "./routes.js";
|
|
6
8
|
import type { AuthResponsePayload, TransformAuthResponseContext } from "@rebasepro/types";
|
|
7
9
|
import type { resolveAuthHooks } from "./auth-hooks.js";
|
|
8
10
|
interface SessionRoutesConfig {
|
|
9
11
|
router: Hono<HonoEnv>;
|
|
12
|
+
/** The backend these routes sign and verify for. */
|
|
13
|
+
jwt: JwtService;
|
|
14
|
+
/** The backend's auth limiters. */
|
|
15
|
+
limiters: AuthLimiters;
|
|
10
16
|
config: AuthModuleConfig;
|
|
11
17
|
/**
|
|
12
18
|
* The caller's guard for a signed-in user, with the revocation watermark
|
|
@@ -28,11 +34,7 @@ interface SessionRoutesConfig {
|
|
|
28
34
|
isAnonymous?: boolean;
|
|
29
35
|
metadata?: Record<string, unknown> | null;
|
|
30
36
|
}, roleIds: string[], accessToken: string, refreshToken: string, providerId: string) => unknown;
|
|
31
|
-
createSessionAndTokens:
|
|
32
|
-
roleIds: string[];
|
|
33
|
-
accessToken: string;
|
|
34
|
-
refreshToken: string;
|
|
35
|
-
}>;
|
|
37
|
+
createSessionAndTokens: CreateSessionAndTokens;
|
|
36
38
|
applyTransformHook: (response: AuthResponsePayload, method: TransformAuthResponseContext["method"], request: Request, uid: string) => Promise<AuthResponsePayload>;
|
|
37
39
|
/**
|
|
38
40
|
* The `register` captcha, built by the caller so a misconfiguration fails
|
|
@@ -41,6 +43,15 @@ interface SessionRoutesConfig {
|
|
|
41
43
|
* `/register`. Absent when captcha is off or `register` is not protected.
|
|
42
44
|
*/
|
|
43
45
|
registerCaptcha?: MiddlewareHandler<HonoEnv>;
|
|
46
|
+
/**
|
|
47
|
+
* Mail the account a verification link, in the background. Upgrading a
|
|
48
|
+
* guest is registration, and registration starts the address proof.
|
|
49
|
+
*/
|
|
50
|
+
sendVerificationMail?: (user: {
|
|
51
|
+
id: string;
|
|
52
|
+
email: string;
|
|
53
|
+
displayName?: string | null;
|
|
54
|
+
}) => void;
|
|
44
55
|
}
|
|
45
56
|
export declare function mountSessionRoutes(opts: SessionRoutesConfig): void;
|
|
46
57
|
export {};
|
|
@@ -37,6 +37,61 @@ import type { AccessTokenPayload } from "./jwt.js";
|
|
|
37
37
|
* failure is logged at warn so it is visible rather than silent.
|
|
38
38
|
*/
|
|
39
39
|
export declare function isAccessTokenRevoked(authRepo: Pick<AuthRepository, "getTokensValidAfter">, payload: Pick<AccessTokenPayload, "uid" | "iat">): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* The repository reads {@link judgeAccessToken} may make. All optional: a
|
|
42
|
+
* repository answers what it can, and the judge says what it could not ask.
|
|
43
|
+
*/
|
|
44
|
+
export type AccessJudgeRepository = Partial<Pick<AuthRepository, "getAccountAccessState" | "getUserWithRoles" | "getTokensValidAfter">>;
|
|
45
|
+
/**
|
|
46
|
+
* Why an access token that verifies is not honoured.
|
|
47
|
+
*
|
|
48
|
+
* - `revoked`: issued before the account's revocation watermark — a sign-out
|
|
49
|
+
* everywhere, a password change or reset.
|
|
50
|
+
* - `session-revoked`: its own sign-in was ended — `POST /auth/logout`, or
|
|
51
|
+
* `DELETE /auth/sessions/:id` from another device. Needs the token's `sid`.
|
|
52
|
+
* - `account-deleted`: the account it names no longer exists.
|
|
53
|
+
* - `account-disabled`: an administrator switched the account off.
|
|
54
|
+
*/
|
|
55
|
+
export type AccessTokenRefusal = "revoked" | "session-revoked" | "account-deleted" | "account-disabled";
|
|
56
|
+
export type AccessTokenVerdict = {
|
|
57
|
+
live: true;
|
|
58
|
+
/**
|
|
59
|
+
* The account's roles now, or `undefined` when the repository could
|
|
60
|
+
* not say (it reads neither the account nor its roles).
|
|
61
|
+
*/
|
|
62
|
+
roles?: string[];
|
|
63
|
+
} | {
|
|
64
|
+
live: false;
|
|
65
|
+
refusal: AccessTokenRefusal;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Is the account behind this verified access token still the one that may use
|
|
69
|
+
* it — and with which roles?
|
|
70
|
+
*
|
|
71
|
+
* A verified signature says who the token was minted for, an hour ago at
|
|
72
|
+
* most. This asks the database what has happened to that account since. Every
|
|
73
|
+
* door that honours an access token — the data plane, the admin gates, the
|
|
74
|
+
* realtime socket — asks it here, so they cannot disagree about it.
|
|
75
|
+
*
|
|
76
|
+
* They did. A deleted account read as "not revoked": the watermark lives on
|
|
77
|
+
* the user row, so once the row was gone there was no watermark, and the
|
|
78
|
+
* roles lookup answered `[]` rather than "nobody". A token its owner had
|
|
79
|
+
* revoked came back to life when an administrator deleted the account, as an
|
|
80
|
+
* authenticated principal with that uid, for the rest of its lifetime. MCP
|
|
81
|
+
* refresh and personal API keys already treated a missing account as revoked;
|
|
82
|
+
* the main door did not.
|
|
83
|
+
*
|
|
84
|
+
* Throws when the repository does. Unlike the watermark read on its own, this
|
|
85
|
+
* one decides the roles a request runs with, so a failure is a refusal (the
|
|
86
|
+
* callers answer 503) rather than a guess.
|
|
87
|
+
*
|
|
88
|
+
* Except one failure that is an answer: the store refusing the uid as a value
|
|
89
|
+
* its id column cannot hold — `u1` against a UUID key. That names no account,
|
|
90
|
+
* exactly as a well-formed id nobody has does, so it is `account-deleted` and
|
|
91
|
+
* the caller answers 401. Answered as a failure it was a 503 asking the
|
|
92
|
+
* client to try again, which it would do forever.
|
|
93
|
+
*/
|
|
94
|
+
export declare function judgeAccessToken(authRepo: AccessJudgeRepository, payload: Pick<AccessTokenPayload, "uid" | "iat" | "sid">): Promise<AccessTokenVerdict>;
|
|
40
95
|
/**
|
|
41
96
|
* End every session this user holds, on every device.
|
|
42
97
|
*
|
|
@@ -72,4 +127,4 @@ export declare function revokeAllSessions(authRepo: Pick<AuthRepository, "delete
|
|
|
72
127
|
* `null` removes the password instead, for the same reason and with the same
|
|
73
128
|
* revocation: see `confirmAddressOwnership`.
|
|
74
129
|
*/
|
|
75
|
-
export declare function replaceUserPassword(authRepo: Pick<AuthRepository, "updatePassword" | "deleteAllRefreshTokensForUser" | "setTokensValidAfter"
|
|
130
|
+
export declare function replaceUserPassword(authRepo: Pick<AuthRepository, "updatePassword" | "deleteAllRefreshTokensForUser" | "setTokensValidAfter"> & Partial<Pick<AuthRepository, "deleteAllPasswordResetTokensForUser">>, uid: string, passwordHash: string | null): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who may read the user picker (`GET /api/admin/users/pick`).
|
|
3
|
+
*
|
|
4
|
+
* A `userSelect` field stores a user's id, and the person filling it in picks
|
|
5
|
+
* that user from a list. Listing the users is an admin-plane read
|
|
6
|
+
* (`users:read`), which an editor does not hold — so the picker answers a
|
|
7
|
+
* narrower question for a wider audience: id, name, email and avatar, to
|
|
8
|
+
* anyone who may write a collection that has such a field.
|
|
9
|
+
*
|
|
10
|
+
* "May write" is the collection's `securityRules` for an insert or an update,
|
|
11
|
+
* evaluated the way the admin panel decides whether to offer the form, with
|
|
12
|
+
* one difference. A rule that depends only on the row (an owner field) counts
|
|
13
|
+
* as allowing, since the person may write some row. A rule written as SQL the
|
|
14
|
+
* policy model cannot read cannot be judged ahead, and here it counts as
|
|
15
|
+
* refusing: read optimistically, it would let any signed-in person list every
|
|
16
|
+
* user's name and email. A key or token narrowed by scopes must also hold
|
|
17
|
+
* `data:write` on that collection.
|
|
18
|
+
*
|
|
19
|
+
* The collections are the backend's own (`c.var.services`), read when the
|
|
20
|
+
* question is asked, so a schema edited live is what is judged.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import type { Context } from "hono";
|
|
25
|
+
import { type CollectionConfig, type Properties } from "@rebasepro/types";
|
|
26
|
+
import type { HonoEnv } from "../api/types.js";
|
|
27
|
+
/** Tell the process default's picker which collections it serves. */
|
|
28
|
+
export declare function configureUserPicking(collections: () => readonly CollectionConfig[]): void;
|
|
29
|
+
/** @internal The process default's collections getter, to snapshot or restore it. */
|
|
30
|
+
export declare function defaultUserPicking(): () => readonly CollectionConfig[];
|
|
31
|
+
/** Whether any property, at any depth, is a `userSelect` field. */
|
|
32
|
+
export declare function propertiesReferenceUsers(properties: Properties | undefined): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether this request's caller may read the user picker: they hold
|
|
35
|
+
* `users:read`, or they may write a collection with a `userSelect` field.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mayPickUsers(c: Context<HonoEnv>): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify a bearer credential outside the HTTP middlewares — for a custom
|
|
3
|
+
* socket, a tunnel, anything an app authenticates from a frame or a header it
|
|
4
|
+
* read itself.
|
|
5
|
+
*
|
|
6
|
+
* One answer for the two kinds of credential a person can hold: a session
|
|
7
|
+
* token, and an API key (`rk_`). Both come back as who the caller acts as and
|
|
8
|
+
* what it may do, so the endpoint checks a scope the same way either way.
|
|
9
|
+
*
|
|
10
|
+
* A backend answers for itself — `backend.verifyCredential(token)`, against its
|
|
11
|
+
* own keys, store and access model. {@link verifyCredential} answers for the
|
|
12
|
+
* process default.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import type { ApiKeyStore } from "./api-keys/api-key-store.js";
|
|
17
|
+
import { type AccessControl } from "./access.js";
|
|
18
|
+
import { type JwtService } from "./jwt.js";
|
|
19
|
+
/** Who a verified credential acts as, and what it may do. */
|
|
20
|
+
export interface VerifiedCredential {
|
|
21
|
+
uid: string;
|
|
22
|
+
roles: string[];
|
|
23
|
+
scopes: string[];
|
|
24
|
+
/** `"api-key"` when an `rk_` key was presented, otherwise `"session"`. */
|
|
25
|
+
kind: "session" | "api-key";
|
|
26
|
+
}
|
|
27
|
+
/** What a credential is checked against: one backend's keys, key store and access model. */
|
|
28
|
+
export interface CredentialAuthority {
|
|
29
|
+
jwt: JwtService;
|
|
30
|
+
access: AccessControl;
|
|
31
|
+
apiKeyStore?: ApiKeyStore;
|
|
32
|
+
}
|
|
33
|
+
/** Install the key store the process default's {@link verifyCredential} checks `rk_` keys against. */
|
|
34
|
+
export declare function configureCredentialStore(store: ApiKeyStore | undefined): void;
|
|
35
|
+
/** @internal The process default's key store, to snapshot or restore it. */
|
|
36
|
+
export declare function defaultCredentialStore(): ApiKeyStore | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The identity and scopes behind a bearer credential, checked against one
|
|
39
|
+
* backend, or null when it does not verify — expired, revoked, unknown, or a
|
|
40
|
+
* key on a backend with no key store.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyCredentialAgainst(authority: CredentialAuthority, token: string): Promise<VerifiedCredential | null>;
|
|
43
|
+
/**
|
|
44
|
+
* The identity and scopes behind a bearer credential, as the process default
|
|
45
|
+
* answers — expired, revoked, unknown, or a key on a backend with no key store
|
|
46
|
+
* all come back null. A backend built by `createRebaseBackend` answers for
|
|
47
|
+
* itself: `backend.verifyCredential(token)`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function verifyCredential(token: string): Promise<VerifiedCredential | null>;
|