@mdbase-dev/sdk 0.1.19 → 0.1.22
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 +2 -1
- package/dist/app-grant/client.js +17 -3
- package/dist/app-grant/client.js.map +1 -1
- package/dist/app-grant/setup.js +27 -23
- package/dist/app-grant/setup.js.map +1 -1
- package/dist/app-host/installation-sign-in.d.ts +1 -1
- package/dist/app-host/installation-sign-in.js +8 -6
- package/dist/app-host/installation-sign-in.js.map +1 -1
- package/dist/application/asset-pins.json +4 -4
- package/dist/application/private-collections.js +12 -1
- package/dist/application/private-collections.js.map +1 -1
- package/dist/application/worker.js +12 -11
- package/dist/browser/mdbase-sdk.js +81 -46
- package/dist/browser/mdbase-sdk.min.js +40 -40
- package/dist/client.d.ts +7 -0
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/native/provenance.json +5 -5
- package/dist/native/runtime.wasm +0 -0
- package/dist/transport/relay-pipe.js +12 -5
- package/dist/transport/relay-pipe.js.map +1 -1
- package/package.json +1 -1
|
@@ -15693,12 +15693,12 @@ function appReleaseTrust() {
|
|
|
15693
15693
|
// src/application/asset-pins.json
|
|
15694
15694
|
var asset_pins_default = {
|
|
15695
15695
|
runtime: {
|
|
15696
|
-
sha256: "
|
|
15697
|
-
bytes:
|
|
15698
|
-
maxBytes:
|
|
15696
|
+
sha256: "6b32d1e00b1282e908c14b7831816cda77aa9b9f6d6b82c3a7a5686698a4ed6b",
|
|
15697
|
+
bytes: 3983181,
|
|
15698
|
+
maxBytes: 3983181,
|
|
15699
15699
|
source: {
|
|
15700
15700
|
repository: "mdbase-dev/mdbase-connect",
|
|
15701
|
-
commit: "
|
|
15701
|
+
commit: "f098508b75998959e1b5f081924a67418660da63"
|
|
15702
15702
|
}
|
|
15703
15703
|
},
|
|
15704
15704
|
sqlite: {
|
|
@@ -17251,7 +17251,7 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17251
17251
|
closed = false;
|
|
17252
17252
|
busy = false;
|
|
17253
17253
|
nativeAcknowledged = false;
|
|
17254
|
-
|
|
17254
|
+
closedPairing = null;
|
|
17255
17255
|
/** Definite authenticated pre-proof refusal only, never an HTTP unknown. */
|
|
17256
17256
|
wrongAccountRequestId = null;
|
|
17257
17257
|
lifetime = new AbortController();
|
|
@@ -17504,8 +17504,9 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17504
17504
|
if (!response2.ok) {
|
|
17505
17505
|
const error4 = value2.error;
|
|
17506
17506
|
if (!auth && response2.status === 404 && (path === "/v1/pairing-requests" || path === `/v1/pairing-requests/${this.state.requestId}/exchange` || path === `/v1/pairing-requests/${this.state.requestId}/attest`) && error4 && typeof error4 === "object" && !Array.isArray(error4) && (error4.code === "installation_pairing_expired" || error4.code === "installation_pairing_denied")) {
|
|
17507
|
-
|
|
17508
|
-
|
|
17507
|
+
const reason = error4.code === "installation_pairing_expired" ? "expired" : "refused";
|
|
17508
|
+
this.closedPairing = { requestId: this.state.requestId, reason };
|
|
17509
|
+
throw fail3(reason);
|
|
17509
17510
|
}
|
|
17510
17511
|
const server = appServerProblem(response2.status, value2, response2.headers);
|
|
17511
17512
|
const refusal2 = new AppInstallationSignInError(appServerOutcome(server) ?? "refused", server);
|
|
@@ -17545,7 +17546,7 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17545
17546
|
renewExpiredPairing() {
|
|
17546
17547
|
return this.exclusive(async () => {
|
|
17547
17548
|
const s = this.state;
|
|
17548
|
-
if (s.token || this.
|
|
17549
|
+
if (s.token || this.closedPairing?.requestId !== s.requestId) throw fail3("recovery_required");
|
|
17549
17550
|
const bytes10 = crypto.getRandomValues(new Uint8Array(32));
|
|
17550
17551
|
try {
|
|
17551
17552
|
const requestId = crypto.randomUUID(), secret = `pair_${btoa(String.fromCharCode(...bytes10)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`;
|
|
@@ -17553,7 +17554,7 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17553
17554
|
const { requestSent: _sent, ...unsent } = s;
|
|
17554
17555
|
const selection = s.selection ? withoutPortalMetadata(s.selection) : s.selection;
|
|
17555
17556
|
await this.save({ ...unsent, selection, requestId, secret, renewal: { requestId: s.requestId, secret: s.secret } });
|
|
17556
|
-
this.
|
|
17557
|
+
this.closedPairing = null;
|
|
17557
17558
|
return await this.startRequest();
|
|
17558
17559
|
} finally {
|
|
17559
17560
|
bytes10.fill(0);
|
|
@@ -17564,6 +17565,7 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17564
17565
|
if (this.state.token) return this.view();
|
|
17565
17566
|
const s = this.state;
|
|
17566
17567
|
if (s.recoveryFor && hint !== null && hint !== s.recoveryFor.collectionId) throw fail3("binding");
|
|
17568
|
+
if (this.closedPairing?.requestId === s.requestId) throw fail3(this.closedPairing.reason);
|
|
17567
17569
|
let reply;
|
|
17568
17570
|
try {
|
|
17569
17571
|
reply = await this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: s.requestId, pairing_secret: s.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: s.requestedCreateCollections, ...s.requestedPrivateDevice === true ? { requested_private_device: true } : {}, ...s.recoveryFor ? { recovery_collection_id: s.recoveryFor.collectionId } : {}, ...s.renewal ? { renewal: { request_id: s.renewal.requestId, pairing_secret: s.renewal.secret } } : {} }, ...hint ? { collection_hint: hint } : {} });
|
|
@@ -17579,7 +17581,6 @@ var AppProtectedInstallationSignIn = class _AppProtectedInstallationSignIn {
|
|
|
17579
17581
|
this.assertRecoveryTarget(v);
|
|
17580
17582
|
const uri = verificationUri(v.verification_uri, `${s.cpOrigin}/pair/${s.requestId}`, hint);
|
|
17581
17583
|
if (v.pairing_id !== s.requestId || v.pairing_secret !== s.secret || uri === null || v.installation_device !== true || v.app_id !== s.appId || v.app_origin !== s.origin || v.app_name !== this.options.appName || !Number.isSafeInteger(v.expires_in) || v.expires_in < 0 || v.expires_in > 600) throw fail3("response");
|
|
17582
|
-
this.expiredRequestId = null;
|
|
17583
17584
|
if (this.state.requestSent !== s.requestId) await this.save({ ...this.state, requestSent: s.requestId });
|
|
17584
17585
|
return Object.freeze({ ...this.view(), verificationUri: uri });
|
|
17585
17586
|
}
|
|
@@ -25966,7 +25967,7 @@ var MdbaseClient = class _MdbaseClient {
|
|
|
25966
25967
|
listeners.delete(listener);
|
|
25967
25968
|
};
|
|
25968
25969
|
} });
|
|
25969
|
-
Object.defineProperties(watch, { state: { get: () => state }, error: { get: () => error4 } });
|
|
25970
|
+
Object.defineProperties(watch, { state: { get: () => state }, error: { get: () => error4 }, cursor: { get: () => last } });
|
|
25970
25971
|
return Object.freeze(watch);
|
|
25971
25972
|
}
|
|
25972
25973
|
/** Validate `o.refs`, or every record without them. Every record is validated a
|
|
@@ -8426,7 +8426,7 @@ var MdbaseSDK = (() => {
|
|
|
8426
8426
|
listeners.delete(listener);
|
|
8427
8427
|
};
|
|
8428
8428
|
} });
|
|
8429
|
-
Object.defineProperties(watch, { state: { get: () => state2 }, error: { get: () => error5 } });
|
|
8429
|
+
Object.defineProperties(watch, { state: { get: () => state2 }, error: { get: () => error5 }, cursor: { get: () => last } });
|
|
8430
8430
|
return Object.freeze(watch);
|
|
8431
8431
|
}
|
|
8432
8432
|
/** Validate `o.refs`, or every record without them. Every record is validated a
|
|
@@ -26990,7 +26990,7 @@ ${end.comment}` : end.comment;
|
|
|
26990
26990
|
closed = false;
|
|
26991
26991
|
busy = false;
|
|
26992
26992
|
nativeAcknowledged = false;
|
|
26993
|
-
|
|
26993
|
+
closedPairing = null;
|
|
26994
26994
|
/** Definite authenticated pre-proof refusal only, never an HTTP unknown. */
|
|
26995
26995
|
wrongAccountRequestId = null;
|
|
26996
26996
|
lifetime = new AbortController();
|
|
@@ -27243,8 +27243,9 @@ ${end.comment}` : end.comment;
|
|
|
27243
27243
|
if (!response2.ok) {
|
|
27244
27244
|
const error5 = value2.error;
|
|
27245
27245
|
if (!auth && response2.status === 404 && (path === "/v1/pairing-requests" || path === `/v1/pairing-requests/${this.state.requestId}/exchange` || path === `/v1/pairing-requests/${this.state.requestId}/attest`) && error5 && typeof error5 === "object" && !Array.isArray(error5) && (error5.code === "installation_pairing_expired" || error5.code === "installation_pairing_denied")) {
|
|
27246
|
-
|
|
27247
|
-
|
|
27246
|
+
const reason = error5.code === "installation_pairing_expired" ? "expired" : "refused";
|
|
27247
|
+
this.closedPairing = { requestId: this.state.requestId, reason };
|
|
27248
|
+
throw fail3(reason);
|
|
27248
27249
|
}
|
|
27249
27250
|
const server = appServerProblem(response2.status, value2, response2.headers);
|
|
27250
27251
|
const refusal2 = new AppInstallationSignInError(appServerOutcome(server) ?? "refused", server);
|
|
@@ -27284,7 +27285,7 @@ ${end.comment}` : end.comment;
|
|
|
27284
27285
|
renewExpiredPairing() {
|
|
27285
27286
|
return this.exclusive(async () => {
|
|
27286
27287
|
const s = this.state;
|
|
27287
|
-
if (s.token || this.
|
|
27288
|
+
if (s.token || this.closedPairing?.requestId !== s.requestId) throw fail3("recovery_required");
|
|
27288
27289
|
const bytes10 = crypto.getRandomValues(new Uint8Array(32));
|
|
27289
27290
|
try {
|
|
27290
27291
|
const requestId = crypto.randomUUID(), secret = `pair_${btoa(String.fromCharCode(...bytes10)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`;
|
|
@@ -27292,7 +27293,7 @@ ${end.comment}` : end.comment;
|
|
|
27292
27293
|
const { requestSent: _sent, ...unsent } = s;
|
|
27293
27294
|
const selection = s.selection ? withoutPortalMetadata(s.selection) : s.selection;
|
|
27294
27295
|
await this.save({ ...unsent, selection, requestId, secret, renewal: { requestId: s.requestId, secret: s.secret } });
|
|
27295
|
-
this.
|
|
27296
|
+
this.closedPairing = null;
|
|
27296
27297
|
return await this.startRequest();
|
|
27297
27298
|
} finally {
|
|
27298
27299
|
bytes10.fill(0);
|
|
@@ -27303,6 +27304,7 @@ ${end.comment}` : end.comment;
|
|
|
27303
27304
|
if (this.state.token) return this.view();
|
|
27304
27305
|
const s = this.state;
|
|
27305
27306
|
if (s.recoveryFor && hint !== null && hint !== s.recoveryFor.collectionId) throw fail3("binding");
|
|
27307
|
+
if (this.closedPairing?.requestId === s.requestId) throw fail3(this.closedPairing.reason);
|
|
27306
27308
|
let reply;
|
|
27307
27309
|
try {
|
|
27308
27310
|
reply = await this.json("/v1/pairing-requests", false, { installation: { app_id: s.appId, request_id: s.requestId, pairing_secret: s.secret, installation_id: s.installationId, device_id: s.deviceId, kind: s.kind, requested_create_collections: s.requestedCreateCollections, ...s.requestedPrivateDevice === true ? { requested_private_device: true } : {}, ...s.recoveryFor ? { recovery_collection_id: s.recoveryFor.collectionId } : {}, ...s.renewal ? { renewal: { request_id: s.renewal.requestId, pairing_secret: s.renewal.secret } } : {} }, ...hint ? { collection_hint: hint } : {} });
|
|
@@ -27318,7 +27320,6 @@ ${end.comment}` : end.comment;
|
|
|
27318
27320
|
this.assertRecoveryTarget(v);
|
|
27319
27321
|
const uri = verificationUri(v.verification_uri, `${s.cpOrigin}/pair/${s.requestId}`, hint);
|
|
27320
27322
|
if (v.pairing_id !== s.requestId || v.pairing_secret !== s.secret || uri === null || v.installation_device !== true || v.app_id !== s.appId || v.app_origin !== s.origin || v.app_name !== this.options.appName || !Number.isSafeInteger(v.expires_in) || v.expires_in < 0 || v.expires_in > 600) throw fail3("response");
|
|
27321
|
-
this.expiredRequestId = null;
|
|
27322
27323
|
if (this.state.requestSent !== s.requestId) await this.save({ ...this.state, requestSent: s.requestId });
|
|
27323
27324
|
return Object.freeze({ ...this.view(), verificationUri: uri });
|
|
27324
27325
|
}
|
|
@@ -36911,7 +36912,7 @@ ${end.comment}` : end.comment;
|
|
|
36911
36912
|
}
|
|
36912
36913
|
ws.binaryType = "arraybuffer";
|
|
36913
36914
|
let opened = false;
|
|
36914
|
-
let
|
|
36915
|
+
let terminal;
|
|
36915
36916
|
let buf = new Uint8Array(0);
|
|
36916
36917
|
let onmessage = null;
|
|
36917
36918
|
let onclose = null;
|
|
@@ -36927,8 +36928,10 @@ ${end.comment}` : end.comment;
|
|
|
36927
36928
|
},
|
|
36928
36929
|
set onclose(f) {
|
|
36929
36930
|
onclose = f;
|
|
36931
|
+
if (f && terminal) f(terminal);
|
|
36930
36932
|
},
|
|
36931
36933
|
send(m2) {
|
|
36934
|
+
if (terminal) throw terminal;
|
|
36932
36935
|
if (m2.length > 65535) throw mdbaseError("too_large", "Noise message over 65535 bytes");
|
|
36933
36936
|
const f = new Uint8Array(4 + m2.length);
|
|
36934
36937
|
new DataView(f.buffer).setUint32(0, m2.length);
|
|
@@ -36943,8 +36946,9 @@ ${end.comment}` : end.comment;
|
|
|
36943
36946
|
}
|
|
36944
36947
|
};
|
|
36945
36948
|
const fail20 = (e) => {
|
|
36946
|
-
if (
|
|
36947
|
-
|
|
36949
|
+
if (terminal) return;
|
|
36950
|
+
terminal = e;
|
|
36951
|
+
if (!opened) {
|
|
36948
36952
|
signal?.removeEventListener("abort", onAbort);
|
|
36949
36953
|
reject(e);
|
|
36950
36954
|
} else onclose?.(e);
|
|
@@ -36967,6 +36971,7 @@ ${end.comment}` : end.comment;
|
|
|
36967
36971
|
);
|
|
36968
36972
|
};
|
|
36969
36973
|
ws.onmessage = (ev) => {
|
|
36974
|
+
if (terminal) return;
|
|
36970
36975
|
const d = ev.data;
|
|
36971
36976
|
if (typeof d === "string") {
|
|
36972
36977
|
let msg;
|
|
@@ -36977,12 +36982,11 @@ ${end.comment}` : end.comment;
|
|
|
36977
36982
|
}
|
|
36978
36983
|
if (msg.type === "pipe_opened" && !opened) {
|
|
36979
36984
|
opened = true;
|
|
36980
|
-
settled2 = true;
|
|
36981
36985
|
signal?.removeEventListener("abort", onAbort);
|
|
36982
36986
|
resolve2(carrier);
|
|
36983
36987
|
} else if (msg.type === "pipe_close") {
|
|
36984
|
-
ws.close();
|
|
36985
36988
|
fail20(pipeCloseError(4e3, msg.reason));
|
|
36989
|
+
ws.close();
|
|
36986
36990
|
}
|
|
36987
36991
|
return;
|
|
36988
36992
|
}
|
|
@@ -37373,10 +37377,15 @@ ${end.comment}` : end.comment;
|
|
|
37373
37377
|
const plans = /* @__PURE__ */ new WeakMap();
|
|
37374
37378
|
const noops = /* @__PURE__ */ new WeakSet();
|
|
37375
37379
|
let busy2 = false;
|
|
37380
|
+
let release;
|
|
37376
37381
|
async function exclusive2(work) {
|
|
37377
37382
|
if (busy2) throw mdbaseError("rate_limited", "A setup operation is already running.");
|
|
37378
37383
|
busy2 = true;
|
|
37379
37384
|
try {
|
|
37385
|
+
if (release) {
|
|
37386
|
+
await release;
|
|
37387
|
+
release = void 0;
|
|
37388
|
+
}
|
|
37380
37389
|
return await work();
|
|
37381
37390
|
} finally {
|
|
37382
37391
|
busy2 = false;
|
|
@@ -37448,42 +37457,45 @@ ${end.comment}` : end.comment;
|
|
|
37448
37457
|
return Object.freeze({ ...result2, changes, summary: `This app will make ${changes.length} ${changes.length === 1 ? "change" : "changes"} to this collection.` });
|
|
37449
37458
|
}
|
|
37450
37459
|
const shown = (p, review) => JSON.stringify([p.status, p.canApply, p.summary, p.changes, p.conflicts, p.adoptable, p.packs, p.staged, p.records, p.refusal ?? null, review.promoted, review.retained]);
|
|
37460
|
+
async function plan(options) {
|
|
37461
|
+
await fence(void 0, options.signal);
|
|
37462
|
+
if (!declared) {
|
|
37463
|
+
if (input.operations.includes("apply_collection_setup") || input.operations.includes("assess_collection_setup")) throw unavailable4();
|
|
37464
|
+
const empty2 = setupPlan({ status: "current", assessmentDigest: `sha256:${"0".repeat(64)}`, review: { configuration: [], packs: [], staged: [] } }, { canManage: false, canCreateRecords: false, records: [] });
|
|
37465
|
+
noops.add(empty2);
|
|
37466
|
+
return empty2;
|
|
37467
|
+
}
|
|
37468
|
+
await reconcile(options.signal);
|
|
37469
|
+
const { s, review, options: original } = await native(options);
|
|
37470
|
+
const result2 = word(s, review);
|
|
37471
|
+
plans.set(result2, { session: s, review, options: original, consumed: false });
|
|
37472
|
+
return result2;
|
|
37473
|
+
}
|
|
37451
37474
|
const api = {
|
|
37452
|
-
|
|
37453
|
-
const p = await api.plan(options), bound = plans.get(p);
|
|
37454
|
-
if (bound) {
|
|
37455
|
-
await cancel(bound.session, bound.review.ticket);
|
|
37456
|
-
await fence(bound.session, options.signal);
|
|
37457
|
-
}
|
|
37458
|
-
return p.status === "current" ? "ready" : p.status === "conflict" ? "incompatible" : "setup_required";
|
|
37459
|
-
},
|
|
37460
|
-
async plan(options = {}) {
|
|
37475
|
+
assess(options = {}) {
|
|
37461
37476
|
return exclusive2(async () => {
|
|
37462
|
-
await
|
|
37463
|
-
if (
|
|
37464
|
-
|
|
37465
|
-
|
|
37466
|
-
|
|
37467
|
-
|
|
37468
|
-
}
|
|
37469
|
-
await reconcile(options.signal);
|
|
37470
|
-
const { s, review, options: original } = await native(options);
|
|
37471
|
-
const result2 = word(s, review);
|
|
37472
|
-
plans.set(result2, { session: s, review, options: original, consumed: false });
|
|
37473
|
-
return result2;
|
|
37477
|
+
const p = await plan(options), bound = plans.get(p);
|
|
37478
|
+
if (bound) {
|
|
37479
|
+
release = cancel(bound.session, bound.review.ticket);
|
|
37480
|
+
await fence(bound.session, options.signal);
|
|
37481
|
+
}
|
|
37482
|
+
return p.status === "current" ? "ready" : p.status === "conflict" ? "incompatible" : "setup_required";
|
|
37474
37483
|
});
|
|
37475
37484
|
},
|
|
37476
|
-
|
|
37485
|
+
plan(options = {}) {
|
|
37486
|
+
return exclusive2(() => plan(options));
|
|
37487
|
+
},
|
|
37488
|
+
async apply(plan2, options = {}) {
|
|
37477
37489
|
return exclusive2(async () => {
|
|
37478
|
-
if (noops.has(
|
|
37490
|
+
if (noops.has(plan2)) {
|
|
37479
37491
|
await fence(void 0, options.signal);
|
|
37480
37492
|
return "ready";
|
|
37481
37493
|
}
|
|
37482
|
-
let bound = plans.get(
|
|
37494
|
+
let bound = plans.get(plan2);
|
|
37483
37495
|
if (!bound) throw new TypeError("setup.apply needs the original plan returned by setup.plan");
|
|
37484
37496
|
if (bound.consumed) throw changed();
|
|
37485
|
-
if (
|
|
37486
|
-
if (
|
|
37497
|
+
if (plan2.refusal) throw mdbaseError(plan2.refusal.code === "setup_conflict" ? "conflict" : "forbidden", plan2.refusal.message, plan2.refusal.code);
|
|
37498
|
+
if (plan2.status === "current") {
|
|
37487
37499
|
await fence(bound.session, options.signal);
|
|
37488
37500
|
const after = await native({ signal: options.signal });
|
|
37489
37501
|
await cancel(after.s, after.review.ticket);
|
|
@@ -37526,7 +37538,7 @@ ${end.comment}` : end.comment;
|
|
|
37526
37538
|
const fresh = await native({ ...bound.options, signal: options.signal });
|
|
37527
37539
|
try {
|
|
37528
37540
|
await fence(fresh.s, options.signal);
|
|
37529
|
-
if (fresh.review.assessment.status !== "provision" || shown(word(fresh.s, fresh.review), fresh.review) !== shown(
|
|
37541
|
+
if (fresh.review.assessment.status !== "provision" || shown(word(fresh.s, fresh.review), fresh.review) !== shown(plan2, bound.review)) throw changed(mid, e);
|
|
37530
37542
|
} catch (error5) {
|
|
37531
37543
|
await cancel(fresh.s, fresh.review.ticket);
|
|
37532
37544
|
throw error5;
|
|
@@ -37998,6 +38010,7 @@ ${end.comment}` : end.comment;
|
|
|
37998
38010
|
storeValue;
|
|
37999
38011
|
registration = null;
|
|
38000
38012
|
tokens = /* @__PURE__ */ new Map();
|
|
38013
|
+
routeProbe;
|
|
38001
38014
|
refreshing = /* @__PURE__ */ new Map();
|
|
38002
38015
|
forgotten = /* @__PURE__ */ new Set();
|
|
38003
38016
|
/** Bumped by every whole-store wipe: work prepared under an older epoch
|
|
@@ -38466,8 +38479,14 @@ ${end.comment}` : end.comment;
|
|
|
38466
38479
|
/** The collection's availability now, from its route. Never throws for `unavailable`. */
|
|
38467
38480
|
async availability(collection2, options = {}) {
|
|
38468
38481
|
const id6 = collection2.toLowerCase();
|
|
38482
|
+
const probe = this.routeProbe = {};
|
|
38469
38483
|
try {
|
|
38470
|
-
|
|
38484
|
+
const { token, route: route2, availability } = await this.route(id6, options.signal);
|
|
38485
|
+
const credentials = this.tokens.get(id6);
|
|
38486
|
+
if (availability.state === "available" && !options.signal?.aborted && credentials?.access === token) {
|
|
38487
|
+
probe.ready = { credentials, route: route2, until: performance.now() + 3e3, signal: options.signal };
|
|
38488
|
+
}
|
|
38489
|
+
return availability;
|
|
38471
38490
|
} catch (e) {
|
|
38472
38491
|
const reason = isMdbaseError(e) ? fieldOf(e.details, "availability") : void 0;
|
|
38473
38492
|
if (typeof reason === "string") {
|
|
@@ -38505,7 +38524,7 @@ ${end.comment}` : end.comment;
|
|
|
38505
38524
|
}
|
|
38506
38525
|
}
|
|
38507
38526
|
/**
|
|
38508
|
-
* A connector for `connect()`:
|
|
38527
|
+
* A connector for `connect()`: each open uses a fresh route, refuses an
|
|
38509
38528
|
* unavailable collection with its reason, and opens a Noise IK session through the
|
|
38510
38529
|
* relay to a serving device (sticky while it stays listed). The first open pins
|
|
38511
38530
|
* its original consent/key identity; new consent requires a new connector.
|
|
@@ -38519,6 +38538,8 @@ ${end.comment}` : end.comment;
|
|
|
38519
38538
|
return registerNextRelayFence({
|
|
38520
38539
|
description: `app-grant:${id6}`,
|
|
38521
38540
|
open: async (hello, signal) => {
|
|
38541
|
+
const primed = original === void 0 ? this.routeProbe?.ready : void 0;
|
|
38542
|
+
this.routeProbe = void 0;
|
|
38522
38543
|
const grant = await (original ??= this.heldGrant(id6));
|
|
38523
38544
|
await this.assertCurrent(grant);
|
|
38524
38545
|
const connector = noiseConnector({
|
|
@@ -38526,7 +38547,7 @@ ${end.comment}` : end.comment;
|
|
|
38526
38547
|
staticKey: staticKeyOf2(grant),
|
|
38527
38548
|
target: async (s) => {
|
|
38528
38549
|
await this.assertCurrent(grant);
|
|
38529
|
-
const { token, route: route2, availability } = await this.route(id6, s);
|
|
38550
|
+
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, s);
|
|
38530
38551
|
await this.assertCurrent(grant);
|
|
38531
38552
|
if (availability.state === "unavailable") throw collectionUnavailableError(availability.reason);
|
|
38532
38553
|
if (!UUID10.test(route2.grant)) throw mdbaseError("unauthenticated", "the route names no grant", "route_mismatch");
|
|
@@ -38625,6 +38646,7 @@ ${end.comment}` : end.comment;
|
|
|
38625
38646
|
await store2.deleteGrant(id6);
|
|
38626
38647
|
this.forgotten.add(id6);
|
|
38627
38648
|
this.tokens.delete(id6);
|
|
38649
|
+
this.routeProbe = void 0;
|
|
38628
38650
|
});
|
|
38629
38651
|
}
|
|
38630
38652
|
/**
|
|
@@ -38643,6 +38665,7 @@ ${end.comment}` : end.comment;
|
|
|
38643
38665
|
* or runs after and fails its revision/epoch check instead of re-saving.
|
|
38644
38666
|
*/
|
|
38645
38667
|
async forgetAllGrants() {
|
|
38668
|
+
this.routeProbe = void 0;
|
|
38646
38669
|
this.epoch++;
|
|
38647
38670
|
const store2 = await this.store();
|
|
38648
38671
|
let ids = [];
|
|
@@ -50755,12 +50778,12 @@ ${end.comment}` : end.comment;
|
|
|
50755
50778
|
// src/application/asset-pins.json
|
|
50756
50779
|
var asset_pins_default = {
|
|
50757
50780
|
runtime: {
|
|
50758
|
-
sha256: "
|
|
50759
|
-
bytes:
|
|
50760
|
-
maxBytes:
|
|
50781
|
+
sha256: "6b32d1e00b1282e908c14b7831816cda77aa9b9f6d6b82c3a7a5686698a4ed6b",
|
|
50782
|
+
bytes: 3983181,
|
|
50783
|
+
maxBytes: 3983181,
|
|
50761
50784
|
source: {
|
|
50762
50785
|
repository: "mdbase-dev/mdbase-connect",
|
|
50763
|
-
commit: "
|
|
50786
|
+
commit: "f098508b75998959e1b5f081924a67418660da63"
|
|
50764
50787
|
}
|
|
50765
50788
|
},
|
|
50766
50789
|
sqlite: {
|
|
@@ -52460,10 +52483,21 @@ ${end.comment}` : end.comment;
|
|
|
52460
52483
|
bind(account, grants) {
|
|
52461
52484
|
const next = grants.filter((c) => c.account_id === account);
|
|
52462
52485
|
if (this.bindingsAccount === account && JSON.stringify(next) === JSON.stringify(this.bindings)) return;
|
|
52486
|
+
const previous = this.bindings;
|
|
52463
52487
|
this.bindingsAccount = account;
|
|
52464
52488
|
this.bindings = Object.freeze([...next]);
|
|
52465
52489
|
this.settled = null;
|
|
52466
52490
|
this.listed = null;
|
|
52491
|
+
const open2 = this.open;
|
|
52492
|
+
if (open2) {
|
|
52493
|
+
const original = previous?.find((c) => c.collection_id === open2.id);
|
|
52494
|
+
const replacement = next.find((c) => c.collection_id === open2.id);
|
|
52495
|
+
if (!replacement || account !== open2.scope.account) this.close(false);
|
|
52496
|
+
else if (replacement.grant_id !== original?.grant_id || replacement.client_noise_public_key !== original?.client_noise_public_key) {
|
|
52497
|
+
void this.openCollection(open2.id, open2.scope).catch(() => {
|
|
52498
|
+
});
|
|
52499
|
+
}
|
|
52500
|
+
}
|
|
52467
52501
|
this.setList([]);
|
|
52468
52502
|
}
|
|
52469
52503
|
async nativeAuthorization(call2, portal, signal) {
|
|
@@ -52580,6 +52614,7 @@ ${end.comment}` : end.comment;
|
|
|
52580
52614
|
this.close(false);
|
|
52581
52615
|
const open2 = {
|
|
52582
52616
|
id: collectionId,
|
|
52617
|
+
scope,
|
|
52583
52618
|
life: new AbortController(),
|
|
52584
52619
|
client: null,
|
|
52585
52620
|
setup: null,
|