@ping-app/ping-openmls-sdk 0.10.4 → 0.10.6
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/index.cjs +168 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -15
- package/dist/index.d.ts +69 -15
- package/dist/index.js +168 -64
- package/dist/index.js.map +1 -1
- package/dist/notification-preview.d.cts +1 -1
- package/dist/notification-preview.d.ts +1 -1
- package/dist/storage/indexeddb.d.cts +1 -1
- package/dist/storage/indexeddb.d.ts +1 -1
- package/dist/transport/websocket.d.cts +1 -1
- package/dist/transport/websocket.d.ts +1 -1
- package/dist/{types-omhvRjtq.d.cts → types-D8fIp-_0.d.cts} +28 -0
- package/dist/{types-omhvRjtq.d.ts → types-D8fIp-_0.d.ts} +28 -0
- package/dist/worker.cjs +34 -5
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +38 -6
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/ping_wasm.d.ts +43 -2
- package/wasm/ping_wasm.js +104 -35
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +6 -2
package/dist/worker.js
CHANGED
|
@@ -64,7 +64,10 @@ import init, {
|
|
|
64
64
|
openStateBackup as wasmOpenStateBackup,
|
|
65
65
|
refreshStateBackup as wasmRefreshStateBackup,
|
|
66
66
|
endPending as wasmEndPending,
|
|
67
|
-
|
|
67
|
+
beginAccountSetupInMemoryOn as wasmBeginAccountSetupInMemoryOn,
|
|
68
|
+
prepareDeviceKey as wasmPrepareDeviceKey,
|
|
69
|
+
discardPreparedDeviceKey as wasmDiscardPreparedDeviceKey,
|
|
70
|
+
deviceStartCheck as wasmDeviceStartCheck
|
|
68
71
|
} from "../wasm/ping_wasm";
|
|
69
72
|
|
|
70
73
|
// src/pending-root-store.ts
|
|
@@ -423,6 +426,11 @@ function accountExclusive(run) {
|
|
|
423
426
|
}
|
|
424
427
|
return locks.request(ACCOUNT_LOCK_NAME, run);
|
|
425
428
|
}
|
|
429
|
+
function linkBeginExclusive(run) {
|
|
430
|
+
const locks = globalThis.navigator?.locks;
|
|
431
|
+
if (!locks || typeof locks.request !== "function") return run();
|
|
432
|
+
return locks.request(ACCOUNT_LOCK_NAME, run);
|
|
433
|
+
}
|
|
426
434
|
function pendingStore() {
|
|
427
435
|
accountWorker();
|
|
428
436
|
pendingRootStore ??= new PendingRootStore();
|
|
@@ -898,12 +906,13 @@ async function dispatchRequest(msg) {
|
|
|
898
906
|
case "beginDeviceLink": {
|
|
899
907
|
clientWorker();
|
|
900
908
|
transportFeatures = msg.transportFeatures ?? { fetchLogSince: false, fetchLogHeads: false };
|
|
901
|
-
const
|
|
909
|
+
const linkTransport = makeProxyTransport(transportFeatures);
|
|
910
|
+
const begun = await linkBeginExclusive(() => wasmBeginDeviceLink(
|
|
902
911
|
msg.deviceLabel,
|
|
903
912
|
makeProxyStorage(msg.storageFeatures),
|
|
904
|
-
|
|
913
|
+
linkTransport,
|
|
905
914
|
msg.nowMs
|
|
906
|
-
);
|
|
915
|
+
));
|
|
907
916
|
try {
|
|
908
917
|
client = begun.takeClient();
|
|
909
918
|
client.onMessage((m) => {
|
|
@@ -1014,6 +1023,22 @@ async function dispatchRequest(msg) {
|
|
|
1014
1023
|
);
|
|
1015
1024
|
});
|
|
1016
1025
|
}
|
|
1026
|
+
// The prepared device key: the two calls that write hold the origin's
|
|
1027
|
+
// account lock (two tabs that prepare at once answer ONE key); a realm
|
|
1028
|
+
// with no Web Locks is refused, typed. The predicate reads only.
|
|
1029
|
+
case "prepareDeviceKey": {
|
|
1030
|
+
return accountExclusive(() => wasmPrepareDeviceKey(makeProxyStorage(msg.storageFeatures), msg.nowMs));
|
|
1031
|
+
}
|
|
1032
|
+
case "discardPreparedDeviceKey": {
|
|
1033
|
+
return accountExclusive(() => wasmDiscardPreparedDeviceKey(makeProxyStorage(msg.storageFeatures)));
|
|
1034
|
+
}
|
|
1035
|
+
case "deviceStartCheck": {
|
|
1036
|
+
accountWorker();
|
|
1037
|
+
return wasmDeviceStartCheck(
|
|
1038
|
+
makeProxyStorage(msg.storageFeatures),
|
|
1039
|
+
msg.expectedDeviceId ?? null
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1017
1042
|
case "pendingStatus": {
|
|
1018
1043
|
const store = pendingStore();
|
|
1019
1044
|
return wasmPendingStatus(
|
|
@@ -1166,8 +1191,15 @@ async function dispatchRequest(msg) {
|
|
|
1166
1191
|
case "beginAccountSetupInMemory": {
|
|
1167
1192
|
accountWorker();
|
|
1168
1193
|
if (setupSession) throw new Error("account refused: setup-session-open");
|
|
1169
|
-
|
|
1170
|
-
|
|
1194
|
+
return accountExclusive(async () => {
|
|
1195
|
+
if (setupSession) throw new Error("account refused: setup-session-open");
|
|
1196
|
+
setupSession = await wasmBeginAccountSetupInMemoryOn(
|
|
1197
|
+
makeProxyStorage(msg.storageFeatures),
|
|
1198
|
+
msg.identityState,
|
|
1199
|
+
msg.nowMs
|
|
1200
|
+
);
|
|
1201
|
+
return null;
|
|
1202
|
+
});
|
|
1171
1203
|
}
|
|
1172
1204
|
case "setupSessionMakeBackup":
|
|
1173
1205
|
return openSession().makeBackup(msg.phrase, msg.accountId, msg.hostState, msg.nowMs);
|