@asstio-dev/storefront 0.55.0 → 0.55.1
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/consent/coordinator.js +27 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -221,6 +221,7 @@ class Coordinator {
|
|
|
221
221
|
if (d.owner !== "none" || owner === null || !owner.startsWith("t."))
|
|
222
222
|
return;
|
|
223
223
|
d.owner = owner;
|
|
224
|
+
d.minted = true;
|
|
224
225
|
if (this.owner === "none")
|
|
225
226
|
this.owner = owner;
|
|
226
227
|
}
|
|
@@ -228,6 +229,8 @@ class Coordinator {
|
|
|
228
229
|
const statuses = {};
|
|
229
230
|
const answer = outcome.kind === "answer" && outcome.answer.ok ? outcome.answer.data : null;
|
|
230
231
|
const compensate = [];
|
|
232
|
+
/** Compensations stored as `unsynced` entries (identity `(site, purpose, owner, device, seq + 1)`). */
|
|
233
|
+
const persisted = [];
|
|
231
234
|
const done = await this.locked(async () => {
|
|
232
235
|
const off = this.readOff();
|
|
233
236
|
const parsed = parseConsent(this.jar.get(this.names.consent));
|
|
@@ -268,6 +271,9 @@ class Coordinator {
|
|
|
268
271
|
else if (answer.applied[p] === true) {
|
|
269
272
|
const granted = { state: "granted", seq: req.seq, at: s.pending.at, ...(s.pending.off !== undefined ? { off: s.pending.off } : {}) };
|
|
270
273
|
c = { ...c, ref: d.ref ?? c.ref, purposes: { ...c.purposes, [p]: granted } };
|
|
274
|
+
// As at allocation: this grant replaces the owner's older withdrawal of the purpose. An entry here was stored after this
|
|
275
|
+
// grant's allocation, so it is the compensation of an older grant (code review #1).
|
|
276
|
+
c = withoutEntries(c, (e) => e.site === this.site && e.purpose === p && e.owner === d.owner);
|
|
271
277
|
applying.push(p);
|
|
272
278
|
}
|
|
273
279
|
else {
|
|
@@ -277,6 +283,19 @@ class Coordinator {
|
|
|
277
283
|
}
|
|
278
284
|
else if (s && (s.seq > req.seq || (s.pending !== undefined && s.pending.seq > req.seq))) {
|
|
279
285
|
statuses[p] = "not_saved"; // superseded: a newer decision of this device took the slot; its answer decides
|
|
286
|
+
if (answer.applied[p] === true && d.minted === true && s.state === "withdrawn" && s.seq > req.seq
|
|
287
|
+
&& !c.unsynced.some((e) => e.site === this.site && e.purpose === p && e.owner === d.owner)) {
|
|
288
|
+
// ...unless this grant minted the token and the newer refusal holds no entry for it: the refusal was captured as
|
|
289
|
+
// `none` before the mint, so its PUT fails the owner check and nothing would ever withdraw the minted token's grant.
|
|
290
|
+
// It is compensated for the minted owner at `seq + 1` (any newer decision of the device is above it), with an entry
|
|
291
|
+
// so `start()` replays it if this PUT fails.
|
|
292
|
+
compensate.push(p);
|
|
293
|
+
const entry = { site: this.site, purpose: p, owner: d.owner, device: req.device, seq: req.seq + 1 };
|
|
294
|
+
const r = withEntry(c, entry);
|
|
295
|
+
c = r.cookie;
|
|
296
|
+
if (r.stored)
|
|
297
|
+
persisted.push(entry);
|
|
298
|
+
}
|
|
280
299
|
}
|
|
281
300
|
else if (refusalBlocks(off, d.decidedAt, d.off)) {
|
|
282
301
|
statuses[p] = "refused_meanwhile"; // the marker was folded away by a lock holder: invalidated
|
|
@@ -317,10 +336,12 @@ class Coordinator {
|
|
|
317
336
|
for (const p of req.grants)
|
|
318
337
|
statuses[p] = "not_saved";
|
|
319
338
|
if (compensate.length > 0) {
|
|
320
|
-
await this.submit({
|
|
339
|
+
const outcome = await this.submit({
|
|
321
340
|
clientLabel: null, notice: null, order: { device: req.device, seq: req.seq + 1 },
|
|
322
341
|
purposes: Object.fromEntries(compensate.map((p) => [p, "withdrawn"])),
|
|
323
342
|
}, d.owner, false);
|
|
343
|
+
// A stored compensation is matched like any withdrawal: dropped when acknowledged, kept for `start()` otherwise.
|
|
344
|
+
await Promise.all(persisted.map((e) => this.withdrawalAnswer(e, outcome)));
|
|
324
345
|
}
|
|
325
346
|
return statuses;
|
|
326
347
|
}
|
|
@@ -367,6 +388,11 @@ class Coordinator {
|
|
|
367
388
|
if (!parsed || !parsed.unsynced.some((e) => sameIdentity(e, id)))
|
|
368
389
|
return null;
|
|
369
390
|
let c = this.prepare(parsed, this.readOff());
|
|
391
|
+
// A newer grant of the same owner and purpose is in flight: its answer decides, and a re-send at a fresh seq would land above
|
|
392
|
+
// it. The entry stays (that grant drops it when applied; `start()` replays it otherwise) (code review #1).
|
|
393
|
+
const inFlight = c.purposes[id.purpose]?.pending;
|
|
394
|
+
if (inFlight && inFlight.owner === id.owner)
|
|
395
|
+
return null;
|
|
370
396
|
let seq = c.seq + 1;
|
|
371
397
|
if (seq >= SEQ_LIMIT - 1) {
|
|
372
398
|
c = this.fresh(c);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.55.
|
|
1
|
+
export declare const SDK_VERSION = "0.55.1";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/version-file.mjs from package.json; do not edit or commit.
|
|
2
|
-
export const SDK_VERSION = "0.55.
|
|
2
|
+
export const SDK_VERSION = "0.55.1";
|