@rebasepro/server 0.22.0 → 0.23.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.
Files changed (114) hide show
  1. package/dist/{GCSStorageController-CLIJXwGS.js → GCSStorageController-CjrA4PMo.js} +37 -23
  2. package/dist/GCSStorageController-CjrA4PMo.js.map +1 -0
  3. package/dist/{S3StorageController-Dcuf8lMA.js → S3StorageController-B6pKDNVj.js} +2 -2
  4. package/dist/{S3StorageController-Dcuf8lMA.js.map → S3StorageController-B6pKDNVj.js.map} +1 -1
  5. package/dist/api/ast-schema-editor.d.ts +35 -0
  6. package/dist/api/live-schema-routes.d.ts +14 -0
  7. package/dist/api/rest/api-generator.d.ts +117 -35
  8. package/dist/api/rest/auth-collection-writes.d.ts +85 -0
  9. package/dist/api/rest/field-access-query.d.ts +6 -2
  10. package/dist/api/rest/idempotency.d.ts +7 -1
  11. package/dist/api/rest/nested-write-access.d.ts +46 -0
  12. package/dist/api/rest/write-validation.d.ts +32 -0
  13. package/dist/{ast-schema-editor-CslO8Oje.js → ast-schema-editor-Mvr50v_S.js} +104 -4
  14. package/dist/ast-schema-editor-Mvr50v_S.js.map +1 -0
  15. package/dist/auth/address-ownership.d.ts +53 -0
  16. package/dist/auth/admin-user-ops.d.ts +35 -2
  17. package/dist/auth/auth-hooks.d.ts +4 -0
  18. package/dist/auth/captcha.d.ts +5 -0
  19. package/dist/auth/interfaces.d.ts +36 -6
  20. package/dist/auth/jwt.d.ts +17 -0
  21. package/dist/auth/oauth-signin-policy.d.ts +25 -8
  22. package/dist/auth/rate-limiter.d.ts +31 -1
  23. package/dist/auth/session-routes.d.ts +7 -0
  24. package/dist/auth/token-revocation.d.ts +4 -1
  25. package/dist/{auth-CCDpk2rn.js → auth-B-GIMpDG.js} +639 -228
  26. package/dist/auth-B-GIMpDG.js.map +1 -0
  27. package/dist/backend-DTAOsLQc.js +30 -0
  28. package/dist/backend-DTAOsLQc.js.map +1 -0
  29. package/dist/backup/backup-common.d.ts +19 -0
  30. package/dist/{backup-DzI9jLwc.js → backup-D7YR94N3.js} +69 -8
  31. package/dist/backup-D7YR94N3.js.map +1 -0
  32. package/dist/boot/driver.d.ts +10 -0
  33. package/dist/boot/env.d.ts +2 -2
  34. package/dist/boot/fetch-bundle.d.ts +18 -1
  35. package/dist/boot/rls-audit-option.d.ts +26 -0
  36. package/dist/boot/sources.d.ts +1 -0
  37. package/dist/{contract-routes-eLxV0le1.js → contract-routes-CbFjuBwa.js} +2 -2
  38. package/dist/{contract-routes-eLxV0le1.js.map → contract-routes-CbFjuBwa.js.map} +1 -1
  39. package/dist/cron/cron-routes.d.ts +7 -2
  40. package/dist/cron/cron-scheduler.d.ts +128 -8
  41. package/dist/cron/cron-store.d.ts +72 -8
  42. package/dist/cron/index.d.ts +1 -1
  43. package/dist/{cron-loader-CQjvjpEw.js → cron-loader-DfTj2Hbi.js} +2 -2
  44. package/dist/{cron-loader-CQjvjpEw.js.map → cron-loader-DfTj2Hbi.js.map} +1 -1
  45. package/dist/{cron-routes-B7CRGfiq.js → cron-routes-eE8nif_b.js} +33 -12
  46. package/dist/cron-routes-eE8nif_b.js.map +1 -0
  47. package/dist/{cron-scheduler-COPQxlEq.js → cron-scheduler-B0pLfAix.js} +394 -68
  48. package/dist/cron-scheduler-B0pLfAix.js.map +1 -0
  49. package/dist/{cron-store-BYGZFNWk.js → cron-store-TcoGz-xS.js} +133 -12
  50. package/dist/cron-store-TcoGz-xS.js.map +1 -0
  51. package/dist/{ddl-bootstrap-CfNvxMuK.js → ddl-bootstrap-C6mo0Kmz.js} +2 -25
  52. package/dist/ddl-bootstrap-C6mo0Kmz.js.map +1 -0
  53. package/dist/email/link-base.d.ts +5 -4
  54. package/dist/email/smtp-email-service.d.ts +13 -1
  55. package/dist/email/templates.d.ts +9 -0
  56. package/dist/email/types.d.ts +3 -2
  57. package/dist/env.d.ts +24 -5
  58. package/dist/{history-recorder-BQmB0P_j.js → history-recorder-B4MpJfJK.js} +8 -6
  59. package/dist/history-recorder-B4MpJfJK.js.map +1 -0
  60. package/dist/{history-store-CetkrBBD.js → history-store-BhxWOuz9.js} +2 -2
  61. package/dist/{history-store-CetkrBBD.js.map → history-store-BhxWOuz9.js.map} +1 -1
  62. package/dist/index.d.ts +6 -2
  63. package/dist/index.es.js +2717 -866
  64. package/dist/index.es.js.map +1 -1
  65. package/dist/init/docs.d.ts +5 -2
  66. package/dist/init/shutdown.d.ts +8 -3
  67. package/dist/jobs/index.d.ts +2 -2
  68. package/dist/jobs/job-queue.d.ts +23 -2
  69. package/dist/jobs/job-store.d.ts +37 -5
  70. package/dist/jobs/types.d.ts +8 -6
  71. package/dist/{jobs-Bjr8DZAi.js → jobs-CazMYhyy.js} +305 -166
  72. package/dist/jobs-CazMYhyy.js.map +1 -0
  73. package/dist/{jwt-C4OW-DNq.js → jwt-DnQHNFCl.js} +77 -25
  74. package/dist/{jwt-C4OW-DNq.js.map → jwt-DnQHNFCl.js.map} +1 -1
  75. package/dist/{keys-Qfc4XieN.js → keys-CogCQpxG.js} +18 -3
  76. package/dist/{keys-Qfc4XieN.js.map → keys-CogCQpxG.js.map} +1 -1
  77. package/dist/{logs-routes-3EEzPjhl.js → logs-routes-Bj4TYYUl.js} +7 -4
  78. package/dist/{logs-routes-3EEzPjhl.js.map → logs-routes-Bj4TYYUl.js.map} +1 -1
  79. package/dist/mcp/mcp-routes.d.ts +38 -2
  80. package/dist/mcp/mcp-tools.d.ts +7 -1
  81. package/dist/mcp/oauth-routes.d.ts +27 -0
  82. package/dist/mcp/oauth-store.d.ts +29 -13
  83. package/dist/metrics/history-recorder.d.ts +1 -1
  84. package/dist/{openapi-generator-D8uFz-LW.js → openapi-generator-O_O24MAT.js} +34 -12
  85. package/dist/openapi-generator-O_O24MAT.js.map +1 -0
  86. package/dist/{query-parser-BleZmY18.js → query-parser-DGRVFNM3.js} +39 -30
  87. package/dist/query-parser-DGRVFNM3.js.map +1 -0
  88. package/dist/rls-audit/index.d.ts +4 -0
  89. package/dist/{schema-editor-routes-DdLihzp0.js → schema-editor-routes-C5-lh_jO.js} +2 -2
  90. package/dist/{schema-editor-routes-DdLihzp0.js.map → schema-editor-routes-C5-lh_jO.js.map} +1 -1
  91. package/dist/{src-1vL-I1Po.js → src-pmvW7BFx.js} +122 -14
  92. package/dist/src-pmvW7BFx.js.map +1 -0
  93. package/dist/{src-Br6ARbs6.js → src-vkcwKXbT.js} +2 -27
  94. package/dist/{src-Br6ARbs6.js.map → src-vkcwKXbT.js.map} +1 -1
  95. package/dist/storage/GCSStorageController.d.ts +11 -1
  96. package/dist/storage/keys.d.ts +12 -0
  97. package/dist/storage/rendition-cache.d.ts +11 -1
  98. package/dist/storage/request-keys.d.ts +67 -0
  99. package/dist/storage/types.d.ts +17 -1
  100. package/dist/types-BfKcm9do.js.map +1 -1
  101. package/package.json +9 -9
  102. package/dist/GCSStorageController-CLIJXwGS.js.map +0 -1
  103. package/dist/ast-schema-editor-CslO8Oje.js.map +0 -1
  104. package/dist/auth-CCDpk2rn.js.map +0 -1
  105. package/dist/backup-DzI9jLwc.js.map +0 -1
  106. package/dist/cron-routes-B7CRGfiq.js.map +0 -1
  107. package/dist/cron-scheduler-COPQxlEq.js.map +0 -1
  108. package/dist/cron-store-BYGZFNWk.js.map +0 -1
  109. package/dist/ddl-bootstrap-CfNvxMuK.js.map +0 -1
  110. package/dist/history-recorder-BQmB0P_j.js.map +0 -1
  111. package/dist/jobs-Bjr8DZAi.js.map +0 -1
  112. package/dist/openapi-generator-D8uFz-LW.js.map +0 -1
  113. package/dist/query-parser-BleZmY18.js.map +0 -1
  114. package/dist/src-1vL-I1Po.js.map +0 -1
@@ -4,7 +4,7 @@ globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
5
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./rolldown-runtime-dW7B1o5h.js";
6
6
  import { r as logger } from "./logger-DO2PZc4i.js";
7
- import { i as canonicalStorageId } from "./keys-Qfc4XieN.js";
7
+ import { a as canonicalStorageId } from "./keys-CogCQpxG.js";
8
8
  import { createPrivateKey, createPublicKey } from "crypto";
9
9
  //#region src/utils/portable-crypto.ts
10
10
  /**
@@ -4436,6 +4436,7 @@ var jwt_exports = /* @__PURE__ */ __exportAll({
4436
4436
  hasAsymmetricSigningKey: () => hasAsymmetricSigningKey,
4437
4437
  hashRefreshToken: () => hashRefreshToken,
4438
4438
  isJwtConfigured: () => isJwtConfigured,
4439
+ parseDurationMs: () => parseDurationMs,
4439
4440
  signPurposeToken: () => signPurposeToken,
4440
4441
  verifyAccessToken: () => verifyAccessToken,
4441
4442
  verifyDownloadToken: () => verifyDownloadToken,
@@ -4523,9 +4524,18 @@ function configureJwt(config) {
4523
4524
  active = resolved.find((key) => key.kid === config.activeKid) ?? null;
4524
4525
  if (!active) throw new Error(`auth.activeKid is "${config.activeKid}", which is not among the configured signing keys (${resolved.map((k) => `"${k.kid}"`).join(", ")}). Signing with a key nobody published produces tokens no verifier can check.`);
4525
4526
  } else active = resolved[0];
4527
+ const lifetimes = {};
4528
+ for (const key of ["accessExpiresIn", "refreshExpiresIn"]) {
4529
+ const value = config[key];
4530
+ if (value === void 0) continue;
4531
+ if (parseDurationMs(value) === null) throw new Error(`auth.${key} is "${value}", which is not a lifetime. Give a positive number and a unit — "15m", "1h", "30d", "1w", "2 weeks" — in the grammar the token signer reads (vercel/ms). A bare number is refused: the signer reads it as milliseconds.`);
4532
+ lifetimes[key] = value;
4533
+ }
4526
4534
  jwtConfig = {
4527
4535
  ...jwtConfig,
4528
- ...config
4536
+ ...config,
4537
+ accessExpiresIn: lifetimes.accessExpiresIn ?? jwtConfig.accessExpiresIn,
4538
+ refreshExpiresIn: lifetimes.refreshExpiresIn ?? jwtConfig.refreshExpiresIn
4529
4539
  };
4530
4540
  signingKeys = resolved;
4531
4541
  activeSigningKey = active;
@@ -4585,16 +4595,59 @@ async function generateAccessToken(uid, roles, aal = "aal1", customClaims, isAno
4585
4595
  * Get the expiration time of an access token in milliseconds from now
4586
4596
  */
4587
4597
  function getAccessTokenExpiryMs() {
4588
- const match = (jwtConfig.accessExpiresIn || "1h").match(/^(\d+)([dhms])$/);
4589
- if (!match) return 3600 * 1e3;
4590
- const value = parseInt(match[1], 10);
4591
- switch (match[2]) {
4592
- case "d": return value * 24 * 60 * 60 * 1e3;
4593
- case "h": return value * 60 * 60 * 1e3;
4594
- case "m": return value * 60 * 1e3;
4595
- case "s": return value * 1e3;
4596
- default: return 3600 * 1e3;
4597
- }
4598
+ return parseDurationMs(jwtConfig.accessExpiresIn || "1h") ?? 3600 * 1e3;
4599
+ }
4600
+ var DURATION_UNIT_MS = {
4601
+ ms: 1,
4602
+ msec: 1,
4603
+ msecs: 1,
4604
+ millisecond: 1,
4605
+ milliseconds: 1,
4606
+ s: 1e3,
4607
+ sec: 1e3,
4608
+ secs: 1e3,
4609
+ second: 1e3,
4610
+ seconds: 1e3,
4611
+ m: 6e4,
4612
+ min: 6e4,
4613
+ mins: 6e4,
4614
+ minute: 6e4,
4615
+ minutes: 6e4,
4616
+ h: 36e5,
4617
+ hr: 36e5,
4618
+ hrs: 36e5,
4619
+ hour: 36e5,
4620
+ hours: 36e5,
4621
+ d: 864e5,
4622
+ day: 864e5,
4623
+ days: 864e5,
4624
+ w: 6048e5,
4625
+ week: 6048e5,
4626
+ weeks: 6048e5,
4627
+ y: 315576e5,
4628
+ yr: 315576e5,
4629
+ yrs: 315576e5,
4630
+ year: 315576e5,
4631
+ years: 315576e5
4632
+ };
4633
+ /**
4634
+ * A lifetime setting in milliseconds, or null when it is not one.
4635
+ *
4636
+ * The grammar is vercel/ms, because that is what `jsonwebtoken` reads
4637
+ * `expiresIn` with: the token's `exp` and the expiry this module reports
4638
+ * have to come from one reading of the same string, and they used to come
4639
+ * from two — ours understood `<integer><d|h|m|s>` and nothing else.
4640
+ *
4641
+ * Stricter than ms in two ways, both about values nobody means: a bare number
4642
+ * (ms reads "3600" as 3.6 seconds) and a lifetime of zero or less.
4643
+ */
4644
+ function parseDurationMs(value) {
4645
+ const match = /^(\d+(?:\.\d+)?|\.\d+) *([a-z]+)$/i.exec(value);
4646
+ if (!match) return null;
4647
+ const unit = DURATION_UNIT_MS[match[2].toLowerCase()];
4648
+ if (unit === void 0) return null;
4649
+ const ms = parseFloat(match[1]) * unit;
4650
+ return ms > 0 && Number.isFinite(ms) ? ms : null;
4598
4651
  }
4599
4652
  /**
4600
4653
  * Get the expiration timestamp for an access token
@@ -4670,7 +4723,7 @@ function hashRefreshToken(token) {
4670
4723
  * what is actually enforced, which is worse than knowing the ceiling.
4671
4724
  */
4672
4725
  var MAX_COOKIE_AGE_MS = 400 * 24 * 60 * 60 * 1e3;
4673
- /** Fallback when `refreshExpiresIn` is unset or unparseable. */
4726
+ /** Fallback when `refreshExpiresIn` is unset. {@link configureJwt} refuses an unparseable one. */
4674
4727
  var DEFAULT_REFRESH_TTL_MS = MAX_COOKIE_AGE_MS;
4675
4728
  /**
4676
4729
  * How long a refresh token is valid for, in milliseconds.
@@ -4682,16 +4735,8 @@ var DEFAULT_REFRESH_TTL_MS = MAX_COOKIE_AGE_MS;
4682
4735
  * when they say they expect to still be signed in.
4683
4736
  */
4684
4737
  function getRefreshTokenTtlMs() {
4685
- const match = jwtConfig.refreshExpiresIn?.match(/^(\d+)([dhms])$/);
4686
- if (!match) return DEFAULT_REFRESH_TTL_MS;
4687
- const value = parseInt(match[1], 10);
4688
- switch (match[2]) {
4689
- case "d": return value * 24 * 60 * 60 * 1e3;
4690
- case "h": return value * 60 * 60 * 1e3;
4691
- case "m": return value * 60 * 1e3;
4692
- case "s": return value * 1e3;
4693
- default: return DEFAULT_REFRESH_TTL_MS;
4694
- }
4738
+ const duration = jwtConfig.refreshExpiresIn;
4739
+ return (duration ? parseDurationMs(duration) : null) ?? DEFAULT_REFRESH_TTL_MS;
4695
4740
  }
4696
4741
  /**
4697
4742
  * Calculate refresh token expiration date
@@ -4732,13 +4777,20 @@ async function generateMfaPendingToken(uid, expiresInSeconds = 300) {
4732
4777
  *
4733
4778
  * Returns `null` for anything else — including a perfectly valid *access*
4734
4779
  * token, which must not be interchangeable with this one in either direction.
4780
+ *
4781
+ * `iat` comes back with the uid because this token is a first factor that was
4782
+ * accepted at that instant, and a sign-out everywhere after it has to void it
4783
+ * the way it voids an access token — see `isAccessTokenRevoked`.
4735
4784
  */
4736
4785
  async function verifyMfaPendingToken(token) {
4737
4786
  if (!jwtConfig.secret) throw new Error("JWT secret not configured. Call configureJwt() first.");
4738
4787
  try {
4739
4788
  const decoded = await verifyJwt(token, jwtConfig.secret, { algorithms: ["HS256"] });
4740
4789
  if (decoded.purpose !== "mfa-pending" || !decoded.uid) return null;
4741
- return { uid: decoded.uid };
4790
+ return {
4791
+ uid: decoded.uid,
4792
+ iat: typeof decoded.iat === "number" ? decoded.iat : void 0
4793
+ };
4742
4794
  } catch {
4743
4795
  return null;
4744
4796
  }
@@ -4916,4 +4968,4 @@ async function verifyMcpAccessToken(token, expectedAudience) {
4916
4968
  //#endregion
4917
4969
  export { require_jsonwebtoken as C, sha256Bytes as D, randomInt as E, sha256Hex as O, normalizePemFromEnv as S, randomHex as T, verifyAccessToken as _, generateMcpAccessToken as a, verifyMfaPendingToken as b, getAccessTokenExpiry as c, getRefreshTokenTtlMs as d, hasAsymmetricSigningKey as f, signPurposeToken as g, jwt_exports as h, generateDownloadToken as i, getJwks as l, isJwtConfigured as m, configureJwt as n, generateMfaPendingToken as o, hashRefreshToken as p, generateAccessToken as r, generateRefreshToken as s, MAX_COOKIE_AGE_MS as t, getRefreshTokenExpiry as u, verifyDownloadToken as v, constantTimeEqual as w, verifyPurposeToken as x, verifyMcpAccessToken as y };
4918
4970
 
4919
- //# sourceMappingURL=jwt-C4OW-DNq.js.map
4971
+ //# sourceMappingURL=jwt-DnQHNFCl.js.map