@ping-app/ping-openmls-sdk 0.10.1 → 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 +78 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -3
- package/dist/index.d.ts +51 -3
- package/dist/index.js +77 -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-B1GFwNXa.d.cts → types-BOXvsHgp.d.cts} +40 -1
- package/dist/{types-B1GFwNXa.d.ts → types-BOXvsHgp.d.ts} +40 -1
- package/dist/worker.cjs +9 -0
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +10 -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 +36 -2
- package/wasm/ping_wasm.js +104 -22
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as MessageBatchMeta } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, B as BackupPhraseCheck, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as ExportedSecret, u as MessageBatchMeta } from './types-BOXvsHgp.cjs';
|
|
2
|
+
export { v as AddMemberStatus, w as AddMemberVerdict, x as BackupCheckFailure, y as BufferOverflow, z as Bytes, F as CatchupSnapshotEntry, G as ConversationRemoval, J as ConversationUpdate, N as DeviceInfo, O as DeviceRemovalFailure, D as DiscoveredDevice, Q as HistoryAppEvent, V as Hlc, W as IdentityRotationFailure, X as LogGap, Y as MessageKind, Z as OverflowReason, _ as SenderRole, $ as StrandReason, a0 as StrandedConversation, a1 as WelcomeFailure, a2 as WelcomeFailureReason } from './types-BOXvsHgp.cjs';
|
|
3
3
|
export { IndexedDbStorage } from './storage/indexeddb.cjs';
|
|
4
4
|
export { WebSocketTransport } from './transport/websocket.cjs';
|
|
5
5
|
export { MAX_PREVIEW_PREREQUISITES, NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.cjs';
|
|
@@ -950,6 +950,27 @@ declare class MessagingClient {
|
|
|
950
950
|
/** Decrypt a recovery blob from `GET /v1/recovery/blobs`. Throws on wrong mnemonic or a
|
|
951
951
|
* tampered blob. The returned `identity_export` is the secret seed for `init`. */
|
|
952
952
|
static decryptBackup(blob: Uint8Array, mnemonicPhrase: string): Promise<RecoveryBackup>;
|
|
953
|
+
/**
|
|
954
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
955
|
+
* it), with THREE answers to switch on:
|
|
956
|
+
*
|
|
957
|
+
* - `{ outcome: "opens" }`;
|
|
958
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
959
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
960
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
961
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
962
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
963
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
964
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
965
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
966
|
+
*
|
|
967
|
+
* `decryptBackup` rejects with one message for the last two alike; it is unchanged.
|
|
968
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
969
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
970
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
971
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
972
|
+
*/
|
|
973
|
+
static checkBackupPhrase(blob: Uint8Array, mnemonicPhrase: string): Promise<BackupPhraseCheck>;
|
|
953
974
|
/** Seal+sign a `HistoryBundle` for a recipient device. `recipientPub` (X25519, 32B) is the
|
|
954
975
|
* recipient's ephemeral pubkey from the linking QR; `senderIdentitySecret` (Ed25519 seed,
|
|
955
976
|
* 32B) is this account's identity key. Returns the blob to POST to /v1/history-transfers. */
|
|
@@ -1093,6 +1114,22 @@ declare class MessagingClient {
|
|
|
1093
1114
|
* byte-equality is enforced by `protocol/conformance/export_secret/`.
|
|
1094
1115
|
*/
|
|
1095
1116
|
exportConversationSecret(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<Uint8Array>;
|
|
1117
|
+
/**
|
|
1118
|
+
* {@link exportConversationSecret} together with the MLS epoch the secret was
|
|
1119
|
+
* exported at, from one read under one lock inside the core: the pair can
|
|
1120
|
+
* never disagree across a Commit.
|
|
1121
|
+
*
|
|
1122
|
+
* A host that files a key under an epoch number (a call's media key ring)
|
|
1123
|
+
* takes BOTH from this call. A conversation handle's `epoch` is this thread's
|
|
1124
|
+
* copy and any other read is a second request, so either may be a Commit away
|
|
1125
|
+
* from the secret.
|
|
1126
|
+
*
|
|
1127
|
+
* Same derivation, same arguments and the same refusals as
|
|
1128
|
+
* {@link exportConversationSecret}: at one epoch both answer the same bytes.
|
|
1129
|
+
* `secret` is a secret: never log it, persist it only encrypted, and call
|
|
1130
|
+
* `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
|
|
1131
|
+
*/
|
|
1132
|
+
exportConversationSecretWithEpoch(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<ExportedSecret>;
|
|
1096
1133
|
/**
|
|
1097
1134
|
* Subscribe to decrypted application messages, one call per message. A
|
|
1098
1135
|
* batch or page result (the sequenced paths) is fanned out here per
|
|
@@ -1143,6 +1180,17 @@ declare class MessagingClient {
|
|
|
1143
1180
|
private callTransportMethod;
|
|
1144
1181
|
private handleWorker;
|
|
1145
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Read a `{ outcome, reason? }` answer of the SDK's backup phrase check (the wasm
|
|
1185
|
+
* `checkBackupPhrase`, the React Native bridge) as a {@link BackupPhraseCheck}.
|
|
1186
|
+
*
|
|
1187
|
+
* The rule: ONLY the exact code `"authenticationFailed"` is proof that the phrase
|
|
1188
|
+
* does not open the backup, and only the exact code `"opens"` says that it does.
|
|
1189
|
+
* Everything else is a doubt: a value that is not such an object, an outcome this
|
|
1190
|
+
* build does not know, and a `couldNotCheck` whose reason it does not know (read as
|
|
1191
|
+
* `"internal"`). Nothing but the codes is carried over.
|
|
1192
|
+
*/
|
|
1193
|
+
declare function backupPhraseCheckFromWire(raw: unknown): BackupPhraseCheck;
|
|
1146
1194
|
/** A stateless SDK call ran on a one-shot worker that failed before it could answer:
|
|
1147
1195
|
* the worker could not be created (`spawn`), the request could not be posted (`post`),
|
|
1148
1196
|
* the worker script failed to load, import or run (`error`), or its reply could not be
|
|
@@ -1226,4 +1274,4 @@ declare function emulateSendBatch(transport: Pick<Transport, "send">, envelopes:
|
|
|
1226
1274
|
* server error code rides along for diagnostics. */
|
|
1227
1275
|
declare function describeTransportError(e: unknown): string;
|
|
1228
1276
|
|
|
1229
|
-
export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
|
|
1277
|
+
export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, BackupPhraseCheck, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, backupPhraseCheckFromWire, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as MessageBatchMeta } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { M as MessageEnvelope, S as Storage, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, L as LinkingTicket, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, I as IdentityRotation, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, i as IncomingMessage, j as SequencedEnvelope, k as ApplyBatchResult, l as SyncStepResult, m as LogPosition, n as LogHead, P as PendingApply, o as CatchupAppEvent, p as CatchupSnapshotView, R as RecoveryBackup, B as BackupPhraseCheck, H as HistoryBundle, q as AdmitChatEntry, r as AdmitChatOutcome, s as DeviceRemovalReport, t as ExportedSecret, u as MessageBatchMeta } from './types-BOXvsHgp.js';
|
|
2
|
+
export { v as AddMemberStatus, w as AddMemberVerdict, x as BackupCheckFailure, y as BufferOverflow, z as Bytes, F as CatchupSnapshotEntry, G as ConversationRemoval, J as ConversationUpdate, N as DeviceInfo, O as DeviceRemovalFailure, D as DiscoveredDevice, Q as HistoryAppEvent, V as Hlc, W as IdentityRotationFailure, X as LogGap, Y as MessageKind, Z as OverflowReason, _ as SenderRole, $ as StrandReason, a0 as StrandedConversation, a1 as WelcomeFailure, a2 as WelcomeFailureReason } from './types-BOXvsHgp.js';
|
|
3
3
|
export { IndexedDbStorage } from './storage/indexeddb.js';
|
|
4
4
|
export { WebSocketTransport } from './transport/websocket.js';
|
|
5
5
|
export { MAX_PREVIEW_PREREQUISITES, NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.js';
|
|
@@ -950,6 +950,27 @@ declare class MessagingClient {
|
|
|
950
950
|
/** Decrypt a recovery blob from `GET /v1/recovery/blobs`. Throws on wrong mnemonic or a
|
|
951
951
|
* tampered blob. The returned `identity_export` is the secret seed for `init`. */
|
|
952
952
|
static decryptBackup(blob: Uint8Array, mnemonicPhrase: string): Promise<RecoveryBackup>;
|
|
953
|
+
/**
|
|
954
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
955
|
+
* it), with THREE answers to switch on:
|
|
956
|
+
*
|
|
957
|
+
* - `{ outcome: "opens" }`;
|
|
958
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
959
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
960
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
961
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
962
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
963
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
964
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
965
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
966
|
+
*
|
|
967
|
+
* `decryptBackup` rejects with one message for the last two alike; it is unchanged.
|
|
968
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
969
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
970
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
971
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
972
|
+
*/
|
|
973
|
+
static checkBackupPhrase(blob: Uint8Array, mnemonicPhrase: string): Promise<BackupPhraseCheck>;
|
|
953
974
|
/** Seal+sign a `HistoryBundle` for a recipient device. `recipientPub` (X25519, 32B) is the
|
|
954
975
|
* recipient's ephemeral pubkey from the linking QR; `senderIdentitySecret` (Ed25519 seed,
|
|
955
976
|
* 32B) is this account's identity key. Returns the blob to POST to /v1/history-transfers. */
|
|
@@ -1093,6 +1114,22 @@ declare class MessagingClient {
|
|
|
1093
1114
|
* byte-equality is enforced by `protocol/conformance/export_secret/`.
|
|
1094
1115
|
*/
|
|
1095
1116
|
exportConversationSecret(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<Uint8Array>;
|
|
1117
|
+
/**
|
|
1118
|
+
* {@link exportConversationSecret} together with the MLS epoch the secret was
|
|
1119
|
+
* exported at, from one read under one lock inside the core: the pair can
|
|
1120
|
+
* never disagree across a Commit.
|
|
1121
|
+
*
|
|
1122
|
+
* A host that files a key under an epoch number (a call's media key ring)
|
|
1123
|
+
* takes BOTH from this call. A conversation handle's `epoch` is this thread's
|
|
1124
|
+
* copy and any other read is a second request, so either may be a Commit away
|
|
1125
|
+
* from the secret.
|
|
1126
|
+
*
|
|
1127
|
+
* Same derivation, same arguments and the same refusals as
|
|
1128
|
+
* {@link exportConversationSecret}: at one epoch both answer the same bytes.
|
|
1129
|
+
* `secret` is a secret: never log it, persist it only encrypted, and call
|
|
1130
|
+
* `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
|
|
1131
|
+
*/
|
|
1132
|
+
exportConversationSecretWithEpoch(conv: ConversationId, label: string, context: Uint8Array, length: number): Promise<ExportedSecret>;
|
|
1096
1133
|
/**
|
|
1097
1134
|
* Subscribe to decrypted application messages, one call per message. A
|
|
1098
1135
|
* batch or page result (the sequenced paths) is fanned out here per
|
|
@@ -1143,6 +1180,17 @@ declare class MessagingClient {
|
|
|
1143
1180
|
private callTransportMethod;
|
|
1144
1181
|
private handleWorker;
|
|
1145
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Read a `{ outcome, reason? }` answer of the SDK's backup phrase check (the wasm
|
|
1185
|
+
* `checkBackupPhrase`, the React Native bridge) as a {@link BackupPhraseCheck}.
|
|
1186
|
+
*
|
|
1187
|
+
* The rule: ONLY the exact code `"authenticationFailed"` is proof that the phrase
|
|
1188
|
+
* does not open the backup, and only the exact code `"opens"` says that it does.
|
|
1189
|
+
* Everything else is a doubt: a value that is not such an object, an outcome this
|
|
1190
|
+
* build does not know, and a `couldNotCheck` whose reason it does not know (read as
|
|
1191
|
+
* `"internal"`). Nothing but the codes is carried over.
|
|
1192
|
+
*/
|
|
1193
|
+
declare function backupPhraseCheckFromWire(raw: unknown): BackupPhraseCheck;
|
|
1146
1194
|
/** A stateless SDK call ran on a one-shot worker that failed before it could answer:
|
|
1147
1195
|
* the worker could not be created (`spawn`), the request could not be posted (`post`),
|
|
1148
1196
|
* the worker script failed to load, import or run (`error`), or its reply could not be
|
|
@@ -1226,4 +1274,4 @@ declare function emulateSendBatch(transport: Pick<Transport, "send">, envelopes:
|
|
|
1226
1274
|
* server error code rides along for diagnostics. */
|
|
1227
1275
|
declare function describeTransportError(e: unknown): string;
|
|
1228
1276
|
|
|
1229
|
-
export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
|
|
1277
|
+
export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, BackupPhraseCheck, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, IdentityRotation, IncomingMessage, KeyPackageEntry, LinkingTicket, LogHead, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, NotPermittedError, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, RecoveryBackup, SENDER_MISMATCH_PREFIX, SenderMismatchError, SequencedEnvelope, Storage, SyncStepResult, Transport, UserId, ValidationError, WIRE_VERSION_MIN_ACCEPTED, backupPhraseCheckFromWire, describeTransportError, emulateSendBatch, isNotPermittedError, isSenderMismatchError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
|
package/dist/index.js
CHANGED
|
@@ -2070,6 +2070,40 @@ var MessagingClient = class _MessagingClient {
|
|
|
2070
2070
|
mnemonicPhrase
|
|
2071
2071
|
});
|
|
2072
2072
|
}
|
|
2073
|
+
/**
|
|
2074
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
2075
|
+
* it), with THREE answers to switch on:
|
|
2076
|
+
*
|
|
2077
|
+
* - `{ outcome: "opens" }`;
|
|
2078
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
2079
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
2080
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
2081
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
2082
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
2083
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
2084
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
2085
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
2086
|
+
*
|
|
2087
|
+
* `decryptBackup` rejects with one message for the last two alike; it is unchanged.
|
|
2088
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
2089
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
2090
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
2091
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
2092
|
+
*/
|
|
2093
|
+
static async checkBackupPhrase(blob, mnemonicPhrase) {
|
|
2094
|
+
try {
|
|
2095
|
+
return backupPhraseCheckFromWire(
|
|
2096
|
+
await _MessagingClient.ephemeralWorkerCall({
|
|
2097
|
+
kind: "checkBackupPhrase",
|
|
2098
|
+
id: 1,
|
|
2099
|
+
blob,
|
|
2100
|
+
mnemonicPhrase
|
|
2101
|
+
})
|
|
2102
|
+
);
|
|
2103
|
+
} catch {
|
|
2104
|
+
return { outcome: "couldNotCheck", reason: "internal" };
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2073
2107
|
// ------------------------ Peer-assisted history transfer ------------------------
|
|
2074
2108
|
// Authenticated (sign-then-encrypt) device-to-device history used by linking and
|
|
2075
2109
|
// post-recovery peer re-add. Confidential to the recipient's ephemeral X25519 key AND
|
|
@@ -2322,6 +2356,34 @@ var MessagingClient = class _MessagingClient {
|
|
|
2322
2356
|
length
|
|
2323
2357
|
});
|
|
2324
2358
|
}
|
|
2359
|
+
/**
|
|
2360
|
+
* {@link exportConversationSecret} together with the MLS epoch the secret was
|
|
2361
|
+
* exported at, from one read under one lock inside the core: the pair can
|
|
2362
|
+
* never disagree across a Commit.
|
|
2363
|
+
*
|
|
2364
|
+
* A host that files a key under an epoch number (a call's media key ring)
|
|
2365
|
+
* takes BOTH from this call. A conversation handle's `epoch` is this thread's
|
|
2366
|
+
* copy and any other read is a second request, so either may be a Commit away
|
|
2367
|
+
* from the secret.
|
|
2368
|
+
*
|
|
2369
|
+
* Same derivation, same arguments and the same refusals as
|
|
2370
|
+
* {@link exportConversationSecret}: at one epoch both answer the same bytes.
|
|
2371
|
+
* `secret` is a secret: never log it, persist it only encrypted, and call
|
|
2372
|
+
* `secret.fill(0)` after use. `epoch` is a plain number and may be logged.
|
|
2373
|
+
*/
|
|
2374
|
+
async exportConversationSecretWithEpoch(conv, label, context, length) {
|
|
2375
|
+
if (length <= 0 || length > 1024) {
|
|
2376
|
+
throw new Error("exportConversationSecretWithEpoch: length must be 1..=1024");
|
|
2377
|
+
}
|
|
2378
|
+
return await this.call({
|
|
2379
|
+
kind: "exportConversationSecretWithEpoch",
|
|
2380
|
+
id: this.nextId++,
|
|
2381
|
+
conv,
|
|
2382
|
+
label,
|
|
2383
|
+
context,
|
|
2384
|
+
length
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2325
2387
|
/**
|
|
2326
2388
|
* Subscribe to decrypted application messages, one call per message. A
|
|
2327
2389
|
* batch or page result (the sequenced paths) is fanned out here per
|
|
@@ -2607,6 +2669,20 @@ var MessagingClient = class _MessagingClient {
|
|
|
2607
2669
|
}
|
|
2608
2670
|
}
|
|
2609
2671
|
};
|
|
2672
|
+
var BACKUP_CHECK_FAILURES = [
|
|
2673
|
+
"invalidPhrase",
|
|
2674
|
+
"unsupportedVersion",
|
|
2675
|
+
"malformed",
|
|
2676
|
+
"undecodable",
|
|
2677
|
+
"internal"
|
|
2678
|
+
];
|
|
2679
|
+
function backupPhraseCheckFromWire(raw) {
|
|
2680
|
+
const rec = raw !== null && typeof raw === "object" ? raw : {};
|
|
2681
|
+
if (rec.outcome === "opens") return { outcome: "opens" };
|
|
2682
|
+
if (rec.outcome === "authenticationFailed") return { outcome: "authenticationFailed" };
|
|
2683
|
+
const reason = rec.outcome === "couldNotCheck" ? BACKUP_CHECK_FAILURES.find((known) => known === rec.reason) : void 0;
|
|
2684
|
+
return { outcome: "couldNotCheck", reason: reason ?? "internal" };
|
|
2685
|
+
}
|
|
2610
2686
|
var EphemeralWorkerError = class extends Error {
|
|
2611
2687
|
reason;
|
|
2612
2688
|
constructor(reason) {
|
|
@@ -2724,6 +2800,7 @@ export {
|
|
|
2724
2800
|
ValidationError,
|
|
2725
2801
|
WIRE_VERSION_MIN_ACCEPTED,
|
|
2726
2802
|
WebSocketTransport,
|
|
2803
|
+
backupPhraseCheckFromWire,
|
|
2727
2804
|
describeTransportError,
|
|
2728
2805
|
emulateSendBatch,
|
|
2729
2806
|
isNotPermittedError,
|