@ping-app/ping-openmls-sdk 0.10.2 → 0.10.3
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 +50 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.js +49 -0
- 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-gAmJFSC-.d.cts → types-BOXvsHgp.d.cts} +30 -1
- package/dist/{types-gAmJFSC-.d.ts → types-BOXvsHgp.d.ts} +30 -1
- package/dist/worker.cjs +2 -0
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +3 -0
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/ping_wasm.d.ts +20 -2
- package/wasm/ping_wasm.js +60 -22
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +3 -2
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(src_exports, {
|
|
|
52
52
|
ValidationError: () => ValidationError,
|
|
53
53
|
WIRE_VERSION_MIN_ACCEPTED: () => WIRE_VERSION_MIN_ACCEPTED,
|
|
54
54
|
WebSocketTransport: () => WebSocketTransport,
|
|
55
|
+
backupPhraseCheckFromWire: () => backupPhraseCheckFromWire,
|
|
55
56
|
describeTransportError: () => describeTransportError,
|
|
56
57
|
emulateSendBatch: () => emulateSendBatch,
|
|
57
58
|
isNotPermittedError: () => isNotPermittedError,
|
|
@@ -2137,6 +2138,40 @@ var MessagingClient = class _MessagingClient {
|
|
|
2137
2138
|
mnemonicPhrase
|
|
2138
2139
|
});
|
|
2139
2140
|
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
2143
|
+
* it), with THREE answers to switch on:
|
|
2144
|
+
*
|
|
2145
|
+
* - `{ outcome: "opens" }`;
|
|
2146
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
2147
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
2148
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
2149
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
2150
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
2151
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
2152
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
2153
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
2154
|
+
*
|
|
2155
|
+
* `decryptBackup` rejects with one message for the last two alike; it is unchanged.
|
|
2156
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
2157
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
2158
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
2159
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
2160
|
+
*/
|
|
2161
|
+
static async checkBackupPhrase(blob, mnemonicPhrase) {
|
|
2162
|
+
try {
|
|
2163
|
+
return backupPhraseCheckFromWire(
|
|
2164
|
+
await _MessagingClient.ephemeralWorkerCall({
|
|
2165
|
+
kind: "checkBackupPhrase",
|
|
2166
|
+
id: 1,
|
|
2167
|
+
blob,
|
|
2168
|
+
mnemonicPhrase
|
|
2169
|
+
})
|
|
2170
|
+
);
|
|
2171
|
+
} catch {
|
|
2172
|
+
return { outcome: "couldNotCheck", reason: "internal" };
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2140
2175
|
// ------------------------ Peer-assisted history transfer ------------------------
|
|
2141
2176
|
// Authenticated (sign-then-encrypt) device-to-device history used by linking and
|
|
2142
2177
|
// post-recovery peer re-add. Confidential to the recipient's ephemeral X25519 key AND
|
|
@@ -2702,6 +2737,20 @@ var MessagingClient = class _MessagingClient {
|
|
|
2702
2737
|
}
|
|
2703
2738
|
}
|
|
2704
2739
|
};
|
|
2740
|
+
var BACKUP_CHECK_FAILURES = [
|
|
2741
|
+
"invalidPhrase",
|
|
2742
|
+
"unsupportedVersion",
|
|
2743
|
+
"malformed",
|
|
2744
|
+
"undecodable",
|
|
2745
|
+
"internal"
|
|
2746
|
+
];
|
|
2747
|
+
function backupPhraseCheckFromWire(raw) {
|
|
2748
|
+
const rec = raw !== null && typeof raw === "object" ? raw : {};
|
|
2749
|
+
if (rec.outcome === "opens") return { outcome: "opens" };
|
|
2750
|
+
if (rec.outcome === "authenticationFailed") return { outcome: "authenticationFailed" };
|
|
2751
|
+
const reason = rec.outcome === "couldNotCheck" ? BACKUP_CHECK_FAILURES.find((known) => known === rec.reason) : void 0;
|
|
2752
|
+
return { outcome: "couldNotCheck", reason: reason ?? "internal" };
|
|
2753
|
+
}
|
|
2705
2754
|
var EphemeralWorkerError = class extends Error {
|
|
2706
2755
|
reason;
|
|
2707
2756
|
constructor(reason) {
|
|
@@ -2820,6 +2869,7 @@ function sameBytesU8(a, b) {
|
|
|
2820
2869
|
ValidationError,
|
|
2821
2870
|
WIRE_VERSION_MIN_ACCEPTED,
|
|
2822
2871
|
WebSocketTransport,
|
|
2872
|
+
backupPhraseCheckFromWire,
|
|
2823
2873
|
describeTransportError,
|
|
2824
2874
|
emulateSendBatch,
|
|
2825
2875
|
isNotPermittedError,
|