@tinycloud/replica 0.3.0-beta.5 → 0.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.
- package/dist/kv-storage-testing.js.map +1 -1
- package/dist/kv-storage.js +7 -6
- package/dist/kv-storage.js.map +1 -1
- package/dist/{kv-storage.worker.67e46cebbda277040312a770449123633491901d6cceacea95754a843e01e9c9.js → kv-storage.worker.850a5e19b486939f03586f7d1294934f54f44cca0224450b1ba94dfb07912a75.js} +568 -560
- package/dist/kv-storage.worker.js +568 -560
- package/dist/kv-storage.worker.js.map +1 -1
- package/dist/replica.worker.js +562 -555
- package/dist/replica.worker.js.map +1 -1
- package/dist/sqlite.cjs +9 -6
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.js +9 -6
- package/dist/sqlite.js.map +1 -1
- package/package.json +2 -2
package/dist/sqlite.cjs
CHANGED
|
@@ -1366,12 +1366,15 @@ var SqliteReplicaStore = class _SqliteReplicaStore {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
#storeGrantPolicy(g, policy, existing) {
|
|
1368
1368
|
const installedAt = existing?.installedAt ?? policy.at;
|
|
1369
|
+
const keepExisting = existing !== null && existing.consentDeadline < policy.consentDeadline;
|
|
1370
|
+
const consentDeadline = keepExisting ? existing.consentDeadline : policy.consentDeadline;
|
|
1371
|
+
const consentAnchor = keepExisting ? existing.consentAnchor : policy.consentAnchor;
|
|
1369
1372
|
const effectiveExpiresAt = Math.min(
|
|
1370
1373
|
g.expiresAt === null ? Infinity : g.expiresAt * 1e3,
|
|
1371
1374
|
installedAt + policy.ttlMs,
|
|
1372
|
-
|
|
1375
|
+
consentDeadline
|
|
1373
1376
|
);
|
|
1374
|
-
if (!Number.isSafeInteger(installedAt) || installedAt < 0 || !Number.isSafeInteger(effectiveExpiresAt) || effectiveExpiresAt < 0 || !Number.isSafeInteger(
|
|
1377
|
+
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) {
|
|
1375
1378
|
throw new ReplicaError(ReplicaErrorCode.GRANT_EXPIRED, "The replica grant has no finite effective expiry.");
|
|
1376
1379
|
}
|
|
1377
1380
|
this.#db.run(
|
|
@@ -1383,11 +1386,11 @@ var SqliteReplicaStore = class _SqliteReplicaStore {
|
|
|
1383
1386
|
g.cid,
|
|
1384
1387
|
installedAt,
|
|
1385
1388
|
effectiveExpiresAt,
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
+
consentDeadline,
|
|
1390
|
+
consentAnchor.at,
|
|
1391
|
+
consentAnchor.source
|
|
1389
1392
|
);
|
|
1390
|
-
return { installedAt, effectiveExpiresAt, consentDeadline
|
|
1393
|
+
return { installedAt, effectiveExpiresAt, consentDeadline, consentAnchor };
|
|
1391
1394
|
}
|
|
1392
1395
|
async installGatedGrant(g, policy) {
|
|
1393
1396
|
return this.#guardedWrite("Installing the gated grant", () => {
|