@mdbase-dev/sdk 0.2.0 → 0.2.2
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/app-host/cloud-copy-host.d.ts +1 -0
- package/dist/app-host/cloud-copy-host.js +43 -3
- package/dist/app-host/cloud-copy-host.js.map +1 -1
- package/dist/app-host/installation-sign-in.d.ts +3 -0
- package/dist/app-host/installation-sign-in.js +10 -0
- package/dist/app-host/installation-sign-in.js.map +1 -1
- package/dist/app-host/scoped-sign-in-session.d.ts +2 -0
- package/dist/app-host/scoped-sign-in-session.js +10 -0
- package/dist/app-host/scoped-sign-in-session.js.map +1 -1
- package/dist/app-host/web-collection.js +43 -3
- package/dist/app-host/web-collection.js.map +1 -1
- package/dist/app-host/web-sign-in-session.d.ts +8 -0
- package/dist/app-host/web-sign-in-session.js +32 -0
- package/dist/app-host/web-sign-in-session.js.map +1 -1
- package/dist/application/collection-selection.js +5 -4
- package/dist/application/collection-selection.js.map +1 -1
- package/dist/application/entry.js +8 -1
- package/dist/application/entry.js.map +1 -1
- package/dist/application/front-door.d.ts +5 -0
- package/dist/application/front-door.js.map +1 -1
- package/dist/application/runtime.d.ts +2 -0
- package/dist/application/runtime.js +5 -0
- package/dist/application/runtime.js.map +1 -1
- package/dist/application/worker-host.js +3 -0
- package/dist/application/worker-host.js.map +1 -1
- package/dist/application/worker-protocol.d.ts +1 -1
- package/dist/application/worker-protocol.js +1 -1
- package/dist/application/worker-protocol.js.map +1 -1
- package/dist/application/worker.js +139 -11
- package/dist/browser/mdbase-sdk.js +140 -13
- package/dist/browser/mdbase-sdk.min.js +62 -62
- package/dist/native/provenance.json +1 -1
- package/dist/testing/application.d.ts +1 -1
- package/dist/testing/application.js +5 -0
- package/dist/testing/application.js.map +1 -1
- package/dist/testing/test-app.js +1 -1
- package/dist/testing/test-app.js.map +1 -1
- package/package.json +1 -1
|
@@ -27884,6 +27884,15 @@ ${end.comment}` : end.comment;
|
|
|
27884
27884
|
this.check();
|
|
27885
27885
|
return !this.state.token && this.state.requestSent === this.state.requestId;
|
|
27886
27886
|
}
|
|
27887
|
+
/** The person stopped waiting for this sign-in: a restart no longer resumes
|
|
27888
|
+
* it. The request itself is kept, so the next gesture sends it again. */
|
|
27889
|
+
forgetSentRequest() {
|
|
27890
|
+
return this.exclusive(async () => {
|
|
27891
|
+
if (this.state.token || this.state.requestSent === void 0) return;
|
|
27892
|
+
const { requestSent: _sent, ...unsent } = this.state;
|
|
27893
|
+
await this.save(unsent);
|
|
27894
|
+
});
|
|
27895
|
+
}
|
|
27887
27896
|
/** True when this installation registered a Web Push channel (so a browser
|
|
27888
27897
|
* push subscription exists for the app). Metadata only. */
|
|
27889
27898
|
hasWebPushChannel() {
|
|
@@ -29455,7 +29464,7 @@ ${end.comment}` : end.comment;
|
|
|
29455
29464
|
};
|
|
29456
29465
|
if (!Array.isArray(value2) || value2.length !== 5 || value2[0] !== APPLICATION_WORKER_PROTOCOL || value2[1] !== binding2 || !Number.isInteger(value2[2]) || value2[2] < 0 || value2[2] > APPLICATION_WORKER_MAX_ID || value2[2] === 0 && value2[3] !== "foreground" && value2[3] !== "approvalClosed" || value2[2] !== 0 && value2[3] === "approvalClosed") return fail20();
|
|
29457
29466
|
const action = value2[3], payload = value2[4];
|
|
29458
|
-
if (!["start", "authorize", "renewExpiredPairing", "select", "clearSelection", "forget", "refreshCollections", "signOut", "deleteCollection", "requestFileAccess", "pollFileAccess", "openUnsynced", "attachUnsynced", "detachUnsynced", "retireUnsynced", "discardUnsynced", "foreground", "approvalClosed", "close", "unlock"].includes(action)) fail20();
|
|
29467
|
+
if (!["start", "authorize", "renewExpiredPairing", "select", "clearSelection", "forget", "refreshCollections", "signOut", "deleteCollection", "requestFileAccess", "pollFileAccess", "openUnsynced", "attachUnsynced", "detachUnsynced", "retireUnsynced", "discardUnsynced", "foreground", "approvalClosed", "cancelAuthorization", "close", "unlock"].includes(action)) fail20();
|
|
29459
29468
|
const uuid12 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
29460
29469
|
if (action === "requestFileAccess") {
|
|
29461
29470
|
if (!Array.isArray(payload) || payload.length !== 3 || typeof payload[0] !== "string" || !uuid12.test(payload[0]) || !Array.isArray(payload[1]) || !payload[1].length || payload[1].length > 6 || payload[1].some((a) => typeof a !== "string" || !["list", "read", "add", "replace", "move", "delete"].includes(a)) || typeof payload[2] !== "string" || !payload[2] || payload[2].length > 140) fail20();
|
|
@@ -44902,6 +44911,7 @@ ${end.comment}` : end.comment;
|
|
|
44902
44911
|
timerPorts = /* @__PURE__ */ new Set();
|
|
44903
44912
|
readWork = null;
|
|
44904
44913
|
readAbort = null;
|
|
44914
|
+
readWake = null;
|
|
44905
44915
|
readClient = null;
|
|
44906
44916
|
readVerified = false;
|
|
44907
44917
|
/** One data facade per attached tab (the first, then any follower tabs). */
|
|
@@ -45511,7 +45521,9 @@ ${end.comment}` : end.comment;
|
|
|
45511
45521
|
/** Feed one push frame to the native replica (current log session only). */
|
|
45512
45522
|
pushLog(frame) {
|
|
45513
45523
|
try {
|
|
45514
|
-
|
|
45524
|
+
const accepted = this.native?.pushLog(frame) === true;
|
|
45525
|
+
if (accepted) this.readWake?.();
|
|
45526
|
+
return accepted;
|
|
45515
45527
|
} catch {
|
|
45516
45528
|
return false;
|
|
45517
45529
|
}
|
|
@@ -45606,6 +45618,47 @@ ${end.comment}` : end.comment;
|
|
|
45606
45618
|
const ctrl = new AbortController(), abort = () => ctrl.abort();
|
|
45607
45619
|
const pump = () => local ? null : this.pump;
|
|
45608
45620
|
this.readAbort = ctrl;
|
|
45621
|
+
let readPushed = false;
|
|
45622
|
+
let wakeSleep = null;
|
|
45623
|
+
if (pump()) {
|
|
45624
|
+
this.readWake = () => {
|
|
45625
|
+
readPushed = true;
|
|
45626
|
+
wakeSleep?.();
|
|
45627
|
+
};
|
|
45628
|
+
}
|
|
45629
|
+
const waitRetry = (ms) => {
|
|
45630
|
+
if (readPushed) {
|
|
45631
|
+
readPushed = false;
|
|
45632
|
+
return Promise.resolve();
|
|
45633
|
+
}
|
|
45634
|
+
if (!pump()) return waitForOpenRetry(ms, ctrl.signal);
|
|
45635
|
+
return new Promise((resolve2, reject) => {
|
|
45636
|
+
if (ctrl.signal.aborted) {
|
|
45637
|
+
reject(ctrl.signal.reason);
|
|
45638
|
+
return;
|
|
45639
|
+
}
|
|
45640
|
+
const finish = () => {
|
|
45641
|
+
clearTimeout(wait2);
|
|
45642
|
+
ctrl.signal.removeEventListener("abort", cancel);
|
|
45643
|
+
if (wakeSleep === onWake) wakeSleep = null;
|
|
45644
|
+
};
|
|
45645
|
+
const onWake = () => {
|
|
45646
|
+
finish();
|
|
45647
|
+
readPushed = false;
|
|
45648
|
+
resolve2();
|
|
45649
|
+
};
|
|
45650
|
+
const cancel = () => {
|
|
45651
|
+
finish();
|
|
45652
|
+
reject(ctrl.signal.reason);
|
|
45653
|
+
};
|
|
45654
|
+
const wait2 = setTimeout(() => {
|
|
45655
|
+
finish();
|
|
45656
|
+
resolve2();
|
|
45657
|
+
}, ms);
|
|
45658
|
+
wakeSleep = onWake;
|
|
45659
|
+
ctrl.signal.addEventListener("abort", cancel, { once: true });
|
|
45660
|
+
});
|
|
45661
|
+
};
|
|
45609
45662
|
signal.addEventListener("abort", abort, { once: true });
|
|
45610
45663
|
let timer2 = null;
|
|
45611
45664
|
let stage = "read_connect";
|
|
@@ -45708,13 +45761,14 @@ ${end.comment}` : end.comment;
|
|
|
45708
45761
|
let delay = 250;
|
|
45709
45762
|
while (!ctrl.signal.aborted) {
|
|
45710
45763
|
stage = "read_catch_up";
|
|
45764
|
+
readPushed = false;
|
|
45711
45765
|
this.native.tick();
|
|
45712
45766
|
const turn = pump();
|
|
45713
45767
|
if (turn) await Promise.race([turn.pump(), aborted]);
|
|
45714
45768
|
this.checkCollection(signal);
|
|
45715
45769
|
const observation = observe();
|
|
45716
45770
|
if (cold && initialSyncWait(observation.status) !== null) {
|
|
45717
|
-
await
|
|
45771
|
+
await waitRetry(delay);
|
|
45718
45772
|
delay = Math.min(1e3, delay * 2);
|
|
45719
45773
|
continue;
|
|
45720
45774
|
}
|
|
@@ -45733,7 +45787,7 @@ ${end.comment}` : end.comment;
|
|
|
45733
45787
|
if (!(error5 instanceof MdbaseError) || error5.code !== "unavailable" || !pump() || ctrl.signal.aborted)
|
|
45734
45788
|
throw error5;
|
|
45735
45789
|
}
|
|
45736
|
-
await
|
|
45790
|
+
await waitRetry(delay);
|
|
45737
45791
|
delay = Math.min(1e3, delay * 2);
|
|
45738
45792
|
}
|
|
45739
45793
|
throw stopped();
|
|
@@ -45745,6 +45799,8 @@ ${end.comment}` : end.comment;
|
|
|
45745
45799
|
if (timer2 !== null) clearTimeout(timer2);
|
|
45746
45800
|
signal.removeEventListener("abort", abort);
|
|
45747
45801
|
ctrl.signal.removeEventListener("abort", rejectAbort);
|
|
45802
|
+
this.readWake = null;
|
|
45803
|
+
wakeSleep = null;
|
|
45748
45804
|
this.readClient?.close();
|
|
45749
45805
|
this.readClient = null;
|
|
45750
45806
|
this.readAbort = null;
|
|
@@ -46201,6 +46257,7 @@ ${end.comment}` : end.comment;
|
|
|
46201
46257
|
let keys2 = "settled";
|
|
46202
46258
|
let push = null, paused = false, pausing = null, kicked = false;
|
|
46203
46259
|
let ended = null;
|
|
46260
|
+
let pendingEnd = null;
|
|
46204
46261
|
const attached = /* @__PURE__ */ new Map();
|
|
46205
46262
|
const timerKeys2 = /* @__PURE__ */ new Map();
|
|
46206
46263
|
const timerKey = () => {
|
|
@@ -46238,6 +46295,7 @@ ${end.comment}` : end.comment;
|
|
|
46238
46295
|
timer2 = null;
|
|
46239
46296
|
if (pausing !== null) clearTimeout(pausing);
|
|
46240
46297
|
pausing = null;
|
|
46298
|
+
pendingEnd = null;
|
|
46241
46299
|
try {
|
|
46242
46300
|
push?.close();
|
|
46243
46301
|
} catch {
|
|
@@ -46368,7 +46426,15 @@ ${end.comment}` : end.comment;
|
|
|
46368
46426
|
}
|
|
46369
46427
|
};
|
|
46370
46428
|
const startLog = () => host.startCollectionLog({ signal: life.signal, fetch: options.fetch, allowLoopbackHttp: options.allowLoopbackHttp });
|
|
46429
|
+
const applyEnd = (reason) => {
|
|
46430
|
+
ended = reason;
|
|
46431
|
+
kick();
|
|
46432
|
+
onLive(false);
|
|
46433
|
+
settleInitial?.();
|
|
46434
|
+
changed3();
|
|
46435
|
+
};
|
|
46371
46436
|
const openPush = () => {
|
|
46437
|
+
if (push || !current3()) return;
|
|
46372
46438
|
try {
|
|
46373
46439
|
push = typeof host.openLogPush === "function" ? host.openLogPush({
|
|
46374
46440
|
push: (frame) => {
|
|
@@ -46379,19 +46445,32 @@ ${end.comment}` : end.comment;
|
|
|
46379
46445
|
live: onLive,
|
|
46380
46446
|
// Access ended: the replica has the `closed` push; drive so it
|
|
46381
46447
|
// settles, then the session stops this collection in every tab.
|
|
46448
|
+
// While waitForVerifiedRead is still running, record the reason
|
|
46449
|
+
// without failing or slowing the open and surface it once started.
|
|
46382
46450
|
ended: (reason) => {
|
|
46383
|
-
|
|
46384
|
-
|
|
46385
|
-
|
|
46386
|
-
|
|
46387
|
-
|
|
46451
|
+
if (!started) {
|
|
46452
|
+
pendingEnd ??= reason;
|
|
46453
|
+
onLive(false);
|
|
46454
|
+
return;
|
|
46455
|
+
}
|
|
46456
|
+
applyEnd(reason);
|
|
46388
46457
|
}
|
|
46389
46458
|
}) : null;
|
|
46390
46459
|
} catch {
|
|
46391
46460
|
push = null;
|
|
46392
46461
|
}
|
|
46393
46462
|
if (push) {
|
|
46394
|
-
|
|
46463
|
+
try {
|
|
46464
|
+
push.start();
|
|
46465
|
+
} catch {
|
|
46466
|
+
try {
|
|
46467
|
+
push.close();
|
|
46468
|
+
} catch {
|
|
46469
|
+
}
|
|
46470
|
+
push = null;
|
|
46471
|
+
setPaused(true);
|
|
46472
|
+
return;
|
|
46473
|
+
}
|
|
46395
46474
|
onLive(false);
|
|
46396
46475
|
} else setPaused(true);
|
|
46397
46476
|
};
|
|
@@ -46698,12 +46777,18 @@ ${end.comment}` : end.comment;
|
|
|
46698
46777
|
}
|
|
46699
46778
|
}
|
|
46700
46779
|
if (!local) {
|
|
46780
|
+
openPush();
|
|
46701
46781
|
report("syncing");
|
|
46702
46782
|
await host.waitForVerifiedRead({ signal: life.signal, cold: !warm, onProgress: report });
|
|
46703
46783
|
check3();
|
|
46704
46784
|
}
|
|
46705
46785
|
started = true;
|
|
46706
46786
|
host.onLogWork?.(kick);
|
|
46787
|
+
if (pendingEnd !== null) {
|
|
46788
|
+
const reason = pendingEnd;
|
|
46789
|
+
pendingEnd = null;
|
|
46790
|
+
applyEnd(reason);
|
|
46791
|
+
}
|
|
46707
46792
|
if (local) {
|
|
46708
46793
|
keys2 = "pending";
|
|
46709
46794
|
kicked = true;
|
|
@@ -46714,7 +46799,6 @@ ${end.comment}` : end.comment;
|
|
|
46714
46799
|
}, PAUSED_AFTER_MS);
|
|
46715
46800
|
} else {
|
|
46716
46801
|
schedule();
|
|
46717
|
-
openPush();
|
|
46718
46802
|
if (warm) {
|
|
46719
46803
|
report("syncing");
|
|
46720
46804
|
await waitForWarmSync();
|
|
@@ -50018,6 +50102,11 @@ ${end.comment}` : end.comment;
|
|
|
50018
50102
|
return this.settled();
|
|
50019
50103
|
}, caller);
|
|
50020
50104
|
}
|
|
50105
|
+
/** Stop waiting for Connect: signed out again, or the collection list when signed in. */
|
|
50106
|
+
cancelAuthorization(options = {}) {
|
|
50107
|
+
const caller = this.signal(options);
|
|
50108
|
+
return this.action(async () => this.complete(await this.worker.request("cancelAuthorization", null, caller), caller), caller);
|
|
50109
|
+
}
|
|
50021
50110
|
clearSelection(options = {}) {
|
|
50022
50111
|
const caller = this.signal(options);
|
|
50023
50112
|
return this.action(async () => {
|
|
@@ -51398,11 +51487,11 @@ ${end.comment}` : end.comment;
|
|
|
51398
51487
|
if (this.closed || this.opening) return;
|
|
51399
51488
|
const s = this.session.getSnapshot();
|
|
51400
51489
|
if (this.approval) {
|
|
51401
|
-
if (this.approval.settled && s.status === "signed_out" && s.problem !== null) {
|
|
51490
|
+
if (this.approval.settled && s.status === "signed_out" && (s.problem !== null || s.approval?.outcome === "closed")) {
|
|
51402
51491
|
const a = this.approval;
|
|
51403
51492
|
this.approval = null;
|
|
51404
51493
|
this.attempted = void 0;
|
|
51405
|
-
this.lastApproval = Object.freeze({ kind: a.kind, outcome: s.problem === "approval_window_closed" ? "closed" : "declined", collectionId: a.collectionId });
|
|
51494
|
+
this.lastApproval = Object.freeze({ kind: a.kind, outcome: s.problem === "approval_window_closed" || s.approval?.outcome === "closed" ? "closed" : "declined", collectionId: a.collectionId });
|
|
51406
51495
|
this.refresh();
|
|
51407
51496
|
} else {
|
|
51408
51497
|
if (!this.approval.settled || inFlight(s)) return;
|
|
@@ -52954,6 +53043,7 @@ ${end.comment}` : end.comment;
|
|
|
52954
53043
|
start: refuse,
|
|
52955
53044
|
signIn: refuse,
|
|
52956
53045
|
addCollection: refuse,
|
|
53046
|
+
cancelAuthorization: refuse,
|
|
52957
53047
|
select: refuse,
|
|
52958
53048
|
approve: refuse,
|
|
52959
53049
|
reauthorize: refuse,
|
|
@@ -53182,6 +53272,12 @@ ${end.comment}` : end.comment;
|
|
|
53182
53272
|
return id6 ? this.approve(id6, options2) : selection.reauthorize(options2);
|
|
53183
53273
|
}),
|
|
53184
53274
|
addCollection: (options2) => this.track(() => this.approve(null, options2)),
|
|
53275
|
+
cancelAuthorization: (options2) => this.track(() => this.call(async (runtime2) => {
|
|
53276
|
+
await runtime2.queue(() => runtime2.cancelAuthorization(options2));
|
|
53277
|
+
const after = runtime2.getNativeSnapshot();
|
|
53278
|
+
if (this.unsyncedFirst && after.status === "signed_out" && !after.unsynced && this.choose().getSnapshot().requested.collectionId === null)
|
|
53279
|
+
await runtime2.queue(() => runtime2.openUnsynced(options2));
|
|
53280
|
+
})),
|
|
53185
53281
|
refreshCollectionList: (options2) => this.track(() => Promise.all([this.call((runtime2) => runtime2.queue(() => runtime2.refreshCollections(options2))), this.privates?.refresh(this.account()).catch(() => {
|
|
53186
53282
|
})])),
|
|
53187
53283
|
requestAccess: (request3, options2) => this.requestAccess(request3, options2),
|
|
@@ -55474,6 +55570,37 @@ ${end.comment}` : end.comment;
|
|
|
55474
55570
|
return false;
|
|
55475
55571
|
}
|
|
55476
55572
|
}
|
|
55573
|
+
/** The person stopped waiting for Connect (the app's Cancel). Ends the wait
|
|
55574
|
+
* as a closed approval window does, without another read: the collection
|
|
55575
|
+
* list when signed in, otherwise signed out. A restart no longer resumes a
|
|
55576
|
+
* sent sign-in request; the next sign-in gesture sends that SAME request,
|
|
55577
|
+
* so an approval given meanwhile is still received. Waits for an operation
|
|
55578
|
+
* in flight (the sign-in gesture's own, or an approval read) to settle;
|
|
55579
|
+
* resolves unchanged when nothing is being authorized. */
|
|
55580
|
+
async cancelAuthorization() {
|
|
55581
|
+
this.check();
|
|
55582
|
+
while (this.pending) {
|
|
55583
|
+
await this.pending.catch(() => {
|
|
55584
|
+
});
|
|
55585
|
+
this.check();
|
|
55586
|
+
}
|
|
55587
|
+
return this.operation(async () => {
|
|
55588
|
+
if (this.base.status !== "authorizing") return this.getSnapshot();
|
|
55589
|
+
this.closeApprovalWindow();
|
|
55590
|
+
const closed = Object.freeze({ outcome: "closed" });
|
|
55591
|
+
if (this.consentPending) {
|
|
55592
|
+
this.consentPending = false;
|
|
55593
|
+
this.publish({ status: "unselected", problem: null, approval: closed });
|
|
55594
|
+
await this.refreshCollections();
|
|
55595
|
+
} else {
|
|
55596
|
+
await this.flow.forgetSentRequest();
|
|
55597
|
+
this.check();
|
|
55598
|
+
this.restoredPending = false;
|
|
55599
|
+
this.publish({ status: "signed_out", problem: null, approval: closed });
|
|
55600
|
+
}
|
|
55601
|
+
return this.getSnapshot();
|
|
55602
|
+
});
|
|
55603
|
+
}
|
|
55477
55604
|
/** One scheduled approval read. If the held window was already closed, this
|
|
55478
55605
|
* read is the final one: Connect records an approval before its window
|
|
55479
55606
|
* closes, so only a still-pending, definite answer ends the wait. */
|