@tinycloud/cli 1.3.0-beta.26 → 1.3.0-beta.27

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.
@@ -7657,12 +7657,15 @@ CREATE TABLE IF NOT EXISTS grant_install (
7657
7657
  }
7658
7658
  #storeGrantPolicy(g, policy, existing) {
7659
7659
  const installedAt = existing?.installedAt ?? policy.at;
7660
+ const keepExisting = existing !== null && existing.consentDeadline < policy.consentDeadline;
7661
+ const consentDeadline = keepExisting ? existing.consentDeadline : policy.consentDeadline;
7662
+ const consentAnchor = keepExisting ? existing.consentAnchor : policy.consentAnchor;
7660
7663
  const effectiveExpiresAt = Math.min(
7661
7664
  g.expiresAt === null ? Infinity : g.expiresAt * 1e3,
7662
7665
  installedAt + policy.ttlMs,
7663
- policy.consentDeadline
7666
+ consentDeadline
7664
7667
  );
7665
- if (!Number.isSafeInteger(installedAt) || installedAt < 0 || !Number.isSafeInteger(effectiveExpiresAt) || effectiveExpiresAt < 0 || !Number.isSafeInteger(policy.consentDeadline) || policy.consentDeadline < 0 || !Number.isSafeInteger(policy.consentAnchor.at) || policy.consentAnchor.at < 0 || !Number.isSafeInteger(policy.ttlMs) || policy.ttlMs <= 0) {
7668
+ if (!Number.isSafeInteger(installedAt) || installedAt < 0 || !Number.isSafeInteger(effectiveExpiresAt) || effectiveExpiresAt < 0 || !Number.isSafeInteger(consentDeadline) || consentDeadline < 0 || !Number.isSafeInteger(consentAnchor.at) || consentAnchor.at < 0 || !Number.isSafeInteger(policy.ttlMs) || policy.ttlMs <= 0) {
7666
7669
  throw new ReplicaError3(ReplicaErrorCode3.GRANT_EXPIRED, "The replica grant has no finite effective expiry.");
7667
7670
  }
7668
7671
  this.#db.run(
@@ -7674,11 +7677,11 @@ CREATE TABLE IF NOT EXISTS grant_install (
7674
7677
  g.cid,
7675
7678
  installedAt,
7676
7679
  effectiveExpiresAt,
7677
- policy.consentDeadline,
7678
- policy.consentAnchor.at,
7679
- policy.consentAnchor.source
7680
+ consentDeadline,
7681
+ consentAnchor.at,
7682
+ consentAnchor.source
7680
7683
  );
7681
- return { installedAt, effectiveExpiresAt, consentDeadline: policy.consentDeadline, consentAnchor: policy.consentAnchor };
7684
+ return { installedAt, effectiveExpiresAt, consentDeadline, consentAnchor };
7682
7685
  }
7683
7686
  async installGatedGrant(g, policy) {
7684
7687
  return this.#guardedWrite("Installing the gated grant", () => {