@mdbase-dev/sdk 0.1.0-beta.193 → 0.1.0-beta.198
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 +25 -1
- package/dist/app-host/cloud-copy-host.js +23 -14
- package/dist/app-host/cloud-copy-host.js.map +1 -1
- package/dist/app-host/index.d.ts +1 -1
- package/dist/app-host/index.js.map +1 -1
- package/dist/app-host/web-sign-in-problem.d.ts +8 -0
- package/dist/app-host/web-sign-in-problem.js +16 -4
- package/dist/app-host/web-sign-in-problem.js.map +1 -1
- package/dist/app-host/web-sign-in-session.js +5 -2
- package/dist/app-host/web-sign-in-session.js.map +1 -1
- package/dist/application/asset-pins.json +4 -4
- package/dist/application/runtime.js +31 -5
- package/dist/application/runtime.js.map +1 -1
- package/dist/application/worker.js +42 -27
- package/dist/browser/mdbase-sdk.js +65 -32
- package/dist/browser/mdbase-sdk.min.js +62 -62
- package/dist/native/provenance.json +5 -5
- package/dist/native/runtime.wasm +0 -0
- package/package.json +1 -1
|
@@ -15687,12 +15687,12 @@ function appReleaseTrust() {
|
|
|
15687
15687
|
// src/application/asset-pins.json
|
|
15688
15688
|
var asset_pins_default = {
|
|
15689
15689
|
runtime: {
|
|
15690
|
-
sha256: "
|
|
15691
|
-
bytes:
|
|
15692
|
-
maxBytes:
|
|
15690
|
+
sha256: "78cf586d0550931a912e986bc79b94b4cfdbeffa8abab0faec57824f4c5da35f",
|
|
15691
|
+
bytes: 3885861,
|
|
15692
|
+
maxBytes: 3885861,
|
|
15693
15693
|
source: {
|
|
15694
15694
|
repository: "mdbase-dev/mdbase-connect",
|
|
15695
|
-
commit: "
|
|
15695
|
+
commit: "ebfd22bfff3dd268c404637a4aefd1b876acaa2b"
|
|
15696
15696
|
}
|
|
15697
15697
|
},
|
|
15698
15698
|
sqlite: {
|
|
@@ -36782,16 +36782,18 @@ var AppCpDeviceRegistration = class {
|
|
|
36782
36782
|
|
|
36783
36783
|
// src/app-host/cloud-copy-host.ts
|
|
36784
36784
|
var AppCloudCopyHostError = class extends Error {
|
|
36785
|
-
constructor(reason) {
|
|
36786
|
-
super(`app cloud copy host: ${reason}
|
|
36785
|
+
constructor(reason, stage, options) {
|
|
36786
|
+
super(`app cloud copy host: ${reason}`, options);
|
|
36787
36787
|
this.reason = reason;
|
|
36788
|
+
this.stage = stage;
|
|
36788
36789
|
this.name = "AppCloudCopyHostError";
|
|
36789
36790
|
}
|
|
36790
36791
|
reason;
|
|
36792
|
+
stage;
|
|
36791
36793
|
};
|
|
36792
36794
|
var MAX_FACADES = 32;
|
|
36793
36795
|
var DRIVE_TURNS = 8;
|
|
36794
|
-
var fail15 = (r) => new AppCloudCopyHostError(r);
|
|
36796
|
+
var fail15 = (r, stage) => new AppCloudCopyHostError(r, stage);
|
|
36795
36797
|
var equal10 = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
36796
36798
|
var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
36797
36799
|
constructor(source, installation, originalRelease, origin4, lifetime) {
|
|
@@ -36982,7 +36984,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
36982
36984
|
await host?.close();
|
|
36983
36985
|
if (e instanceof AppCloudCopyHostError || e instanceof AppStrictDeviceApprovalError)
|
|
36984
36986
|
throw e;
|
|
36985
|
-
throw
|
|
36987
|
+
throw new AppCloudCopyHostError("unavailable", "device_open", { cause: e });
|
|
36986
36988
|
}
|
|
36987
36989
|
}
|
|
36988
36990
|
/** SAME protected installation flow -> SAME original native lifetime. No
|
|
@@ -37528,7 +37530,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37528
37530
|
nonce: async ({ signal }) => {
|
|
37529
37531
|
const r = await request3(`${origin4}/v1/nonce`, { signal, cache: "no-store", credentials: "omit", redirect: "error", referrerPolicy: "no-referrer" });
|
|
37530
37532
|
const text6 = (await r.text()).trim();
|
|
37531
|
-
if (!r.ok || !/^[0-9a-f]{64}$/.test(text6)) throw fail15("unavailable");
|
|
37533
|
+
if (!r.ok || !/^[0-9a-f]{64}$/.test(text6)) throw fail15("unavailable", "push_nonce");
|
|
37532
37534
|
return Uint8Array.from(text6.match(/../g).map((v) => parseInt(v, 16)));
|
|
37533
37535
|
},
|
|
37534
37536
|
signHello: (nonce, token) => current2() ? native.signLogHello(nonce, token) : null
|
|
@@ -37575,7 +37577,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37575
37577
|
this.checkCollection(signal);
|
|
37576
37578
|
if (!this.native || !this.collectionScope || this.adoptedEndpoint === null || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 15e3 || typeof cold !== "boolean" || typeof local !== "boolean" || cold && (local || !this.pump))
|
|
37577
37579
|
throw fail15("binding");
|
|
37578
|
-
if (local && !this.holdsLog()) return Promise.reject(fail15("unavailable"));
|
|
37580
|
+
if (local && !this.holdsLog()) return Promise.reject(fail15("unavailable", "local_read_without_log"));
|
|
37579
37581
|
if (this.readWork)
|
|
37580
37582
|
return this.readWork.then(() => {
|
|
37581
37583
|
this.checkCollection(signal);
|
|
@@ -37594,20 +37596,22 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37594
37596
|
this.readAbort = ctrl;
|
|
37595
37597
|
signal.addEventListener("abort", abort, { once: true });
|
|
37596
37598
|
let timer = null;
|
|
37597
|
-
let
|
|
37599
|
+
let stage = "read_connect";
|
|
37600
|
+
let stopError = null;
|
|
37601
|
+
const stopped = () => stopError ??= fail15(cold ? "sync_stalled" : "unavailable", stage);
|
|
37598
37602
|
let rejectAbort;
|
|
37599
37603
|
const aborted = new Promise((_resolve, reject) => {
|
|
37600
|
-
rejectAbort = () => reject(
|
|
37604
|
+
rejectAbort = () => reject(stopped());
|
|
37601
37605
|
ctrl.signal.addEventListener("abort", rejectAbort, { once: true });
|
|
37602
37606
|
});
|
|
37603
37607
|
void aborted.catch(() => {
|
|
37604
37608
|
});
|
|
37605
37609
|
let shown = null;
|
|
37606
|
-
const report = (
|
|
37607
|
-
if (
|
|
37608
|
-
shown =
|
|
37610
|
+
const report = (stage2) => {
|
|
37611
|
+
if (stage2 === shown) return;
|
|
37612
|
+
shown = stage2;
|
|
37609
37613
|
try {
|
|
37610
|
-
onProgress?.(
|
|
37614
|
+
onProgress?.(stage2);
|
|
37611
37615
|
} catch {
|
|
37612
37616
|
}
|
|
37613
37617
|
};
|
|
@@ -37682,7 +37686,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37682
37686
|
}).then((client) => {
|
|
37683
37687
|
if (ctrl.signal.aborted) {
|
|
37684
37688
|
client.close();
|
|
37685
|
-
throw
|
|
37689
|
+
throw stopped();
|
|
37686
37690
|
}
|
|
37687
37691
|
return client;
|
|
37688
37692
|
}),
|
|
@@ -37691,6 +37695,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37691
37695
|
this.checkCollection(signal);
|
|
37692
37696
|
let delay = 250;
|
|
37693
37697
|
while (!ctrl.signal.aborted) {
|
|
37698
|
+
stage = "read_catch_up";
|
|
37694
37699
|
this.native.tick();
|
|
37695
37700
|
const turn = pump();
|
|
37696
37701
|
if (turn) await Promise.race([turn.pump(), aborted]);
|
|
@@ -37701,13 +37706,14 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37701
37706
|
delay = Math.min(1e3, delay * 2);
|
|
37702
37707
|
continue;
|
|
37703
37708
|
}
|
|
37709
|
+
stage = "read_query";
|
|
37704
37710
|
try {
|
|
37705
37711
|
await Promise.race([
|
|
37706
37712
|
this.readClient.query({ limit: 1 }, { signal: ctrl.signal }),
|
|
37707
37713
|
aborted
|
|
37708
37714
|
]);
|
|
37709
37715
|
this.checkCollection(signal);
|
|
37710
|
-
if (ctrl.signal.aborted) throw
|
|
37716
|
+
if (ctrl.signal.aborted) throw stopped();
|
|
37711
37717
|
this.readVerified = true;
|
|
37712
37718
|
return;
|
|
37713
37719
|
} catch (error4) {
|
|
@@ -37718,10 +37724,10 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37718
37724
|
await waitForOpenRetry(delay, ctrl.signal);
|
|
37719
37725
|
delay = Math.min(1e3, delay * 2);
|
|
37720
37726
|
}
|
|
37721
|
-
throw
|
|
37727
|
+
throw stopped();
|
|
37722
37728
|
} catch (error4) {
|
|
37723
37729
|
this.checkCollection(signal);
|
|
37724
|
-
if (ctrl.signal.aborted) throw
|
|
37730
|
+
if (ctrl.signal.aborted) throw stopped();
|
|
37725
37731
|
throw error4;
|
|
37726
37732
|
} finally {
|
|
37727
37733
|
if (timer !== null) clearTimeout(timer);
|
|
@@ -37772,7 +37778,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37772
37778
|
const observation = this.native.observations();
|
|
37773
37779
|
if (observation.requiresReopen || observation.keyringRebuildFailed) throw fail15("recovery_required");
|
|
37774
37780
|
const wait2 = initialSyncWait(observation.status);
|
|
37775
|
-
if (wait2 === "offline" || this.pump?.transportHealth?.kind === "offline") throw fail15("unavailable");
|
|
37781
|
+
if (wait2 === "offline" || this.pump?.transportHealth?.kind === "offline") throw fail15("unavailable", "key_wait_offline");
|
|
37776
37782
|
const reason = wait2 === "waiting_for_key" ? keyWaitDetail(observation.status)?.key : void 0;
|
|
37777
37783
|
if (wait2 === null || reason !== void 0 && reason !== "reading") {
|
|
37778
37784
|
if (await locked()) return "locked";
|
|
@@ -37934,7 +37940,7 @@ var AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
|
37934
37940
|
this.collectionSql.fence();
|
|
37935
37941
|
this.authority?.close();
|
|
37936
37942
|
await this.sqlClose?.();
|
|
37937
|
-
if (fenceFailed) throw fail15("unavailable");
|
|
37943
|
+
if (fenceFailed) throw fail15("unavailable", "close_fence");
|
|
37938
37944
|
} finally {
|
|
37939
37945
|
this.key = null;
|
|
37940
37946
|
this.noise = null;
|
|
@@ -38142,7 +38148,14 @@ var AppCollectionJoinLedger = class {
|
|
|
38142
38148
|
// src/app-host/web-sign-in-problem.ts
|
|
38143
38149
|
var reasons = /* @__PURE__ */ new Set(["binding", "fenced", "busy", "open_in_another_tab", "account_confirmation_required", "recovery_account_mismatch", "outcome_unknown", "response", "refused", "expired", "recovery_required", "unavailable", "collection_migrating", "collection_not_yet_migrated", "account_suspended", "update_required", "private_device_limit", "private_device_not_allowed"]);
|
|
38144
38150
|
var domCodes = /* @__PURE__ */ new Set(["AbortError", "ConstraintError", "DataCloneError", "InvalidStateError", "NotAllowedError", "NotFoundError", "NotReadableError", "OperationError", "QuotaExceededError", "SecurityError", "TimeoutError", "TransactionInactiveError", "UnknownError", "VersionError"]);
|
|
38145
|
-
var
|
|
38151
|
+
var stages = /* @__PURE__ */ new Set(["device_open", "push_nonce", "local_read_without_log", "read_connect", "read_catch_up", "read_query", "key_wait_offline", "close_fence"]);
|
|
38152
|
+
var result = (problem4, name2, code, extra = {}) => Object.freeze({ problem: problem4, detail: Object.freeze({ name: name2, code, ...Object.fromEntries(Object.entries(extra).filter(([, v]) => v !== void 0)) }) });
|
|
38153
|
+
function hostExtra(error4) {
|
|
38154
|
+
const stage = stages.has(error4.stage) ? error4.stage : void 0;
|
|
38155
|
+
if (stage !== "device_open" || error4.cause instanceof AppCloudCopyHostError) return { stage };
|
|
38156
|
+
const { name: name2, code } = webSignInProblem(error4.cause).detail;
|
|
38157
|
+
return { stage, cause: Object.freeze({ name: name2, code }) };
|
|
38158
|
+
}
|
|
38146
38159
|
function webSignInProblem(error4) {
|
|
38147
38160
|
try {
|
|
38148
38161
|
for (const [type, name2] of [
|
|
@@ -38161,8 +38174,9 @@ function webSignInProblem(error4) {
|
|
|
38161
38174
|
if (error4 instanceof type) {
|
|
38162
38175
|
const code = error4.reason;
|
|
38163
38176
|
const server = ("server" in error4 ? sanitizeAppServerProblem(error4.server) : null) ?? void 0;
|
|
38164
|
-
|
|
38165
|
-
|
|
38177
|
+
const extra = { server, ...error4 instanceof AppCloudCopyHostError ? hostExtra(error4) : {} };
|
|
38178
|
+
if (code === "sync_stalled") return result("unavailable", name2, code, extra);
|
|
38179
|
+
return reasons.has(code) ? result(code, name2, code, extra) : result("open_failed", name2, null, extra);
|
|
38166
38180
|
}
|
|
38167
38181
|
}
|
|
38168
38182
|
if (error4 instanceof AppReplicaOwnerError && error4.reason === "busy") return result("open_in_another_tab", "AppReplicaOwnerError", "busy");
|
|
@@ -38306,6 +38320,7 @@ async function eraseAppInstallationData(scope) {
|
|
|
38306
38320
|
// src/app-host/web-sign-in-session.ts
|
|
38307
38321
|
var closedView = Object.freeze({ status: "unselected", problem: null, transport: null, live: null });
|
|
38308
38322
|
var failure = (reason) => new AppInstallationSignInError(reason);
|
|
38323
|
+
var keptDetail = (update, previous, detail) => update.problem === void 0 || update.problem === previous ? detail : void 0;
|
|
38309
38324
|
var liveOutcomes = /* @__PURE__ */ new Set(["collection_not_yet_migrated", "collection_migrating", "account_suspended", "update_required"]);
|
|
38310
38325
|
var AppWebSignInSession = class {
|
|
38311
38326
|
lifetime = new AbortController();
|
|
@@ -38432,7 +38447,7 @@ var AppWebSignInSession = class {
|
|
|
38432
38447
|
}
|
|
38433
38448
|
setBase(update) {
|
|
38434
38449
|
const { problemDetail: previousDetail, ...previous } = this.base;
|
|
38435
|
-
const detail = update.
|
|
38450
|
+
const detail = update.problemDetail ?? keptDetail(update, previous.problem, previousDetail);
|
|
38436
38451
|
this.base = Object.freeze({ ...previous, ...update, selectedCollectionId: null, signIn: this.flow?.view() ?? null, ...detail ? { problemDetail: detail } : {} });
|
|
38437
38452
|
}
|
|
38438
38453
|
/** One open collection's status, problem and transport. */
|
|
@@ -38447,7 +38462,7 @@ var AppWebSignInSession = class {
|
|
|
38447
38462
|
this.setBase({ timing });
|
|
38448
38463
|
const { problemDetail: previousDetail, unlock: previousLock, ...previous } = slot.view;
|
|
38449
38464
|
const { unlock: nextLock, ...rest } = update;
|
|
38450
|
-
const detail = update.
|
|
38465
|
+
const detail = update.problemDetail ?? keptDetail(update, previous.problem, previousDetail);
|
|
38451
38466
|
const openingProgress = (update.status ?? previous.status) === "opening" ? "openingProgress" in update ? update.openingProgress ?? null : previous.openingProgress ?? null : null;
|
|
38452
38467
|
const lock = (update.status ?? previous.status) === "needs_unlock" ? nextLock ?? previousLock ?? null : null;
|
|
38453
38468
|
slot.view = Object.freeze({ ...previous, ...rest, openingProgress, ...lock ? { unlock: lock } : {}, ...detail ? { problemDetail: detail } : {} });
|
|
@@ -44306,16 +44306,18 @@ ${end.comment}` : end.comment;
|
|
|
44306
44306
|
init_device_registration();
|
|
44307
44307
|
init_wasm_runtime();
|
|
44308
44308
|
AppCloudCopyHostError = class extends Error {
|
|
44309
|
-
constructor(reason) {
|
|
44310
|
-
super(`app cloud copy host: ${reason}
|
|
44309
|
+
constructor(reason, stage, options) {
|
|
44310
|
+
super(`app cloud copy host: ${reason}`, options);
|
|
44311
44311
|
this.reason = reason;
|
|
44312
|
+
this.stage = stage;
|
|
44312
44313
|
this.name = "AppCloudCopyHostError";
|
|
44313
44314
|
}
|
|
44314
44315
|
reason;
|
|
44316
|
+
stage;
|
|
44315
44317
|
};
|
|
44316
44318
|
MAX_FACADES = 32;
|
|
44317
44319
|
DRIVE_TURNS = 8;
|
|
44318
|
-
fail16 = (r) => new AppCloudCopyHostError(r);
|
|
44320
|
+
fail16 = (r, stage) => new AppCloudCopyHostError(r, stage);
|
|
44319
44321
|
equal10 = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
44320
44322
|
AppWebCloudCopyHost = class _AppWebCloudCopyHost {
|
|
44321
44323
|
constructor(source, installation, originalRelease, origin4, lifetime) {
|
|
@@ -44506,7 +44508,7 @@ ${end.comment}` : end.comment;
|
|
|
44506
44508
|
await host?.close();
|
|
44507
44509
|
if (e instanceof AppCloudCopyHostError || e instanceof AppStrictDeviceApprovalError)
|
|
44508
44510
|
throw e;
|
|
44509
|
-
throw
|
|
44511
|
+
throw new AppCloudCopyHostError("unavailable", "device_open", { cause: e });
|
|
44510
44512
|
}
|
|
44511
44513
|
}
|
|
44512
44514
|
/** SAME protected installation flow -> SAME original native lifetime. No
|
|
@@ -45052,7 +45054,7 @@ ${end.comment}` : end.comment;
|
|
|
45052
45054
|
nonce: async ({ signal }) => {
|
|
45053
45055
|
const r = await request3(`${origin4}/v1/nonce`, { signal, cache: "no-store", credentials: "omit", redirect: "error", referrerPolicy: "no-referrer" });
|
|
45054
45056
|
const text9 = (await r.text()).trim();
|
|
45055
|
-
if (!r.ok || !/^[0-9a-f]{64}$/.test(text9)) throw fail16("unavailable");
|
|
45057
|
+
if (!r.ok || !/^[0-9a-f]{64}$/.test(text9)) throw fail16("unavailable", "push_nonce");
|
|
45056
45058
|
return Uint8Array.from(text9.match(/../g).map((v) => parseInt(v, 16)));
|
|
45057
45059
|
},
|
|
45058
45060
|
signHello: (nonce, token) => current3() ? native.signLogHello(nonce, token) : null
|
|
@@ -45099,7 +45101,7 @@ ${end.comment}` : end.comment;
|
|
|
45099
45101
|
this.checkCollection(signal);
|
|
45100
45102
|
if (!this.native || !this.collectionScope || this.adoptedEndpoint === null || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 15e3 || typeof cold !== "boolean" || typeof local !== "boolean" || cold && (local || !this.pump))
|
|
45101
45103
|
throw fail16("binding");
|
|
45102
|
-
if (local && !this.holdsLog()) return Promise.reject(fail16("unavailable"));
|
|
45104
|
+
if (local && !this.holdsLog()) return Promise.reject(fail16("unavailable", "local_read_without_log"));
|
|
45103
45105
|
if (this.readWork)
|
|
45104
45106
|
return this.readWork.then(() => {
|
|
45105
45107
|
this.checkCollection(signal);
|
|
@@ -45118,20 +45120,22 @@ ${end.comment}` : end.comment;
|
|
|
45118
45120
|
this.readAbort = ctrl;
|
|
45119
45121
|
signal.addEventListener("abort", abort, { once: true });
|
|
45120
45122
|
let timer2 = null;
|
|
45121
|
-
let
|
|
45123
|
+
let stage = "read_connect";
|
|
45124
|
+
let stopError = null;
|
|
45125
|
+
const stopped = () => stopError ??= fail16(cold ? "sync_stalled" : "unavailable", stage);
|
|
45122
45126
|
let rejectAbort;
|
|
45123
45127
|
const aborted = new Promise((_resolve, reject) => {
|
|
45124
|
-
rejectAbort = () => reject(
|
|
45128
|
+
rejectAbort = () => reject(stopped());
|
|
45125
45129
|
ctrl.signal.addEventListener("abort", rejectAbort, { once: true });
|
|
45126
45130
|
});
|
|
45127
45131
|
void aborted.catch(() => {
|
|
45128
45132
|
});
|
|
45129
45133
|
let shown = null;
|
|
45130
|
-
const report = (
|
|
45131
|
-
if (
|
|
45132
|
-
shown =
|
|
45134
|
+
const report = (stage2) => {
|
|
45135
|
+
if (stage2 === shown) return;
|
|
45136
|
+
shown = stage2;
|
|
45133
45137
|
try {
|
|
45134
|
-
onProgress?.(
|
|
45138
|
+
onProgress?.(stage2);
|
|
45135
45139
|
} catch {
|
|
45136
45140
|
}
|
|
45137
45141
|
};
|
|
@@ -45206,7 +45210,7 @@ ${end.comment}` : end.comment;
|
|
|
45206
45210
|
}).then((client) => {
|
|
45207
45211
|
if (ctrl.signal.aborted) {
|
|
45208
45212
|
client.close();
|
|
45209
|
-
throw
|
|
45213
|
+
throw stopped();
|
|
45210
45214
|
}
|
|
45211
45215
|
return client;
|
|
45212
45216
|
}),
|
|
@@ -45215,6 +45219,7 @@ ${end.comment}` : end.comment;
|
|
|
45215
45219
|
this.checkCollection(signal);
|
|
45216
45220
|
let delay = 250;
|
|
45217
45221
|
while (!ctrl.signal.aborted) {
|
|
45222
|
+
stage = "read_catch_up";
|
|
45218
45223
|
this.native.tick();
|
|
45219
45224
|
const turn = pump();
|
|
45220
45225
|
if (turn) await Promise.race([turn.pump(), aborted]);
|
|
@@ -45225,13 +45230,14 @@ ${end.comment}` : end.comment;
|
|
|
45225
45230
|
delay = Math.min(1e3, delay * 2);
|
|
45226
45231
|
continue;
|
|
45227
45232
|
}
|
|
45233
|
+
stage = "read_query";
|
|
45228
45234
|
try {
|
|
45229
45235
|
await Promise.race([
|
|
45230
45236
|
this.readClient.query({ limit: 1 }, { signal: ctrl.signal }),
|
|
45231
45237
|
aborted
|
|
45232
45238
|
]);
|
|
45233
45239
|
this.checkCollection(signal);
|
|
45234
|
-
if (ctrl.signal.aborted) throw
|
|
45240
|
+
if (ctrl.signal.aborted) throw stopped();
|
|
45235
45241
|
this.readVerified = true;
|
|
45236
45242
|
return;
|
|
45237
45243
|
} catch (error5) {
|
|
@@ -45242,10 +45248,10 @@ ${end.comment}` : end.comment;
|
|
|
45242
45248
|
await waitForOpenRetry(delay, ctrl.signal);
|
|
45243
45249
|
delay = Math.min(1e3, delay * 2);
|
|
45244
45250
|
}
|
|
45245
|
-
throw
|
|
45251
|
+
throw stopped();
|
|
45246
45252
|
} catch (error5) {
|
|
45247
45253
|
this.checkCollection(signal);
|
|
45248
|
-
if (ctrl.signal.aborted) throw
|
|
45254
|
+
if (ctrl.signal.aborted) throw stopped();
|
|
45249
45255
|
throw error5;
|
|
45250
45256
|
} finally {
|
|
45251
45257
|
if (timer2 !== null) clearTimeout(timer2);
|
|
@@ -45296,7 +45302,7 @@ ${end.comment}` : end.comment;
|
|
|
45296
45302
|
const observation = this.native.observations();
|
|
45297
45303
|
if (observation.requiresReopen || observation.keyringRebuildFailed) throw fail16("recovery_required");
|
|
45298
45304
|
const wait2 = initialSyncWait(observation.status);
|
|
45299
|
-
if (wait2 === "offline" || this.pump?.transportHealth?.kind === "offline") throw fail16("unavailable");
|
|
45305
|
+
if (wait2 === "offline" || this.pump?.transportHealth?.kind === "offline") throw fail16("unavailable", "key_wait_offline");
|
|
45300
45306
|
const reason = wait2 === "waiting_for_key" ? keyWaitDetail(observation.status)?.key : void 0;
|
|
45301
45307
|
if (wait2 === null || reason !== void 0 && reason !== "reading") {
|
|
45302
45308
|
if (await locked()) return "locked";
|
|
@@ -45458,7 +45464,7 @@ ${end.comment}` : end.comment;
|
|
|
45458
45464
|
this.collectionSql.fence();
|
|
45459
45465
|
this.authority?.close();
|
|
45460
45466
|
await this.sqlClose?.();
|
|
45461
|
-
if (fenceFailed) throw fail16("unavailable");
|
|
45467
|
+
if (fenceFailed) throw fail16("unavailable", "close_fence");
|
|
45462
45468
|
} finally {
|
|
45463
45469
|
this.key = null;
|
|
45464
45470
|
this.noise = null;
|
|
@@ -49026,7 +49032,21 @@ ${end.comment}` : end.comment;
|
|
|
49026
49032
|
}
|
|
49027
49033
|
return Object.freeze([id6, password ? "password" : "recoveryKey", bytes10]);
|
|
49028
49034
|
}
|
|
49029
|
-
|
|
49035
|
+
function nativeCause(detail) {
|
|
49036
|
+
try {
|
|
49037
|
+
if (!detail || !NAME3.test(String(detail.name))) return void 0;
|
|
49038
|
+
const name3 = (value2) => typeof value2 === "string" && NAME3.test(value2) ? value2 : "-";
|
|
49039
|
+
let token = `${detail.name}:${name3(detail.code)}`;
|
|
49040
|
+
if (typeof detail.stage === "string" && NAME3.test(detail.stage)) token += `@${detail.stage}`;
|
|
49041
|
+
if (detail.cause && NAME3.test(String(detail.cause.name))) token += ` cause=${detail.cause.name}:${name3(detail.cause.code)}`;
|
|
49042
|
+
const status = detail.server?.status;
|
|
49043
|
+
if (Number.isInteger(status) && status >= 100 && status <= 599) token += ` http=${status}${detail.server.code && NAME3.test(detail.server.code) ? `:${detail.server.code}` : ""}`;
|
|
49044
|
+
return token;
|
|
49045
|
+
} catch {
|
|
49046
|
+
return void 0;
|
|
49047
|
+
}
|
|
49048
|
+
}
|
|
49049
|
+
var ApplicationRuntimeError, NAME3, emptyReadiness, ApplicationRuntime;
|
|
49030
49050
|
var init_runtime = __esm({
|
|
49031
49051
|
"src/application/runtime.ts"() {
|
|
49032
49052
|
"use strict";
|
|
@@ -49047,6 +49067,7 @@ ${end.comment}` : end.comment;
|
|
|
49047
49067
|
}
|
|
49048
49068
|
code;
|
|
49049
49069
|
};
|
|
49070
|
+
NAME3 = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
49050
49071
|
emptyReadiness = () => {
|
|
49051
49072
|
const facet3 = Object.freeze({ checking: false, assessment: null, problem: null });
|
|
49052
49073
|
return Object.freeze({ checking: false, assessment: null, problem: null, facets: Object.freeze({ capabilities: facet3, contracts: facet3, configuration: facet3, files: facet3, people: facet3, notifications: facet3 }) });
|
|
@@ -49194,7 +49215,7 @@ ${end.comment}` : end.comment;
|
|
|
49194
49215
|
this.snapshot = Object.freeze({ ...this.raw, status: this.stopped ? "closed" : "blocked", problem: this.stopped ? null : this.stopFailed ? "application_stop_failed" : "application_closing", selectedCollectionId: null, unlock: null, readiness: emptyReadiness() });
|
|
49195
49216
|
} else {
|
|
49196
49217
|
const readiness3 = this.scope.getReadiness() ?? emptyReadiness();
|
|
49197
|
-
let status = this.raw.status, problem7 = this.raw.problem, detail;
|
|
49218
|
+
let status = this.raw.status, problem7 = this.raw.problem, detail, native = this.raw.problemDetail;
|
|
49198
49219
|
const id6 = this.raw.selectedCollectionId;
|
|
49199
49220
|
const released = this.retiring && readiness3.problem?.code === "readiness_fenced";
|
|
49200
49221
|
const waiting = id6 !== null && (this.scope.getReadiness() === null || released) && this.portsFailed !== id6;
|
|
@@ -49206,18 +49227,21 @@ ${end.comment}` : end.comment;
|
|
|
49206
49227
|
const blocked = readiness3.problem ?? readiness3.assessment?.problem;
|
|
49207
49228
|
problem7 = blocked?.code ?? "application_readiness_unavailable";
|
|
49208
49229
|
detail = blocked?.detail;
|
|
49230
|
+
native = void 0;
|
|
49209
49231
|
}
|
|
49210
49232
|
}
|
|
49211
|
-
const diagnostic2 = `${problem7}:${detail ?? ""}`;
|
|
49233
|
+
const diagnostic2 = `${problem7}:${detail ?? nativeCause(native) ?? ""}`;
|
|
49212
49234
|
if (status === "blocked" && problem7 && diagnostic2 !== this.loggedProblem) {
|
|
49213
49235
|
this.loggedProblem = diagnostic2;
|
|
49214
49236
|
try {
|
|
49215
|
-
|
|
49237
|
+
const cause = detail ?? nativeCause(native);
|
|
49238
|
+
if (cause) console.error("mdbase application blocked:", problem7, cause);
|
|
49216
49239
|
else console.error("mdbase application blocked:", problem7);
|
|
49217
49240
|
} catch {
|
|
49218
49241
|
}
|
|
49219
49242
|
} else if (status !== "blocked") this.loggedProblem = null;
|
|
49220
|
-
|
|
49243
|
+
const { problemDetail: _native, ...raw } = this.raw;
|
|
49244
|
+
this.snapshot = Object.freeze({ ...raw, ...native ? { problemDetail: native } : {}, status, problem: problem7, openingProgress: status === "opening" ? readiness3.checking ? "checking_setup" : this.raw.openingProgress ?? null : null, collections: Object.freeze(this.raw.collections.map((value2) => Object.freeze({ ...value2 }))), readiness: readiness3 });
|
|
49221
49245
|
}
|
|
49222
49246
|
for (const listener of [...this.listeners]) try {
|
|
49223
49247
|
listener();
|
|
@@ -50295,12 +50319,12 @@ ${end.comment}` : end.comment;
|
|
|
50295
50319
|
// src/application/asset-pins.json
|
|
50296
50320
|
var asset_pins_default = {
|
|
50297
50321
|
runtime: {
|
|
50298
|
-
sha256: "
|
|
50299
|
-
bytes:
|
|
50300
|
-
maxBytes:
|
|
50322
|
+
sha256: "78cf586d0550931a912e986bc79b94b4cfdbeffa8abab0faec57824f4c5da35f",
|
|
50323
|
+
bytes: 3885861,
|
|
50324
|
+
maxBytes: 3885861,
|
|
50301
50325
|
source: {
|
|
50302
50326
|
repository: "mdbase-dev/mdbase-connect",
|
|
50303
|
-
commit: "
|
|
50327
|
+
commit: "ebfd22bfff3dd268c404637a4aefd1b876acaa2b"
|
|
50304
50328
|
}
|
|
50305
50329
|
},
|
|
50306
50330
|
sqlite: {
|
|
@@ -54045,7 +54069,14 @@ ${end.comment}` : end.comment;
|
|
|
54045
54069
|
init_cp_problem();
|
|
54046
54070
|
var reasons = /* @__PURE__ */ new Set(["binding", "fenced", "busy", "open_in_another_tab", "account_confirmation_required", "recovery_account_mismatch", "outcome_unknown", "response", "refused", "expired", "recovery_required", "unavailable", "collection_migrating", "collection_not_yet_migrated", "account_suspended", "update_required", "private_device_limit", "private_device_not_allowed"]);
|
|
54047
54071
|
var domCodes = /* @__PURE__ */ new Set(["AbortError", "ConstraintError", "DataCloneError", "InvalidStateError", "NotAllowedError", "NotFoundError", "NotReadableError", "OperationError", "QuotaExceededError", "SecurityError", "TimeoutError", "TransactionInactiveError", "UnknownError", "VersionError"]);
|
|
54048
|
-
var
|
|
54072
|
+
var stages2 = /* @__PURE__ */ new Set(["device_open", "push_nonce", "local_read_without_log", "read_connect", "read_catch_up", "read_query", "key_wait_offline", "close_fence"]);
|
|
54073
|
+
var result = (problem7, name3, code, extra = {}) => Object.freeze({ problem: problem7, detail: Object.freeze({ name: name3, code, ...Object.fromEntries(Object.entries(extra).filter(([, v]) => v !== void 0)) }) });
|
|
54074
|
+
function hostExtra(error5) {
|
|
54075
|
+
const stage = stages2.has(error5.stage) ? error5.stage : void 0;
|
|
54076
|
+
if (stage !== "device_open" || error5.cause instanceof AppCloudCopyHostError) return { stage };
|
|
54077
|
+
const { name: name3, code } = webSignInProblem(error5.cause).detail;
|
|
54078
|
+
return { stage, cause: Object.freeze({ name: name3, code }) };
|
|
54079
|
+
}
|
|
54049
54080
|
function webSignInProblem(error5) {
|
|
54050
54081
|
try {
|
|
54051
54082
|
for (const [type, name3] of [
|
|
@@ -54064,8 +54095,9 @@ ${end.comment}` : end.comment;
|
|
|
54064
54095
|
if (error5 instanceof type) {
|
|
54065
54096
|
const code = error5.reason;
|
|
54066
54097
|
const server = ("server" in error5 ? sanitizeAppServerProblem(error5.server) : null) ?? void 0;
|
|
54067
|
-
|
|
54068
|
-
|
|
54098
|
+
const extra = { server, ...error5 instanceof AppCloudCopyHostError ? hostExtra(error5) : {} };
|
|
54099
|
+
if (code === "sync_stalled") return result("unavailable", name3, code, extra);
|
|
54100
|
+
return reasons.has(code) ? result(code, name3, code, extra) : result("open_failed", name3, null, extra);
|
|
54069
54101
|
}
|
|
54070
54102
|
}
|
|
54071
54103
|
if (error5 instanceof AppReplicaOwnerError && error5.reason === "busy") return result("open_in_another_tab", "AppReplicaOwnerError", "busy");
|
|
@@ -54199,6 +54231,7 @@ ${end.comment}` : end.comment;
|
|
|
54199
54231
|
init_errors();
|
|
54200
54232
|
var closedView = Object.freeze({ status: "unselected", problem: null, transport: null, live: null });
|
|
54201
54233
|
var failure2 = (reason) => new AppInstallationSignInError(reason);
|
|
54234
|
+
var keptDetail = (update, previous, detail) => update.problem === void 0 || update.problem === previous ? detail : void 0;
|
|
54202
54235
|
var liveOutcomes = /* @__PURE__ */ new Set(["collection_not_yet_migrated", "collection_migrating", "account_suspended", "update_required"]);
|
|
54203
54236
|
var AppWebSignInSession = class {
|
|
54204
54237
|
lifetime = new AbortController();
|
|
@@ -54325,7 +54358,7 @@ ${end.comment}` : end.comment;
|
|
|
54325
54358
|
}
|
|
54326
54359
|
setBase(update) {
|
|
54327
54360
|
const { problemDetail: previousDetail, ...previous } = this.base;
|
|
54328
|
-
const detail = update.
|
|
54361
|
+
const detail = update.problemDetail ?? keptDetail(update, previous.problem, previousDetail);
|
|
54329
54362
|
this.base = Object.freeze({ ...previous, ...update, selectedCollectionId: null, signIn: this.flow?.view() ?? null, ...detail ? { problemDetail: detail } : {} });
|
|
54330
54363
|
}
|
|
54331
54364
|
/** One open collection's status, problem and transport. */
|
|
@@ -54340,7 +54373,7 @@ ${end.comment}` : end.comment;
|
|
|
54340
54373
|
this.setBase({ timing });
|
|
54341
54374
|
const { problemDetail: previousDetail, unlock: previousLock, ...previous } = slot.view;
|
|
54342
54375
|
const { unlock: nextLock, ...rest } = update;
|
|
54343
|
-
const detail = update.
|
|
54376
|
+
const detail = update.problemDetail ?? keptDetail(update, previous.problem, previousDetail);
|
|
54344
54377
|
const openingProgress = (update.status ?? previous.status) === "opening" ? "openingProgress" in update ? update.openingProgress ?? null : previous.openingProgress ?? null : null;
|
|
54345
54378
|
const lock = (update.status ?? previous.status) === "needs_unlock" ? nextLock ?? previousLock ?? null : null;
|
|
54346
54379
|
slot.view = Object.freeze({ ...previous, ...rest, openingProgress, ...lock ? { unlock: lock } : {}, ...detail ? { problemDetail: detail } : {} });
|