@mdbase-dev/sdk 0.1.0-beta.186 → 0.1.0-beta.187
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/README.md +29 -0
- package/dist/app-host/installation-sign-in.d.ts +3 -0
- package/dist/app-host/installation-sign-in.js +11 -2
- package/dist/app-host/installation-sign-in.js.map +1 -1
- package/dist/app-host/web-sign-in-session.d.ts +2 -0
- package/dist/app-host/web-sign-in-session.js +25 -3
- package/dist/app-host/web-sign-in-session.js.map +1 -1
- package/dist/application/asset-pins.json +4 -4
- package/dist/application/entry.d.ts +19 -2
- package/dist/application/entry.js +25 -5
- package/dist/application/entry.js.map +1 -1
- package/dist/application/packaged-assets.d.ts +5 -2
- package/dist/application/packaged-assets.js +9 -6
- package/dist/application/packaged-assets.js.map +1 -1
- package/dist/application/worker.js +41 -16
- package/dist/application/worker.js.map +1 -1
- package/dist/browser/mdbase-sdk.js +50 -16
- package/dist/browser/mdbase-sdk.min.js +20 -20
- package/dist/native/provenance.json +5 -5
- package/dist/native/runtime.wasm +0 -0
- package/package.json +1 -1
|
@@ -30021,7 +30021,7 @@ ${end.comment}` : end.comment;
|
|
|
30021
30021
|
const base = "version,requestId,installationId,deviceId,secret,appId,kind,origin,cpOrigin,environment,selection,confirmed,nativeStarted,proof,token";
|
|
30022
30022
|
const legacy = parsed?.version === 1;
|
|
30023
30023
|
const fields3 = `${base},requestedCreateCollections,collectionIds,createCollections,consentRequest`;
|
|
30024
|
-
const r = legacy ? { ...object5(parsed, base), version: 3, renewal: null, requestedCreateCollections: false, collectionIds: [], createCollections: false, consentRequest: null } : parsed?.version === 2 ? { ...object5(parsed, fields3), version: 3, renewal: null } : object5(parsed, `${fields3},renewal${Object.hasOwn(parsed, "collectionSelection") ? ",collectionSelection" : ""}${Object.hasOwn(parsed, "timerConsent") ? ",timerConsent" : ""}${Object.hasOwn(parsed, "timerChannel") ? ",timerChannel" : ""}${Object.hasOwn(parsed, "owner") ? ",owner" : ""}${Object.hasOwn(parsed, "collectionListing") ? ",collectionListing" : ""}${Object.hasOwn(parsed, "collectionRecoveries") ? ",collectionRecoveries" : ""}${Object.hasOwn(parsed, "recoveryFor") ? ",recoveryFor" : ""}${Object.hasOwn(parsed, "nativeAuthorization") ? ",nativeAuthorization" : ""}${Object.hasOwn(parsed, "nativeSelection") ? ",nativeSelection" : ""}${Object.hasOwn(parsed, "nativeGrants") ? ",nativeGrants" : ""}${Object.hasOwn(parsed, "requestedPrivateDevice") ? ",requestedPrivateDevice" : ""}${Object.hasOwn(parsed, "privateDeviceCollectionIds") ? ",privateDeviceCollectionIds" : ""}`);
|
|
30024
|
+
const r = legacy ? { ...object5(parsed, base), version: 3, renewal: null, requestedCreateCollections: false, collectionIds: [], createCollections: false, consentRequest: null } : parsed?.version === 2 ? { ...object5(parsed, fields3), version: 3, renewal: null } : object5(parsed, `${fields3},renewal${Object.hasOwn(parsed, "collectionSelection") ? ",collectionSelection" : ""}${Object.hasOwn(parsed, "timerConsent") ? ",timerConsent" : ""}${Object.hasOwn(parsed, "timerChannel") ? ",timerChannel" : ""}${Object.hasOwn(parsed, "owner") ? ",owner" : ""}${Object.hasOwn(parsed, "collectionListing") ? ",collectionListing" : ""}${Object.hasOwn(parsed, "collectionRecoveries") ? ",collectionRecoveries" : ""}${Object.hasOwn(parsed, "recoveryFor") ? ",recoveryFor" : ""}${Object.hasOwn(parsed, "nativeAuthorization") ? ",nativeAuthorization" : ""}${Object.hasOwn(parsed, "nativeSelection") ? ",nativeSelection" : ""}${Object.hasOwn(parsed, "nativeGrants") ? ",nativeGrants" : ""}${Object.hasOwn(parsed, "requestedPrivateDevice") ? ",requestedPrivateDevice" : ""}${Object.hasOwn(parsed, "privateDeviceCollectionIds") ? ",privateDeviceCollectionIds" : ""}${Object.hasOwn(parsed, "requestSent") ? ",requestSent" : ""}`);
|
|
30025
30025
|
if (r.version !== 3 || r.appId !== p.appId || r.owner !== p.owner || r.kind !== (p.installationKind ?? "app-runtime") || r.origin !== p.origin || r.cpOrigin !== p.cpOrigin || r.environment !== p.environment || typeof r.confirmed !== "boolean" || typeof r.nativeStarted !== "boolean") throw fail3("recovery_required");
|
|
30026
30026
|
const s = r;
|
|
30027
30027
|
if (typeof s.requestedCreateCollections !== "boolean" || typeof s.createCollections !== "boolean" || p.requestedCreateCollections !== void 0 && p.requestedCreateCollections !== s.requestedCreateCollections) throw fail3("binding");
|
|
@@ -30065,6 +30065,7 @@ ${end.comment}` : end.comment;
|
|
|
30065
30065
|
text4(r2.secret, /^pair_[A-Za-z0-9_-]{43}$/);
|
|
30066
30066
|
if (r2.requestId === s.requestId || r2.secret === s.secret) throw fail3("recovery_required");
|
|
30067
30067
|
}
|
|
30068
|
+
if (s.requestSent !== void 0 && s.requestSent !== s.requestId) throw fail3("recovery_required");
|
|
30068
30069
|
if (s.timerChannel !== void 0) {
|
|
30069
30070
|
if (!s.token || !s.selection) throw fail3("recovery_required");
|
|
30070
30071
|
try {
|
|
@@ -30266,7 +30267,8 @@ ${end.comment}` : end.comment;
|
|
|
30266
30267
|
try {
|
|
30267
30268
|
const requestId = crypto.randomUUID(), secret = `pair_${btoa(String.fromCharCode(...bytes10)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")}`;
|
|
30268
30269
|
if (requestId === s.requestId || requestId === s.renewal?.requestId || secret === s.secret) throw fail3("binding");
|
|
30269
|
-
|
|
30270
|
+
const { requestSent: _sent, ...unsent } = s;
|
|
30271
|
+
await this.save({ ...unsent, requestId, secret, renewal: { requestId: s.requestId, secret: s.secret } });
|
|
30270
30272
|
this.expiredRequestId = null;
|
|
30271
30273
|
return await this.startRequest();
|
|
30272
30274
|
} finally {
|
|
@@ -30294,6 +30296,7 @@ ${end.comment}` : end.comment;
|
|
|
30294
30296
|
const uri = verificationUri(v.verification_uri, `${s.cpOrigin}/pair/${s.requestId}`, hint);
|
|
30295
30297
|
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");
|
|
30296
30298
|
this.expiredRequestId = null;
|
|
30299
|
+
if (this.state.requestSent !== s.requestId) await this.save({ ...this.state, requestSent: s.requestId });
|
|
30297
30300
|
return Object.freeze({ ...this.view(), verificationUri: uri });
|
|
30298
30301
|
}
|
|
30299
30302
|
/** Scoped replies must echo the immutable protected CID. Legacy normal
|
|
@@ -30795,6 +30798,12 @@ ${end.comment}` : end.comment;
|
|
|
30795
30798
|
}
|
|
30796
30799
|
});
|
|
30797
30800
|
}
|
|
30801
|
+
/** A sign-in gesture sent this pending request and Connect accepted it: a
|
|
30802
|
+
* restarted session may keep reading it. False once signed in. */
|
|
30803
|
+
requestSent() {
|
|
30804
|
+
this.check();
|
|
30805
|
+
return !this.state.token && this.state.requestSent === this.state.requestId;
|
|
30806
|
+
}
|
|
30798
30807
|
/** True when this installation registered a Web Push channel (so a browser
|
|
30799
30808
|
* push subscription exists for the app). Metadata only. */
|
|
30800
30809
|
hasWebPushChannel() {
|
|
@@ -50052,12 +50061,12 @@ ${end.comment}` : end.comment;
|
|
|
50052
50061
|
// src/application/asset-pins.json
|
|
50053
50062
|
var asset_pins_default = {
|
|
50054
50063
|
runtime: {
|
|
50055
|
-
sha256: "
|
|
50056
|
-
bytes:
|
|
50057
|
-
maxBytes:
|
|
50064
|
+
sha256: "7004351583c3a79411e644fafe9f5786816d32ea058605d1905fd50666012f40",
|
|
50065
|
+
bytes: 3875815,
|
|
50066
|
+
maxBytes: 3875815,
|
|
50058
50067
|
source: {
|
|
50059
50068
|
repository: "mdbase-dev/mdbase-connect",
|
|
50060
|
-
commit: "
|
|
50069
|
+
commit: "aae332572834fbfa065c0f696017c0de3540649d"
|
|
50061
50070
|
}
|
|
50062
50071
|
},
|
|
50063
50072
|
sqlite: {
|
|
@@ -50080,16 +50089,16 @@ ${end.comment}` : end.comment;
|
|
|
50080
50089
|
var runtime = Object.freeze({ sha256: asset_pins_default.runtime.sha256, bytes: asset_pins_default.runtime.bytes, maxBytes: asset_pins_default.runtime.maxBytes });
|
|
50081
50090
|
var sqlite = Object.freeze({ sha256: asset_pins_default.sqlite.sha256, bytes: asset_pins_default.sqlite.bytes, maxBytes: asset_pins_default.sqlite.maxBytes });
|
|
50082
50091
|
var unavailable = () => mdbaseError("unavailable", "SDK packaged application assets unavailable", "application_packaged_assets_unavailable");
|
|
50083
|
-
function packagedApplicationAssets(environment, appOrigin) {
|
|
50092
|
+
function packagedApplicationAssets(environment, appOrigin, anchor) {
|
|
50084
50093
|
if (!applicationEnvironmentAllowed(environment)) throw unavailable();
|
|
50085
50094
|
const release = appReleaseTrust();
|
|
50086
50095
|
selectAppEnvironment({ environment, appOrigin, release });
|
|
50087
50096
|
let runtimeUrl, sqliteUrl;
|
|
50088
50097
|
try {
|
|
50089
|
-
const module = new URL(import_meta.url);
|
|
50098
|
+
const module = new URL(anchor ?? import_meta.url);
|
|
50090
50099
|
if (urlOrigin(module) !== appOrigin || module.username || module.password) throw unavailable();
|
|
50091
|
-
runtimeUrl = new URL("../native/runtime.wasm", import_meta.url);
|
|
50092
|
-
sqliteUrl = new URL("../native/sqlite3.wasm", import_meta.url);
|
|
50100
|
+
runtimeUrl = anchor === void 0 ? new URL("../native/runtime.wasm", import_meta.url) : new URL("../native/runtime.wasm", module);
|
|
50101
|
+
sqliteUrl = anchor === void 0 ? new URL("../native/sqlite3.wasm", import_meta.url) : new URL("../native/sqlite3.wasm", module);
|
|
50093
50102
|
if (urlOrigin(runtimeUrl) !== appOrigin || urlOrigin(sqliteUrl) !== appOrigin) throw unavailable();
|
|
50094
50103
|
} catch {
|
|
50095
50104
|
throw unavailable();
|
|
@@ -50098,7 +50107,7 @@ ${end.comment}` : end.comment;
|
|
|
50098
50107
|
const initializeSqlite = async (options) => {
|
|
50099
50108
|
const WorkerScope = globalThis.WorkerGlobalScope;
|
|
50100
50109
|
if (typeof WorkerScope !== "function" || !(globalThis instanceof WorkerScope)) throw unavailable();
|
|
50101
|
-
const initializer = new URL("../native/sqlite3.js", import_meta.url);
|
|
50110
|
+
const initializer = anchor === void 0 ? new URL("../native/sqlite3.js", import_meta.url) : new URL("../native/sqlite3.js", anchor);
|
|
50102
50111
|
const { default: initialize } = await import(
|
|
50103
50112
|
/* @vite-ignore */
|
|
50104
50113
|
/* webpackIgnore: true */
|
|
@@ -52135,6 +52144,7 @@ ${end.comment}` : end.comment;
|
|
|
52135
52144
|
signOut: refuse
|
|
52136
52145
|
});
|
|
52137
52146
|
}
|
|
52147
|
+
var isWorker = (value2) => typeof value2 === "object" && value2 !== null && ["postMessage", "terminate", "addEventListener", "removeEventListener"].every((name3) => typeof value2[name3] === "function");
|
|
52138
52148
|
var browserHost = (origin4) => typeof Worker === "function" && typeof MessageChannel === "function" && currentAppOrigin() !== null && isAppOrigin(origin4);
|
|
52139
52149
|
function signInOpener(value2, declaration) {
|
|
52140
52150
|
if (value2 === void 0) return null;
|
|
@@ -52227,6 +52237,7 @@ ${end.comment}` : end.comment;
|
|
|
52227
52237
|
pendingSave = null;
|
|
52228
52238
|
signIn;
|
|
52229
52239
|
typeIssues;
|
|
52240
|
+
createWorker;
|
|
52230
52241
|
/** SDK-10: this tab's Private collections (page-side thin clients, never the Worker). */
|
|
52231
52242
|
privates = null;
|
|
52232
52243
|
/** Open the unsynced collection when started signed out; tried once per start. */
|
|
@@ -52243,6 +52254,9 @@ ${end.comment}` : end.comment;
|
|
|
52243
52254
|
if (typeIssues !== "block" && typeIssues !== "degrade") throw new TypeError('readiness.typeIssues must be "block" or "degrade"');
|
|
52244
52255
|
this.typeIssues = typeIssues;
|
|
52245
52256
|
this.unsyncedFirst = options.unsynced === true;
|
|
52257
|
+
if (options.urlSelection !== void 0 && typeof options.urlSelection !== "boolean") throw new TypeError("urlSelection must be a boolean");
|
|
52258
|
+
if (options.worker !== void 0 && typeof options.worker !== "function") throw new TypeError("worker must be a function");
|
|
52259
|
+
this.createWorker = options.worker ?? null;
|
|
52246
52260
|
this.signIn = signInOpener(options.signIn, this.declaration);
|
|
52247
52261
|
if (!browserHost(this.declaration.origin)) {
|
|
52248
52262
|
this.app = unavailableApplication();
|
|
@@ -52266,7 +52280,7 @@ ${end.comment}` : end.comment;
|
|
|
52266
52280
|
this.notify();
|
|
52267
52281
|
} });
|
|
52268
52282
|
this.selection = new ApplicationCollectionSelection({
|
|
52269
|
-
browser: new ApplicationBrowserSelection(this.declaration.origin, {}, browserApplicationSelectionPort()),
|
|
52283
|
+
browser: new ApplicationBrowserSelection(this.declaration.origin, {}, options.urlSelection === false ? null : browserApplicationSelectionPort()),
|
|
52270
52284
|
session: this.selectionSession(),
|
|
52271
52285
|
memory: this.memory
|
|
52272
52286
|
});
|
|
@@ -52723,8 +52737,13 @@ ${end.comment}` : end.comment;
|
|
|
52723
52737
|
if (role2.kind === "follower") return install(new ApplicationRuntime2({ declaration, compiledManifest: this.compiled, typeIssues: this.typeIssues, cpOrigin: environment.cpOrigin, port: role2.port, binding: role2.binding, releaseWorker: () => role2.leave(), nativeAuthorization: (call2, portal, signal) => this.nativeAuthorization(call2, portal, signal) }));
|
|
52724
52738
|
const channel = new MessageChannel(), binding2 = crypto.randomUUID();
|
|
52725
52739
|
let worker;
|
|
52740
|
+
const create = this.createWorker, hosted = create ? new URL("./worker.js", moduleUrl).href : null;
|
|
52726
52741
|
try {
|
|
52727
|
-
worker = new Worker(new URL("./worker.js", import_meta2.url), { type: "module" });
|
|
52742
|
+
if (!create) worker = new Worker(new URL("./worker.js", import_meta2.url), { type: "module" });
|
|
52743
|
+
else {
|
|
52744
|
+
worker = create(hosted);
|
|
52745
|
+
if (!isWorker(worker)) throw new TypeError("not a Worker");
|
|
52746
|
+
}
|
|
52728
52747
|
} catch {
|
|
52729
52748
|
tabs?.resign();
|
|
52730
52749
|
channel.port1.close();
|
|
@@ -52743,7 +52762,7 @@ ${end.comment}` : end.comment;
|
|
|
52743
52762
|
tabs?.resign();
|
|
52744
52763
|
}, nativeAuthorization: (call2, portal, signal) => this.nativeAuthorization(call2, portal, signal) });
|
|
52745
52764
|
try {
|
|
52746
|
-
worker.postMessage([APPLICATION_WORKER_PROTOCOL, binding2, declaration, ...storageNamespace === null ? [] : [storageNamespace]], [channel.port2]);
|
|
52765
|
+
worker.postMessage([APPLICATION_WORKER_PROTOCOL, binding2, declaration, ...hosted !== null ? [storageNamespace, hosted] : storageNamespace === null ? [] : [storageNamespace]], [channel.port2]);
|
|
52747
52766
|
} catch {
|
|
52748
52767
|
worker.removeEventListener("error", failed);
|
|
52749
52768
|
worker.terminate();
|
|
@@ -53666,6 +53685,8 @@ ${end.comment}` : end.comment;
|
|
|
53666
53685
|
receiptRead = null;
|
|
53667
53686
|
foregroundRead = null;
|
|
53668
53687
|
attested = false;
|
|
53688
|
+
/** start() resumed a request sent before a restart: an expired or cancelled one ends quietly. */
|
|
53689
|
+
restoredPending = false;
|
|
53669
53690
|
acknowledged = false;
|
|
53670
53691
|
consentPending = false;
|
|
53671
53692
|
listCached = false;
|
|
@@ -53871,7 +53892,10 @@ ${end.comment}` : end.comment;
|
|
|
53871
53892
|
}
|
|
53872
53893
|
await this.refreshCollections(kept);
|
|
53873
53894
|
}
|
|
53874
|
-
} else
|
|
53895
|
+
} else {
|
|
53896
|
+
this.restoredPending = view2.state === "pending" && this.flow.requestSent();
|
|
53897
|
+
this.publish({ status: view2.state === "pending" && !this.restoredPending ? "signed_out" : "authorizing" });
|
|
53898
|
+
}
|
|
53875
53899
|
return this.getSnapshot();
|
|
53876
53900
|
});
|
|
53877
53901
|
}
|
|
@@ -53907,6 +53931,7 @@ ${end.comment}` : end.comment;
|
|
|
53907
53931
|
beginAuthorization(portal, options) {
|
|
53908
53932
|
const hint = { collectionHint: options.collectionHint ?? null };
|
|
53909
53933
|
const view2 = this.flow.view();
|
|
53934
|
+
this.restoredPending = false;
|
|
53910
53935
|
this.authorizationStartedAt = performance.now();
|
|
53911
53936
|
this.publish({ timing: Object.freeze({ firstScreenMs: null, readyMs: null }), approval: null });
|
|
53912
53937
|
return this.operation(async () => {
|
|
@@ -54090,7 +54115,16 @@ ${end.comment}` : end.comment;
|
|
|
54090
54115
|
}
|
|
54091
54116
|
return;
|
|
54092
54117
|
}
|
|
54093
|
-
let view2
|
|
54118
|
+
let view2;
|
|
54119
|
+
try {
|
|
54120
|
+
view2 = await this.exchangeReceipt(() => this.flow.exchange());
|
|
54121
|
+
} catch (error5) {
|
|
54122
|
+
if (!this.restoredPending || !(error5 instanceof AppInstallationSignInError) || error5.reason !== "expired" && error5.reason !== "refused") throw error5;
|
|
54123
|
+
this.check();
|
|
54124
|
+
this.restoredPending = false;
|
|
54125
|
+
this.publish({ status: "signed_out", problem: null });
|
|
54126
|
+
return;
|
|
54127
|
+
}
|
|
54094
54128
|
this.check();
|
|
54095
54129
|
if (!view2) return;
|
|
54096
54130
|
if (view2.state === "account_selected") {
|