@tinycloud/sdk-services 3.2.6-beta.4 → 3.3.0-beta.7

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 (45) hide show
  1. package/dist/{BaseService-1Ug6y7DC.d.cts → BaseService-Cc6Ueicm.d.cts} +1 -1
  2. package/dist/{BaseService-Bn07Vudy.d.ts → BaseService-DOdXd7sr.d.ts} +1 -1
  3. package/dist/encryption/index.cjs +8 -0
  4. package/dist/encryption/index.cjs.map +1 -1
  5. package/dist/encryption/index.d.cts +2 -2
  6. package/dist/encryption/index.d.ts +2 -2
  7. package/dist/encryption/index.js +8 -0
  8. package/dist/encryption/index.js.map +1 -1
  9. package/dist/index.cjs +94 -57
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +29 -6
  12. package/dist/index.d.ts +29 -6
  13. package/dist/index.js +93 -57
  14. package/dist/index.js.map +1 -1
  15. package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
  16. package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
  17. package/dist/kv/index.cjs +66 -21
  18. package/dist/kv/index.cjs.map +1 -1
  19. package/dist/kv/index.d.cts +4 -4
  20. package/dist/kv/index.d.ts +4 -4
  21. package/dist/kv/index.js +66 -21
  22. package/dist/kv/index.js.map +1 -1
  23. package/dist/kv/replication/grantPolicy.cjs +82 -0
  24. package/dist/kv/replication/grantPolicy.cjs.map +1 -0
  25. package/dist/kv/replication/grantPolicy.d.cts +19 -0
  26. package/dist/kv/replication/grantPolicy.d.ts +19 -0
  27. package/dist/kv/replication/grantPolicy.js +50 -0
  28. package/dist/kv/replication/grantPolicy.js.map +1 -0
  29. package/dist/kv/replication/index.cjs +571 -128
  30. package/dist/kv/replication/index.cjs.map +1 -1
  31. package/dist/kv/replication/index.d.cts +3 -3
  32. package/dist/kv/replication/index.d.ts +3 -3
  33. package/dist/kv/replication/index.js +571 -128
  34. package/dist/kv/replication/index.js.map +1 -1
  35. package/dist/{scope-BnyVPZ5E.d.ts → scope-B-m6cKH-.d.ts} +310 -7
  36. package/dist/{scope-CQ5kmHlt.d.cts → scope-B7oeKdLM.d.cts} +310 -7
  37. package/dist/sql/index.cjs +70 -36
  38. package/dist/sql/index.cjs.map +1 -1
  39. package/dist/sql/index.d.cts +2 -2
  40. package/dist/sql/index.d.ts +2 -2
  41. package/dist/sql/index.js +70 -36
  42. package/dist/sql/index.js.map +1 -1
  43. package/dist/{types-gmdUiorz.d.cts → types-BjH0ZtGy.d.cts} +6 -0
  44. package/dist/{types-gmdUiorz.d.ts → types-BjH0ZtGy.d.ts} +6 -0
  45. package/package.json +16 -2
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/kv/replication/grantPolicy.ts
21
+ var grantPolicy_exports = {};
22
+ __export(grantPolicy_exports, {
23
+ MAX_GRANT_TTL_MS: () => MAX_GRANT_TTL_MS,
24
+ clampConsentAnchor: () => clampConsentAnchor,
25
+ consentDeadlineMs: () => consentDeadlineMs,
26
+ effectiveGrantExpiry: () => effectiveGrantExpiry,
27
+ mintRemainingMs: () => mintRemainingMs,
28
+ needsSilentRenewal: () => needsSilentRenewal
29
+ });
30
+ module.exports = __toCommonJS(grantPolicy_exports);
31
+
32
+ // src/kv/replication/grantPolicyConstants.ts
33
+ var HOUR_MS = 60 * 60 * 1e3;
34
+ var DAY_MS = 24 * HOUR_MS;
35
+ var MAX_GRANT_TTL_MS = 7 * DAY_MS;
36
+ var CONSENT_WINDOW_MS = 7 * DAY_MS;
37
+ var RENEW_BELOW_FRACTION = 0.25;
38
+
39
+ // src/kv/replication/grantPolicy.ts
40
+ var EXPIRED = Number.NEGATIVE_INFINITY;
41
+ var consentDeadlineMs = (anchor) => Number.isFinite(anchor.at) ? anchor.at + CONSENT_WINDOW_MS : EXPIRED;
42
+ var clampConsentAnchor = (anchor, now) => {
43
+ if (anchor === null || !Number.isFinite(anchor.at) || !Number.isFinite(now)) return null;
44
+ return anchor.at > now ? { at: now, source: anchor.source } : anchor;
45
+ };
46
+ var effectiveGrantExpiry = ({
47
+ signedExpiresAt,
48
+ installedAt,
49
+ grantTtlMs,
50
+ consentDeadline
51
+ }) => {
52
+ const signedValid = signedExpiresAt === null || Number.isFinite(signedExpiresAt);
53
+ if (!signedValid || !Number.isFinite(installedAt) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) {
54
+ return EXPIRED;
55
+ }
56
+ const ttl = Math.min(grantTtlMs, MAX_GRANT_TTL_MS);
57
+ const localBound = Math.min(installedAt + ttl, consentDeadline);
58
+ return signedExpiresAt === null ? localBound : Math.min(signedExpiresAt, localBound);
59
+ };
60
+ var mintRemainingMs = ({ now, grantTtlMs, consentDeadline }) => {
61
+ if (!Number.isFinite(now) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) return 0;
62
+ return Math.min(Math.min(grantTtlMs, MAX_GRANT_TTL_MS), consentDeadline - now);
63
+ };
64
+ var needsSilentRenewal = ({ now, installedAt, effectiveExpiresAt, consentDeadline }) => {
65
+ if (!Number.isFinite(now) || !Number.isFinite(installedAt) || !Number.isFinite(effectiveExpiresAt) || !Number.isFinite(consentDeadline)) {
66
+ return false;
67
+ }
68
+ if (!(now < consentDeadline)) return false;
69
+ const remaining = effectiveExpiresAt - now;
70
+ const lifetime = effectiveExpiresAt - installedAt;
71
+ return remaining < lifetime * RENEW_BELOW_FRACTION;
72
+ };
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ MAX_GRANT_TTL_MS,
76
+ clampConsentAnchor,
77
+ consentDeadlineMs,
78
+ effectiveGrantExpiry,
79
+ mintRemainingMs,
80
+ needsSilentRenewal
81
+ });
82
+ //# sourceMappingURL=grantPolicy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/kv/replication/grantPolicy.ts","../../../src/kv/replication/grantPolicyConstants.ts"],"sourcesContent":["/**\n * Grant lifetime policy (TC-858 plan §6, CONTRACT.md §3). Pure functions over epoch\n * milliseconds. Types and constants come from the shared contract; this file only implements them.\n *\n * Every function fails closed: a non-finite input yields a value that refuses the mint, renewal or\n * read, never a permissive one.\n */\nimport { CONSENT_WINDOW_MS, MAX_GRANT_TTL_MS, RENEW_BELOW_FRACTION } from \"./grantPolicyConstants\";\nexport { MAX_GRANT_TTL_MS } from \"./grantPolicyConstants\";\nimport type {\n ConsentDeadlineMs,\n EffectiveGrantExpiry,\n MintRemainingMs,\n NeedsSilentRenewal,\n ReplicaConsentAnchor,\n} from \"./grantPolicyTypes\";\n\n/** An instant that has already passed: nothing is minted, renewed or served against it. */\nconst EXPIRED = Number.NEGATIVE_INFINITY;\n\n/**\n * Caller contract: clamp the anchor with {@link clampConsentAnchor} first. A non-finite anchor\n * yields an already-passed deadline.\n */\nexport const consentDeadlineMs: ConsentDeadlineMs = (anchor) =>\n Number.isFinite(anchor.at) ? anchor.at + CONSENT_WINDOW_MS : EXPIRED;\n\n/**\n * Returns the anchor the deadline may be computed from. A non-finite anchor or clock yields\n * `null` (no anchor, so no mint). An anchor dated after `now` is pulled back to `now`, so a\n * future-dated anchor cannot extend the 7 d window.\n */\nexport const clampConsentAnchor = (\n anchor: ReplicaConsentAnchor | null,\n now: number,\n): ReplicaConsentAnchor | null => {\n if (anchor === null || !Number.isFinite(anchor.at) || !Number.isFinite(now)) return null;\n return anchor.at > now ? { at: now, source: anchor.source } : anchor;\n};\n\nexport const effectiveGrantExpiry: EffectiveGrantExpiry = ({\n signedExpiresAt,\n installedAt,\n grantTtlMs,\n consentDeadline,\n}) => {\n const signedValid = signedExpiresAt === null || Number.isFinite(signedExpiresAt);\n if (!signedValid || !Number.isFinite(installedAt) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) {\n return EXPIRED;\n }\n const ttl = Math.min(grantTtlMs, MAX_GRANT_TTL_MS);\n const localBound = Math.min(installedAt + ttl, consentDeadline);\n return signedExpiresAt === null ? localBound : Math.min(signedExpiresAt, localBound);\n};\n\nexport const mintRemainingMs: MintRemainingMs = ({ now, grantTtlMs, consentDeadline }) => {\n if (!Number.isFinite(now) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) return 0;\n return Math.min(Math.min(grantTtlMs, MAX_GRANT_TTL_MS), consentDeadline - now);\n};\n\nexport const needsSilentRenewal: NeedsSilentRenewal = ({ now, installedAt, effectiveExpiresAt, consentDeadline }) => {\n if (\n !Number.isFinite(now) ||\n !Number.isFinite(installedAt) ||\n !Number.isFinite(effectiveExpiresAt) ||\n !Number.isFinite(consentDeadline)\n ) {\n return false;\n }\n if (!(now < consentDeadline)) return false;\n const remaining = effectiveExpiresAt - now;\n const lifetime = effectiveExpiresAt - installedAt;\n return remaining < lifetime * RENEW_BELOW_FRACTION;\n};\n","/** Grant lifetime constants without browser storage identifiers. */\nconst HOUR_MS = 60 * 60 * 1000;\nconst DAY_MS = 24 * HOUR_MS;\n\n/** Default device-grant lifetime from install (24 h). All durations are milliseconds. */\nexport const DEFAULT_GRANT_TTL_MS = DAY_MS;\n/** `grantTtlMs` above this (7 d) is a config error: TypeError at construction. */\nexport const MAX_GRANT_TTL_MS = 7 * DAY_MS;\n/** Consent deadline = consent anchor + this window (7 d). */\nexport const CONSENT_WINDOW_MS = 7 * DAY_MS;\n/** Silent renewal starts when remaining effective lifetime < this fraction of the effective lifetime. */\nexport const RENEW_BELOW_FRACTION = 0.25;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAM,UAAU,KAAK,KAAK;AAC1B,IAAM,SAAS,KAAK;AAKb,IAAM,mBAAmB,IAAI;AAE7B,IAAM,oBAAoB,IAAI;AAE9B,IAAM,uBAAuB;;;ADOpC,IAAM,UAAU,OAAO;AAMhB,IAAM,oBAAuC,CAAC,WACnD,OAAO,SAAS,OAAO,EAAE,IAAI,OAAO,KAAK,oBAAoB;AAOxD,IAAM,qBAAqB,CAChC,QACA,QACgC;AAChC,MAAI,WAAW,QAAQ,CAAC,OAAO,SAAS,OAAO,EAAE,KAAK,CAAC,OAAO,SAAS,GAAG,EAAG,QAAO;AACpF,SAAO,OAAO,KAAK,MAAM,EAAE,IAAI,KAAK,QAAQ,OAAO,OAAO,IAAI;AAChE;AAEO,IAAM,uBAA6C,CAAC;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,cAAc,oBAAoB,QAAQ,OAAO,SAAS,eAAe;AAC/E,MAAI,CAAC,eAAe,CAAC,OAAO,SAAS,WAAW,KAAK,CAAC,OAAO,SAAS,UAAU,KAAK,CAAC,OAAO,SAAS,eAAe,GAAG;AACtH,WAAO;AAAA,EACT;AACA,QAAM,MAAM,KAAK,IAAI,YAAY,gBAAgB;AACjD,QAAM,aAAa,KAAK,IAAI,cAAc,KAAK,eAAe;AAC9D,SAAO,oBAAoB,OAAO,aAAa,KAAK,IAAI,iBAAiB,UAAU;AACrF;AAEO,IAAM,kBAAmC,CAAC,EAAE,KAAK,YAAY,gBAAgB,MAAM;AACxF,MAAI,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,UAAU,KAAK,CAAC,OAAO,SAAS,eAAe,EAAG,QAAO;AACvG,SAAO,KAAK,IAAI,KAAK,IAAI,YAAY,gBAAgB,GAAG,kBAAkB,GAAG;AAC/E;AAEO,IAAM,qBAAyC,CAAC,EAAE,KAAK,aAAa,oBAAoB,gBAAgB,MAAM;AACnH,MACE,CAAC,OAAO,SAAS,GAAG,KACpB,CAAC,OAAO,SAAS,WAAW,KAC5B,CAAC,OAAO,SAAS,kBAAkB,KACnC,CAAC,OAAO,SAAS,eAAe,GAChC;AACA,WAAO;AAAA,EACT;AACA,MAAI,EAAE,MAAM,iBAAkB,QAAO;AACrC,QAAM,YAAY,qBAAqB;AACvC,QAAM,WAAW,qBAAqB;AACtC,SAAO,YAAY,WAAW;AAChC;","names":[]}
@@ -0,0 +1,19 @@
1
+ export { MAX_GRANT_TTL_MS } from './grantPolicyConstants.cjs';
2
+ import { ReplicaConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, MintRemainingMs, NeedsSilentRenewal } from './grantPolicyTypes.cjs';
3
+
4
+ /**
5
+ * Caller contract: clamp the anchor with {@link clampConsentAnchor} first. A non-finite anchor
6
+ * yields an already-passed deadline.
7
+ */
8
+ declare const consentDeadlineMs: ConsentDeadlineMs;
9
+ /**
10
+ * Returns the anchor the deadline may be computed from. A non-finite anchor or clock yields
11
+ * `null` (no anchor, so no mint). An anchor dated after `now` is pulled back to `now`, so a
12
+ * future-dated anchor cannot extend the 7 d window.
13
+ */
14
+ declare const clampConsentAnchor: (anchor: ReplicaConsentAnchor | null, now: number) => ReplicaConsentAnchor | null;
15
+ declare const effectiveGrantExpiry: EffectiveGrantExpiry;
16
+ declare const mintRemainingMs: MintRemainingMs;
17
+ declare const needsSilentRenewal: NeedsSilentRenewal;
18
+
19
+ export { clampConsentAnchor, consentDeadlineMs, effectiveGrantExpiry, mintRemainingMs, needsSilentRenewal };
@@ -0,0 +1,19 @@
1
+ export { MAX_GRANT_TTL_MS } from './grantPolicyConstants.js';
2
+ import { ReplicaConsentAnchor, ConsentDeadlineMs, EffectiveGrantExpiry, MintRemainingMs, NeedsSilentRenewal } from './grantPolicyTypes.js';
3
+
4
+ /**
5
+ * Caller contract: clamp the anchor with {@link clampConsentAnchor} first. A non-finite anchor
6
+ * yields an already-passed deadline.
7
+ */
8
+ declare const consentDeadlineMs: ConsentDeadlineMs;
9
+ /**
10
+ * Returns the anchor the deadline may be computed from. A non-finite anchor or clock yields
11
+ * `null` (no anchor, so no mint). An anchor dated after `now` is pulled back to `now`, so a
12
+ * future-dated anchor cannot extend the 7 d window.
13
+ */
14
+ declare const clampConsentAnchor: (anchor: ReplicaConsentAnchor | null, now: number) => ReplicaConsentAnchor | null;
15
+ declare const effectiveGrantExpiry: EffectiveGrantExpiry;
16
+ declare const mintRemainingMs: MintRemainingMs;
17
+ declare const needsSilentRenewal: NeedsSilentRenewal;
18
+
19
+ export { clampConsentAnchor, consentDeadlineMs, effectiveGrantExpiry, mintRemainingMs, needsSilentRenewal };
@@ -0,0 +1,50 @@
1
+ // src/kv/replication/grantPolicyConstants.ts
2
+ var HOUR_MS = 60 * 60 * 1e3;
3
+ var DAY_MS = 24 * HOUR_MS;
4
+ var MAX_GRANT_TTL_MS = 7 * DAY_MS;
5
+ var CONSENT_WINDOW_MS = 7 * DAY_MS;
6
+ var RENEW_BELOW_FRACTION = 0.25;
7
+
8
+ // src/kv/replication/grantPolicy.ts
9
+ var EXPIRED = Number.NEGATIVE_INFINITY;
10
+ var consentDeadlineMs = (anchor) => Number.isFinite(anchor.at) ? anchor.at + CONSENT_WINDOW_MS : EXPIRED;
11
+ var clampConsentAnchor = (anchor, now) => {
12
+ if (anchor === null || !Number.isFinite(anchor.at) || !Number.isFinite(now)) return null;
13
+ return anchor.at > now ? { at: now, source: anchor.source } : anchor;
14
+ };
15
+ var effectiveGrantExpiry = ({
16
+ signedExpiresAt,
17
+ installedAt,
18
+ grantTtlMs,
19
+ consentDeadline
20
+ }) => {
21
+ const signedValid = signedExpiresAt === null || Number.isFinite(signedExpiresAt);
22
+ if (!signedValid || !Number.isFinite(installedAt) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) {
23
+ return EXPIRED;
24
+ }
25
+ const ttl = Math.min(grantTtlMs, MAX_GRANT_TTL_MS);
26
+ const localBound = Math.min(installedAt + ttl, consentDeadline);
27
+ return signedExpiresAt === null ? localBound : Math.min(signedExpiresAt, localBound);
28
+ };
29
+ var mintRemainingMs = ({ now, grantTtlMs, consentDeadline }) => {
30
+ if (!Number.isFinite(now) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) return 0;
31
+ return Math.min(Math.min(grantTtlMs, MAX_GRANT_TTL_MS), consentDeadline - now);
32
+ };
33
+ var needsSilentRenewal = ({ now, installedAt, effectiveExpiresAt, consentDeadline }) => {
34
+ if (!Number.isFinite(now) || !Number.isFinite(installedAt) || !Number.isFinite(effectiveExpiresAt) || !Number.isFinite(consentDeadline)) {
35
+ return false;
36
+ }
37
+ if (!(now < consentDeadline)) return false;
38
+ const remaining = effectiveExpiresAt - now;
39
+ const lifetime = effectiveExpiresAt - installedAt;
40
+ return remaining < lifetime * RENEW_BELOW_FRACTION;
41
+ };
42
+ export {
43
+ MAX_GRANT_TTL_MS,
44
+ clampConsentAnchor,
45
+ consentDeadlineMs,
46
+ effectiveGrantExpiry,
47
+ mintRemainingMs,
48
+ needsSilentRenewal
49
+ };
50
+ //# sourceMappingURL=grantPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/kv/replication/grantPolicyConstants.ts","../../../src/kv/replication/grantPolicy.ts"],"sourcesContent":["/** Grant lifetime constants without browser storage identifiers. */\nconst HOUR_MS = 60 * 60 * 1000;\nconst DAY_MS = 24 * HOUR_MS;\n\n/** Default device-grant lifetime from install (24 h). All durations are milliseconds. */\nexport const DEFAULT_GRANT_TTL_MS = DAY_MS;\n/** `grantTtlMs` above this (7 d) is a config error: TypeError at construction. */\nexport const MAX_GRANT_TTL_MS = 7 * DAY_MS;\n/** Consent deadline = consent anchor + this window (7 d). */\nexport const CONSENT_WINDOW_MS = 7 * DAY_MS;\n/** Silent renewal starts when remaining effective lifetime < this fraction of the effective lifetime. */\nexport const RENEW_BELOW_FRACTION = 0.25;\n","/**\n * Grant lifetime policy (TC-858 plan §6, CONTRACT.md §3). Pure functions over epoch\n * milliseconds. Types and constants come from the shared contract; this file only implements them.\n *\n * Every function fails closed: a non-finite input yields a value that refuses the mint, renewal or\n * read, never a permissive one.\n */\nimport { CONSENT_WINDOW_MS, MAX_GRANT_TTL_MS, RENEW_BELOW_FRACTION } from \"./grantPolicyConstants\";\nexport { MAX_GRANT_TTL_MS } from \"./grantPolicyConstants\";\nimport type {\n ConsentDeadlineMs,\n EffectiveGrantExpiry,\n MintRemainingMs,\n NeedsSilentRenewal,\n ReplicaConsentAnchor,\n} from \"./grantPolicyTypes\";\n\n/** An instant that has already passed: nothing is minted, renewed or served against it. */\nconst EXPIRED = Number.NEGATIVE_INFINITY;\n\n/**\n * Caller contract: clamp the anchor with {@link clampConsentAnchor} first. A non-finite anchor\n * yields an already-passed deadline.\n */\nexport const consentDeadlineMs: ConsentDeadlineMs = (anchor) =>\n Number.isFinite(anchor.at) ? anchor.at + CONSENT_WINDOW_MS : EXPIRED;\n\n/**\n * Returns the anchor the deadline may be computed from. A non-finite anchor or clock yields\n * `null` (no anchor, so no mint). An anchor dated after `now` is pulled back to `now`, so a\n * future-dated anchor cannot extend the 7 d window.\n */\nexport const clampConsentAnchor = (\n anchor: ReplicaConsentAnchor | null,\n now: number,\n): ReplicaConsentAnchor | null => {\n if (anchor === null || !Number.isFinite(anchor.at) || !Number.isFinite(now)) return null;\n return anchor.at > now ? { at: now, source: anchor.source } : anchor;\n};\n\nexport const effectiveGrantExpiry: EffectiveGrantExpiry = ({\n signedExpiresAt,\n installedAt,\n grantTtlMs,\n consentDeadline,\n}) => {\n const signedValid = signedExpiresAt === null || Number.isFinite(signedExpiresAt);\n if (!signedValid || !Number.isFinite(installedAt) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) {\n return EXPIRED;\n }\n const ttl = Math.min(grantTtlMs, MAX_GRANT_TTL_MS);\n const localBound = Math.min(installedAt + ttl, consentDeadline);\n return signedExpiresAt === null ? localBound : Math.min(signedExpiresAt, localBound);\n};\n\nexport const mintRemainingMs: MintRemainingMs = ({ now, grantTtlMs, consentDeadline }) => {\n if (!Number.isFinite(now) || !Number.isFinite(grantTtlMs) || !Number.isFinite(consentDeadline)) return 0;\n return Math.min(Math.min(grantTtlMs, MAX_GRANT_TTL_MS), consentDeadline - now);\n};\n\nexport const needsSilentRenewal: NeedsSilentRenewal = ({ now, installedAt, effectiveExpiresAt, consentDeadline }) => {\n if (\n !Number.isFinite(now) ||\n !Number.isFinite(installedAt) ||\n !Number.isFinite(effectiveExpiresAt) ||\n !Number.isFinite(consentDeadline)\n ) {\n return false;\n }\n if (!(now < consentDeadline)) return false;\n const remaining = effectiveExpiresAt - now;\n const lifetime = effectiveExpiresAt - installedAt;\n return remaining < lifetime * RENEW_BELOW_FRACTION;\n};\n"],"mappings":";AACA,IAAM,UAAU,KAAK,KAAK;AAC1B,IAAM,SAAS,KAAK;AAKb,IAAM,mBAAmB,IAAI;AAE7B,IAAM,oBAAoB,IAAI;AAE9B,IAAM,uBAAuB;;;ACOpC,IAAM,UAAU,OAAO;AAMhB,IAAM,oBAAuC,CAAC,WACnD,OAAO,SAAS,OAAO,EAAE,IAAI,OAAO,KAAK,oBAAoB;AAOxD,IAAM,qBAAqB,CAChC,QACA,QACgC;AAChC,MAAI,WAAW,QAAQ,CAAC,OAAO,SAAS,OAAO,EAAE,KAAK,CAAC,OAAO,SAAS,GAAG,EAAG,QAAO;AACpF,SAAO,OAAO,KAAK,MAAM,EAAE,IAAI,KAAK,QAAQ,OAAO,OAAO,IAAI;AAChE;AAEO,IAAM,uBAA6C,CAAC;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,cAAc,oBAAoB,QAAQ,OAAO,SAAS,eAAe;AAC/E,MAAI,CAAC,eAAe,CAAC,OAAO,SAAS,WAAW,KAAK,CAAC,OAAO,SAAS,UAAU,KAAK,CAAC,OAAO,SAAS,eAAe,GAAG;AACtH,WAAO;AAAA,EACT;AACA,QAAM,MAAM,KAAK,IAAI,YAAY,gBAAgB;AACjD,QAAM,aAAa,KAAK,IAAI,cAAc,KAAK,eAAe;AAC9D,SAAO,oBAAoB,OAAO,aAAa,KAAK,IAAI,iBAAiB,UAAU;AACrF;AAEO,IAAM,kBAAmC,CAAC,EAAE,KAAK,YAAY,gBAAgB,MAAM;AACxF,MAAI,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,UAAU,KAAK,CAAC,OAAO,SAAS,eAAe,EAAG,QAAO;AACvG,SAAO,KAAK,IAAI,KAAK,IAAI,YAAY,gBAAgB,GAAG,kBAAkB,GAAG;AAC/E;AAEO,IAAM,qBAAyC,CAAC,EAAE,KAAK,aAAa,oBAAoB,gBAAgB,MAAM;AACnH,MACE,CAAC,OAAO,SAAS,GAAG,KACpB,CAAC,OAAO,SAAS,WAAW,KAC5B,CAAC,OAAO,SAAS,kBAAkB,KACnC,CAAC,OAAO,SAAS,eAAe,GAChC;AACA,WAAO;AAAA,EACT;AACA,MAAI,EAAE,MAAM,iBAAkB,QAAO;AACrC,QAAM,YAAY,qBAAqB;AACvC,QAAM,WAAW,qBAAqB;AACtC,SAAO,YAAY,WAAW;AAChC;","names":[]}