@rebasepro/server 0.12.1-canary.gf5f1d39 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/GCSStorageController-BEmDYFKc.js +216 -0
- package/dist/GCSStorageController-BEmDYFKc.js.map +1 -0
- package/dist/S3StorageController-B2EDXXMH.js +249 -0
- package/dist/S3StorageController-B2EDXXMH.js.map +1 -0
- package/dist/admin_block-CcSGdH7M.js +124 -0
- package/dist/admin_block-CcSGdH7M.js.map +1 -0
- package/dist/api/rest/write-validation.d.ts +22 -0
- package/dist/auth/bearer-token.d.ts +26 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/middleware.d.ts +2 -0
- package/dist/auth/rate-limiter.d.ts +0 -11
- package/dist/auth/require-auth.d.ts +39 -0
- package/dist/auth-CuC9M2x6.js +8961 -0
- package/dist/auth-CuC9M2x6.js.map +1 -0
- package/dist/backend-CIxN4FVm.js +15 -0
- package/dist/backend-CIxN4FVm.js.map +1 -0
- package/dist/backup-CVggVhR2.js +163 -0
- package/dist/backup-CVggVhR2.js.map +1 -0
- package/dist/boot/boot.d.ts +53 -0
- package/dist/boot/driver.d.ts +35 -6
- package/dist/boot/fetch-bundle.d.ts +43 -0
- package/dist/boot/version-skew.d.ts +77 -0
- package/dist/contract-routes-Dj8i5AiM.js +264 -0
- package/dist/contract-routes-Dj8i5AiM.js.map +1 -0
- package/dist/cron/cron-scheduler.d.ts +34 -0
- package/dist/cron-loader-B1S2MCSl.js +63 -0
- package/dist/cron-loader-B1S2MCSl.js.map +1 -0
- package/dist/cron-routes-CrQ0tK-_.js +62 -0
- package/dist/cron-routes-CrQ0tK-_.js.map +1 -0
- package/dist/cron-scheduler-B3RFt0HS.js +647 -0
- package/dist/cron-scheduler-B3RFt0HS.js.map +1 -0
- package/dist/cron-store-BywZsyfZ.js +164 -0
- package/dist/cron-store-BywZsyfZ.js.map +1 -0
- package/dist/dynamic-import-Dvh-K5fl.js.map +1 -1
- package/dist/errors-CgkCzoj7.js +226 -0
- package/dist/errors-CgkCzoj7.js.map +1 -0
- package/dist/function-loader-B_1fYfUY.js +86 -0
- package/dist/function-loader-B_1fYfUY.js.map +1 -0
- package/dist/function-routes-C0cLIy3N.js +28 -0
- package/dist/function-routes-C0cLIy3N.js.map +1 -0
- package/dist/functions/define-function.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +8123 -17984
- package/dist/index.es.js.map +1 -1
- package/dist/init.d.ts +21 -5
- package/dist/{jwt-D-eI6TTu.js → jwt-DD6EtpGj.js} +32 -13
- package/dist/{jwt-D-eI6TTu.js.map → jwt-DD6EtpGj.js.map} +1 -1
- package/dist/logger-BYU66ENZ.js.map +1 -1
- package/dist/logs-routes-BYA72C_C.js +100 -0
- package/dist/logs-routes-BYA72C_C.js.map +1 -0
- package/dist/{openapi-generator-Bjzmb5cn.js → openapi-generator-BEwyiaAr.js} +9 -3
- package/dist/openapi-generator-BEwyiaAr.js.map +1 -0
- package/dist/{schema-editor-routes-DDxfOIid.js → schema-editor-routes-CbF20Mf1.js} +4 -3
- package/dist/{schema-editor-routes-DDxfOIid.js.map → schema-editor-routes-CbF20Mf1.js.map} +1 -1
- package/dist/singleton.d.ts +4 -2
- package/dist/{src-CoOAMnBh.js → src-Cum9kox5.js} +501 -86
- package/dist/src-Cum9kox5.js.map +1 -0
- package/dist/src-_qQ3RNCK.js +279 -0
- package/dist/src-_qQ3RNCK.js.map +1 -0
- package/dist/types-DSnOC4mF.js +38 -0
- package/dist/types-DSnOC4mF.js.map +1 -0
- package/package.json +10 -10
- package/dist/openapi-generator-Bjzmb5cn.js.map +0 -1
- package/dist/src-CoOAMnBh.js.map +0 -1
- package/dist/src-Ivjud8jD.js +0 -957
- package/dist/src-Ivjud8jD.js.map +0 -1
- /package/dist/{chunk-DSJWtz9O.js → rolldown-runtime-DSJWtz9O.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin_block-CcSGdH7M.js","names":[],"sources":["../../types/src/types/admin_block.ts"],"sourcesContent":["/**\n * The keys of a collection's admin block, as data.\n *\n * There is no *type* for the block in this package any more, and that is the point:\n * `admin` is not declared on `BaseCollectionConfig` or on any property here, so a\n * BaaS install cannot even write one. `@rebasepro/admin-types` adds the field back by\n * declaration merging, which is why installing it is what makes the admin surface\n * appear.\n *\n * The *list* still has to live here, because three runtime consumers need it and two\n * of them are core — see below.\n */\n\n/**\n * Every key that belongs inside a collection's `admin` block, as data.\n *\n * The type that describes these fields is `AdminCollectionOptions` in\n * `@rebasepro/admin-types`, and it is erased at build time — but three runtime\n * consumers need the list, and two of them are core:\n *\n * - `serializeCollections`, to drop the block from the contract\n * - the ts-morph schema editor in `@rebasepro/server`, which rewrites collection\n * files on disk from the admin panel and has to know where each key goes. A key\n * missing from this list gets written to the *top level* of the file, where the\n * backend ignores it and the panel never finds it again.\n * - the `collections-admin-block` codemod\n *\n * `@rebasepro/admin-types` re-exports this and asserts it names only real option\n * keys; the count is pinned by a test there.\n *\n * @group Models\n */\nexport const ADMIN_COLLECTION_KEYS = [\n \"Actions\",\n \"additionalFields\",\n \"alwaysApplyDefaultValues\",\n \"components\",\n \"defaultEntityAction\",\n \"defaultFilter\",\n \"defaultSelectedView\",\n \"defaultSize\",\n \"defaultViewMode\",\n \"disableDefaultActions\",\n \"enabledViews\",\n \"entityActions\",\n \"entityViews\",\n \"exportable\",\n \"filterPresets\",\n \"fixedFilter\",\n \"form\",\n \"formAutoSave\",\n \"formView\",\n \"group\",\n \"hideFromNavigation\",\n \"hideIdFromCollection\",\n \"hideIdFromForm\",\n \"icon\",\n \"includeJsonView\",\n \"inlineEditing\",\n \"kanban\",\n \"listProperties\",\n \"localChangesBackup\",\n \"openEntityMode\",\n \"orderProperty\",\n \"pagination\",\n \"previewProperties\",\n \"propertiesOrder\",\n \"selectionController\",\n \"selectionEnabled\",\n \"sideDialogWidth\",\n \"sort\",\n \"titleProperty\"\n] as const;\n\n/** A key of a collection's `admin` block. @group Models */\nexport type AdminCollectionKey = typeof ADMIN_COLLECTION_KEYS[number];\n\n/**\n * Every key that belongs inside a *property's* `admin` block, as data.\n *\n * The union of `AdminPropertyOptions` and its per-type extensions\n * (`AdminStringOptions`, `AdminArrayOptions`, …) in `@rebasepro/admin-types`.\n * It lives here for the same reason {@link ADMIN_COLLECTION_KEYS} does: the\n * runtime consumers are core packages that the BaaS guard forbids from\n * importing `@rebasepro/admin-types`. Here it is the boot-time collection\n * validator in `@rebasepro/server`, which has to tell \"you left `readOnly` at\n * the top of the property, where nothing reads it\" apart from \"you invented a\n * key we have never heard of\".\n *\n * `@rebasepro/admin-types` re-exports this and asserts it names only real\n * option keys.\n *\n * @group Models\n */\nexport const ADMIN_PROPERTY_KEYS = [\n \"canAddElements\",\n \"clearable\",\n \"columnWidth\",\n \"customProps\",\n \"disabled\",\n \"expanded\",\n \"Field\",\n \"Filter\",\n \"filterOperators\",\n \"fixedFilter\",\n \"hideFromCollection\",\n \"includeEntityLink\",\n \"includeId\",\n \"markdown\",\n \"minimalistView\",\n \"multiline\",\n \"Preview\",\n \"previewAsTag\",\n \"previewProperties\",\n \"readOnly\",\n \"sortable\",\n \"span\",\n \"spreadChildren\",\n \"urlPreview\",\n \"widget\",\n] as const;\n\n/** A key of a property's `admin` block. @group Models */\nexport type AdminPropertyKey = typeof ADMIN_PROPERTY_KEYS[number];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,wBAAwB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;;;;;;;;;;;;;;;;;;AAsBA,IAAa,sBAAsB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ"}
|
|
@@ -20,3 +20,25 @@ export declare function assertKnownWriteFields(values: Record<string, unknown>,
|
|
|
20
20
|
rowIndex?: number;
|
|
21
21
|
extraKnownFields?: readonly string[];
|
|
22
22
|
}): void;
|
|
23
|
+
/**
|
|
24
|
+
* Narrow response rows to the fields the caller asked for.
|
|
25
|
+
*
|
|
26
|
+
* `?fields=id,title` is documented in the generated OpenAPI — "Comma-separated
|
|
27
|
+
* list of fields to return (field selection)" — and it is the first thing shown
|
|
28
|
+
* on every endpoint in the API Explorer. It was parsed into `options.fields`
|
|
29
|
+
* and then read by nothing at all: no driver referenced it, and every request
|
|
30
|
+
* came back with every column. A caller asking for two fields of a `posts` row
|
|
31
|
+
* still received its whole `content`.
|
|
32
|
+
*
|
|
33
|
+
* This shapes the *response*, which is what the parameter says it does; it is
|
|
34
|
+
* not a column pushdown, so it saves bandwidth rather than database work.
|
|
35
|
+
*
|
|
36
|
+
* `id` always survives. Rows are addressed by it everywhere above this layer —
|
|
37
|
+
* the admin table, realtime reconciliation, the offline cache — and a row that
|
|
38
|
+
* arrives without one is not a smaller row, it is an unusable one. Asking for
|
|
39
|
+
* `fields=title` and being unable to open the record you clicked is a worse
|
|
40
|
+
* answer than one extra key.
|
|
41
|
+
*/
|
|
42
|
+
export declare function projectResponseFields<T extends Record<string, unknown>>(rows: T[], fields: readonly string[] | undefined, collection: CollectionConfig, options?: {
|
|
43
|
+
include?: readonly string[];
|
|
44
|
+
}): T[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing of the `Authorization: Bearer <token>` header.
|
|
3
|
+
*
|
|
4
|
+
* Its own module rather than a helper inside `middleware.ts`, because the
|
|
5
|
+
* API-key middleware needs it too and `middleware.ts` already imports from
|
|
6
|
+
* there — putting it in either one would close an import cycle.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Pull the token out of an `Authorization: Bearer <token>` header.
|
|
12
|
+
*
|
|
13
|
+
* RFC 7235 §2.1 makes the auth-scheme name case-insensitive, and plenty of
|
|
14
|
+
* clients send `bearer` — HTTP libraries that lower-case what they emit,
|
|
15
|
+
* hand-written curl, proxies that normalise headers. Matching `"Bearer "`
|
|
16
|
+
* exactly turned those into a 401 that, from the caller's side, is
|
|
17
|
+
* indistinguishable from a rejected token; people spend an afternoon
|
|
18
|
+
* regenerating credentials that were fine. Only the scheme is folded — the
|
|
19
|
+
* token itself is returned byte-for-byte.
|
|
20
|
+
*
|
|
21
|
+
* Returns `undefined` when there is no header or it names another scheme.
|
|
22
|
+
* That is deliberately distinct from an empty token (`Bearer ` with nothing
|
|
23
|
+
* after it), which callers still route into verification so it fails as a bad
|
|
24
|
+
* token rather than as a missing header.
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractBearerToken(authHeader: string | undefined | null): string | undefined;
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type { AuthModuleConfig, CookieAuthConfig } from "./routes";
|
|
|
28
28
|
export { mountMagicLinkRoutes } from "./magic-link-routes";
|
|
29
29
|
export { createResetPasswordRoute } from "./reset-password-admin";
|
|
30
30
|
export type { ResetPasswordRouteConfig } from "./reset-password-admin";
|
|
31
|
-
export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter,
|
|
31
|
+
export { createRateLimiter, defaultAuthLimiter, strictAuthLimiter, createDataRateLimiter, apiKeyKeyGenerator } from "./rate-limiter";
|
|
32
32
|
export type { DataRateLimitConfig } from "./rate-limiter";
|
|
33
33
|
export { MemoryRateLimitStore } from "./rate-limit-store";
|
|
34
34
|
export type { RateLimitStore, RateLimitDecision } from "./rate-limit-store";
|
|
@@ -3,6 +3,8 @@ import { DataDriver } from "@rebasepro/types";
|
|
|
3
3
|
import { AccessTokenPayload } from "./jwt";
|
|
4
4
|
import type { HonoEnv } from "../api/types";
|
|
5
5
|
import type { ApiKeyStore } from "./api-keys/api-key-store";
|
|
6
|
+
import { extractBearerToken } from "./bearer-token";
|
|
7
|
+
export { extractBearerToken };
|
|
6
8
|
/**
|
|
7
9
|
* Result from a custom auth validator.
|
|
8
10
|
* - `false`/`null`/`undefined` = not authenticated
|
|
@@ -98,15 +98,4 @@ export interface DataRateLimitConfig {
|
|
|
98
98
|
* `enabled: false` rather than pay for it twice.
|
|
99
99
|
*/
|
|
100
100
|
export declare function createDataRateLimiter(config?: DataRateLimitConfig): MiddlewareHandler<HonoEnv>;
|
|
101
|
-
/**
|
|
102
|
-
* Create a rate limiter specifically for API key requests.
|
|
103
|
-
*
|
|
104
|
-
* @deprecated Use {@link createDataRateLimiter}, which limits signed-in users
|
|
105
|
-
* and anonymous callers too. This one skips every request that is not
|
|
106
|
-
* API-key-authenticated, which was most of them.
|
|
107
|
-
*
|
|
108
|
-
* @param defaultLimit - Fallback limit when the key has no `rate_limit` set.
|
|
109
|
-
* @param windowMs - Time window in milliseconds (default: 15 minutes).
|
|
110
|
-
*/
|
|
111
|
-
export declare function createApiKeyRateLimiter(defaultLimit?: number, windowMs?: number): MiddlewareHandler<HonoEnv>;
|
|
112
101
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AuthAdapter } from "@rebasepro/types";
|
|
2
|
+
import type { RebaseAuthConfig } from "../init";
|
|
3
|
+
/**
|
|
4
|
+
* Whether the `auth` config is an `AuthAdapter` (it can verify a request) or a
|
|
5
|
+
* plain `RebaseAuthConfig`. Lives here rather than in `init.ts` so this module
|
|
6
|
+
* stays free of it; `init.ts` re-exports it under its original name.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isAuthAdapter(auth: RebaseAuthConfig | AuthAdapter): auth is AuthAdapter;
|
|
9
|
+
/**
|
|
10
|
+
* Does this server require an authenticated caller?
|
|
11
|
+
*
|
|
12
|
+
* One predicate, because there are two enforcement points — the HTTP data
|
|
13
|
+
* routes and the realtime socket — and they used to compute it separately. The
|
|
14
|
+
* socket's copy read
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* authConfig?.requireAuth !== false && !!authConfig?.jwtSecret
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* which differs from this in two ways, both of them open. With no auth config
|
|
21
|
+
* at all it returned `false` while the HTTP side returned `true`, so a server
|
|
22
|
+
* that answered 401 to every `/api/data` read served the same rows over the
|
|
23
|
+
* socket. And an explicit `requireAuth: true` was ANDed away whenever the
|
|
24
|
+
* credential came from an adapter rather than a local `jwtSecret` — asking for
|
|
25
|
+
* authentication was what switched it off.
|
|
26
|
+
*
|
|
27
|
+
* It is worth stating why that is worse than an ordinary missing check: the
|
|
28
|
+
* socket seeds each session with `authenticated: !requireAuth`, so a `false`
|
|
29
|
+
* here does not skip a gate, it marks every client that connects as already
|
|
30
|
+
* past it.
|
|
31
|
+
*
|
|
32
|
+
* Its own module rather than a helper in `init.ts` so the drivers can import it
|
|
33
|
+
* without pulling the backend entry point in behind it.
|
|
34
|
+
*
|
|
35
|
+
* - an `AuthAdapter` always implies auth is required (secure by default)
|
|
36
|
+
* - a `RebaseAuthConfig` is honoured, and only an explicit `false` opens it
|
|
37
|
+
* - no auth configuration at all defaults to required
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveRequireAuth(auth?: RebaseAuthConfig | AuthAdapter): boolean;
|