@quilibrium/quilibrium-js-sdk-channels 2.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Quilibrium Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,332 @@
1
+ import * as ch from './channelwasm';
2
+ export type NewDoubleRatchetParameters = {
3
+ session_key: number[];
4
+ sending_header_key: number[];
5
+ next_receiving_header_key: number[];
6
+ is_sender: boolean;
7
+ sending_ephemeral_private_key: number[];
8
+ receiving_ephemeral_key?: number[];
9
+ };
10
+ export type NewTripleRatchetParameters = {
11
+ peers: number[][];
12
+ peer_key: number[];
13
+ identity_key: number[];
14
+ signed_pre_key: number[];
15
+ threshold: number;
16
+ async_dkg_ratchet: boolean;
17
+ };
18
+ export type EncryptionKeyPair = {
19
+ public_key: number[];
20
+ private_key: number[];
21
+ };
22
+ export type SigningKeyPair = {
23
+ public_key: number[];
24
+ private_key: number[];
25
+ };
26
+ export type SenderX3DH = {
27
+ sending_identity_private_key: number[];
28
+ sending_ephemeral_private_key: number[];
29
+ receiving_identity_key: number[];
30
+ receiving_signed_pre_key: number[];
31
+ session_key_length: number;
32
+ };
33
+ export type ReceiverX3DH = {
34
+ sending_identity_private_key: number[];
35
+ sending_signed_private_key: number[];
36
+ receiving_identity_key: number[];
37
+ receiving_ephemeral_key: number[];
38
+ session_key_length: number;
39
+ };
40
+ export type DoubleRatchetStateAndEnvelope = {
41
+ ratchet_state: string;
42
+ envelope: string;
43
+ };
44
+ export type DoubleRatchetStateAndMessage = {
45
+ ratchet_state: string;
46
+ message: number[];
47
+ };
48
+ export type TripleRatchetStateAndMetadata = {
49
+ ratchet_state: string;
50
+ metadata: {
51
+ [key: string]: string;
52
+ };
53
+ };
54
+ export type TripleRatchetStateAndEnvelope = {
55
+ ratchet_state: string;
56
+ envelope: string;
57
+ };
58
+ export type TripleRatchetStateAndMessage = {
59
+ ratchet_state: string;
60
+ message: number[];
61
+ };
62
+ export type DoubleRatchetParticipant = {
63
+ sending_ephemeral_private_key: string;
64
+ receiving_ephemeral_key: string;
65
+ root_key: string;
66
+ sending_chain_key: string;
67
+ current_sending_header_key: string;
68
+ current_receiving_header_key: string;
69
+ next_sending_header_key: string;
70
+ next_receiving_header_key: string;
71
+ receiving_chain_key: string;
72
+ current_sending_chain_length: number;
73
+ previous_sending_chain_length: number;
74
+ current_receiving_chain_length: number;
75
+ previous_receiving_chain_length: number;
76
+ skipped_keys_map: {
77
+ [key: string]: {
78
+ [key: number]: string;
79
+ };
80
+ };
81
+ };
82
+ export type MessageCiphertext = {
83
+ ciphertext: string;
84
+ initialization_vector: string;
85
+ associated_data?: string;
86
+ };
87
+ export type SealedInboxMessageDecryptRequest = {
88
+ inbox_private_key: number[];
89
+ ephemeral_public_key: number[];
90
+ ciphertext: MessageCiphertext;
91
+ };
92
+ export type SealedInboxMessageEncryptRequest = {
93
+ inbox_public_key: number[];
94
+ ephemeral_private_key: number[];
95
+ plaintext: number[];
96
+ };
97
+ export type Ed448Keypair = {
98
+ type: 'ed448';
99
+ public_key: number[];
100
+ private_key: number[];
101
+ };
102
+ export type X448Keypair = {
103
+ type: 'x448';
104
+ public_key: number[];
105
+ private_key: number[];
106
+ };
107
+ export type Keypair = X448Keypair | Ed448Keypair;
108
+ export type UserKeyset = {
109
+ user_key: Ed448Keypair;
110
+ peer_key: X448Keypair;
111
+ };
112
+ export type DeviceKeyset = {
113
+ identity_key: X448Keypair;
114
+ pre_key: X448Keypair;
115
+ inbox_keyset: InboxKeyset;
116
+ };
117
+ export type InboxKeyset = {
118
+ inbox_address: string;
119
+ inbox_key: Ed448Keypair;
120
+ inbox_encryption_key: X448Keypair;
121
+ };
122
+ export type InboxRegistration = {
123
+ inbox_address: string;
124
+ inbox_encryption_public_key: string;
125
+ };
126
+ export type DeviceRegistration = {
127
+ identity_public_key: string;
128
+ pre_public_key: string;
129
+ inbox_registration: InboxRegistration;
130
+ };
131
+ export type UserRegistration = {
132
+ user_address: string;
133
+ user_public_key: string;
134
+ peer_public_key: string;
135
+ device_registrations: DeviceRegistration[];
136
+ signature: string;
137
+ };
138
+ export type SpaceRegistration = {
139
+ space_address: string;
140
+ space_public_key: string;
141
+ owner_public_keys: string[];
142
+ config_public_key: string;
143
+ timestamp: number;
144
+ space_signature: string;
145
+ owner_signatures: string[];
146
+ };
147
+ export type SpaceManifest = {
148
+ space_address: string;
149
+ space_manifest: string;
150
+ timestamp: number;
151
+ ephemeral_public_key: string;
152
+ owner_public_key: string;
153
+ owner_signature: string;
154
+ };
155
+ export type SealedMessageWithNetworkTimestamp = {
156
+ inbox_address: string;
157
+ ephemeral_public_key: string;
158
+ envelope: string;
159
+ inbox_public_key: string;
160
+ inbox_signature: string;
161
+ timestamp: number;
162
+ };
163
+ export type OwnerSealedMessage = {
164
+ inbox_address: string;
165
+ hub_address: string;
166
+ ephemeral_public_key: string;
167
+ envelope: string;
168
+ owner_public_key: string;
169
+ owner_signature: string;
170
+ };
171
+ export type HubSealedMessage = {
172
+ hub_address: string;
173
+ ephemeral_public_key: string;
174
+ envelope: string;
175
+ hub_public_key: string;
176
+ hub_signature: string;
177
+ };
178
+ export type HubControlMessage = {
179
+ hub_address: string;
180
+ inbox_public_key: string;
181
+ hub_public_key: string;
182
+ hub_signature: string;
183
+ inbox_signature: string;
184
+ };
185
+ export type UserConfig = {
186
+ user_address: string;
187
+ user_public_key: string;
188
+ user_config: string;
189
+ timestamp: number;
190
+ signature: string;
191
+ };
192
+ export type UserAttestation = {
193
+ user_address: string;
194
+ attestation: string;
195
+ attestation_valid_until: number;
196
+ attestation_public_key: string;
197
+ attestation_signature: string;
198
+ };
199
+ export type SealedMessage = {
200
+ inbox_address: string;
201
+ ephemeral_public_key: string;
202
+ envelope: string;
203
+ inbox_public_key?: string;
204
+ inbox_signature?: string;
205
+ };
206
+ export type DeleteMessages = {
207
+ inbox_address: string;
208
+ timestamps: number[];
209
+ inbox_public_key: string;
210
+ inbox_signature: string;
211
+ };
212
+ export type SealedMessageAndMetadata = {
213
+ sealed_message: SealedMessage;
214
+ ratchet_state: string;
215
+ receiving_inbox: InboxKeyset;
216
+ sending_inbox: SendingInbox;
217
+ tag: string;
218
+ sent_accept?: boolean;
219
+ };
220
+ export type SendingInbox = {
221
+ inbox_address: string;
222
+ inbox_encryption_key: string;
223
+ inbox_public_key: string;
224
+ inbox_private_key: string;
225
+ };
226
+ export type SignedInboxEnvelopeAndMetadata = {
227
+ inbox_address: string;
228
+ inbox_public_key: string;
229
+ inbox_signature: string;
230
+ envelope: string;
231
+ ratchet_state: string;
232
+ };
233
+ export type UserProfile = {
234
+ user_address: string;
235
+ display_name?: string;
236
+ user_icon?: string;
237
+ };
238
+ export type InitializationEnvelope = UserProfile & {
239
+ return_inbox_address: string;
240
+ return_inbox_encryption_key: string;
241
+ return_inbox_public_key: string;
242
+ return_inbox_private_key: string;
243
+ identity_public_key: string;
244
+ tag: string;
245
+ message: string;
246
+ type: string;
247
+ };
248
+ export type UnsealedEnvelope = InitializationEnvelope & {
249
+ ephemeral_public_key: string;
250
+ };
251
+ export type NewDoubleRatchetRecipientSession = {
252
+ state: string;
253
+ message: string;
254
+ tag: string;
255
+ return_inbox_address: string;
256
+ return_inbox_encryption_key: string;
257
+ return_inbox_public_key: string;
258
+ return_inbox_private_key: string;
259
+ user_address: string;
260
+ identity_public_key: string;
261
+ };
262
+ export type InboxAndEncryptionState = {
263
+ inbox_address: string;
264
+ encryption_state: string;
265
+ };
266
+ export declare const NewUserKeyset: (user_key: Ed448Keypair) => UserKeyset;
267
+ export declare const NewDeviceKeyset: () => Promise<DeviceKeyset>;
268
+ export declare const NewInboxKeyset: () => Promise<InboxKeyset>;
269
+ export declare const ConstructUserRegistration: (userKeyset: UserKeyset, existing_device_keysets: DeviceRegistration[], device_keysets: DeviceKeyset[]) => Promise<UserRegistration>;
270
+ export declare const NewDoubleRatchetSenderSession: (keyset: DeviceKeyset, sender_address: string, device: DeviceRegistration, initial_message: string, sender_name?: string, sender_photo?: string) => Promise<SealedMessageAndMetadata[]>;
271
+ export declare const SealSyncEnvelope: (inbox_address: string, hub_address: string, hub_keyset: Ed448Keypair, owner_keyset: Ed448Keypair, message: string) => Promise<OwnerSealedMessage>;
272
+ export declare const UnsealSyncEnvelope: (hub_keyset: Ed448Keypair, envelope: OwnerSealedMessage) => Promise<any>;
273
+ export declare const UnsealInboxEnvelope: (privKey: number[], envelope: {
274
+ inbox_public_key: string;
275
+ ephemeral_public_key: string;
276
+ envelope: string;
277
+ }) => Promise<any>;
278
+ export declare const SealInboxEnvelope: (pubKey: string, message: string) => Promise<{
279
+ inbox_public_key: string;
280
+ ephemeral_public_key: string;
281
+ envelope: string;
282
+ }>;
283
+ export declare const SealHubEnvelope: (address: string, keyset: Ed448Keypair, message: string) => Promise<HubSealedMessage>;
284
+ export declare const UnsealHubEnvelope: (keyset: Ed448Keypair, envelope: HubSealedMessage) => Promise<any>;
285
+ export declare const UnsealInitializationEnvelope: (keyset: DeviceKeyset, initial_message: SealedMessage) => UnsealedEnvelope;
286
+ export declare const NewDoubleRatchetRecipientSession: (keyset: DeviceKeyset, initial_message: UnsealedEnvelope) => Promise<NewDoubleRatchetRecipientSession>;
287
+ export type DoubleRatchetStateAndInboxKeys = {
288
+ ratchet_state: string;
289
+ receiving_inbox: InboxKeyset;
290
+ sending_inbox: SendingInbox;
291
+ tag: string;
292
+ sent_accept?: boolean;
293
+ };
294
+ export declare const DoubleRatchetInboxEncryptForceSenderInit: (device_keyset: DeviceKeyset, encryption_states: DoubleRatchetStateAndInboxKeys[], message: string, acceptee: UserRegistration, sender_name?: string, sender_photo?: string) => SealedMessageAndMetadata[];
295
+ export declare const DoubleRatchetInboxEncrypt: (device_keyset: DeviceKeyset, encryption_states: DoubleRatchetStateAndInboxKeys[], message: string, acceptee: UserRegistration, sender_name?: string, sender_photo?: string) => SealedMessageAndMetadata[];
296
+ export declare const ConfirmDoubleRatchetSenderSession: (encryption_state: DoubleRatchetStateAndInboxKeys, message: SealedMessage) => {
297
+ receiving_inbox: InboxKeyset;
298
+ user_profile: UserProfile;
299
+ tag: string;
300
+ sending_inbox: SendingInbox;
301
+ ratchet_state: string;
302
+ message: string;
303
+ };
304
+ export declare const DoubleRatchetInboxDecrypt: (encryption_state: DoubleRatchetStateAndInboxKeys, message: SealedMessage) => {
305
+ ratchet_state: string;
306
+ message: string;
307
+ } | {
308
+ receiving_inbox: InboxKeyset;
309
+ user_profile: UserProfile;
310
+ tag: any;
311
+ sending_inbox: SendingInbox;
312
+ ratchet_state: string;
313
+ message: string;
314
+ };
315
+ export type PeerMessageSet = {
316
+ [peer: string]: string;
317
+ };
318
+ export type TripleRatchetInitializationBundle = {
319
+ ratchet_state: string;
320
+ metadata: PeerMessageSet;
321
+ };
322
+ export declare const EstablishTripleRatchetSessionForSpace: (user_keyset: UserKeyset, device_keyset: DeviceKeyset, registration: UserRegistration, total?: number) => Promise<{
323
+ state: string;
324
+ template: any;
325
+ evals: number[][];
326
+ }>;
327
+ export declare const TripleRatchetInitRound1: typeof ch.js_triple_ratchet_init_round_1;
328
+ export declare const TripleRatchetInitRound2: typeof ch.js_triple_ratchet_init_round_2;
329
+ export declare const TripleRatchetInitRound3: typeof ch.js_triple_ratchet_init_round_3;
330
+ export declare const TripleRatchetInitRound4: typeof ch.js_triple_ratchet_init_round_4;
331
+ export declare const TripleRatchetEncrypt: typeof ch.js_triple_ratchet_encrypt;
332
+ export declare const TripleRatchetDecrypt: typeof ch.js_triple_ratchet_decrypt;
@@ -0,0 +1,34 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { StoredPasskey } from '../../passkeys/types';
3
+ type PasskeysContextValue = {
4
+ currentPasskeyInfo: {
5
+ credentialId: string;
6
+ address: string;
7
+ publicKey: string;
8
+ displayName?: string;
9
+ pfpUrl?: string;
10
+ completedOnboarding: boolean;
11
+ } | undefined;
12
+ showPasskeyPrompt: {
13
+ value: boolean;
14
+ importMode?: boolean;
15
+ };
16
+ setShowPasskeyPrompt: (state: {
17
+ value: boolean;
18
+ importMode?: boolean;
19
+ }) => void;
20
+ passkeyRegistrationComplete?: boolean;
21
+ setPasskeyRegistrationComplete: (value: boolean | undefined) => void;
22
+ passkeyRegistrationError?: string;
23
+ setPasskeyRegistrationError: (value: string | undefined) => void;
24
+ signWithPasskey: (credentialId: string, payload: string) => Promise<string>;
25
+ exportKey: (credentialId: string) => Promise<string>;
26
+ updateStoredPasskey: (credentialId: string, storedPasskey: StoredPasskey) => void;
27
+ };
28
+ type PasskeysContextProps = {
29
+ fqAppPrefix: string;
30
+ children: ReactNode;
31
+ };
32
+ declare const PasskeysProvider: FC<PasskeysContextProps>;
33
+ declare const usePasskeysContext: () => PasskeysContextValue;
34
+ export { PasskeysProvider, usePasskeysContext };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import * as secureChannel from '../../channel/channel';
3
+ export declare const PasskeyModal: ({ fqAppPrefix, getUserRegistration, uploadRegistration, }: {
4
+ fqAppPrefix: string;
5
+ getUserRegistration: (address: string) => Promise<secureChannel.UserRegistration>;
6
+ uploadRegistration: ({ address, registration, }: {
7
+ address: string;
8
+ registration: secureChannel.UserRegistration;
9
+ }) => Promise<void>;
10
+ }) => React.JSX.Element;