@mdbase-dev/sdk 0.1.41 → 0.2.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/app-grant/client.d.ts +4 -2
- package/dist/app-grant/client.js +56 -37
- package/dist/app-grant/client.js.map +1 -1
- 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/asset-pins.json +4 -4
- 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 +143 -15
- package/dist/browser/mdbase-sdk.js +243 -74
- package/dist/browser/mdbase-sdk.min.js +64 -64
- package/dist/describe-error.js +7 -1
- package/dist/describe-error.js.map +1 -1
- package/dist/native/provenance.json +5 -5
- package/dist/native/runtime.wasm +0 -0
- 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/dist/transport/next-relay.d.ts +5 -1
- package/dist/transport/next-relay.js +72 -37
- package/dist/transport/next-relay.js.map +1 -1
- package/package.json +1 -1
|
@@ -9982,8 +9982,15 @@ var MdbaseSDK = (() => {
|
|
|
9982
9982
|
application_connection_unavailable: "unavailable",
|
|
9983
9983
|
readiness_unavailable: "unavailable",
|
|
9984
9984
|
grant_activation_timeout: "unavailable",
|
|
9985
|
+
// Relay pipe closes (pipeCloseError), published as a Private snapshot's problem. A
|
|
9986
|
+
// close without a known reason names no cause: an intermediary can strip the close
|
|
9987
|
+
// status of a real refusal (it arrives as 1005).
|
|
9985
9988
|
relay_closed: "unavailable",
|
|
9986
9989
|
pipe_closed: "unavailable",
|
|
9990
|
+
authorization_unavailable: "unavailable",
|
|
9991
|
+
grant_lease_expired: "unavailable",
|
|
9992
|
+
grant_inactive: "forbidden",
|
|
9993
|
+
connector_busy: "rate_limited",
|
|
9987
9994
|
application_connection_people_unavailable: "people_access",
|
|
9988
9995
|
people_unavailable: "people_access",
|
|
9989
9996
|
people_response: "people_access",
|
|
@@ -27877,6 +27884,15 @@ ${end.comment}` : end.comment;
|
|
|
27877
27884
|
this.check();
|
|
27878
27885
|
return !this.state.token && this.state.requestSent === this.state.requestId;
|
|
27879
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
|
+
}
|
|
27880
27896
|
/** True when this installation registered a Web Push channel (so a browser
|
|
27881
27897
|
* push subscription exists for the app). Metadata only. */
|
|
27882
27898
|
hasWebPushChannel() {
|
|
@@ -29448,7 +29464,7 @@ ${end.comment}` : end.comment;
|
|
|
29448
29464
|
};
|
|
29449
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();
|
|
29450
29466
|
const action = value2[3], payload = value2[4];
|
|
29451
|
-
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();
|
|
29452
29468
|
const uuid12 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
29453
29469
|
if (action === "requestFileAccess") {
|
|
29454
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();
|
|
@@ -37166,55 +37182,76 @@ ${end.comment}` : end.comment;
|
|
|
37166
37182
|
const usable = route2.targets.filter(
|
|
37167
37183
|
(t) => UUID9.test(t.device) && /^[0-9a-f]{64}$/.test(t.noise_pk) && !!t.relay_collection && UUID9.test(t.relay_collection)
|
|
37168
37184
|
);
|
|
37169
|
-
const
|
|
37170
|
-
|
|
37171
|
-
|
|
37185
|
+
const rank = (t) => {
|
|
37186
|
+
const tier2 = t.online === true ? 0 : t.online === void 0 ? 1 : 2;
|
|
37187
|
+
return tier2 * 2 + (t.device === sticky ? 0 : 1);
|
|
37188
|
+
};
|
|
37189
|
+
return usable.map((target2, index) => ({ target: target2, index, rank: rank(target2) })).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ target: target2 }) => target2);
|
|
37190
|
+
}
|
|
37191
|
+
function attemptTargets(route2, sticky) {
|
|
37192
|
+
const ordered = orderTargets(route2, sticky);
|
|
37193
|
+
const online = ordered.filter((t) => t.online === true);
|
|
37194
|
+
return online.length ? online : ordered.slice(0, 1);
|
|
37195
|
+
}
|
|
37196
|
+
function isRetryableTargetError(error5, signal) {
|
|
37197
|
+
return !signal?.aborted && isMdbaseError(error5) && (error5.code === "unavailable" || error5.code === "rate_limited");
|
|
37172
37198
|
}
|
|
37173
37199
|
function nextRelayConnector(o) {
|
|
37174
37200
|
const collection2 = o.collection, next = o.next, staticKey = o.staticKey;
|
|
37175
37201
|
if (!UUID9.test(collection2)) throw mdbaseError("invalid_request", "collection must be a UUID");
|
|
37176
37202
|
const routeCall = next.route.bind(next), pipeCall = next.openPipe.bind(next);
|
|
37203
|
+
const description = `next-relay:${collection2}`;
|
|
37177
37204
|
let sticky = null;
|
|
37178
|
-
|
|
37179
|
-
description
|
|
37180
|
-
|
|
37181
|
-
|
|
37205
|
+
return registerNextRelayFence({
|
|
37206
|
+
description,
|
|
37207
|
+
open: async (hello, signal) => {
|
|
37208
|
+
if (signal?.aborted) throw mdbaseError("cancelled", "connect aborted");
|
|
37182
37209
|
const route2 = await bridged(() => routeCall(collection2, signal ? { signal } : {}));
|
|
37210
|
+
if (signal?.aborted) throw mdbaseError("cancelled", "connect aborted");
|
|
37183
37211
|
if (route2.collection.toLowerCase() !== collection2.toLowerCase() || !UUID9.test(route2.grant)) {
|
|
37184
37212
|
throw mdbaseError("unauthenticated", "the route does not match this collection's grant", "route_mismatch");
|
|
37185
37213
|
}
|
|
37186
37214
|
const availability = parseCollectionAvailability(route2.availability);
|
|
37187
37215
|
if (availability?.state === "unavailable") throw collectionUnavailableError(availability.reason);
|
|
37188
|
-
const
|
|
37189
|
-
if (!
|
|
37216
|
+
const targets2 = attemptTargets(route2, sticky);
|
|
37217
|
+
if (!targets2.length) {
|
|
37190
37218
|
throw mdbaseError(
|
|
37191
37219
|
"unavailable",
|
|
37192
37220
|
route2.reason === "no_device_registered" ? "this collection has no device set up to serve it" : "no device of this collection is online",
|
|
37193
37221
|
route2.reason ?? "no_device_online"
|
|
37194
37222
|
);
|
|
37195
37223
|
}
|
|
37196
|
-
|
|
37197
|
-
const
|
|
37198
|
-
|
|
37199
|
-
|
|
37200
|
-
|
|
37201
|
-
|
|
37202
|
-
|
|
37203
|
-
|
|
37204
|
-
|
|
37205
|
-
|
|
37206
|
-
|
|
37207
|
-
|
|
37224
|
+
let firstError;
|
|
37225
|
+
for (const selected of targets2) {
|
|
37226
|
+
const target2 = Object.freeze({ ...selected });
|
|
37227
|
+
const hex14 = target2.noise_pk;
|
|
37228
|
+
const remoteStatic = new Uint8Array(32);
|
|
37229
|
+
for (let i = 0; i < 32; i++) remoteStatic[i] = parseInt(hex14.slice(2 * i, 2 * i + 2), 16);
|
|
37230
|
+
const connector = noiseConnector({
|
|
37231
|
+
description,
|
|
37232
|
+
staticKey,
|
|
37233
|
+
target: async () => ({
|
|
37234
|
+
// Must equal the daemon's pipe_open prologue: relay collection, grant, device.
|
|
37235
|
+
prologue: clientPrologue(uuidToBytes(target2.relay_collection), uuidToBytes(route2.grant), uuidToBytes(target2.device)),
|
|
37236
|
+
remoteStatic,
|
|
37237
|
+
device: target2.device,
|
|
37238
|
+
openCarrier: async (carrierSignal) => {
|
|
37239
|
+
const pipe = await bridged(() => pipeCall(collection2, target2, carrierSignal ? { signal: carrierSignal } : {}));
|
|
37240
|
+
return duplexCarrier(pipe);
|
|
37241
|
+
}
|
|
37242
|
+
})
|
|
37243
|
+
});
|
|
37244
|
+
try {
|
|
37245
|
+
const opened = await connector.open(hello, signal);
|
|
37246
|
+
sticky = opened.device ?? null;
|
|
37247
|
+
return opened;
|
|
37248
|
+
} catch (error5) {
|
|
37249
|
+
if (!isRetryableTargetError(error5, signal)) throw error5;
|
|
37250
|
+
if (sticky === target2.device) sticky = null;
|
|
37251
|
+
firstError ??= error5;
|
|
37208
37252
|
}
|
|
37209
|
-
}
|
|
37210
|
-
|
|
37211
|
-
});
|
|
37212
|
-
return registerNextRelayFence({
|
|
37213
|
-
description: connector.description,
|
|
37214
|
-
open: async (hello, signal) => {
|
|
37215
|
-
const opened = await connector.open(hello, signal);
|
|
37216
|
-
sticky = opened.device ?? null;
|
|
37217
|
-
return opened;
|
|
37253
|
+
}
|
|
37254
|
+
throw firstError;
|
|
37218
37255
|
},
|
|
37219
37256
|
get target() {
|
|
37220
37257
|
return sticky;
|
|
@@ -38558,8 +38595,10 @@ ${end.comment}` : end.comment;
|
|
|
38558
38595
|
/**
|
|
38559
38596
|
* A connector for `connect()`: each open uses a fresh route, refuses an
|
|
38560
38597
|
* unavailable collection with its reason, and opens a Noise IK session through the
|
|
38561
|
-
* relay to a serving device (
|
|
38562
|
-
*
|
|
38598
|
+
* relay to a serving device (preferring the last reached device while it stays
|
|
38599
|
+
* online and serving, and failing over to another online target otherwise). The
|
|
38600
|
+
* first open pins its original consent/key identity; new consent requires a new
|
|
38601
|
+
* connector.
|
|
38563
38602
|
*/
|
|
38564
38603
|
connector(collection2) {
|
|
38565
38604
|
const id6 = collection2.toLowerCase();
|
|
@@ -38574,20 +38613,23 @@ ${end.comment}` : end.comment;
|
|
|
38574
38613
|
this.routeProbe = void 0;
|
|
38575
38614
|
const grant = await (original ??= this.heldGrant(id6));
|
|
38576
38615
|
await this.assertCurrent(grant);
|
|
38577
|
-
|
|
38578
|
-
|
|
38579
|
-
|
|
38580
|
-
|
|
38581
|
-
|
|
38582
|
-
|
|
38583
|
-
|
|
38584
|
-
|
|
38585
|
-
|
|
38586
|
-
|
|
38587
|
-
|
|
38588
|
-
|
|
38589
|
-
|
|
38590
|
-
|
|
38616
|
+
if (signal?.aborted) throw mdbaseError("cancelled", "connect aborted");
|
|
38617
|
+
const { token, route: route2, availability } = primed && !primed.signal?.aborted && performance.now() < primed.until && primed.credentials === this.tokens.get(id6) && sameGrant(grant, primed.credentials) && primed.credentials.expiresAt > Date.now() ? { token: primed.credentials.access, route: primed.route, availability: { state: "available" } } : await this.route(id6, signal);
|
|
38618
|
+
await this.assertCurrent(grant);
|
|
38619
|
+
if (signal?.aborted) throw mdbaseError("cancelled", "connect aborted");
|
|
38620
|
+
if (availability.state === "unavailable") throw collectionUnavailableError(availability.reason);
|
|
38621
|
+
if (!UUID10.test(route2.grant)) throw mdbaseError("unauthenticated", "the route names no grant", "route_mismatch");
|
|
38622
|
+
const targets2 = attemptTargets(route2, sticky);
|
|
38623
|
+
if (!targets2.length) throw collectionUnavailableError("device_offline");
|
|
38624
|
+
let firstError;
|
|
38625
|
+
for (const target2 of targets2) {
|
|
38626
|
+
await this.assertCurrent(grant);
|
|
38627
|
+
const remoteStatic = new Uint8Array(32);
|
|
38628
|
+
for (let i = 0; i < 32; i++) remoteStatic[i] = parseInt(target2.noise_pk.slice(2 * i, 2 * i + 2), 16);
|
|
38629
|
+
const connector = noiseConnector({
|
|
38630
|
+
description: `app-grant:${id6}`,
|
|
38631
|
+
staticKey: staticKeyOf2(grant),
|
|
38632
|
+
target: async () => ({
|
|
38591
38633
|
prologue: clientPrologue(uuidToBytes(target2.relay_collection), uuidToBytes(route2.grant), uuidToBytes(target2.device)),
|
|
38592
38634
|
remoteStatic,
|
|
38593
38635
|
device: target2.device,
|
|
@@ -38608,19 +38650,28 @@ ${end.comment}` : end.comment;
|
|
|
38608
38650
|
throw e;
|
|
38609
38651
|
}
|
|
38610
38652
|
}
|
|
38611
|
-
}
|
|
38653
|
+
})
|
|
38654
|
+
});
|
|
38655
|
+
let opened;
|
|
38656
|
+
try {
|
|
38657
|
+
opened = await connector.open(hello, signal);
|
|
38658
|
+
} catch (error5) {
|
|
38659
|
+
if (!isRetryableTargetError(error5, signal)) throw error5;
|
|
38660
|
+
if (sticky === target2.device) sticky = null;
|
|
38661
|
+
firstError ??= error5;
|
|
38662
|
+
continue;
|
|
38612
38663
|
}
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38664
|
+
try {
|
|
38665
|
+
await this.assertCurrent(grant);
|
|
38666
|
+
} catch (e) {
|
|
38667
|
+
opened.port.close();
|
|
38668
|
+
throw e;
|
|
38669
|
+
}
|
|
38670
|
+
bindOriginalAppGrant(opened.port, grant);
|
|
38671
|
+
sticky = opened.device ?? null;
|
|
38672
|
+
return opened;
|
|
38620
38673
|
}
|
|
38621
|
-
|
|
38622
|
-
sticky = opened.device ?? null;
|
|
38623
|
-
return opened;
|
|
38674
|
+
throw firstError;
|
|
38624
38675
|
},
|
|
38625
38676
|
get target() {
|
|
38626
38677
|
return sticky;
|
|
@@ -44860,6 +44911,7 @@ ${end.comment}` : end.comment;
|
|
|
44860
44911
|
timerPorts = /* @__PURE__ */ new Set();
|
|
44861
44912
|
readWork = null;
|
|
44862
44913
|
readAbort = null;
|
|
44914
|
+
readWake = null;
|
|
44863
44915
|
readClient = null;
|
|
44864
44916
|
readVerified = false;
|
|
44865
44917
|
/** One data facade per attached tab (the first, then any follower tabs). */
|
|
@@ -45469,7 +45521,9 @@ ${end.comment}` : end.comment;
|
|
|
45469
45521
|
/** Feed one push frame to the native replica (current log session only). */
|
|
45470
45522
|
pushLog(frame) {
|
|
45471
45523
|
try {
|
|
45472
|
-
|
|
45524
|
+
const accepted = this.native?.pushLog(frame) === true;
|
|
45525
|
+
if (accepted) this.readWake?.();
|
|
45526
|
+
return accepted;
|
|
45473
45527
|
} catch {
|
|
45474
45528
|
return false;
|
|
45475
45529
|
}
|
|
@@ -45564,6 +45618,47 @@ ${end.comment}` : end.comment;
|
|
|
45564
45618
|
const ctrl = new AbortController(), abort = () => ctrl.abort();
|
|
45565
45619
|
const pump = () => local ? null : this.pump;
|
|
45566
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
|
+
};
|
|
45567
45662
|
signal.addEventListener("abort", abort, { once: true });
|
|
45568
45663
|
let timer2 = null;
|
|
45569
45664
|
let stage = "read_connect";
|
|
@@ -45666,13 +45761,14 @@ ${end.comment}` : end.comment;
|
|
|
45666
45761
|
let delay = 250;
|
|
45667
45762
|
while (!ctrl.signal.aborted) {
|
|
45668
45763
|
stage = "read_catch_up";
|
|
45764
|
+
readPushed = false;
|
|
45669
45765
|
this.native.tick();
|
|
45670
45766
|
const turn = pump();
|
|
45671
45767
|
if (turn) await Promise.race([turn.pump(), aborted]);
|
|
45672
45768
|
this.checkCollection(signal);
|
|
45673
45769
|
const observation = observe();
|
|
45674
45770
|
if (cold && initialSyncWait(observation.status) !== null) {
|
|
45675
|
-
await
|
|
45771
|
+
await waitRetry(delay);
|
|
45676
45772
|
delay = Math.min(1e3, delay * 2);
|
|
45677
45773
|
continue;
|
|
45678
45774
|
}
|
|
@@ -45691,7 +45787,7 @@ ${end.comment}` : end.comment;
|
|
|
45691
45787
|
if (!(error5 instanceof MdbaseError) || error5.code !== "unavailable" || !pump() || ctrl.signal.aborted)
|
|
45692
45788
|
throw error5;
|
|
45693
45789
|
}
|
|
45694
|
-
await
|
|
45790
|
+
await waitRetry(delay);
|
|
45695
45791
|
delay = Math.min(1e3, delay * 2);
|
|
45696
45792
|
}
|
|
45697
45793
|
throw stopped();
|
|
@@ -45703,6 +45799,8 @@ ${end.comment}` : end.comment;
|
|
|
45703
45799
|
if (timer2 !== null) clearTimeout(timer2);
|
|
45704
45800
|
signal.removeEventListener("abort", abort);
|
|
45705
45801
|
ctrl.signal.removeEventListener("abort", rejectAbort);
|
|
45802
|
+
this.readWake = null;
|
|
45803
|
+
wakeSleep = null;
|
|
45706
45804
|
this.readClient?.close();
|
|
45707
45805
|
this.readClient = null;
|
|
45708
45806
|
this.readAbort = null;
|
|
@@ -46159,6 +46257,7 @@ ${end.comment}` : end.comment;
|
|
|
46159
46257
|
let keys2 = "settled";
|
|
46160
46258
|
let push = null, paused = false, pausing = null, kicked = false;
|
|
46161
46259
|
let ended = null;
|
|
46260
|
+
let pendingEnd = null;
|
|
46162
46261
|
const attached = /* @__PURE__ */ new Map();
|
|
46163
46262
|
const timerKeys2 = /* @__PURE__ */ new Map();
|
|
46164
46263
|
const timerKey = () => {
|
|
@@ -46196,6 +46295,7 @@ ${end.comment}` : end.comment;
|
|
|
46196
46295
|
timer2 = null;
|
|
46197
46296
|
if (pausing !== null) clearTimeout(pausing);
|
|
46198
46297
|
pausing = null;
|
|
46298
|
+
pendingEnd = null;
|
|
46199
46299
|
try {
|
|
46200
46300
|
push?.close();
|
|
46201
46301
|
} catch {
|
|
@@ -46326,7 +46426,15 @@ ${end.comment}` : end.comment;
|
|
|
46326
46426
|
}
|
|
46327
46427
|
};
|
|
46328
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
|
+
};
|
|
46329
46436
|
const openPush = () => {
|
|
46437
|
+
if (push || !current3()) return;
|
|
46330
46438
|
try {
|
|
46331
46439
|
push = typeof host.openLogPush === "function" ? host.openLogPush({
|
|
46332
46440
|
push: (frame) => {
|
|
@@ -46337,19 +46445,32 @@ ${end.comment}` : end.comment;
|
|
|
46337
46445
|
live: onLive,
|
|
46338
46446
|
// Access ended: the replica has the `closed` push; drive so it
|
|
46339
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.
|
|
46340
46450
|
ended: (reason) => {
|
|
46341
|
-
|
|
46342
|
-
|
|
46343
|
-
|
|
46344
|
-
|
|
46345
|
-
|
|
46451
|
+
if (!started) {
|
|
46452
|
+
pendingEnd ??= reason;
|
|
46453
|
+
onLive(false);
|
|
46454
|
+
return;
|
|
46455
|
+
}
|
|
46456
|
+
applyEnd(reason);
|
|
46346
46457
|
}
|
|
46347
46458
|
}) : null;
|
|
46348
46459
|
} catch {
|
|
46349
46460
|
push = null;
|
|
46350
46461
|
}
|
|
46351
46462
|
if (push) {
|
|
46352
|
-
|
|
46463
|
+
try {
|
|
46464
|
+
push.start();
|
|
46465
|
+
} catch {
|
|
46466
|
+
try {
|
|
46467
|
+
push.close();
|
|
46468
|
+
} catch {
|
|
46469
|
+
}
|
|
46470
|
+
push = null;
|
|
46471
|
+
setPaused(true);
|
|
46472
|
+
return;
|
|
46473
|
+
}
|
|
46353
46474
|
onLive(false);
|
|
46354
46475
|
} else setPaused(true);
|
|
46355
46476
|
};
|
|
@@ -46656,12 +46777,18 @@ ${end.comment}` : end.comment;
|
|
|
46656
46777
|
}
|
|
46657
46778
|
}
|
|
46658
46779
|
if (!local) {
|
|
46780
|
+
openPush();
|
|
46659
46781
|
report("syncing");
|
|
46660
46782
|
await host.waitForVerifiedRead({ signal: life.signal, cold: !warm, onProgress: report });
|
|
46661
46783
|
check3();
|
|
46662
46784
|
}
|
|
46663
46785
|
started = true;
|
|
46664
46786
|
host.onLogWork?.(kick);
|
|
46787
|
+
if (pendingEnd !== null) {
|
|
46788
|
+
const reason = pendingEnd;
|
|
46789
|
+
pendingEnd = null;
|
|
46790
|
+
applyEnd(reason);
|
|
46791
|
+
}
|
|
46665
46792
|
if (local) {
|
|
46666
46793
|
keys2 = "pending";
|
|
46667
46794
|
kicked = true;
|
|
@@ -46672,7 +46799,6 @@ ${end.comment}` : end.comment;
|
|
|
46672
46799
|
}, PAUSED_AFTER_MS);
|
|
46673
46800
|
} else {
|
|
46674
46801
|
schedule();
|
|
46675
|
-
openPush();
|
|
46676
46802
|
if (warm) {
|
|
46677
46803
|
report("syncing");
|
|
46678
46804
|
await waitForWarmSync();
|
|
@@ -49976,6 +50102,11 @@ ${end.comment}` : end.comment;
|
|
|
49976
50102
|
return this.settled();
|
|
49977
50103
|
}, caller);
|
|
49978
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
|
+
}
|
|
49979
50110
|
clearSelection(options = {}) {
|
|
49980
50111
|
const caller = this.signal(options);
|
|
49981
50112
|
return this.action(async () => {
|
|
@@ -50810,12 +50941,12 @@ ${end.comment}` : end.comment;
|
|
|
50810
50941
|
// src/application/asset-pins.json
|
|
50811
50942
|
var asset_pins_default = {
|
|
50812
50943
|
runtime: {
|
|
50813
|
-
sha256: "
|
|
50814
|
-
bytes:
|
|
50815
|
-
maxBytes:
|
|
50944
|
+
sha256: "381efa4ca7c0648254068b587cf5bea04c0587b0d0b37359f6093ab78a55ee19",
|
|
50945
|
+
bytes: 4008498,
|
|
50946
|
+
maxBytes: 4008498,
|
|
50816
50947
|
source: {
|
|
50817
50948
|
repository: "mdbase-dev/mdbase-connect",
|
|
50818
|
-
commit: "
|
|
50949
|
+
commit: "48acdc9d1a95b2d299565f0df122b80d32697229"
|
|
50819
50950
|
}
|
|
50820
50951
|
},
|
|
50821
50952
|
sqlite: {
|
|
@@ -51356,11 +51487,11 @@ ${end.comment}` : end.comment;
|
|
|
51356
51487
|
if (this.closed || this.opening) return;
|
|
51357
51488
|
const s = this.session.getSnapshot();
|
|
51358
51489
|
if (this.approval) {
|
|
51359
|
-
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")) {
|
|
51360
51491
|
const a = this.approval;
|
|
51361
51492
|
this.approval = null;
|
|
51362
51493
|
this.attempted = void 0;
|
|
51363
|
-
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 });
|
|
51364
51495
|
this.refresh();
|
|
51365
51496
|
} else {
|
|
51366
51497
|
if (!this.approval.settled || inFlight(s)) return;
|
|
@@ -52912,6 +53043,7 @@ ${end.comment}` : end.comment;
|
|
|
52912
53043
|
start: refuse,
|
|
52913
53044
|
signIn: refuse,
|
|
52914
53045
|
addCollection: refuse,
|
|
53046
|
+
cancelAuthorization: refuse,
|
|
52915
53047
|
select: refuse,
|
|
52916
53048
|
approve: refuse,
|
|
52917
53049
|
reauthorize: refuse,
|
|
@@ -53140,6 +53272,12 @@ ${end.comment}` : end.comment;
|
|
|
53140
53272
|
return id6 ? this.approve(id6, options2) : selection.reauthorize(options2);
|
|
53141
53273
|
}),
|
|
53142
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
|
+
})),
|
|
53143
53281
|
refreshCollectionList: (options2) => this.track(() => Promise.all([this.call((runtime2) => runtime2.queue(() => runtime2.refreshCollections(options2))), this.privates?.refresh(this.account()).catch(() => {
|
|
53144
53282
|
})])),
|
|
53145
53283
|
requestAccess: (request3, options2) => this.requestAccess(request3, options2),
|
|
@@ -55432,6 +55570,37 @@ ${end.comment}` : end.comment;
|
|
|
55432
55570
|
return false;
|
|
55433
55571
|
}
|
|
55434
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
|
+
}
|
|
55435
55604
|
/** One scheduled approval read. If the held window was already closed, this
|
|
55436
55605
|
* read is the final one: Connect records an approval before its window
|
|
55437
55606
|
* closes, so only a still-pending, definite answer ends the wait. */
|