@rebasepro/server 0.23.0 → 0.24.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/README.md +1 -1
- package/bin/rebase-server.js +4 -2
- package/dist/{GCSStorageController-CjrA4PMo.js → GCSStorageController-BSiP1c-f.js} +22 -8
- package/dist/GCSStorageController-BSiP1c-f.js.map +1 -0
- package/dist/{S3StorageController-B6pKDNVj.js → S3StorageController-CAwFRgjV.js} +19 -7
- package/dist/S3StorageController-CAwFRgjV.js.map +1 -0
- package/dist/api/ast-schema-editor.d.ts +92 -1
- package/dist/api/errors.d.ts +9 -0
- package/dist/api/live-schema-routes.d.ts +38 -8
- package/dist/api/logs-routes.d.ts +39 -1
- package/dist/api/openapi-generator.d.ts +17 -0
- package/dist/api/rest/api-generator.d.ts +44 -10
- package/dist/api/rest/write-validation.d.ts +2 -2
- package/dist/api/types.d.ts +17 -1
- package/dist/{ast-schema-editor-Mvr50v_S.js → ast-schema-editor-CWqS_sLJ.js} +309 -11
- package/dist/ast-schema-editor-CWqS_sLJ.js.map +1 -0
- package/dist/auth/access.d.ts +105 -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-users-route.d.ts +1 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +56 -55
- package/dist/auth/api-keys/api-key-routes.d.ts +41 -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 +8 -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 +41 -0
- package/dist/auth/expired-token-sweep.d.ts +67 -0
- package/dist/auth/impersonation.d.ts +110 -0
- package/dist/auth/index.d.ts +4 -2
- package/dist/auth/interfaces.d.ts +110 -59
- package/dist/auth/jwt.d.ts +49 -3
- package/dist/auth/magic-link-routes.d.ts +2 -6
- package/dist/auth/mfa-routes.d.ts +2 -9
- package/dist/auth/middleware.d.ts +17 -5
- package/dist/auth/otp-routes.d.ts +2 -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 +41 -0
- package/dist/auth/routes.d.ts +45 -0
- package/dist/auth/scope-routes.d.ts +22 -0
- package/dist/auth/session-routes.d.ts +11 -6
- package/dist/auth/token-revocation.d.ts +50 -1
- package/dist/auth/verify-credential.d.ts +28 -0
- package/dist/{auth-B-GIMpDG.js → auth-DMLngxn_.js} +2159 -569
- package/dist/auth-DMLngxn_.js.map +1 -0
- package/dist/backend-DTAOsLQc.js.map +1 -1
- package/dist/backup/backup-common.d.ts +10 -0
- package/dist/backup/backup-routes.d.ts +24 -4
- package/dist/backup/backup-schedule.d.ts +33 -0
- package/dist/backup/backup-storage.d.ts +14 -0
- package/dist/backup/index.d.ts +2 -0
- package/dist/backup-CN0s50D2.js +444 -0
- package/dist/backup-CN0s50D2.js.map +1 -0
- package/dist/boot/bundle.d.ts +19 -0
- package/dist/boot/env.d.ts +49 -4
- package/dist/boot/security-headers.d.ts +26 -0
- package/dist/boot/static-routing.d.ts +56 -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-fz8i4pxs.js} +17 -4
- package/dist/contract-routes-fz8i4pxs.js.map +1 -0
- package/dist/cron/cron-scheduler.d.ts +25 -20
- package/dist/cron/cron-store.d.ts +6 -2
- package/dist/{cron-loader-DfTj2Hbi.js → cron-loader-CwaANlOG.js} +4 -4
- package/dist/cron-loader-CwaANlOG.js.map +1 -0
- package/dist/{cron-routes-eE8nif_b.js → cron-routes-Bc-SB0Se.js} +10 -7
- package/dist/cron-routes-Bc-SB0Se.js.map +1 -0
- package/dist/{cron-scheduler-B0pLfAix.js → cron-scheduler-CYQgco86.js} +52 -34
- package/dist/cron-scheduler-CYQgco86.js.map +1 -0
- package/dist/{cron-store-TcoGz-xS.js → cron-store-D2Q9-Aco.js} +10 -15
- package/dist/cron-store-D2Q9-Aco.js.map +1 -0
- package/dist/{ddl-bootstrap-C6mo0Kmz.js → ddl-bootstrap-BaqMSa4Y.js} +2 -2
- package/dist/{ddl-bootstrap-C6mo0Kmz.js.map → ddl-bootstrap-BaqMSa4Y.js.map} +1 -1
- package/dist/email/index.d.ts +2 -2
- package/dist/email/templates.d.ts +22 -0
- package/dist/email/types.d.ts +26 -0
- package/dist/env.d.ts +1 -2
- package/dist/{errors-DWsX4yTd.js → errors-D6_y86c5.js} +102 -8
- package/dist/errors-D6_y86c5.js.map +1 -0
- package/dist/{function-loader-xnbDAPfa.js → function-loader-D7o5Epjj.js} +2 -2
- package/dist/{function-loader-xnbDAPfa.js.map → function-loader-D7o5Epjj.js.map} +1 -1
- package/dist/{function-routes-Chet4-lB.js → function-routes-CaNG4waN.js} +24 -12
- package/dist/function-routes-CaNG4waN.js.map +1 -0
- package/dist/functions/context.d.ts +17 -6
- package/dist/functions/guards.d.ts +22 -5
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/index.js +90 -36
- package/dist/functions/index.js.map +1 -1
- package/dist/{history-recorder-B4MpJfJK.js → history-recorder-Nr8zLvoU.js} +4 -4
- package/dist/{history-recorder-B4MpJfJK.js.map → history-recorder-Nr8zLvoU.js.map} +1 -1
- package/dist/{history-store-BhxWOuz9.js → history-store-rcAm_xFR.js} +2 -2
- package/dist/{history-store-BhxWOuz9.js.map → history-store-rcAm_xFR.js.map} +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.es.js +3084 -753
- package/dist/index.es.js.map +1 -1
- package/dist/init/health.d.ts +17 -2
- package/dist/init/shutdown.d.ts +10 -0
- package/dist/init.d.ts +54 -0
- package/dist/{jobs-CazMYhyy.js → jobs-DqYNfquG.js} +5 -5
- package/dist/{jobs-CazMYhyy.js.map → jobs-DqYNfquG.js.map} +1 -1
- package/dist/{jwt-DnQHNFCl.js → jwt-R6bSPMjk.js} +39 -15
- package/dist/{jwt-DnQHNFCl.js.map → jwt-R6bSPMjk.js.map} +1 -1
- package/dist/{keys-CogCQpxG.js → keys-GAVZqbqx.js} +3 -17
- package/dist/{keys-CogCQpxG.js.map → keys-GAVZqbqx.js.map} +1 -1
- package/dist/{logger-DO2PZc4i.js → logger-D-S-hO5e.js} +26 -3
- package/dist/logger-D-S-hO5e.js.map +1 -0
- package/dist/{logs-routes-Bj4TYYUl.js → logs-routes-DAdv37GI.js} +48 -8
- package/dist/logs-routes-DAdv37GI.js.map +1 -0
- package/dist/mcp/consent-page.d.ts +1 -1
- package/dist/mcp/mcp-routes.d.ts +7 -0
- package/dist/mcp/mcp-tools.d.ts +15 -9
- package/dist/mcp/oauth-metadata.d.ts +21 -16
- package/dist/mcp/oauth-routes.d.ts +7 -1
- package/dist/{openapi-generator-O_O24MAT.js → openapi-generator-DAq_XVDu.js} +104 -13
- package/dist/openapi-generator-DAq_XVDu.js.map +1 -0
- package/dist/{proxy-Czngl3p9.js → proxy-qRlqeUmO.js} +2 -2
- package/dist/{proxy-Czngl3p9.js.map → proxy-qRlqeUmO.js.map} +1 -1
- package/dist/{query-parser-DGRVFNM3.js → query-parser-BgiKJKvc.js} +6 -56
- package/dist/query-parser-BgiKJKvc.js.map +1 -0
- package/dist/{request-timeout-C_4C2BeR.js → request-timeout-DgH7j8qO.js} +3 -3
- package/dist/{request-timeout-C_4C2BeR.js.map → request-timeout-DgH7j8qO.js.map} +1 -1
- package/dist/schema-edit/apply-schema-change.d.ts +63 -3
- package/dist/schema-edit/project-root.d.ts +3 -2
- package/dist/schema-edit/remote-source.d.ts +9 -4
- package/dist/{schema-editor-routes-C5-lh_jO.js → schema-editor-routes-oIyuWl3L.js} +12 -7
- package/dist/schema-editor-routes-oIyuWl3L.js.map +1 -0
- package/dist/serve-spa.d.ts +58 -0
- package/dist/services/routed-realtime-service.d.ts +11 -0
- package/dist/soft-delete-params-BWPilMPF.js +59 -0
- package/dist/soft-delete-params-BWPilMPF.js.map +1 -0
- package/dist/{src-vkcwKXbT.js → src-CatHFUym.js} +439 -20
- package/dist/src-CatHFUym.js.map +1 -0
- package/dist/{src-pmvW7BFx.js → src-I3aG1PcY.js} +252 -70
- package/dist/src-I3aG1PcY.js.map +1 -0
- package/dist/storage/GCSStorageController.d.ts +2 -0
- package/dist/storage/LocalStorageController.d.ts +2 -0
- package/dist/storage/S3StorageController.d.ts +2 -0
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/property-limits.d.ts +41 -6
- package/dist/storage/request-keys.d.ts +15 -0
- package/dist/storage/requested-object.d.ts +74 -0
- package/dist/storage/routes.d.ts +36 -18
- package/dist/storage/tus-handler.d.ts +30 -5
- package/dist/storage/types.d.ts +19 -0
- package/dist/types-BfKcm9do.js.map +1 -1
- package/dist/utils/logger.d.ts +12 -0
- package/package.json +5 -5
- package/dist/GCSStorageController-CjrA4PMo.js.map +0 -1
- 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.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.map +0 -1
- package/dist/errors-DWsX4yTd.js.map +0 -1
- package/dist/function-routes-Chet4-lB.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/query-parser-DGRVFNM3.js.map +0 -1
- package/dist/schema-editor-routes-C5-lh_jO.js.map +0 -1
- package/dist/src-pmvW7BFx.js.map +0 -1
- package/dist/src-vkcwKXbT.js.map +0 -1
package/dist/functions/index.js
CHANGED
|
@@ -233,31 +233,33 @@ function defineFunction(definition) {
|
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region src/auth/admin-roles.ts
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* a
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* neither of them owns it.
|
|
247
|
-
*
|
|
248
|
-
* `schema-admin` is here deliberately: it can reach the schema editor and the
|
|
249
|
-
* SQL surfaces, which is administrative by any definition that matters. If a
|
|
250
|
-
* genuinely lesser role is added later, it does not belong in this list — it
|
|
251
|
-
* belongs in a capability check of its own.
|
|
236
|
+
* The admin role and scope matching, for code that may not import
|
|
237
|
+
* `@rebasepro/types`.
|
|
238
|
+
*
|
|
239
|
+
* The custom-functions surface (`@rebasepro/server/functions`) must bundle for
|
|
240
|
+
* a runtime with no Node built-ins and imports nothing but `hono`, so its
|
|
241
|
+
* guards cannot reach the canonical definitions in `@rebasepro/types`
|
|
242
|
+
* (`ADMIN_ROLE`, `hasAdminRole`, `scopeGrants`). These are the same rules,
|
|
243
|
+
* restated, and `test/admin-roles.test.ts` holds them equal.
|
|
244
|
+
*
|
|
245
|
+
* Everything else imports the `@rebasepro/types` versions.
|
|
252
246
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
247
|
+
/** The one built-in role. It holds every scope. */
|
|
248
|
+
var ADMIN_ROLE_NAME = "admin";
|
|
249
|
+
/** Does this list of roles include the admin role? */
|
|
250
|
+
function holdsAdminRole(roles) {
|
|
251
|
+
return !!roles?.includes(ADMIN_ROLE_NAME);
|
|
257
252
|
}
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Does a set of held scopes grant `scope`, optionally on one `target`? The
|
|
255
|
+
* unqualified grant covers every target; `scope:target` covers its own.
|
|
256
|
+
*/
|
|
257
|
+
function heldScopesGrant(held, scope, target) {
|
|
258
|
+
for (const entry of held) {
|
|
259
|
+
if (entry === scope) return true;
|
|
260
|
+
if (target !== void 0 && entry === `${scope}:${target}`) return true;
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
261
263
|
}
|
|
262
264
|
//#endregion
|
|
263
265
|
//#region src/functions/context.ts
|
|
@@ -310,16 +312,31 @@ function hasRole(c, ...roles) {
|
|
|
310
312
|
const held = new Set(getRoles(c));
|
|
311
313
|
return roles.some((role) => held.has(role));
|
|
312
314
|
}
|
|
315
|
+
/** Whether the caller holds the `admin` role, which holds every scope. */
|
|
316
|
+
function isAdmin(c) {
|
|
317
|
+
return holdsAdminRole(getRoles(c));
|
|
318
|
+
}
|
|
313
319
|
/**
|
|
314
|
-
*
|
|
320
|
+
* Everything the caller may do, as `resource:action[:target]` scope strings —
|
|
321
|
+
* the data plane, the app's own `auth.scopes`, and whatever their roles (or
|
|
322
|
+
* their API key) hold. Empty for an anonymous request.
|
|
315
323
|
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* Those two lists disagreed once, and the gap made every public registrant an
|
|
319
|
-
* administrator; see that file.
|
|
324
|
+
* Resolved by the framework before the handler runs; `undefined` only when no
|
|
325
|
+
* Rebase auth middleware ran (see {@link identityResolved}).
|
|
320
326
|
*/
|
|
321
|
-
function
|
|
322
|
-
return
|
|
327
|
+
function getScopes(c) {
|
|
328
|
+
return read(c, "scopes");
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Whether the caller holds `scope`, on `target` when one is given.
|
|
332
|
+
*
|
|
333
|
+
* For an app scope declared under `auth.scopes` — `project:deploy` — a
|
|
334
|
+
* signed-in person always holds it, so this narrows only API keys and tokens.
|
|
335
|
+
* Whether the *person* may deploy *this* project is still the handler's to
|
|
336
|
+
* decide.
|
|
337
|
+
*/
|
|
338
|
+
function hasScope(c, scope, target) {
|
|
339
|
+
return heldScopesGrant(getScopes(c) ?? [], scope, target);
|
|
323
340
|
}
|
|
324
341
|
/** Whether the request carries an identity at all. */
|
|
325
342
|
function isAuthenticated(c) {
|
|
@@ -428,15 +445,14 @@ var requireAuth = async (c, next) => {
|
|
|
428
445
|
} }, 401);
|
|
429
446
|
};
|
|
430
447
|
/**
|
|
431
|
-
* Reject callers without
|
|
448
|
+
* Reject callers without the `admin` role with 403.
|
|
432
449
|
*
|
|
433
450
|
* Must come **after** {@link requireAuth}: on its own it answers 401 for an
|
|
434
451
|
* anonymous caller, which is right, but pairing them keeps the two failures
|
|
435
452
|
* distinguishable — 401 "who are you", 403 "not you".
|
|
436
453
|
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* divergence that list exists to prevent.
|
|
454
|
+
* Prefer {@link requireScope} for anything an app declares a scope for: a
|
|
455
|
+
* scope can be granted to a narrower role and to a key, and `admin` cannot.
|
|
440
456
|
*/
|
|
441
457
|
var requireAdmin = async (c, next) => {
|
|
442
458
|
if (!getUser(c)) {
|
|
@@ -483,6 +499,44 @@ function requireRole(...roles) {
|
|
|
483
499
|
return next();
|
|
484
500
|
};
|
|
485
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Reject callers who do not hold `scope` with 403.
|
|
504
|
+
*
|
|
505
|
+
* `scope` is a built-in scope or one the app declares under `auth.scopes` on
|
|
506
|
+
* the users collection. `target` narrows it to one resource — a key holding
|
|
507
|
+
* `project:deploy:p1` passes `requireScope("project:deploy", c => c.req.param("project"))`
|
|
508
|
+
* for `p1` only — and may be read from the request.
|
|
509
|
+
*
|
|
510
|
+
* A signed-in person holds every app scope, so for a person this is no
|
|
511
|
+
* authorization at all: it narrows API keys and tokens. Decide whether the
|
|
512
|
+
* person may act in the handler, as you would without it.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```ts
|
|
516
|
+
* app.post("/deploy/:project", requireAuth, requireScope("project:deploy", c => c.req.param("project")), handler);
|
|
517
|
+
* ```
|
|
518
|
+
*/
|
|
519
|
+
function requireScope(scope, target) {
|
|
520
|
+
return async (c, next) => {
|
|
521
|
+
if (!getUser(c)) {
|
|
522
|
+
if (!identityResolved(c)) return c.json(unresolvedIdentity(), 500);
|
|
523
|
+
return c.json({ error: {
|
|
524
|
+
message: "Authentication required",
|
|
525
|
+
code: "UNAUTHORIZED"
|
|
526
|
+
} }, 401);
|
|
527
|
+
}
|
|
528
|
+
const resolvedTarget = typeof target === "function" ? target(c) : target;
|
|
529
|
+
if (!hasScope(c, scope, resolvedTarget)) {
|
|
530
|
+
const wanted = resolvedTarget !== void 0 ? `${scope}:${resolvedTarget}` : scope;
|
|
531
|
+
return c.json({ error: {
|
|
532
|
+
message: `This credential does not hold the "${wanted}" scope.`,
|
|
533
|
+
code: "SCOPE_MISSING",
|
|
534
|
+
details: { requiredScope: wanted }
|
|
535
|
+
} }, 403);
|
|
536
|
+
}
|
|
537
|
+
return next();
|
|
538
|
+
};
|
|
539
|
+
}
|
|
486
540
|
//#endregion
|
|
487
541
|
//#region src/functions/runtime-env.ts
|
|
488
542
|
/**
|
|
@@ -634,7 +688,7 @@ function isProduction() {
|
|
|
634
688
|
var configuredLevel;
|
|
635
689
|
function getMinLevel() {
|
|
636
690
|
if (configuredLevel) return configuredLevel;
|
|
637
|
-
const env = (hostEnv().LOG_LEVEL || "info").toLowerCase();
|
|
691
|
+
const env = (hostEnv().LOG_LEVEL || "info").trim().toLowerCase();
|
|
638
692
|
if (env in LOG_PRIORITY) return env;
|
|
639
693
|
return "info";
|
|
640
694
|
}
|
|
@@ -1024,6 +1078,6 @@ var ApiError = class ApiError extends Error {
|
|
|
1024
1078
|
}
|
|
1025
1079
|
};
|
|
1026
1080
|
//#endregion
|
|
1027
|
-
export { ApiError, defineFunction, env, getApiKey, getDriver, getEnv, getRequestId, getRoles, getUser, getUserId, hasRole, identityResolved, isAdmin, isAuthenticated, isNodeRuntime, lazyResource, rebase, requireAdmin, requireAuth, requireDriver, requireEnv, requireRole, runtimeKey, waitUntil };
|
|
1081
|
+
export { ApiError, defineFunction, env, getApiKey, getDriver, getEnv, getRequestId, getRoles, getScopes, getUser, getUserId, hasRole, hasScope, identityResolved, isAdmin, isAuthenticated, isNodeRuntime, lazyResource, rebase, requireAdmin, requireAuth, requireDriver, requireEnv, requireRole, requireScope, runtimeKey, waitUntil };
|
|
1028
1082
|
|
|
1029
1083
|
//# sourceMappingURL=index.js.map
|