@bitwarden/sdk-internal 0.2.0-main.7 → 0.2.0-main.700

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.
@@ -1,5 +1,3740 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ import { Tagged } from "type-fest";
5
+
6
+ /**
7
+ * A string that **MUST** be a valid UUID.
8
+ *
9
+ * Never create or cast to this type directly, use the `uuid<T>()` function instead.
10
+ */
11
+ export type Uuid = unknown;
12
+
13
+ /**
14
+ * RFC3339 compliant date-time string.
15
+ * @typeParam T - Not used in JavaScript.
16
+ */
17
+ export type DateTime<T = unknown> = string;
18
+
19
+ /**
20
+ * UTC date-time string. Not used in JavaScript.
21
+ */
22
+ export type Utc = unknown;
23
+
24
+ /**
25
+ * An integer that is known not to equal zero.
26
+ */
27
+ export type NonZeroU32 = number;
28
+
29
+ export interface AccountCryptographyInitializationError extends Error {
30
+ name: "AccountCryptographyInitializationError";
31
+ variant:
32
+ | "WrongUserKeyType"
33
+ | "WrongUserKey"
34
+ | "CorruptData"
35
+ | "TamperedData"
36
+ | "KeyStoreAlreadyInitialized"
37
+ | "GenericCrypto";
38
+ }
39
+
40
+ export function isAccountCryptographyInitializationError(
41
+ error: any,
42
+ ): error is AccountCryptographyInitializationError;
43
+
44
+ export interface AcquireCookieError extends Error {
45
+ name: "AcquireCookieError";
46
+ variant:
47
+ | "Cancelled"
48
+ | "UnsupportedConfiguration"
49
+ | "CookieNameMismatch"
50
+ | "RepositoryGetError"
51
+ | "RepositorySaveError";
52
+ }
53
+
54
+ export function isAcquireCookieError(error: any): error is AcquireCookieError;
55
+
56
+ export interface AlreadyRunningError extends Error {
57
+ name: "AlreadyRunningError";
58
+ }
59
+
60
+ export function isAlreadyRunningError(error: any): error is AlreadyRunningError;
61
+
62
+ export interface CallError extends Error {
63
+ name: "CallError";
64
+ }
65
+
66
+ export function isCallError(error: any): error is CallError;
67
+
68
+ export interface ChannelError extends Error {
69
+ name: "ChannelError";
70
+ }
71
+
72
+ export function isChannelError(error: any): error is ChannelError;
73
+
74
+ export interface CipherDeleteAttachmentError extends Error {
75
+ name: "CipherDeleteAttachmentError";
76
+ variant: "Api" | "Repository" | "MissingField" | "VaultParse";
77
+ }
78
+
79
+ export function isCipherDeleteAttachmentError(error: any): error is CipherDeleteAttachmentError;
80
+
81
+ export interface CipherError extends Error {
82
+ name: "CipherError";
83
+ variant:
84
+ | "MissingField"
85
+ | "Crypto"
86
+ | "Decrypt"
87
+ | "Encrypt"
88
+ | "AttachmentsWithoutKeys"
89
+ | "OrganizationAlreadySet"
90
+ | "Repository"
91
+ | "Chrono"
92
+ | "SerdeJson"
93
+ | "Api";
94
+ }
95
+
96
+ export function isCipherError(error: any): error is CipherError;
97
+
98
+ export interface CipherRiskError extends Error {
99
+ name: "CipherRiskError";
100
+ variant: "Reqwest";
101
+ }
102
+
103
+ export function isCipherRiskError(error: any): error is CipherRiskError;
104
+
105
+ export interface CollectionDecryptError extends Error {
106
+ name: "CollectionDecryptError";
107
+ variant: "Crypto";
108
+ }
109
+
110
+ export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
111
+
112
+ export interface CreateCipherAdminError extends Error {
113
+ name: "CreateCipherAdminError";
114
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated";
115
+ }
116
+
117
+ export function isCreateCipherAdminError(error: any): error is CreateCipherAdminError;
118
+
119
+ export interface CreateCipherError extends Error {
120
+ name: "CreateCipherError";
121
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
122
+ }
123
+
124
+ export function isCreateCipherError(error: any): error is CreateCipherError;
125
+
126
+ export interface CreateFolderError extends Error {
127
+ name: "CreateFolderError";
128
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
129
+ }
130
+
131
+ export function isCreateFolderError(error: any): error is CreateFolderError;
132
+
133
+ export interface CreateSendError extends Error {
134
+ name: "CreateSendError";
135
+ variant: "Api" | "Crypto" | "EmptyEmailList" | "MissingField" | "Repository" | "SendParse";
136
+ }
137
+
138
+ export function isCreateSendError(error: any): error is CreateSendError;
139
+
140
+ export interface CryptoClientError extends Error {
141
+ name: "CryptoClientError";
142
+ variant:
143
+ | "NotAuthenticated"
144
+ | "Crypto"
145
+ | "InvalidKdfSettings"
146
+ | "PasswordProtectedKeyEnvelope"
147
+ | "InvalidPrfInput"
148
+ | "InvalidUpgradeToken"
149
+ | "UpgradeTokenRequired"
150
+ | "InvalidKeyType";
151
+ }
152
+
153
+ export function isCryptoClientError(error: any): error is CryptoClientError;
154
+
155
+ export interface CryptoError extends Error {
156
+ name: "CryptoError";
157
+ variant:
158
+ | "Decrypt"
159
+ | "InvalidKey"
160
+ | "KeyDecrypt"
161
+ | "InvalidKeyLen"
162
+ | "InvalidUtf8String"
163
+ | "MissingKey"
164
+ | "MissingField"
165
+ | "MissingKeyId"
166
+ | "KeyOperationNotSupported"
167
+ | "ReadOnlyKeyStore"
168
+ | "InvalidKeyStoreOperation"
169
+ | "InsufficientKdfParameters"
170
+ | "EncString"
171
+ | "Rsa"
172
+ | "Fingerprint"
173
+ | "Argon"
174
+ | "ZeroNumber"
175
+ | "OperationNotSupported"
176
+ | "WrongKeyType"
177
+ | "WrongCoseKeyId"
178
+ | "InvalidNonceLength"
179
+ | "InvalidPadding"
180
+ | "Signature"
181
+ | "Encoding";
182
+ }
183
+
184
+ export function isCryptoError(error: any): error is CryptoError;
185
+
186
+ export interface DatabaseError extends Error {
187
+ name: "DatabaseError";
188
+ variant: "UnsupportedConfiguration" | "ThreadBoundRunner" | "Serialization" | "JS" | "Internal";
189
+ }
190
+
191
+ export function isDatabaseError(error: any): error is DatabaseError;
192
+
193
+ export interface DecryptError extends Error {
194
+ name: "DecryptError";
195
+ variant: "Crypto";
196
+ }
197
+
198
+ export function isDecryptError(error: any): error is DecryptError;
199
+
200
+ export interface DecryptFileError extends Error {
201
+ name: "DecryptFileError";
202
+ variant: "Decrypt" | "Io";
203
+ }
204
+
205
+ export function isDecryptFileError(error: any): error is DecryptFileError;
206
+
207
+ export interface DeleteAttachmentAdminError extends Error {
208
+ name: "DeleteAttachmentAdminError";
209
+ variant: "Api";
210
+ }
211
+
212
+ export function isDeleteAttachmentAdminError(error: any): error is DeleteAttachmentAdminError;
213
+
214
+ export interface DeleteCipherAdminError extends Error {
215
+ name: "DeleteCipherAdminError";
216
+ variant: "Api";
217
+ }
218
+
219
+ export function isDeleteCipherAdminError(error: any): error is DeleteCipherAdminError;
220
+
221
+ export interface DeleteCipherError extends Error {
222
+ name: "DeleteCipherError";
223
+ variant: "Api" | "Repository";
224
+ }
225
+
226
+ export function isDeleteCipherError(error: any): error is DeleteCipherError;
227
+
228
+ export interface DeriveKeyConnectorError extends Error {
229
+ name: "DeriveKeyConnectorError";
230
+ variant: "WrongPassword" | "Crypto";
231
+ }
232
+
233
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
234
+
235
+ export interface DeserializeError extends Error {
236
+ name: "DeserializeError";
237
+ }
238
+
239
+ export function isDeserializeError(error: any): error is DeserializeError;
240
+
241
+ export interface EditCipherAdminError extends Error {
242
+ name: "EditCipherAdminError";
243
+ variant:
244
+ | "ItemNotFound"
245
+ | "Crypto"
246
+ | "Api"
247
+ | "VaultParse"
248
+ | "MissingField"
249
+ | "NotAuthenticated"
250
+ | "Repository"
251
+ | "Uuid"
252
+ | "Decrypt";
253
+ }
254
+
255
+ export function isEditCipherAdminError(error: any): error is EditCipherAdminError;
256
+
257
+ export interface EditCipherError extends Error {
258
+ name: "EditCipherError";
259
+ variant:
260
+ | "ItemNotFound"
261
+ | "Crypto"
262
+ | "Api"
263
+ | "VaultParse"
264
+ | "MissingField"
265
+ | "NotAuthenticated"
266
+ | "Repository"
267
+ | "Uuid";
268
+ }
269
+
270
+ export function isEditCipherError(error: any): error is EditCipherError;
271
+
272
+ export interface EditFolderError extends Error {
273
+ name: "EditFolderError";
274
+ variant:
275
+ | "ItemNotFound"
276
+ | "Crypto"
277
+ | "Api"
278
+ | "VaultParse"
279
+ | "MissingField"
280
+ | "Repository"
281
+ | "Uuid";
282
+ }
283
+
284
+ export function isEditFolderError(error: any): error is EditFolderError;
285
+
286
+ export interface EditSendError extends Error {
287
+ name: "EditSendError";
288
+ variant:
289
+ | "ItemNotFound"
290
+ | "Crypto"
291
+ | "Api"
292
+ | "EmptyEmailList"
293
+ | "MissingField"
294
+ | "Repository"
295
+ | "Uuid"
296
+ | "SendParse"
297
+ | "IdMismatch";
298
+ }
299
+
300
+ export function isEditSendError(error: any): error is EditSendError;
301
+
302
+ export interface EncryptError extends Error {
303
+ name: "EncryptError";
304
+ variant: "Crypto" | "MissingUserId";
305
+ }
306
+
307
+ export function isEncryptError(error: any): error is EncryptError;
308
+
309
+ export interface EncryptFileError extends Error {
310
+ name: "EncryptFileError";
311
+ variant: "Encrypt" | "Io";
312
+ }
313
+
314
+ export function isEncryptFileError(error: any): error is EncryptFileError;
315
+
316
+ export interface EncryptionSettingsError extends Error {
317
+ name: "EncryptionSettingsError";
318
+ variant:
319
+ | "Crypto"
320
+ | "CryptoInitialization"
321
+ | "MissingPrivateKey"
322
+ | "UserIdAlreadySet"
323
+ | "WrongPin"
324
+ | "UserKeyStateUpdateFailed"
325
+ | "UserKeyStateRetrievalFailed"
326
+ | "InvalidUpgradeToken"
327
+ | "KeyConnectorRetrievalFailed"
328
+ | "LocalUserDataKeyInitFailed"
329
+ | "LocalUserDataKeyLoadFailed";
330
+ }
331
+
332
+ export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
333
+
334
+ export interface EnrollAdminPasswordResetError extends Error {
335
+ name: "EnrollAdminPasswordResetError";
336
+ variant: "Crypto";
337
+ }
338
+
339
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
340
+
341
+ export interface ExportError extends Error {
342
+ name: "ExportError";
343
+ variant:
344
+ | "MissingField"
345
+ | "NotAuthenticated"
346
+ | "Csv"
347
+ | "Cxf"
348
+ | "Json"
349
+ | "EncryptedJson"
350
+ | "BitwardenCrypto"
351
+ | "Cipher";
352
+ }
353
+
354
+ export function isExportError(error: any): error is ExportError;
355
+
356
+ export interface GetCipherError extends Error {
357
+ name: "GetCipherError";
358
+ variant: "ItemNotFound" | "Crypto" | "Repository";
359
+ }
360
+
361
+ export function isGetCipherError(error: any): error is GetCipherError;
362
+
363
+ export interface GetFolderError extends Error {
364
+ name: "GetFolderError";
365
+ variant: "ItemNotFound" | "Crypto" | "Repository";
366
+ }
367
+
368
+ export function isGetFolderError(error: any): error is GetFolderError;
369
+
370
+ export interface GetOrganizationCiphersAdminError extends Error {
371
+ name: "GetOrganizationCiphersAdminError";
372
+ variant: "Crypto" | "VaultParse" | "Api";
373
+ }
374
+
375
+ export function isGetOrganizationCiphersAdminError(
376
+ error: any,
377
+ ): error is GetOrganizationCiphersAdminError;
378
+
379
+ export interface GetSendError extends Error {
380
+ name: "GetSendError";
381
+ variant: "ItemNotFound" | "Crypto" | "MissingField" | "Repository";
382
+ }
383
+
384
+ export function isGetSendError(error: any): error is GetSendError;
385
+
386
+ export interface KeyGenerationError extends Error {
387
+ name: "KeyGenerationError";
388
+ variant: "KeyGeneration" | "KeyConversion";
389
+ }
390
+
391
+ export function isKeyGenerationError(error: any): error is KeyGenerationError;
392
+
393
+ export interface MakeKeysError extends Error {
394
+ name: "MakeKeysError";
395
+ variant:
396
+ | "AccountCryptographyInitialization"
397
+ | "MasterPasswordDerivation"
398
+ | "RequestModelCreation"
399
+ | "Crypto";
400
+ }
401
+
402
+ export function isMakeKeysError(error: any): error is MakeKeysError;
403
+
404
+ export interface MasterPasswordError extends Error {
405
+ name: "MasterPasswordError";
406
+ variant:
407
+ | "EncryptionKeyMalformed"
408
+ | "KdfMalformed"
409
+ | "InvalidKdfConfiguration"
410
+ | "MissingField"
411
+ | "Crypto"
412
+ | "WrongPassword";
413
+ }
414
+
415
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
416
+
417
+ export interface MigrateToKeyConnectorError extends Error {
418
+ name: "MigrateToKeyConnectorError";
419
+ variant: "UserKeyNotAvailable" | "CryptoError" | "ApiError" | "KeyConnectorApiError";
420
+ }
421
+
422
+ export function isMigrateToKeyConnectorError(error: any): error is MigrateToKeyConnectorError;
423
+
424
+ export interface PasswordError extends Error {
425
+ name: "PasswordError";
426
+ variant: "NoCharacterSetEnabled" | "InvalidLength";
427
+ }
428
+
429
+ export function isPasswordError(error: any): error is PasswordError;
430
+
431
+ export interface PasswordLoginError extends Error {
432
+ name: "PasswordLoginError";
433
+ variant: "InvalidUsernameOrPassword" | "PasswordAuthenticationDataDerivation" | "Unknown";
434
+ }
435
+
436
+ export function isPasswordLoginError(error: any): error is PasswordLoginError;
437
+
438
+ export interface PasswordPreloginError extends Error {
439
+ name: "PasswordPreloginError";
440
+ variant: "Api" | "Unknown";
441
+ }
442
+
443
+ export function isPasswordPreloginError(error: any): error is PasswordPreloginError;
444
+
445
+ export interface ReceiveError extends Error {
446
+ name: "ReceiveError";
447
+ variant: "Channel" | "Timeout" | "Cancelled";
448
+ }
449
+
450
+ export function isReceiveError(error: any): error is ReceiveError;
451
+
452
+ export interface RegistrationError extends Error {
453
+ name: "RegistrationError";
454
+ variant: "KeyConnectorApi" | "Api" | "Crypto";
455
+ }
456
+
457
+ export function isRegistrationError(error: any): error is RegistrationError;
458
+
459
+ export interface RequestError extends Error {
460
+ name: "RequestError";
461
+ variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
462
+ }
463
+
464
+ export function isRequestError(error: any): error is RequestError;
465
+
466
+ export interface RestoreCipherAdminError extends Error {
467
+ name: "RestoreCipherAdminError";
468
+ variant: "Api" | "VaultParse" | "Crypto";
469
+ }
470
+
471
+ export function isRestoreCipherAdminError(error: any): error is RestoreCipherAdminError;
472
+
473
+ export interface RestoreCipherError extends Error {
474
+ name: "RestoreCipherError";
475
+ variant: "Api" | "VaultParse" | "Repository" | "Crypto";
476
+ }
477
+
478
+ export function isRestoreCipherError(error: any): error is RestoreCipherError;
479
+
480
+ export interface RotateCryptographyStateError extends Error {
481
+ name: "RotateCryptographyStateError";
482
+ variant: "KeyMissing" | "InvalidData";
483
+ }
484
+
485
+ export function isRotateCryptographyStateError(error: any): error is RotateCryptographyStateError;
486
+
487
+ export interface RotateUserKeysError extends Error {
488
+ name: "RotateUserKeysError";
489
+ variant:
490
+ | "ApiError"
491
+ | "CryptoError"
492
+ | "InvalidPublicKey"
493
+ | "UntrustedKeyError"
494
+ | "UnimplementedKeyRotationMethod";
495
+ }
496
+
497
+ export function isRotateUserKeysError(error: any): error is RotateUserKeysError;
498
+
499
+ export interface ServerCommunicationConfigRepositoryError extends Error {
500
+ name: "ServerCommunicationConfigRepositoryError";
501
+ variant: "GetError" | "SaveError";
502
+ }
503
+
504
+ export function isServerCommunicationConfigRepositoryError(
505
+ error: any,
506
+ ): error is ServerCommunicationConfigRepositoryError;
507
+
508
+ export interface SshKeyExportError extends Error {
509
+ name: "SshKeyExportError";
510
+ variant: "KeyConversion";
511
+ }
512
+
513
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
514
+
515
+ export interface SshKeyImportError extends Error {
516
+ name: "SshKeyImportError";
517
+ variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
518
+ }
519
+
520
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
521
+
522
+ export interface StateRegistryError extends Error {
523
+ name: "StateRegistryError";
524
+ variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
525
+ }
526
+
527
+ export function isStateRegistryError(error: any): error is StateRegistryError;
528
+
529
+ export interface StatefulCryptoError extends Error {
530
+ name: "StatefulCryptoError";
531
+ variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
532
+ }
533
+
534
+ export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
535
+
536
+ export interface SubscribeError extends Error {
537
+ name: "SubscribeError";
538
+ variant: "NotStarted";
539
+ }
540
+
541
+ export function isSubscribeError(error: any): error is SubscribeError;
542
+
543
+ export interface SyncError extends Error {
544
+ name: "SyncError";
545
+ variant: "NetworkError" | "DataError";
546
+ }
547
+
548
+ export function isSyncError(error: any): error is SyncError;
549
+
550
+ export interface TestError extends Error {
551
+ name: "TestError";
552
+ }
553
+
554
+ export function isTestError(error: any): error is TestError;
555
+
556
+ export interface TotpError extends Error {
557
+ name: "TotpError";
558
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
559
+ }
560
+
561
+ export function isTotpError(error: any): error is TotpError;
562
+
563
+ export interface TypedReceiveError extends Error {
564
+ name: "TypedReceiveError";
565
+ variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
566
+ }
567
+
568
+ export function isTypedReceiveError(error: any): error is TypedReceiveError;
569
+
570
+ export interface UsernameError extends Error {
571
+ name: "UsernameError";
572
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
573
+ }
574
+
575
+ export function isUsernameError(error: any): error is UsernameError;
576
+
577
+ export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
578
+
579
+ /**
580
+ * @deprecated Use PasswordManagerClient instead
581
+ */
582
+ export type BitwardenClient = PasswordManagerClient;
583
+
584
+ /**
585
+ * Platform API interface for acquiring SSO cookies.
586
+ *
587
+ * Platform clients implement this interface to handle cookie acquisition
588
+ * through browser redirects or other platform-specific mechanisms.
589
+ */
590
+ export interface ServerCommunicationConfigPlatformApi {
591
+ /**
592
+ * Acquires cookies using the provided vault URL.
593
+ *
594
+ * This typically involves redirecting to an IdP login page and extracting
595
+ * cookies from the load balancer response. For sharded cookies, returns
596
+ * multiple entries with names like "CookieName-0", "CookieName-1", etc.
597
+ *
598
+ * @param vaultUrl The full vault URL (e.g., "https://vault.bitwarden.com" or "https://localhost:8000")
599
+ * @returns An array of AcquiredCookie objects, or undefined if acquisition failed or was cancelled
600
+ */
601
+ acquireCookies(vaultUrl: string): Promise<AcquiredCookie[] | undefined>;
602
+ }
603
+
604
+ /**
605
+ * Repository interface for storing server communication configuration.
606
+ *
607
+ * Implementations use StateProvider (or equivalent storage mechanism) to
608
+ * persist configuration across sessions. The hostname is typically the vault
609
+ * server's hostname (e.g., "vault.acme.com").
610
+ */
611
+ export interface ServerCommunicationConfigRepository {
612
+ /**
613
+ * Retrieves the server communication configuration for a given hostname.
614
+ *
615
+ * @param hostname The server hostname (e.g., "vault.acme.com")
616
+ * @returns The configuration if it exists, undefined otherwise
617
+ */
618
+ get(hostname: string): Promise<ServerCommunicationConfig | undefined>;
619
+
620
+ /**
621
+ * Saves the server communication configuration for a given hostname.
622
+ *
623
+ * @param hostname The server hostname (e.g., "vault.acme.com")
624
+ * @param config The configuration to store
625
+ */
626
+ save(hostname: string, config: ServerCommunicationConfig): Promise<void>;
627
+ }
628
+
629
+ export interface IpcCommunicationBackendSender {
630
+ send(message: OutgoingMessage): Promise<void>;
631
+ }
632
+
633
+ export interface IpcSessionRepository {
634
+ get(endpoint: Endpoint): Promise<any | undefined>;
635
+ save(endpoint: Endpoint, session: any): Promise<void>;
636
+ remove(endpoint: Endpoint): Promise<void>;
637
+ }
638
+
639
+ export interface Repository<T> {
640
+ get(id: string): Promise<T | null>;
641
+ list(): Promise<T[]>;
642
+ set(id: string, value: T): Promise<void>;
643
+ setBulk(values: [string, T][]): Promise<void>;
644
+ remove(id: string): Promise<void>;
645
+ removeBulk(keys: string[]): Promise<void>;
646
+ removeAll(): Promise<void>;
647
+ }
648
+
649
+ export interface TokenProvider {
650
+ get_access_token(): Promise<string | undefined>;
651
+ }
652
+
653
+ export type DataEnvelope = Tagged<string, "DataEnvelope">;
654
+
655
+ export type EncString = Tagged<string, "EncString">;
656
+
657
+ export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
658
+
659
+ export type PublicKey = Tagged<string, "PublicKey">;
660
+
661
+ export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
662
+
663
+ export type SignedSecurityState = string;
664
+
665
+ export type SymmetricKeyEnvelope = Tagged<string, "SymmetricKeyEnvelope">;
666
+
667
+ /**
668
+ * A cookie acquired from the platform
669
+ *
670
+ * Represents a single cookie name/value pair as received from the browser or HTTP client.
671
+ * For sharded cookies (AWS ALB pattern), each shard is a separate `AcquiredCookie` with
672
+ * its own name including the `-{N}` suffix (e.g., `AWSELBAuthSessionCookie-0`).
673
+ */
674
+ export interface AcquiredCookie {
675
+ /**
676
+ * Cookie name
677
+ *
678
+ * For sharded cookies, this includes the shard suffix (e.g., `AWSELBAuthSessionCookie-0`)
679
+ * For unsharded cookies, this is the cookie name without any suffix.
680
+ */
681
+ name: string;
682
+ /**
683
+ * Cookie value
684
+ */
685
+ value: string;
686
+ }
687
+
688
+ /**
689
+ * A persisted organization encryption key.
690
+ *
691
+ * Stored in a Repository keyed by [`OrganizationId`].
692
+ * The `org_id` is included in the struct so it can be recovered from `Repository::list()`.
693
+ */
694
+ export interface OrganizationSharedKey {
695
+ /**
696
+ * The organization this key belongs to.
697
+ */
698
+ org_id: OrganizationId;
699
+ /**
700
+ * The organization\'s shared encryption key.
701
+ */
702
+ key: UnsignedSharedKey;
703
+ }
704
+
705
+ /**
706
+ * A request structure for requesting a send access token from the API.
707
+ */
708
+ export interface SendAccessTokenRequest {
709
+ /**
710
+ * The id of the send for which the access token is requested.
711
+ */
712
+ sendId: string;
713
+ /**
714
+ * The optional send access credentials.
715
+ */
716
+ sendAccessCredentials?: SendAccessCredentials;
717
+ }
718
+
719
+ /**
720
+ * A send access token which can be used to access a send.
721
+ */
722
+ export interface SendAccessTokenResponse {
723
+ /**
724
+ * The actual token string.
725
+ */
726
+ token: string;
727
+ /**
728
+ * The timestamp in milliseconds when the token expires.
729
+ */
730
+ expiresAt: number;
731
+ }
732
+
733
+ /**
734
+ * A set of keys where a given `DownstreamKey` is protected by an encrypted public/private
735
+ * key-pair. The `DownstreamKey` is used to encrypt/decrypt data, while the public/private key-pair
736
+ * is used to rotate the `DownstreamKey`.
737
+ *
738
+ * The `PrivateKey` is protected by an `UpstreamKey`, such as a `DeviceKey`, or `PrfKey`,
739
+ * and the `PublicKey` is protected by the `DownstreamKey`. This setup allows:
740
+ *
741
+ * - Access to `DownstreamKey` by knowing the `UpstreamKey`
742
+ * - Rotation to a `NewDownstreamKey` by knowing the current `DownstreamKey`, without needing
743
+ * access to the `UpstreamKey`
744
+ */
745
+ export interface RotateableKeySet {
746
+ /**
747
+ * `DownstreamKey` protected by encapsulation key
748
+ */
749
+ encapsulatedDownstreamKey: UnsignedSharedKey;
750
+ /**
751
+ * Encapsulation key protected by `DownstreamKey`
752
+ */
753
+ encryptedEncapsulationKey: EncString;
754
+ /**
755
+ * Decapsulation key protected by `UpstreamKey`
756
+ */
757
+ encryptedDecapsulationKey: EncString;
758
+ }
759
+
760
+ /**
761
+ * A single log event captured by the Flight Recorder.
762
+ */
763
+ export interface FlightRecorderEvent {
764
+ /**
765
+ * Unix timestamp in milliseconds.
766
+ */
767
+ timestamp: number;
768
+ /**
769
+ * Log level (e.g. \"DEBUG\", \"INFO\", \"WARN\", \"ERROR\").
770
+ */
771
+ level: string;
772
+ /**
773
+ * Target module path (e.g. \"bitwarden_core::client\").
774
+ */
775
+ target: string;
776
+ /**
777
+ * Primary log message.
778
+ */
779
+ message: string;
780
+ /**
781
+ * Structured fields from the tracing event.
782
+ */
783
+ fields: Record<string, string>;
784
+ }
785
+
786
+ /**
787
+ * Active feature flags for the SDK.
788
+ */
789
+ export interface FeatureFlags extends Map<string, boolean> {}
790
+
791
+ /**
792
+ * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
793
+ * Private keys are protected by the user key.
794
+ */
795
+ export type WrappedAccountCryptographicState =
796
+ | { V1: { private_key: EncString } }
797
+ | {
798
+ V2: {
799
+ private_key: EncString;
800
+ signed_public_key: SignedPublicKey | undefined;
801
+ signing_key: EncString;
802
+ security_state: SignedSecurityState;
803
+ };
804
+ };
805
+
806
+ /**
807
+ * Any unexpected error that occurs when making requests to identity. This could be
808
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
809
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
810
+ * unexpected body or status. Used when decoding the server\'s error payload into
811
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
812
+ * available.
813
+ */
814
+ export type UnexpectedIdentityError = string;
815
+
816
+ /**
817
+ * Auth requests supports multiple initialization methods.
818
+ */
819
+ export type AuthRequestMethod =
820
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
821
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
822
+
823
+ /**
824
+ * Available fields on a cipher and can be copied from a the list view in the UI.
825
+ */
826
+ export type CopyableCipherFields =
827
+ | "LoginUsername"
828
+ | "LoginPassword"
829
+ | "LoginTotp"
830
+ | "CardNumber"
831
+ | "CardSecurityCode"
832
+ | "IdentityUsername"
833
+ | "IdentityEmail"
834
+ | "IdentityPhone"
835
+ | "IdentityAddress"
836
+ | "SshKey"
837
+ | "SecureNotes";
838
+
839
+ /**
840
+ * Base64 encoded data
841
+ *
842
+ * Is indifferent about padding when decoding, but always produces padding when encoding.
843
+ */
844
+ export type B64 = string;
845
+
846
+ /**
847
+ * Basic client behavior settings. These settings specify the various targets and behavior of the
848
+ * Bitwarden Client. They are optional and uneditable once the client is initialized.
849
+ *
850
+ * Defaults to
851
+ *
852
+ * ```
853
+ * # use bitwarden_core::{ClientSettings, DeviceType};
854
+ * let settings = ClientSettings {
855
+ * identity_url: \"https://identity.bitwarden.com\".to_string(),
856
+ * api_url: \"https://api.bitwarden.com\".to_string(),
857
+ * user_agent: \"Bitwarden Rust-SDK\".to_string(),
858
+ * device_type: DeviceType::SDK,
859
+ * bitwarden_client_version: None,
860
+ * bitwarden_package_type: None,
861
+ * device_identifier: None,
862
+ * };
863
+ * let default = ClientSettings::default();
864
+ * ```
865
+ */
866
+ export interface ClientSettings {
867
+ /**
868
+ * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
869
+ */
870
+ identityUrl?: string;
871
+ /**
872
+ * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
873
+ */
874
+ apiUrl?: string;
875
+ /**
876
+ * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
877
+ */
878
+ userAgent?: string;
879
+ /**
880
+ * Device type to send to Bitwarden. Defaults to SDK
881
+ */
882
+ deviceType?: DeviceType;
883
+ /**
884
+ * Device identifier to send to Bitwarden. Optional for now in transition period.
885
+ */
886
+ deviceIdentifier?: string | undefined;
887
+ /**
888
+ * Bitwarden Client Version to send to Bitwarden. Optional for now in transition period.
889
+ */
890
+ bitwardenClientVersion?: string | undefined;
891
+ /**
892
+ * Bitwarden Package Type to send to Bitwarden. We should evaluate this field to see if it
893
+ * should be optional later.
894
+ */
895
+ bitwardenPackageType?: string | undefined;
896
+ }
897
+
898
+ /**
899
+ * Bootstrap configuration for server communication
900
+ */
901
+ export type BootstrapConfig =
902
+ | { type: "direct" }
903
+ | ({ type: "ssoCookieVendor" } & SsoCookieVendorConfig);
904
+
905
+ /**
906
+ * Bootstrap configuration variant for [`SetCommunicationTypeRequest`]
907
+ */
908
+ export type BootstrapConfigRequest =
909
+ | { type: "direct" }
910
+ | ({ type: "ssoCookieVendor" } & SsoCookieVendorConfigRequest);
911
+
912
+ /**
913
+ * Common login response model used across different login methods.
914
+ */
915
+ export type LoginResponse = { Authenticated: LoginSuccessResponse };
916
+
917
+ /**
918
+ * Configures the email forwarding service to use.
919
+ * For instructions on how to configure each service, see the documentation:
920
+ * <https://bitwarden.com/help/generator/#username-types>
921
+ */
922
+ export type ForwarderServiceType =
923
+ | { addyIo: { api_token: string; domain: string; base_url: string } }
924
+ | { duckDuckGo: { token: string } }
925
+ | { firefox: { api_token: string } }
926
+ | { fastmail: { api_token: string } }
927
+ | { forwardEmail: { api_token: string; domain: string } }
928
+ | { simpleLogin: { api_key: string; base_url: string } };
929
+
930
+ /**
931
+ * Credentials for getting a send access token using an email and OTP.
932
+ */
933
+ export interface SendEmailOtpCredentials {
934
+ /**
935
+ * The email address to which the OTP will be sent.
936
+ */
937
+ email: string;
938
+ /**
939
+ * The one-time password (OTP) that the user has received via email.
940
+ */
941
+ otp: string;
942
+ }
943
+
944
+ /**
945
+ * Credentials for sending an OTP to the user\'s email address.
946
+ * This is used when the send requires email verification with an OTP.
947
+ */
948
+ export interface SendEmailCredentials {
949
+ /**
950
+ * The email address to which the OTP will be sent.
951
+ */
952
+ email: string;
953
+ }
954
+
955
+ /**
956
+ * Credentials for sending password secured access requests.
957
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
958
+ * struct.
959
+ */
960
+ export interface SendPasswordCredentials {
961
+ /**
962
+ * A Base64-encoded hash of the password protecting the send.
963
+ */
964
+ passwordHashB64: string;
965
+ }
966
+
967
+ /**
968
+ * Describes the source of an incoming IPC message with per-variant metadata.
969
+ *
970
+ * `Source` mirrors [`Endpoint`] but carries additional context about the sender
971
+ * that the application layer needs for security decisions (e.g., checking `origin`
972
+ * for web sources). Use [`From<Source> for Endpoint`] to convert a source into an
973
+ * addressable endpoint (dropping the metadata).
974
+ */
975
+ export type Source =
976
+ | { Web: { tab_id: number; document_id: string; origin: string } }
977
+ | { BrowserForeground: { id: number } }
978
+ | { BrowserBackground: { id: HostId } }
979
+ | "DesktopRenderer"
980
+ | "DesktopMain";
981
+
982
+ /**
983
+ * Device information for login requests.
984
+ * This is common across all login mechanisms and describes the device
985
+ * making the authentication request.
986
+ */
987
+ export interface LoginDeviceRequest {
988
+ /**
989
+ * The type of device making the login request
990
+ * Note: today, we already have the DeviceType on the ApiConfigurations
991
+ * but we do not have the other device fields so we will accept the device data at login time
992
+ * for now. In the future, we might refactor the unauthN client to instantiate with full
993
+ * device info which would deprecate this struct. However, using the device_type here
994
+ * allows us to avoid any timing issues in scenarios where the device type could change
995
+ * between client instantiation and login (unlikely but possible).
996
+ */
997
+ deviceType: DeviceType;
998
+ /**
999
+ * Unique identifier for the device
1000
+ */
1001
+ deviceIdentifier: string;
1002
+ /**
1003
+ * Human-readable name of the device
1004
+ */
1005
+ deviceName: string;
1006
+ /**
1007
+ * Push notification token for the device (only for mobile devices)
1008
+ */
1009
+ devicePushToken: string | undefined;
1010
+ }
1011
+
1012
+ /**
1013
+ * File-based send content
1014
+ */
1015
+ export interface SendFile {
1016
+ /**
1017
+ * The file\'s ID
1018
+ */
1019
+ id: string | undefined;
1020
+ /**
1021
+ * The encrypted file name
1022
+ */
1023
+ fileName: EncString;
1024
+ /**
1025
+ * The file size in bytes as a string
1026
+ */
1027
+ size: string | undefined;
1028
+ /**
1029
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1030
+ */
1031
+ sizeName: string | undefined;
1032
+ }
1033
+
1034
+ /**
1035
+ * Holds both V1 and V2 user keys, each wrapped by the other.
1036
+ */
1037
+ export interface V2UpgradeToken {
1038
+ /**
1039
+ * V1 user key encrypted with V2 key (Cose_Encrypt0_B64 format)
1040
+ */
1041
+ wrapped_user_key_1: EncString;
1042
+ /**
1043
+ * V2 user key encrypted with V1 key (Aes256Cbc_HmacSha256_B64 format)
1044
+ */
1045
+ wrapped_user_key_2: EncString;
1046
+ }
1047
+
1048
+ /**
1049
+ * IPC destination/source endpoint for SDK clients.
1050
+ *
1051
+ * Endpoints are categorized by their role in the connection topology:
1052
+ * - **Host endpoints** ([`HostId`]): Connection hubs that can be addressed relationally or
1053
+ * specifically. ([`BrowserBackground`](Endpoint::BrowserBackground))
1054
+ * - **Leaf endpoints**: Addressed by transport-assigned IDs. ([`Web`](Endpoint::Web),
1055
+ * [`BrowserForeground`](Endpoint::BrowserForeground))
1056
+ * - **Singleton endpoints**: Exactly one instance globally, no ID needed.
1057
+ * ([`DesktopMain`](Endpoint::DesktopMain), [`DesktopRenderer`](Endpoint::DesktopRenderer))
1058
+ */
1059
+ export type Endpoint =
1060
+ | { Web: { tab_id: number; document_id: string } }
1061
+ | { BrowserForeground: { id: number } }
1062
+ | { BrowserBackground: { id: HostId } }
1063
+ | "DesktopRenderer"
1064
+ | "DesktopMain";
1065
+
1066
+ /**
1067
+ * Identifies a host endpoint, one that manages connections for other endpoints.
1068
+ *
1069
+ * Host endpoints can be addressed relationally (when the sender has a direct connection
1070
+ * and there is only one from their perspective) or by a specific transport-assigned ID
1071
+ * (when distinguishing between multiple instances).
1072
+ */
1073
+ export type HostId = "Own" | { Id: number };
1074
+
1075
+ /**
1076
+ * Indicates the authentication strategy to use when accessing a Send
1077
+ */
1078
+ export type AuthType = "Email" | "Password" | "None";
1079
+
1080
+ /**
1081
+ * Invalid grant errors - typically due to invalid credentials.
1082
+ */
1083
+ export type SendAccessTokenInvalidGrantError =
1084
+ | "send_id_invalid"
1085
+ | "password_hash_b64_invalid"
1086
+ | "unknown";
1087
+
1088
+ /**
1089
+ * Invalid request errors - typically due to missing parameters.
1090
+ */
1091
+ export type SendAccessTokenInvalidRequestError =
1092
+ | "send_id_required"
1093
+ | "password_hash_b64_required"
1094
+ | "email_required"
1095
+ | "email_and_otp_required"
1096
+ | "unknown";
1097
+
1098
+ /**
1099
+ * Key Derivation Function for Bitwarden Account
1100
+ *
1101
+ * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
1102
+ * Enum represents all the possible KDFs.
1103
+ */
1104
+ export type Kdf =
1105
+ | { pBKDF2: { iterations: NonZeroU32 } }
1106
+ | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
1107
+
1108
+ /**
1109
+ * Login cipher data needed for risk evaluation.
1110
+ */
1111
+ export interface CipherLoginDetails {
1112
+ /**
1113
+ * Cipher ID to identify which cipher in results.
1114
+ */
1115
+ id: CipherId;
1116
+ /**
1117
+ * The decrypted password to evaluate.
1118
+ */
1119
+ password: string;
1120
+ /**
1121
+ * Username or email (login ciphers only have one field).
1122
+ */
1123
+ username: string | undefined;
1124
+ }
1125
+
1126
+ /**
1127
+ * Minimal CardView only including the needed details for list views
1128
+ */
1129
+ export interface CardListView {
1130
+ /**
1131
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1132
+ */
1133
+ brand: string | undefined;
1134
+ }
1135
+
1136
+ /**
1137
+ * Minimal field view for list/search operations.
1138
+ * Contains only the fields needed for search indexing.
1139
+ */
1140
+ export interface FieldListView {
1141
+ /**
1142
+ * Only populated if the field has a name.
1143
+ */
1144
+ name: string | undefined;
1145
+ /**
1146
+ * Only populated for [FieldType::Text] fields.
1147
+ */
1148
+ value: string | undefined;
1149
+ /**
1150
+ * The field type.
1151
+ */
1152
+ type: FieldType;
1153
+ }
1154
+
1155
+ /**
1156
+ * NewType wrapper for `CipherId`
1157
+ */
1158
+ export type CipherId = Tagged<Uuid, "CipherId">;
1159
+
1160
+ /**
1161
+ * NewType wrapper for `CollectionId`
1162
+ */
1163
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
1164
+
1165
+ /**
1166
+ * NewType wrapper for `FolderId`
1167
+ */
1168
+ export type FolderId = Tagged<Uuid, "FolderId">;
1169
+
1170
+ /**
1171
+ * NewType wrapper for `OrganizationId`
1172
+ */
1173
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
1174
+
1175
+ /**
1176
+ * NewType wrapper for `SendId`
1177
+ */
1178
+ export type SendId = Tagged<Uuid, "SendId">;
1179
+
1180
+ /**
1181
+ * NewType wrapper for `UserId`
1182
+ */
1183
+ export type UserId = Tagged<Uuid, "UserId">;
1184
+
1185
+ /**
1186
+ * Options for configuring risk computation.
1187
+ */
1188
+ export interface CipherRiskOptions {
1189
+ /**
1190
+ * Pre-computed password reuse map (password → count).
1191
+ * If provided, enables reuse detection across ciphers.
1192
+ */
1193
+ passwordMap?: PasswordReuseMap | undefined;
1194
+ /**
1195
+ * Whether to check passwords against Have I Been Pwned API.
1196
+ * When true, makes network requests to check for exposed passwords.
1197
+ */
1198
+ checkExposed?: boolean;
1199
+ /**
1200
+ * Optional HIBP API base URL override. When None, uses the production HIBP URL.
1201
+ * Can be used for testing or alternative password breach checking services.
1202
+ */
1203
+ hibpBaseUrl?: string | undefined;
1204
+ }
1205
+
1206
+ /**
1207
+ * Passphrase generator request options.
1208
+ */
1209
+ export interface PassphraseGeneratorRequest {
1210
+ /**
1211
+ * Number of words in the generated passphrase.
1212
+ * This value must be between 3 and 20.
1213
+ */
1214
+ numWords: number;
1215
+ /**
1216
+ * Character separator between words in the generated passphrase. The value cannot be empty.
1217
+ */
1218
+ wordSeparator: string;
1219
+ /**
1220
+ * When set to true, capitalize the first letter of each word in the generated passphrase.
1221
+ */
1222
+ capitalize: boolean;
1223
+ /**
1224
+ * When set to true, include a number at the end of one of the words in the generated
1225
+ * passphrase.
1226
+ */
1227
+ includeNumber: boolean;
1228
+ }
1229
+
1230
+ /**
1231
+ * Password generator request options.
1232
+ */
1233
+ export interface PasswordGeneratorRequest {
1234
+ /**
1235
+ * Include lowercase characters (a-z).
1236
+ */
1237
+ lowercase: boolean;
1238
+ /**
1239
+ * Include uppercase characters (A-Z).
1240
+ */
1241
+ uppercase: boolean;
1242
+ /**
1243
+ * Include numbers (0-9).
1244
+ */
1245
+ numbers: boolean;
1246
+ /**
1247
+ * Include special characters: ! @ # $ % ^ & *
1248
+ */
1249
+ special: boolean;
1250
+ /**
1251
+ * The length of the generated password.
1252
+ * Note that the password length must be greater than the sum of all the minimums.
1253
+ */
1254
+ length: number;
1255
+ /**
1256
+ * When set to true, the generated password will not contain ambiguous characters.
1257
+ * The ambiguous characters are: I, O, l, 0, 1
1258
+ */
1259
+ avoidAmbiguous: boolean;
1260
+ /**
1261
+ * The minimum number of lowercase characters in the generated password.
1262
+ * When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
1263
+ */
1264
+ minLowercase: number | undefined;
1265
+ /**
1266
+ * The minimum number of uppercase characters in the generated password.
1267
+ * When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
1268
+ */
1269
+ minUppercase: number | undefined;
1270
+ /**
1271
+ * The minimum number of numbers in the generated password.
1272
+ * When set, the value must be between 1 and 9. This value is ignored if numbers is false.
1273
+ */
1274
+ minNumber: number | undefined;
1275
+ /**
1276
+ * The minimum number of special characters in the generated password.
1277
+ * When set, the value must be between 1 and 9. This value is ignored if special is false.
1278
+ */
1279
+ minSpecial: number | undefined;
1280
+ }
1281
+
1282
+ /**
1283
+ * Password reuse map wrapper for WASM compatibility.
1284
+ */
1285
+ export type PasswordReuseMap = Record<string, number>;
1286
+
1287
+ /**
1288
+ * Public SDK request model for logging in via password
1289
+ */
1290
+ export interface PasswordLoginRequest {
1291
+ /**
1292
+ * Common login request fields
1293
+ */
1294
+ loginRequest: LoginRequest;
1295
+ /**
1296
+ * User\'s email address
1297
+ */
1298
+ email: string;
1299
+ /**
1300
+ * User\'s master password
1301
+ */
1302
+ password: string;
1303
+ /**
1304
+ * Prelogin data required for password authentication
1305
+ * (e.g., KDF configuration for deriving the master key)
1306
+ */
1307
+ preloginResponse: PasswordPreloginResponse;
1308
+ }
1309
+
1310
+ /**
1311
+ * Represents errors that can occur when requesting a send access token.
1312
+ * It includes expected and unexpected API errors.
1313
+ */
1314
+ export type SendAccessTokenError =
1315
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
1316
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
1317
+
1318
+ /**
1319
+ * Represents the PIN envelope in memory, when ephemeral PIN unlock is used.
1320
+ */
1321
+ export interface EphemeralPinEnvelopeState {
1322
+ pin_envelope: PasswordProtectedKeyEnvelope;
1323
+ }
1324
+
1325
+ /**
1326
+ * Represents the data required to authenticate with the master password.
1327
+ */
1328
+ export interface MasterPasswordAuthenticationData {
1329
+ kdf: Kdf;
1330
+ salt: string;
1331
+ masterPasswordAuthenticationHash: B64;
1332
+ }
1333
+
1334
+ /**
1335
+ * Represents the data required to unlock with the master password.
1336
+ */
1337
+ export interface MasterPasswordUnlockData {
1338
+ /**
1339
+ * The key derivation function used to derive the master key
1340
+ */
1341
+ kdf: Kdf;
1342
+ /**
1343
+ * The master key wrapped user key
1344
+ */
1345
+ masterKeyWrappedUserKey: EncString;
1346
+ /**
1347
+ * The salt used in the KDF, typically the user\'s email
1348
+ */
1349
+ salt: string;
1350
+ }
1351
+
1352
+ /**
1353
+ * Represents the decrypted symmetric user-key of a user. This is held in ephemeral state of the
1354
+ * client.
1355
+ */
1356
+ export interface UserKeyState {
1357
+ decrypted_user_key: B64;
1358
+ }
1359
+
1360
+ /**
1361
+ * Represents the inner data of a cipher view.
1362
+ */
1363
+ export type CipherViewType =
1364
+ | { login: LoginView }
1365
+ | { card: CardView }
1366
+ | { identity: IdentityView }
1367
+ | { secureNote: SecureNoteView }
1368
+ | { sshKey: SshKeyView };
1369
+
1370
+ /**
1371
+ * Represents the local user data key, wrapped by user key.
1372
+ * This key is used to encrypt local user data (e.g., password generator history).
1373
+ */
1374
+ export interface LocalUserDataKeyState {
1375
+ wrapped_key: EncString;
1376
+ }
1377
+
1378
+ /**
1379
+ * Represents the possible, expected errors that can occur when requesting a send access token.
1380
+ */
1381
+ export type SendAccessTokenApiErrorResponse =
1382
+ | {
1383
+ error: "invalid_request";
1384
+ error_description?: string;
1385
+ send_access_error_type?: SendAccessTokenInvalidRequestError;
1386
+ }
1387
+ | {
1388
+ error: "invalid_grant";
1389
+ error_description?: string;
1390
+ send_access_error_type?: SendAccessTokenInvalidGrantError;
1391
+ }
1392
+ | { error: "invalid_client"; error_description?: string }
1393
+ | { error: "unauthorized_client"; error_description?: string }
1394
+ | { error: "unsupported_grant_type"; error_description?: string }
1395
+ | { error: "invalid_scope"; error_description?: string }
1396
+ | { error: "invalid_target"; error_description?: string };
1397
+
1398
+ /**
1399
+ * Represents the request to initialize the user\'s organizational cryptographic state.
1400
+ */
1401
+ export interface InitOrgCryptoRequest {
1402
+ /**
1403
+ * The encryption keys for all the organizations the user is a part of
1404
+ */
1405
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
1406
+ }
1407
+
1408
+ /**
1409
+ * Represents the result of decrypting a list of ciphers.
1410
+ *
1411
+ * This struct contains two vectors: `successes` and `failures`.
1412
+ * `successes` contains the decrypted `CipherListView` objects,
1413
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1414
+ */
1415
+ export interface DecryptCipherListResult {
1416
+ /**
1417
+ * The decrypted `CipherListView` objects.
1418
+ */
1419
+ successes: CipherListView[];
1420
+ /**
1421
+ * The original `Cipher` objects that failed to decrypt.
1422
+ */
1423
+ failures: Cipher[];
1424
+ }
1425
+
1426
+ /**
1427
+ * Represents the result of decrypting a list of ciphers.
1428
+ *
1429
+ * This struct contains two vectors: `successes` and `failures`.
1430
+ * `successes` contains the decrypted `CipherView` objects,
1431
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1432
+ */
1433
+ export interface DecryptCipherResult {
1434
+ /**
1435
+ * The decrypted `CipherView` objects.
1436
+ */
1437
+ successes: CipherView[];
1438
+ /**
1439
+ * The original `Cipher` objects that failed to decrypt.
1440
+ */
1441
+ failures: Cipher[];
1442
+ }
1443
+
1444
+ /**
1445
+ * Represents the result of fetching and decrypting all ciphers for an organization.
1446
+ *
1447
+ * Contains the encrypted ciphers from the API alongside their decrypted list views.
1448
+ */
1449
+ export interface ListOrganizationCiphersResult {
1450
+ /**
1451
+ * All encrypted ciphers returned from the API.
1452
+ */
1453
+ ciphers: Cipher[];
1454
+ /**
1455
+ * Successfully decrypted `CipherListView` objects.
1456
+ */
1457
+ listViews: CipherListView[];
1458
+ }
1459
+
1460
+ /**
1461
+ * Request for `verify_asymmetric_keys`.
1462
+ */
1463
+ export interface VerifyAsymmetricKeysRequest {
1464
+ /**
1465
+ * The user\'s user key
1466
+ */
1467
+ userKey: B64;
1468
+ /**
1469
+ * The user\'s public key
1470
+ */
1471
+ userPublicKey: B64;
1472
+ /**
1473
+ * User\'s private key, encrypted with the user key
1474
+ */
1475
+ userKeyEncryptedPrivateKey: EncString;
1476
+ }
1477
+
1478
+ /**
1479
+ * Request for deriving a pin protected user key
1480
+ */
1481
+ export interface DerivePinKeyResponse {
1482
+ /**
1483
+ * [UserKey] protected by PIN
1484
+ */
1485
+ pinProtectedUserKey: EncString;
1486
+ /**
1487
+ * PIN protected by [UserKey]
1488
+ */
1489
+ encryptedPin: EncString;
1490
+ }
1491
+
1492
+ /**
1493
+ * Request for deriving a pin protected user key
1494
+ */
1495
+ export interface EnrollPinResponse {
1496
+ /**
1497
+ * [UserKey] protected by PIN
1498
+ */
1499
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
1500
+ /**
1501
+ * PIN protected by [UserKey]
1502
+ */
1503
+ userKeyEncryptedPin: EncString;
1504
+ }
1505
+
1506
+ /**
1507
+ * Request for migrating an account from password to key connector.
1508
+ */
1509
+ export interface DeriveKeyConnectorRequest {
1510
+ /**
1511
+ * Encrypted user key, used to validate the master key
1512
+ */
1513
+ userKeyEncrypted: EncString;
1514
+ /**
1515
+ * The user\'s master password
1516
+ */
1517
+ password: string;
1518
+ /**
1519
+ * The KDF parameters used to derive the master key
1520
+ */
1521
+ kdf: Kdf;
1522
+ /**
1523
+ * The user\'s email address
1524
+ */
1525
+ email: string;
1526
+ }
1527
+
1528
+ /**
1529
+ * Request model for creating a new Send.
1530
+ */
1531
+ export interface SendAddRequest {
1532
+ /**
1533
+ * The name of the Send.
1534
+ */
1535
+ name: string;
1536
+ /**
1537
+ * Optional notes visible to the sender.
1538
+ */
1539
+ notes: string | undefined;
1540
+ /**
1541
+ * The type and content of the Send.
1542
+ */
1543
+ viewType: SendViewType;
1544
+ /**
1545
+ * Maximum number of times the Send can be accessed.
1546
+ */
1547
+ maxAccessCount: number | undefined;
1548
+ /**
1549
+ * Whether the Send is disabled and cannot be accessed.
1550
+ */
1551
+ disabled: boolean;
1552
+ /**
1553
+ * Whether to hide the sender\'s email from recipients.
1554
+ */
1555
+ hideEmail: boolean;
1556
+ /**
1557
+ * Date and time when the Send will be permanently deleted.
1558
+ */
1559
+ deletionDate: DateTime<Utc>;
1560
+ /**
1561
+ * Optional date and time when the Send expires and can no longer be accessed.
1562
+ */
1563
+ expirationDate: DateTime<Utc> | undefined;
1564
+ /**
1565
+ * Authentication method for accessing this Send.
1566
+ */
1567
+ auth: SendAuthType;
1568
+ }
1569
+
1570
+ /**
1571
+ * Request model for editing an existing Send.
1572
+ */
1573
+ export interface SendEditRequest {
1574
+ /**
1575
+ * The name of the Send.
1576
+ */
1577
+ name: string;
1578
+ /**
1579
+ * Optional notes visible to the sender.
1580
+ */
1581
+ notes: string | undefined;
1582
+ /**
1583
+ * The type and content of the Send.
1584
+ */
1585
+ viewType: SendViewType;
1586
+ /**
1587
+ * Maximum number of times the Send can be accessed.
1588
+ */
1589
+ maxAccessCount: number | undefined;
1590
+ /**
1591
+ * Whether the Send is disabled and cannot be accessed.
1592
+ */
1593
+ disabled: boolean;
1594
+ /**
1595
+ * Whether to hide the sender\'s email from recipients.
1596
+ */
1597
+ hideEmail: boolean;
1598
+ /**
1599
+ * Date and time when the Send will be permanently deleted.
1600
+ */
1601
+ deletionDate: DateTime<Utc>;
1602
+ /**
1603
+ * Optional date and time when the Send expires and can no longer be accessed.
1604
+ */
1605
+ expirationDate: DateTime<Utc> | undefined;
1606
+ /**
1607
+ * Authentication method for accessing this Send.
1608
+ */
1609
+ auth: SendAuthType;
1610
+ }
1611
+
1612
+ /**
1613
+ * Request parameters for SSO JIT master password registration.
1614
+ */
1615
+ export interface JitMasterPasswordRegistrationRequest {
1616
+ /**
1617
+ * Organization ID to enroll in
1618
+ */
1619
+ org_id: OrganizationId;
1620
+ /**
1621
+ * Organization\'s public key for encrypting the reset password key. This should be verified by
1622
+ * the client and not verifying may compromise the security of the user\'s account.
1623
+ */
1624
+ org_public_key: B64;
1625
+ /**
1626
+ * Organization SSO identifier
1627
+ */
1628
+ organization_sso_identifier: string;
1629
+ /**
1630
+ * User ID for the account being initialized
1631
+ */
1632
+ user_id: UserId;
1633
+ /**
1634
+ * Salt for master password hashing, usually email
1635
+ */
1636
+ salt: string;
1637
+ /**
1638
+ * Master password for the account
1639
+ */
1640
+ master_password: string;
1641
+ /**
1642
+ * Optional hint for the master password
1643
+ */
1644
+ master_password_hint: string | undefined;
1645
+ /**
1646
+ * Should enroll user into admin password reset
1647
+ */
1648
+ reset_password_enroll: boolean;
1649
+ }
1650
+
1651
+ /**
1652
+ * Request parameters for TDE (Trusted Device Encryption) registration.
1653
+ */
1654
+ export interface TdeRegistrationRequest {
1655
+ /**
1656
+ * Organization ID to enroll in
1657
+ */
1658
+ org_id: OrganizationId;
1659
+ /**
1660
+ * Organization\'s public key for encrypting the reset password key. This should be verified by
1661
+ * the client and not verifying may compromise the security of the user\'s account.
1662
+ */
1663
+ org_public_key: B64;
1664
+ /**
1665
+ * User ID for the account being initialized
1666
+ */
1667
+ user_id: UserId;
1668
+ /**
1669
+ * Device identifier for TDE enrollment
1670
+ */
1671
+ device_identifier: string;
1672
+ /**
1673
+ * Whether to trust this device for TDE
1674
+ */
1675
+ trust_device: boolean;
1676
+ }
1677
+
1678
+ /**
1679
+ * Request to add a cipher.
1680
+ */
1681
+ export interface CipherCreateRequest {
1682
+ organizationId: OrganizationId | undefined;
1683
+ collectionIds: CollectionId[];
1684
+ folderId: FolderId | undefined;
1685
+ name: string;
1686
+ notes: string | undefined;
1687
+ favorite: boolean;
1688
+ reprompt: CipherRepromptType;
1689
+ type: CipherViewType;
1690
+ fields: FieldView[];
1691
+ }
1692
+
1693
+ /**
1694
+ * Request to add or edit a folder.
1695
+ */
1696
+ export interface FolderAddEditRequest {
1697
+ /**
1698
+ * The new name of the folder.
1699
+ */
1700
+ name: string;
1701
+ }
1702
+
1703
+ /**
1704
+ * Request to edit a cipher.
1705
+ */
1706
+ export interface CipherEditRequest {
1707
+ id: CipherId;
1708
+ organizationId: OrganizationId | undefined;
1709
+ folderId: FolderId | undefined;
1710
+ favorite: boolean;
1711
+ reprompt: CipherRepromptType;
1712
+ name: string;
1713
+ notes: string | undefined;
1714
+ fields: FieldView[];
1715
+ type: CipherViewType;
1716
+ revisionDate: DateTime<Utc>;
1717
+ archivedDate: DateTime<Utc> | undefined;
1718
+ attachments: AttachmentView[];
1719
+ key: EncString | undefined;
1720
+ }
1721
+
1722
+ /**
1723
+ * Request to set server communication configuration for a hostname
1724
+ *
1725
+ * This is the input type for
1726
+ * [`ServerCommunicationConfigClient::set_communication_type`](crate::ServerCommunicationConfigClient::set_communication_type).
1727
+ * Unlike [`ServerCommunicationConfig`], this type does not include acquired cookies,
1728
+ * since cookies are managed separately via
1729
+ * [`ServerCommunicationConfigClient::acquire_cookie`](crate::ServerCommunicationConfigClient::acquire_cookie).
1730
+ */
1731
+ export interface SetCommunicationTypeRequest {
1732
+ /**
1733
+ * Bootstrap configuration determining how to establish server communication
1734
+ */
1735
+ bootstrap: BootstrapConfigRequest;
1736
+ }
1737
+
1738
+ /**
1739
+ * Response containing the data required before password-based authentication
1740
+ */
1741
+ export interface PasswordPreloginResponse {
1742
+ /**
1743
+ * The Key Derivation Function (KDF) configuration for the user
1744
+ */
1745
+ kdf: Kdf;
1746
+ /**
1747
+ * The salt used in the KDF process
1748
+ */
1749
+ salt: string;
1750
+ }
1751
+
1752
+ /**
1753
+ * Response for `verify_asymmetric_keys`.
1754
+ */
1755
+ export interface VerifyAsymmetricKeysResponse {
1756
+ /**
1757
+ * Whether the user\'s private key was decryptable by the user key.
1758
+ */
1759
+ privateKeyDecryptable: boolean;
1760
+ /**
1761
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
1762
+ */
1763
+ validPrivateKey: boolean;
1764
+ }
1765
+
1766
+ /**
1767
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
1768
+ */
1769
+ export interface UserCryptoV2KeysResponse {
1770
+ /**
1771
+ * User key
1772
+ */
1773
+ userKey: B64;
1774
+ /**
1775
+ * Wrapped private key
1776
+ */
1777
+ privateKey: EncString;
1778
+ /**
1779
+ * Public key
1780
+ */
1781
+ publicKey: B64;
1782
+ /**
1783
+ * The user\'s public key, signed by the signing key
1784
+ */
1785
+ signedPublicKey: SignedPublicKey;
1786
+ /**
1787
+ * Signing key, encrypted with the user\'s symmetric key
1788
+ */
1789
+ signingKey: EncString;
1790
+ /**
1791
+ * Base64 encoded verifying key
1792
+ */
1793
+ verifyingKey: B64;
1794
+ /**
1795
+ * The user\'s signed security state
1796
+ */
1797
+ securityState: SignedSecurityState;
1798
+ /**
1799
+ * The security state\'s version
1800
+ */
1801
+ securityVersion: number;
1802
+ }
1803
+
1804
+ /**
1805
+ * Response from the `make_key_pair` function
1806
+ */
1807
+ export interface MakeKeyPairResponse {
1808
+ /**
1809
+ * The user\'s public key
1810
+ */
1811
+ userPublicKey: B64;
1812
+ /**
1813
+ * User\'s private key, encrypted with the user key
1814
+ */
1815
+ userKeyEncryptedPrivateKey: EncString;
1816
+ }
1817
+
1818
+ /**
1819
+ * Response from the `make_update_password` function
1820
+ */
1821
+ export interface UpdatePasswordResponse {
1822
+ /**
1823
+ * Hash of the new password
1824
+ */
1825
+ passwordHash: B64;
1826
+ /**
1827
+ * User key, encrypted with the new password
1828
+ */
1829
+ newKey: EncString;
1830
+ }
1831
+
1832
+ /**
1833
+ * Response from the `update_kdf` function
1834
+ */
1835
+ export interface UpdateKdfResponse {
1836
+ /**
1837
+ * The authentication data for the new KDF setting
1838
+ */
1839
+ masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
1840
+ /**
1841
+ * The unlock data for the new KDF setting
1842
+ */
1843
+ masterPasswordUnlockData: MasterPasswordUnlockData;
1844
+ /**
1845
+ * The authentication data for the KDF setting prior to the change
1846
+ */
1847
+ oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
1848
+ }
1849
+
1850
+ /**
1851
+ * Result of JIT master password registration process.
1852
+ */
1853
+ export interface JitMasterPasswordRegistrationResponse {
1854
+ /**
1855
+ * The account cryptographic state of the user
1856
+ */
1857
+ account_cryptographic_state: WrappedAccountCryptographicState;
1858
+ /**
1859
+ * The master password unlock data
1860
+ */
1861
+ master_password_unlock: MasterPasswordUnlockData;
1862
+ /**
1863
+ * The decrypted user key.
1864
+ */
1865
+ user_key: B64;
1866
+ }
1867
+
1868
+ /**
1869
+ * Result of Key Connector registration process.
1870
+ */
1871
+ export interface KeyConnectorRegistrationResult {
1872
+ /**
1873
+ * The account cryptographic state of the user.
1874
+ */
1875
+ account_cryptographic_state: WrappedAccountCryptographicState;
1876
+ /**
1877
+ * The key connector key used for unlocking.
1878
+ */
1879
+ key_connector_key: B64;
1880
+ /**
1881
+ * The encrypted user key, wrapped with the key connector key.
1882
+ */
1883
+ key_connector_key_wrapped_user_key: EncString;
1884
+ /**
1885
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
1886
+ */
1887
+ user_key: B64;
1888
+ }
1889
+
1890
+ /**
1891
+ * Result of TDE registration process.
1892
+ */
1893
+ export interface TdeRegistrationResponse {
1894
+ /**
1895
+ * The account cryptographic state of the user
1896
+ */
1897
+ account_cryptographic_state: WrappedAccountCryptographicState;
1898
+ /**
1899
+ * The device key
1900
+ */
1901
+ device_key: B64;
1902
+ /**
1903
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
1904
+ */
1905
+ user_key: B64;
1906
+ }
1907
+
1908
+ /**
1909
+ * Result of checking password exposure via HIBP API.
1910
+ */
1911
+ export type ExposedPasswordResult =
1912
+ | { type: "NotChecked" }
1913
+ | { type: "Found"; value: number }
1914
+ | { type: "Error"; value: string };
1915
+
1916
+ /**
1917
+ * Risk evaluation result for a single cipher.
1918
+ */
1919
+ export interface CipherRiskResult {
1920
+ /**
1921
+ * Cipher ID matching the input CipherLoginDetails.
1922
+ */
1923
+ id: CipherId;
1924
+ /**
1925
+ * Password strength score from 0 (weakest) to 4 (strongest).
1926
+ * Calculated using zxcvbn with cipher-specific context.
1927
+ */
1928
+ password_strength: number;
1929
+ /**
1930
+ * Result of checking password exposure via HIBP API.
1931
+ * - `NotChecked`: check_exposed was false, or password was empty
1932
+ * - `Found(n)`: Successfully checked, found in n breaches
1933
+ * - `Error(msg)`: HIBP API request failed for this cipher with the given error message
1934
+ */
1935
+ exposed_result: ExposedPasswordResult;
1936
+ /**
1937
+ * Number of times this password appears in the provided password_map.
1938
+ * None if not found or if no password_map was provided.
1939
+ */
1940
+ reuse_count: number | undefined;
1941
+ }
1942
+
1943
+ /**
1944
+ * SDK domain model for Key Connector user decryption option.
1945
+ */
1946
+ export interface KeyConnectorUserDecryptionOption {
1947
+ /**
1948
+ * URL of the Key Connector server to use for decryption.
1949
+ */
1950
+ keyConnectorUrl: string;
1951
+ }
1952
+
1953
+ /**
1954
+ * SDK domain model for Trusted Device user decryption option.
1955
+ */
1956
+ export interface TrustedDeviceUserDecryptionOption {
1957
+ /**
1958
+ * Whether the user has admin approval for device login.
1959
+ */
1960
+ hasAdminApproval: boolean;
1961
+ /**
1962
+ * Whether the user has a device that can approve logins.
1963
+ */
1964
+ hasLoginApprovingDevice: boolean;
1965
+ /**
1966
+ * Whether the user has permission to manage password reset for other users.
1967
+ */
1968
+ hasManageResetPasswordPermission: boolean;
1969
+ /**
1970
+ * Whether the user is in TDE offboarding.
1971
+ */
1972
+ isTdeOffboarding: boolean;
1973
+ /**
1974
+ * The device key encrypted device private key. Only present if the device is trusted.
1975
+ */
1976
+ encryptedPrivateKey?: EncString;
1977
+ /**
1978
+ * The device private key encrypted user key. Only present if the device is trusted.
1979
+ */
1980
+ encryptedUserKey?: UnsignedSharedKey;
1981
+ }
1982
+
1983
+ /**
1984
+ * SDK domain model for WebAuthn PRF user decryption option.
1985
+ */
1986
+ export interface WebAuthnPrfUserDecryptionOption {
1987
+ /**
1988
+ * PRF key encrypted private key
1989
+ */
1990
+ encryptedPrivateKey: EncString;
1991
+ /**
1992
+ * Public Key encrypted user key
1993
+ */
1994
+ encryptedUserKey: UnsignedSharedKey;
1995
+ /**
1996
+ * Credential ID for this WebAuthn PRF credential.
1997
+ * TODO: PM-32163 - can remove `Option<T>` after 3 releases from server v2026.1.1
1998
+ */
1999
+ credentialId: string | undefined;
2000
+ /**
2001
+ * Transport methods available for this credential (e.g., \"usb\", \"nfc\", \"ble\", \"internal\",
2002
+ * \"hybrid\").
2003
+ * TODO: PM-32163 - can remove `Option<T>` after 3 releases from server v2026.1.1
2004
+ */
2005
+ transports: string[] | undefined;
2006
+ }
2007
+
2008
+ /**
2009
+ * SDK domain model for master password policy requirements.
2010
+ * Defines the complexity requirements for a user\'s master password
2011
+ * when enforced by an organization policy.
2012
+ */
2013
+ export interface MasterPasswordPolicyResponse {
2014
+ /**
2015
+ * The minimum complexity score required for the master password.
2016
+ * Complexity is calculated based on password strength metrics.
2017
+ */
2018
+ minComplexity?: number;
2019
+ /**
2020
+ * The minimum length required for the master password.
2021
+ */
2022
+ minLength?: number;
2023
+ /**
2024
+ * Whether the master password must contain at least one lowercase letter.
2025
+ */
2026
+ requireLower?: boolean;
2027
+ /**
2028
+ * Whether the master password must contain at least one uppercase letter.
2029
+ */
2030
+ requireUpper?: boolean;
2031
+ /**
2032
+ * Whether the master password must contain at least one numeric digit.
2033
+ */
2034
+ requireNumbers?: boolean;
2035
+ /**
2036
+ * Whether the master password must contain at least one special character.
2037
+ */
2038
+ requireSpecial?: boolean;
2039
+ /**
2040
+ * Whether this policy should be enforced when the user logs in.
2041
+ * If true, the user will be required to update their master password
2042
+ * if it doesn\'t meet the policy requirements.
2043
+ */
2044
+ enforceOnLogin?: boolean;
2045
+ }
2046
+
2047
+ /**
2048
+ * SDK domain model for user decryption options.
2049
+ * Provides the various methods available to unlock a user\'s vault.
2050
+ */
2051
+ export interface UserDecryptionOptionsResponse {
2052
+ /**
2053
+ * Master password unlock option. None if user doesn\'t have a master password.
2054
+ */
2055
+ masterPasswordUnlock?: MasterPasswordUnlockData;
2056
+ /**
2057
+ * Trusted Device decryption option.
2058
+ */
2059
+ trustedDeviceOption?: TrustedDeviceUserDecryptionOption;
2060
+ /**
2061
+ * Key Connector decryption option.
2062
+ * Mutually exclusive with Trusted Device option.
2063
+ */
2064
+ keyConnectorOption?: KeyConnectorUserDecryptionOption;
2065
+ /**
2066
+ * WebAuthn PRF decryption option.
2067
+ */
2068
+ webauthnPrfOption?: WebAuthnPrfUserDecryptionOption;
2069
+ }
2070
+
2071
+ /**
2072
+ * SDK response model for a successful login.
2073
+ * This is the model that will be exposed to consuming applications.
2074
+ */
2075
+ export interface LoginSuccessResponse {
2076
+ /**
2077
+ * The access token string.
2078
+ */
2079
+ accessToken: string;
2080
+ /**
2081
+ * The duration in seconds until the token expires.
2082
+ */
2083
+ expiresIn: number;
2084
+ /**
2085
+ * The timestamp in milliseconds when the token expires.
2086
+ * We calculate this for more convenient token expiration handling.
2087
+ */
2088
+ expiresAt: number;
2089
+ /**
2090
+ * The scope of the access token.
2091
+ * OAuth 2.0 RFC reference: <https://datatracker.ietf.org/doc/html/rfc6749#section-3.3>
2092
+ */
2093
+ scope: string;
2094
+ /**
2095
+ * The type of the token.
2096
+ * This will be \"Bearer\" for send access tokens.
2097
+ * OAuth 2.0 RFC reference: <https://datatracker.ietf.org/doc/html/rfc6749#section-7.1>
2098
+ */
2099
+ tokenType: string;
2100
+ /**
2101
+ * The optional refresh token string.
2102
+ * This token can be used to obtain new access tokens when the current one expires.
2103
+ */
2104
+ refreshToken: string | undefined;
2105
+ /**
2106
+ * The user key wrapped user private key.
2107
+ * Note: previously known as \"private_key\".
2108
+ */
2109
+ userKeyWrappedUserPrivateKey: string | undefined;
2110
+ /**
2111
+ * Two-factor authentication token for future requests.
2112
+ */
2113
+ twoFactorToken: string | undefined;
2114
+ /**
2115
+ * Indicates whether an admin has reset the user\'s master password,
2116
+ * requiring them to set a new password upon next login.
2117
+ */
2118
+ forcePasswordReset: boolean | undefined;
2119
+ /**
2120
+ * Indicates whether the user uses Key Connector and if the client should have a locally
2121
+ * configured Key Connector URL in their environment.
2122
+ * Note: This is currently only applicable for client_credential grant type logins and
2123
+ * is only expected to be relevant for the CLI
2124
+ */
2125
+ apiUseKeyConnector: boolean | undefined;
2126
+ /**
2127
+ * The user\'s decryption options for unlocking their vault.
2128
+ */
2129
+ userDecryptionOptions: UserDecryptionOptionsResponse;
2130
+ /**
2131
+ * If the user is subject to an organization master password policy,
2132
+ * this field contains the requirements of that policy.
2133
+ */
2134
+ masterPasswordPolicy: MasterPasswordPolicyResponse | undefined;
2135
+ }
2136
+
2137
+ /**
2138
+ * SSO cookie vendor configuration
2139
+ *
2140
+ * This configuration is provided by the server.
2141
+ */
2142
+ export interface SsoCookieVendorConfig {
2143
+ /**
2144
+ * Identity provider login URL for browser redirect during bootstrap
2145
+ */
2146
+ idpLoginUrl: string | undefined;
2147
+ /**
2148
+ * Cookie name (base name, without shard suffix)
2149
+ */
2150
+ cookieName: string | undefined;
2151
+ /**
2152
+ * Cookie domain for validation
2153
+ */
2154
+ cookieDomain: string | undefined;
2155
+ /**
2156
+ * Vault URL for cookie acquisition redirect
2157
+ *
2158
+ * This is the full vault URL (scheme + host + port) where the browser
2159
+ * should be redirected for SSO cookie acquisition.
2160
+ */
2161
+ vaultUrl: string | undefined;
2162
+ /**
2163
+ * Acquired cookies
2164
+ *
2165
+ * For sharded cookies, this contains multiple entries with names like
2166
+ * `AWSELBAuthSessionCookie-0`, `AWSELBAuthSessionCookie-1`, etc.
2167
+ * For unsharded cookies, this contains a single entry with the base name.
2168
+ */
2169
+ cookieValue: AcquiredCookie[] | undefined;
2170
+ }
2171
+
2172
+ /**
2173
+ * SSO cookie vendor configuration for [`SetCommunicationTypeRequest`]
2174
+ *
2175
+ * Contains the server-provided configuration fields without acquired cookies.
2176
+ */
2177
+ export interface SsoCookieVendorConfigRequest {
2178
+ /**
2179
+ * Identity provider login URL for browser redirect during bootstrap
2180
+ */
2181
+ idpLoginUrl: string | undefined;
2182
+ /**
2183
+ * Cookie name (base name, without shard suffix)
2184
+ */
2185
+ cookieName: string | undefined;
2186
+ /**
2187
+ * Cookie domain for validation
2188
+ */
2189
+ cookieDomain: string | undefined;
2190
+ /**
2191
+ * Vault URL for cookie acquisition redirect
2192
+ *
2193
+ * This is the full vault URL (scheme + host + port) where the browser
2194
+ * should be redirected for SSO cookie acquisition.
2195
+ */
2196
+ vaultUrl: string | undefined;
2197
+ }
2198
+
2199
+ /**
2200
+ * Server communication configuration
2201
+ */
2202
+ export interface ServerCommunicationConfig {
2203
+ /**
2204
+ * Bootstrap configuration determining how to establish server communication
2205
+ */
2206
+ bootstrap: BootstrapConfig;
2207
+ }
2208
+
2209
+ /**
2210
+ * State used for initializing the user cryptographic state.
2211
+ */
2212
+ export interface InitUserCryptoRequest {
2213
+ /**
2214
+ * The user\'s ID.
2215
+ */
2216
+ userId: UserId | undefined;
2217
+ /**
2218
+ * The user\'s KDF parameters, as received from the prelogin request
2219
+ */
2220
+ kdfParams: Kdf;
2221
+ /**
2222
+ * The user\'s email address
2223
+ */
2224
+ email: string;
2225
+ /**
2226
+ * The user\'s account cryptographic state, containing their signature and
2227
+ * public-key-encryption keys, along with the signed security state, protected by the user key
2228
+ */
2229
+ accountCryptographicState: WrappedAccountCryptographicState;
2230
+ /**
2231
+ * The method to decrypt the user\'s account symmetric key (user key)
2232
+ */
2233
+ method: InitUserCryptoMethod;
2234
+ /**
2235
+ * Optional V2 upgrade token for automatic key rotation from V1 to V2
2236
+ */
2237
+ upgradeToken?: V2UpgradeToken;
2238
+ }
2239
+
2240
+ /**
2241
+ * Temporary struct to hold metadata related to current account
2242
+ *
2243
+ * Eventually the SDK itself should have this state and we get rid of this struct.
2244
+ */
2245
+ export interface Account {
2246
+ id: Uuid;
2247
+ email: string;
2248
+ name: string | undefined;
2249
+ }
2250
+
2251
+ /**
2252
+ * Text-based send content
2253
+ */
2254
+ export interface SendText {
2255
+ text: EncString | undefined;
2256
+ hidden: boolean;
2257
+ }
2258
+
2259
+ /**
2260
+ * The common bucket of login fields to be re-used across all login mechanisms
2261
+ * (e.g., password, SSO, etc.). This will include handling client_id and 2FA.
2262
+ */
2263
+ export interface LoginRequest {
2264
+ /**
2265
+ * OAuth client identifier
2266
+ */
2267
+ clientId: string;
2268
+ /**
2269
+ * Device information for this login request
2270
+ */
2271
+ device: LoginDeviceRequest;
2272
+ }
2273
+
2274
+ /**
2275
+ * The credentials used for send access requests.
2276
+ */
2277
+ export type SendAccessCredentials =
2278
+ | SendPasswordCredentials
2279
+ | SendEmailOtpCredentials
2280
+ | SendEmailCredentials;
2281
+
2282
+ /**
2283
+ * The crypto method used to initialize the user cryptographic state.
2284
+ */
2285
+ export type InitUserCryptoMethod =
2286
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
2287
+ | { clientManagedState: {} }
2288
+ | { decryptedKey: { decrypted_user_key: string } }
2289
+ | { pin: { pin: string; pin_protected_user_key: EncString } }
2290
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
2291
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
2292
+ | {
2293
+ deviceKey: {
2294
+ device_key: string;
2295
+ protected_device_private_key: EncString;
2296
+ device_protected_user_key: UnsignedSharedKey;
2297
+ };
2298
+ }
2299
+ | { keyConnector: { master_key: B64; user_key: EncString } }
2300
+ | { keyConnectorUrl: { url: string; key_connector_key_wrapped_user_key: EncString } };
2301
+
2302
+ /**
2303
+ * The data necessary to re-share the user-key to a V1 emergency access membership. Note: The
2304
+ * Public-key must be verified/trusted. Further, there is no sender authentication possible here.
2305
+ */
2306
+ export interface V1EmergencyAccessMembership {
2307
+ id: Uuid;
2308
+ grantee_id: Uuid;
2309
+ name: string;
2310
+ public_key: PublicKey;
2311
+ }
2312
+
2313
+ /**
2314
+ * The data necessary to re-share the user-key to a V1 organization membership. Note: The
2315
+ * Public-key must be verified/trusted. Further, there is no sender authentication possible here.
2316
+ */
2317
+ export interface V1OrganizationMembership {
2318
+ organization_id: Uuid;
2319
+ name: string;
2320
+ public_key: PublicKey;
2321
+ }
2322
+
2323
+ /**
2324
+ * The response to a discover/ping request.
2325
+ */
2326
+ export interface DiscoverResponse {
2327
+ /**
2328
+ * The version of the client that responded to the discover request.
2329
+ */
2330
+ version: string;
2331
+ }
2332
+
2333
+ /**
2334
+ * The type of Send, either text or file
2335
+ */
2336
+ export type SendType = "Text" | "File";
2337
+
2338
+ /**
2339
+ * The type of key / signature scheme used for signing and verifying.
2340
+ */
2341
+ export type SignatureAlgorithm = "ed25519" | "mlDsa44";
2342
+
2343
+ /**
2344
+ * Type of collection
2345
+ */
2346
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
2347
+
2348
+ /**
2349
+ * Type-safe authentication method for a Send, including the authentication data.
2350
+ * This ensures that password and email authentication are mutually exclusive.
2351
+ */
2352
+ export type SendAuthType =
2353
+ | { type: "none" }
2354
+ | { type: "password"; password: string }
2355
+ | { type: "emails"; emails: string[] };
2356
+
2357
+ /**
2358
+ * View model for decrypted Send type
2359
+ */
2360
+ export type SendViewType = { File: SendFileView } | { Text: SendTextView };
2361
+
2362
+ /**
2363
+ * View model for decrypted SendFile
2364
+ */
2365
+ export interface SendFileView {
2366
+ /**
2367
+ * The file\'s ID
2368
+ */
2369
+ id: string | undefined;
2370
+ /**
2371
+ * The file name
2372
+ */
2373
+ fileName: string;
2374
+ /**
2375
+ * The file size in bytes as a string
2376
+ */
2377
+ size: string | undefined;
2378
+ /**
2379
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
2380
+ */
2381
+ sizeName: string | undefined;
2382
+ }
2383
+
2384
+ /**
2385
+ * View model for decrypted SendText
2386
+ */
2387
+ export interface SendTextView {
2388
+ /**
2389
+ * The text content of the send
2390
+ */
2391
+ text: string | undefined;
2392
+ /**
2393
+ * Whether the text is hidden-by-default (masked as ********).
2394
+ */
2395
+ hidden: boolean;
2396
+ }
2397
+
2398
+ export interface AncestorMap {
2399
+ ancestors: Map<CollectionId, string>;
2400
+ }
2401
+
2402
+ export interface Attachment {
2403
+ id: string | undefined;
2404
+ url: string | undefined;
2405
+ size: string | undefined;
2406
+ /**
2407
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
2408
+ */
2409
+ sizeName: string | undefined;
2410
+ fileName: EncString | undefined;
2411
+ key: EncString | undefined;
2412
+ }
2413
+
2414
+ export interface AttachmentView {
2415
+ id: string | undefined;
2416
+ url: string | undefined;
2417
+ size: string | undefined;
2418
+ sizeName: string | undefined;
2419
+ fileName: string | undefined;
2420
+ key: EncString | undefined;
2421
+ /**
2422
+ * The decrypted attachmentkey in base64 format.
2423
+ *
2424
+ * **TEMPORARY FIELD**: This field is a temporary workaround to provide
2425
+ * decrypted attachment keys to the TypeScript client during the migration
2426
+ * process. It will be removed once the encryption/decryption logic is
2427
+ * fully migrated to the SDK.
2428
+ *
2429
+ * **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
2430
+ *
2431
+ * Do not rely on this field for long-term use.
2432
+ */
2433
+ decryptedKey: string | undefined;
2434
+ }
2435
+
2436
+ export interface Card {
2437
+ cardholderName: EncString | undefined;
2438
+ expMonth: EncString | undefined;
2439
+ expYear: EncString | undefined;
2440
+ code: EncString | undefined;
2441
+ brand: EncString | undefined;
2442
+ number: EncString | undefined;
2443
+ }
2444
+
2445
+ export interface CardView {
2446
+ cardholderName: string | undefined;
2447
+ expMonth: string | undefined;
2448
+ expYear: string | undefined;
2449
+ code: string | undefined;
2450
+ brand: string | undefined;
2451
+ number: string | undefined;
2452
+ }
2453
+
2454
+ export interface Cipher {
2455
+ id: CipherId | undefined;
2456
+ organizationId: OrganizationId | undefined;
2457
+ folderId: FolderId | undefined;
2458
+ collectionIds: CollectionId[];
2459
+ /**
2460
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
2461
+ * Cipher.
2462
+ */
2463
+ key: EncString | undefined;
2464
+ name: EncString;
2465
+ notes: EncString | undefined;
2466
+ type: CipherType;
2467
+ login: Login | undefined;
2468
+ identity: Identity | undefined;
2469
+ card: Card | undefined;
2470
+ secureNote: SecureNote | undefined;
2471
+ sshKey: SshKey | undefined;
2472
+ favorite: boolean;
2473
+ reprompt: CipherRepromptType;
2474
+ organizationUseTotp: boolean;
2475
+ edit: boolean;
2476
+ permissions: CipherPermissions | undefined;
2477
+ viewPassword: boolean;
2478
+ localData: LocalData | undefined;
2479
+ attachments: Attachment[] | undefined;
2480
+ fields: Field[] | undefined;
2481
+ passwordHistory: PasswordHistory[] | undefined;
2482
+ creationDate: DateTime<Utc>;
2483
+ deletedDate: DateTime<Utc> | undefined;
2484
+ revisionDate: DateTime<Utc>;
2485
+ archivedDate: DateTime<Utc> | undefined;
2486
+ data: string | undefined;
2487
+ }
2488
+
2489
+ export interface CipherListView {
2490
+ id: CipherId | undefined;
2491
+ organizationId: OrganizationId | undefined;
2492
+ folderId: FolderId | undefined;
2493
+ collectionIds: CollectionId[];
2494
+ /**
2495
+ * Temporary, required to support calculating TOTP from CipherListView.
2496
+ */
2497
+ key: EncString | undefined;
2498
+ name: string;
2499
+ subtitle: string;
2500
+ type: CipherListViewType;
2501
+ favorite: boolean;
2502
+ reprompt: CipherRepromptType;
2503
+ organizationUseTotp: boolean;
2504
+ edit: boolean;
2505
+ permissions: CipherPermissions | undefined;
2506
+ viewPassword: boolean;
2507
+ /**
2508
+ * The number of attachments
2509
+ */
2510
+ attachments: number;
2511
+ /**
2512
+ * Indicates if the cipher has old attachments that need to be re-uploaded
2513
+ */
2514
+ hasOldAttachments: boolean;
2515
+ creationDate: DateTime<Utc>;
2516
+ deletedDate: DateTime<Utc> | undefined;
2517
+ revisionDate: DateTime<Utc>;
2518
+ archivedDate: DateTime<Utc> | undefined;
2519
+ /**
2520
+ * Hints for the presentation layer for which fields can be copied.
2521
+ */
2522
+ copyableFields: CopyableCipherFields[];
2523
+ localData: LocalDataView | undefined;
2524
+ /**
2525
+ * Decrypted cipher notes for search indexing.
2526
+ */
2527
+ notes: string | undefined;
2528
+ /**
2529
+ * Decrypted cipher fields for search indexing.
2530
+ * Only includes name and value (for text fields only).
2531
+ */
2532
+ fields: FieldListView[] | undefined;
2533
+ /**
2534
+ * Decrypted attachment filenames for search indexing.
2535
+ */
2536
+ attachmentNames: string[] | undefined;
2537
+ }
2538
+
2539
+ export interface CipherPermissions {
2540
+ delete: boolean;
2541
+ restore: boolean;
2542
+ }
2543
+
2544
+ export interface CipherView {
2545
+ id: CipherId | undefined;
2546
+ organizationId: OrganizationId | undefined;
2547
+ folderId: FolderId | undefined;
2548
+ collectionIds: CollectionId[];
2549
+ /**
2550
+ * Temporary, required to support re-encrypting existing items.
2551
+ */
2552
+ key: EncString | undefined;
2553
+ name: string;
2554
+ notes: string | undefined;
2555
+ type: CipherType;
2556
+ login: LoginView | undefined;
2557
+ identity: IdentityView | undefined;
2558
+ card: CardView | undefined;
2559
+ secureNote: SecureNoteView | undefined;
2560
+ sshKey: SshKeyView | undefined;
2561
+ favorite: boolean;
2562
+ reprompt: CipherRepromptType;
2563
+ organizationUseTotp: boolean;
2564
+ edit: boolean;
2565
+ permissions: CipherPermissions | undefined;
2566
+ viewPassword: boolean;
2567
+ localData: LocalDataView | undefined;
2568
+ attachments: AttachmentView[] | undefined;
2569
+ /**
2570
+ * Attachments that failed to decrypt. Only present when there are decryption failures.
2571
+ */
2572
+ attachmentDecryptionFailures?: AttachmentView[];
2573
+ fields: FieldView[] | undefined;
2574
+ passwordHistory: PasswordHistoryView[] | undefined;
2575
+ creationDate: DateTime<Utc>;
2576
+ deletedDate: DateTime<Utc> | undefined;
2577
+ revisionDate: DateTime<Utc>;
2578
+ archivedDate: DateTime<Utc> | undefined;
2579
+ }
2580
+
2581
+ export interface Collection {
2582
+ id: CollectionId | undefined;
2583
+ organizationId: OrganizationId;
2584
+ name: EncString;
2585
+ externalId: string | undefined;
2586
+ hidePasswords: boolean;
2587
+ readOnly: boolean;
2588
+ manage: boolean;
2589
+ defaultUserCollectionEmail: string | undefined;
2590
+ type: CollectionType;
2591
+ }
2592
+
2593
+ export interface CollectionView {
2594
+ id: CollectionId | undefined;
2595
+ organizationId: OrganizationId;
2596
+ name: string;
2597
+ externalId: string | undefined;
2598
+ hidePasswords: boolean;
2599
+ readOnly: boolean;
2600
+ manage: boolean;
2601
+ type: CollectionType;
2602
+ }
2603
+
2604
+ export interface EncryptionContext {
2605
+ /**
2606
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
2607
+ * Organization-owned ciphers
2608
+ */
2609
+ encryptedFor: UserId;
2610
+ cipher: Cipher;
2611
+ }
2612
+
2613
+ export interface Fido2Credential {
2614
+ credentialId: EncString;
2615
+ keyType: EncString;
2616
+ keyAlgorithm: EncString;
2617
+ keyCurve: EncString;
2618
+ keyValue: EncString;
2619
+ rpId: EncString;
2620
+ userHandle: EncString | undefined;
2621
+ userName: EncString | undefined;
2622
+ counter: EncString;
2623
+ rpName: EncString | undefined;
2624
+ userDisplayName: EncString | undefined;
2625
+ discoverable: EncString;
2626
+ creationDate: DateTime<Utc>;
2627
+ }
2628
+
2629
+ export interface Fido2CredentialFullView {
2630
+ credentialId: string;
2631
+ keyType: string;
2632
+ keyAlgorithm: string;
2633
+ keyCurve: string;
2634
+ keyValue: string;
2635
+ rpId: string;
2636
+ userHandle: string | undefined;
2637
+ userName: string | undefined;
2638
+ counter: string;
2639
+ rpName: string | undefined;
2640
+ userDisplayName: string | undefined;
2641
+ discoverable: string;
2642
+ creationDate: DateTime<Utc>;
2643
+ }
2644
+
2645
+ export interface Fido2CredentialListView {
2646
+ credentialId: string;
2647
+ rpId: string;
2648
+ userHandle: string | undefined;
2649
+ userName: string | undefined;
2650
+ userDisplayName: string | undefined;
2651
+ counter: string;
2652
+ }
2653
+
2654
+ export interface Fido2CredentialNewView {
2655
+ credentialId: string;
2656
+ keyType: string;
2657
+ keyAlgorithm: string;
2658
+ keyCurve: string;
2659
+ rpId: string;
2660
+ userHandle: string | undefined;
2661
+ userName: string | undefined;
2662
+ counter: string;
2663
+ rpName: string | undefined;
2664
+ userDisplayName: string | undefined;
2665
+ creationDate: DateTime<Utc>;
2666
+ }
2667
+
2668
+ export interface Fido2CredentialView {
2669
+ credentialId: string;
2670
+ keyType: string;
2671
+ keyAlgorithm: string;
2672
+ keyCurve: string;
2673
+ keyValue: EncString;
2674
+ rpId: string;
2675
+ userHandle: string | undefined;
2676
+ userName: string | undefined;
2677
+ counter: string;
2678
+ rpName: string | undefined;
2679
+ userDisplayName: string | undefined;
2680
+ discoverable: string;
2681
+ creationDate: DateTime<Utc>;
2682
+ }
2683
+
2684
+ export interface Field {
2685
+ name: EncString | undefined;
2686
+ value: EncString | undefined;
2687
+ type: FieldType;
2688
+ linkedId: LinkedIdType | undefined;
2689
+ }
2690
+
2691
+ export interface FieldView {
2692
+ name: string | undefined;
2693
+ value: string | undefined;
2694
+ type: FieldType;
2695
+ linkedId: LinkedIdType | undefined;
2696
+ }
2697
+
2698
+ export interface Folder {
2699
+ id: FolderId | undefined;
2700
+ name: EncString;
2701
+ revisionDate: DateTime<Utc>;
2702
+ }
2703
+
2704
+ export interface FolderView {
2705
+ id: FolderId | undefined;
2706
+ name: string;
2707
+ revisionDate: DateTime<Utc>;
2708
+ }
2709
+
2710
+ export interface Identity {
2711
+ title: EncString | undefined;
2712
+ firstName: EncString | undefined;
2713
+ middleName: EncString | undefined;
2714
+ lastName: EncString | undefined;
2715
+ address1: EncString | undefined;
2716
+ address2: EncString | undefined;
2717
+ address3: EncString | undefined;
2718
+ city: EncString | undefined;
2719
+ state: EncString | undefined;
2720
+ postalCode: EncString | undefined;
2721
+ country: EncString | undefined;
2722
+ company: EncString | undefined;
2723
+ email: EncString | undefined;
2724
+ phone: EncString | undefined;
2725
+ ssn: EncString | undefined;
2726
+ username: EncString | undefined;
2727
+ passportNumber: EncString | undefined;
2728
+ licenseNumber: EncString | undefined;
2729
+ }
2730
+
2731
+ export interface IdentityView {
2732
+ title: string | undefined;
2733
+ firstName: string | undefined;
2734
+ middleName: string | undefined;
2735
+ lastName: string | undefined;
2736
+ address1: string | undefined;
2737
+ address2: string | undefined;
2738
+ address3: string | undefined;
2739
+ city: string | undefined;
2740
+ state: string | undefined;
2741
+ postalCode: string | undefined;
2742
+ country: string | undefined;
2743
+ company: string | undefined;
2744
+ email: string | undefined;
2745
+ phone: string | undefined;
2746
+ ssn: string | undefined;
2747
+ username: string | undefined;
2748
+ passportNumber: string | undefined;
2749
+ licenseNumber: string | undefined;
2750
+ }
2751
+
2752
+ export interface LocalData {
2753
+ lastUsedDate: DateTime<Utc> | undefined;
2754
+ lastLaunched: DateTime<Utc> | undefined;
2755
+ }
2756
+
2757
+ export interface LocalDataView {
2758
+ lastUsedDate: DateTime<Utc> | undefined;
2759
+ lastLaunched: DateTime<Utc> | undefined;
2760
+ }
2761
+
2762
+ export interface Login {
2763
+ username: EncString | undefined;
2764
+ password: EncString | undefined;
2765
+ passwordRevisionDate: DateTime<Utc> | undefined;
2766
+ uris: LoginUri[] | undefined;
2767
+ totp: EncString | undefined;
2768
+ autofillOnPageLoad: boolean | undefined;
2769
+ fido2Credentials: Fido2Credential[] | undefined;
2770
+ }
2771
+
2772
+ export interface LoginListView {
2773
+ fido2Credentials: Fido2CredentialListView[] | undefined;
2774
+ hasFido2: boolean;
2775
+ username: string | undefined;
2776
+ /**
2777
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
2778
+ */
2779
+ totp: EncString | undefined;
2780
+ uris: LoginUriView[] | undefined;
2781
+ }
2782
+
2783
+ export interface LoginUri {
2784
+ uri: EncString | undefined;
2785
+ match: UriMatchType | undefined;
2786
+ uriChecksum: EncString | undefined;
2787
+ }
2788
+
2789
+ export interface LoginUriView {
2790
+ uri: string | undefined;
2791
+ match: UriMatchType | undefined;
2792
+ uriChecksum: string | undefined;
2793
+ }
2794
+
2795
+ export interface LoginView {
2796
+ username: string | undefined;
2797
+ password: string | undefined;
2798
+ passwordRevisionDate: DateTime<Utc> | undefined;
2799
+ uris: LoginUriView[] | undefined;
2800
+ totp: string | undefined;
2801
+ autofillOnPageLoad: boolean | undefined;
2802
+ fido2Credentials: Fido2Credential[] | undefined;
2803
+ }
2804
+
2805
+ export interface PasswordChangeAndRotateUserKeysRequest {
2806
+ old_password: string;
2807
+ password: string;
2808
+ hint: string | undefined;
2809
+ trusted_emergency_access_public_keys: PublicKey[];
2810
+ trusted_organization_public_keys: PublicKey[];
2811
+ }
2812
+
2813
+ export interface PasswordHistory {
2814
+ password: EncString;
2815
+ lastUsedDate: DateTime<Utc>;
2816
+ }
2817
+
2818
+ export interface PasswordHistoryView {
2819
+ password: string;
2820
+ lastUsedDate: DateTime<Utc>;
2821
+ }
2822
+
2823
+ export interface Repositories {
2824
+ cipher: Repository<Cipher> | null;
2825
+ folder: Repository<Folder> | null;
2826
+ user_key_state: Repository<UserKeyState> | null;
2827
+ local_user_data_key_state: Repository<LocalUserDataKeyState> | null;
2828
+ ephemeral_pin_envelope_state: Repository<EphemeralPinEnvelopeState> | null;
2829
+ organization_shared_key: Repository<OrganizationSharedKey> | null;
2830
+ }
2831
+
2832
+ export interface RotateUserKeysRequest {
2833
+ key_rotation_method: KeyRotationMethod;
2834
+ trusted_emergency_access_public_keys: PublicKey[];
2835
+ trusted_organization_public_keys: PublicKey[];
2836
+ }
2837
+
2838
+ export interface SecureNote {
2839
+ type: SecureNoteType;
2840
+ }
2841
+
2842
+ export interface SecureNoteView {
2843
+ type: SecureNoteType;
2844
+ }
2845
+
2846
+ export interface Send {
2847
+ id: SendId | undefined;
2848
+ accessId: string | undefined;
2849
+ name: EncString;
2850
+ notes: EncString | undefined;
2851
+ key: EncString;
2852
+ password: string | undefined;
2853
+ type: SendType;
2854
+ file: SendFile | undefined;
2855
+ text: SendText | undefined;
2856
+ maxAccessCount: number | undefined;
2857
+ accessCount: number;
2858
+ disabled: boolean;
2859
+ hideEmail: boolean;
2860
+ revisionDate: DateTime<Utc>;
2861
+ deletionDate: DateTime<Utc>;
2862
+ expirationDate: DateTime<Utc> | undefined;
2863
+ /**
2864
+ * Email addresses for OTP authentication (comma-separated).
2865
+ *
2866
+ * **Note**: Mutually exclusive with `password`. If both `password` and `emails` are
2867
+ * set, password authentication takes precedence and email OTP is ignored.
2868
+ */
2869
+ emails: string | undefined;
2870
+ authType: AuthType;
2871
+ }
2872
+
2873
+ export interface SendListView {
2874
+ id: SendId | undefined;
2875
+ accessId: string | undefined;
2876
+ name: string;
2877
+ type: SendType;
2878
+ disabled: boolean;
2879
+ revisionDate: DateTime<Utc>;
2880
+ deletionDate: DateTime<Utc>;
2881
+ expirationDate: DateTime<Utc> | undefined;
2882
+ authType: AuthType;
2883
+ }
2884
+
2885
+ export interface SendView {
2886
+ id: SendId | undefined;
2887
+ accessId: string | undefined;
2888
+ name: string;
2889
+ notes: string | undefined;
2890
+ /**
2891
+ * Base64 encoded key
2892
+ */
2893
+ key: string | undefined;
2894
+ /**
2895
+ * Replace or add a password to an existing send. The SDK will always return None when
2896
+ * decrypting a [Send]
2897
+ * TODO: We should revisit this, one variant is to have `[Create, Update]SendView` DTOs.
2898
+ */
2899
+ newPassword: string | undefined;
2900
+ /**
2901
+ * Denote if an existing send has a password. The SDK will ignore this value when creating or
2902
+ * updating sends.
2903
+ */
2904
+ hasPassword: boolean;
2905
+ type: SendType;
2906
+ file: SendFileView | undefined;
2907
+ text: SendTextView | undefined;
2908
+ maxAccessCount: number | undefined;
2909
+ accessCount: number;
2910
+ disabled: boolean;
2911
+ hideEmail: boolean;
2912
+ revisionDate: DateTime<Utc>;
2913
+ deletionDate: DateTime<Utc>;
2914
+ expirationDate: DateTime<Utc> | undefined;
2915
+ /**
2916
+ * Email addresses for OTP authentication.
2917
+ * **Note**: Mutually exclusive with `new_password`. If both are set, only password
2918
+ * authentication will be used. When creating or editing sends, use [crate::SendAuthType]
2919
+ * to ensure mutual exclusivity at the type level.
2920
+ */
2921
+ emails: string[];
2922
+ authType: AuthType;
2923
+ }
2924
+
2925
+ export interface SshKey {
2926
+ /**
2927
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
2928
+ */
2929
+ privateKey: EncString;
2930
+ /**
2931
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
2932
+ */
2933
+ publicKey: EncString;
2934
+ /**
2935
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
2936
+ */
2937
+ fingerprint: EncString;
2938
+ }
2939
+
2940
+ export interface SshKeyView {
2941
+ /**
2942
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
2943
+ */
2944
+ privateKey: string;
2945
+ /**
2946
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
2947
+ */
2948
+ publicKey: string;
2949
+ /**
2950
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
2951
+ */
2952
+ fingerprint: string;
2953
+ }
2954
+
2955
+ export interface TotpResponse {
2956
+ /**
2957
+ * Generated TOTP code
2958
+ */
2959
+ code: string;
2960
+ /**
2961
+ * Time period
2962
+ */
2963
+ period: number;
2964
+ }
2965
+
2966
+ export interface TrustDeviceResponse {
2967
+ /**
2968
+ * Base64 encoded device key
2969
+ */
2970
+ device_key: B64;
2971
+ /**
2972
+ * UserKey encrypted with DevicePublicKey
2973
+ */
2974
+ protected_user_key: UnsignedSharedKey;
2975
+ /**
2976
+ * DevicePrivateKey encrypted with [DeviceKey]
2977
+ */
2978
+ protected_device_private_key: EncString;
2979
+ /**
2980
+ * DevicePublicKey encrypted with [UserKey](super::UserKey)
2981
+ */
2982
+ protected_device_public_key: EncString;
2983
+ }
2984
+
2985
+ export type AppendType = "random" | { websiteName: { website: string } };
2986
+
2987
+ export type CipherListViewType =
2988
+ | { login: LoginListView }
2989
+ | "secureNote"
2990
+ | { card: CardListView }
2991
+ | "identity"
2992
+ | "sshKey";
2993
+
2994
+ export type DeviceType =
2995
+ | "Android"
2996
+ | "iOS"
2997
+ | "ChromeExtension"
2998
+ | "FirefoxExtension"
2999
+ | "OperaExtension"
3000
+ | "EdgeExtension"
3001
+ | "WindowsDesktop"
3002
+ | "MacOsDesktop"
3003
+ | "LinuxDesktop"
3004
+ | "ChromeBrowser"
3005
+ | "FirefoxBrowser"
3006
+ | "OperaBrowser"
3007
+ | "EdgeBrowser"
3008
+ | "IEBrowser"
3009
+ | "UnknownBrowser"
3010
+ | "AndroidAmazon"
3011
+ | "UWP"
3012
+ | "SafariBrowser"
3013
+ | "VivaldiBrowser"
3014
+ | "VivaldiExtension"
3015
+ | "SafariExtension"
3016
+ | "SDK"
3017
+ | "Server"
3018
+ | "WindowsCLI"
3019
+ | "MacOsCLI"
3020
+ | "LinuxCLI"
3021
+ | "DuckDuckGoBrowser";
3022
+
3023
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
3024
+
3025
+ export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
3026
+
3027
+ export type KeyRotationMethod = { Password: { password: string } } | "KeyConnector" | "Tde";
3028
+
3029
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
3030
+
3031
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
3032
+
3033
+ export type UsernameGeneratorRequest =
3034
+ | { word: { capitalize: boolean; include_number: boolean } }
3035
+ | { subaddress: { type: AppendType; email: string } }
3036
+ | { catchall: { type: AppendType; domain: string } }
3037
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
3038
+
3039
+ export class AttachmentsClient {
3040
+ private constructor();
3041
+ free(): void;
3042
+ [Symbol.dispose](): void;
3043
+ decrypt_buffer(
3044
+ cipher: Cipher,
3045
+ attachment: AttachmentView,
3046
+ encrypted_buffer: Uint8Array,
3047
+ ): Uint8Array;
3048
+ }
3049
+
3050
+ /**
3051
+ * Subclient containing auth functionality.
3052
+ */
3053
+ export class AuthClient {
3054
+ private constructor();
3055
+ free(): void;
3056
+ [Symbol.dispose](): void;
3057
+ /**
3058
+ * Client for login functionality
3059
+ */
3060
+ login(client_settings: ClientSettings): LoginClient;
3061
+ /**
3062
+ * Client for initializing user account cryptography and unlock methods after JIT provisioning
3063
+ */
3064
+ registration(): RegistrationClient;
3065
+ /**
3066
+ * Client for send access functionality
3067
+ */
3068
+ send_access(): SendAccessClient;
3069
+ }
3070
+
3071
+ export enum CardLinkedIdType {
3072
+ CardholderName = 300,
3073
+ ExpMonth = 301,
3074
+ ExpYear = 302,
3075
+ Code = 303,
3076
+ Brand = 304,
3077
+ Number = 305,
3078
+ }
3079
+
3080
+ /**
3081
+ * Client for performing admin operations on ciphers. Unlike the regular CiphersClient,
3082
+ * this client uses the admin server API endpoints, and does not modify local state.
3083
+ */
3084
+ export class CipherAdminClient {
3085
+ private constructor();
3086
+ free(): void;
3087
+ [Symbol.dispose](): void;
3088
+ /**
3089
+ * Creates a new [Cipher] for an organization, using the admin server endpoints.
3090
+ * Creates the Cipher on the server only, does not store it to local state.
3091
+ */
3092
+ create(request: CipherCreateRequest): Promise<CipherView>;
3093
+ /**
3094
+ * Deletes the Cipher with the matching CipherId from the server, using the admin endpoint.
3095
+ * Affects server data only, does not modify local state.
3096
+ */
3097
+ delete(cipher_id: CipherId): Promise<void>;
3098
+ /**
3099
+ * Deletes an attachment from a cipher using the admin endpoint.
3100
+ * Affects server data only, does not modify local state.
3101
+ */
3102
+ delete_attachment(cipher_id: CipherId, attachment_id: string): Promise<void>;
3103
+ /**
3104
+ * Deletes all Cipher objects with a matching CipherId from the server, using the admin
3105
+ * endpoint. Affects server data only, does not modify local state.
3106
+ */
3107
+ delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
3108
+ /**
3109
+ * Edit an existing [Cipher] and save it to the server.
3110
+ */
3111
+ edit(request: CipherEditRequest, original_cipher_view: CipherView): Promise<CipherView>;
3112
+ list_org_ciphers(
3113
+ org_id: OrganizationId,
3114
+ include_member_items: boolean,
3115
+ ): Promise<ListOrganizationCiphersResult>;
3116
+ /**
3117
+ * Restores a soft-deleted cipher on the server, using the admin endpoint.
3118
+ */
3119
+ restore(cipher_id: CipherId): Promise<CipherView>;
3120
+ /**
3121
+ * Restores multiple soft-deleted ciphers on the server.
3122
+ */
3123
+ restore_many(cipher_ids: CipherId[], org_id: OrganizationId): Promise<DecryptCipherListResult>;
3124
+ /**
3125
+ * Soft-deletes the Cipher with the matching CipherId from the server, using the admin
3126
+ * endpoint. Affects server data only, does not modify local state.
3127
+ */
3128
+ soft_delete(cipher_id: CipherId): Promise<void>;
3129
+ /**
3130
+ * Soft-deletes all Cipher objects for the given CipherIds from the server, using the admin
3131
+ * endpoint. Affects server data only, does not modify local state.
3132
+ */
3133
+ soft_delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
3134
+ /**
3135
+ * Adds the cipher matched by [CipherId] to any number of collections on the server.
3136
+ */
3137
+ update_collection(cipher_id: CipherId, collection_ids: CollectionId[]): Promise<CipherView>;
3138
+ }
3139
+
3140
+ export enum CipherRepromptType {
3141
+ None = 0,
3142
+ Password = 1,
3143
+ }
3144
+
3145
+ /**
3146
+ * Client for evaluating credential risk for login ciphers.
3147
+ */
3148
+ export class CipherRiskClient {
3149
+ private constructor();
3150
+ free(): void;
3151
+ [Symbol.dispose](): void;
3152
+ /**
3153
+ * Evaluate security risks for multiple login ciphers concurrently.
3154
+ *
3155
+ * For each cipher:
3156
+ * 1. Calculates password strength (0-4) using zxcvbn with cipher-specific context
3157
+ * 2. Optionally checks if the password has been exposed via Have I Been Pwned API
3158
+ * 3. Counts how many times the password is reused in the provided `password_map`
3159
+ *
3160
+ * Returns a vector of `CipherRisk` results, one for each input cipher.
3161
+ *
3162
+ * ## HIBP Check Results (`exposed_result` field)
3163
+ *
3164
+ * The `exposed_result` field uses the `ExposedPasswordResult` enum with three possible states:
3165
+ * - `NotChecked`: Password exposure check was not performed because:
3166
+ * - `check_exposed` option was `false`, or
3167
+ * - Password was empty
3168
+ * - `Found(n)`: Successfully checked via HIBP API, password appears in `n` data breaches
3169
+ * - `Error(msg)`: HIBP API request failed with error message `msg`
3170
+ *
3171
+ * # Errors
3172
+ *
3173
+ * This method only returns `Err` for internal logic failures. HIBP API errors are
3174
+ * captured per-cipher in the `exposed_result` field as `ExposedPasswordResult::Error(msg)`.
3175
+ */
3176
+ compute_risk(
3177
+ login_details: CipherLoginDetails[],
3178
+ options: CipherRiskOptions,
3179
+ ): Promise<CipherRiskResult[]>;
3180
+ /**
3181
+ * Build password reuse map for a list of login ciphers.
3182
+ *
3183
+ * Returns a map where keys are passwords and values are the number of times
3184
+ * each password appears in the provided list. This map can be passed to `compute_risk()`
3185
+ * to enable password reuse detection.
3186
+ */
3187
+ password_reuse_map(login_details: CipherLoginDetails[]): PasswordReuseMap;
3188
+ }
3189
+
3190
+ export enum CipherType {
3191
+ Login = 1,
3192
+ SecureNote = 2,
3193
+ Card = 3,
3194
+ Identity = 4,
3195
+ SshKey = 5,
3196
+ }
3197
+
3198
+ export class CiphersClient {
3199
+ private constructor();
3200
+ free(): void;
3201
+ [Symbol.dispose](): void;
3202
+ /**
3203
+ * Returns a new client for performing admin operations.
3204
+ * Uses the admin server API endpoints and does not modify local state.
3205
+ */
3206
+ admin(): CipherAdminClient;
3207
+ /**
3208
+ * Creates a new [Cipher] and saves it to the server.
3209
+ */
3210
+ create(request: CipherCreateRequest): Promise<CipherView>;
3211
+ decrypt(cipher: Cipher): Promise<CipherView>;
3212
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
3213
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
3214
+ decrypt_list(ciphers: Cipher[]): Promise<CipherListView[]>;
3215
+ /**
3216
+ * Decrypt full cipher list
3217
+ * Returns both successfully fully decrypted ciphers and any that failed to decrypt
3218
+ */
3219
+ decrypt_list_full_with_failures(ciphers: Cipher[]): Promise<DecryptCipherResult>;
3220
+ /**
3221
+ * Decrypt cipher list with failures
3222
+ * Returns both successfully decrypted ciphers and any that failed to decrypt
3223
+ */
3224
+ decrypt_list_with_failures(ciphers: Cipher[]): Promise<DecryptCipherListResult>;
3225
+ /**
3226
+ * Deletes the [Cipher] with the matching [CipherId] from the server.
3227
+ */
3228
+ delete(cipher_id: CipherId): Promise<void>;
3229
+ /**
3230
+ * Deletes an attachment from a cipher, and updates the local repository with the new cipher
3231
+ * data returned from the API.
3232
+ */
3233
+ delete_attachment(cipher_id: CipherId, attachment_id: string): Promise<Cipher>;
3234
+ /**
3235
+ * Deletes all [Cipher] objects with a matching [CipherId] from the server.
3236
+ */
3237
+ delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
3238
+ /**
3239
+ * Edit an existing [Cipher] and save it to the server.
3240
+ */
3241
+ edit(request: CipherEditRequest): Promise<CipherView>;
3242
+ encrypt(cipher_view: CipherView): Promise<EncryptionContext>;
3243
+ /**
3244
+ * Encrypt a cipher with the provided key. This should only be used when rotating encryption
3245
+ * keys in the Web client.
3246
+ *
3247
+ * Until key rotation is fully implemented in the SDK, this method must be provided the new
3248
+ * symmetric key in base64 format. See PM-23084
3249
+ *
3250
+ * If the cipher has a CipherKey, it will be re-encrypted with the new key.
3251
+ * If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
3252
+ * generated using the new key. Otherwise, the cipher's data will be encrypted with the new
3253
+ * key directly.
3254
+ */
3255
+ encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): Promise<EncryptionContext>;
3256
+ /**
3257
+ * Encrypt a list of cipher views.
3258
+ *
3259
+ * This method attempts to encrypt all ciphers in the list. If any cipher
3260
+ * fails to encrypt, the entire operation fails and an error is returned.
3261
+ */
3262
+ encrypt_list(cipher_views: CipherView[]): Promise<EncryptionContext[]>;
3263
+ /**
3264
+ * Get [Cipher] by ID from state and decrypt it to a [CipherView].
3265
+ */
3266
+ get(cipher_id: string): Promise<CipherView>;
3267
+ /**
3268
+ * Get all ciphers from state and decrypt them to full [CipherView], returning both
3269
+ * successes and failures. This method will not fail when some ciphers fail to decrypt,
3270
+ * allowing for graceful handling of corrupted or problematic cipher data.
3271
+ */
3272
+ get_all(): Promise<DecryptCipherResult>;
3273
+ /**
3274
+ * Get all ciphers from state and decrypt them to [crate::CipherListView], returning both
3275
+ * successes and failures. This method will not fail when some ciphers fail to decrypt,
3276
+ * allowing for graceful handling of corrupted or problematic cipher data.
3277
+ */
3278
+ list(): Promise<DecryptCipherListResult>;
3279
+ move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
3280
+ /**
3281
+ * Restores a soft-deleted cipher on the server.
3282
+ */
3283
+ restore(cipher_id: CipherId): Promise<CipherView>;
3284
+ /**
3285
+ * Restores multiple soft-deleted ciphers on the server.
3286
+ */
3287
+ restore_many(cipher_ids: CipherId[]): Promise<DecryptCipherListResult>;
3288
+ /**
3289
+ * Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
3290
+ * Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
3291
+ * TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
3292
+ * encrypting the rest of the CipherView.
3293
+ * TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
3294
+ */
3295
+ set_fido2_credentials(
3296
+ cipher_view: CipherView,
3297
+ fido2_credentials: Fido2CredentialFullView[],
3298
+ ): CipherView;
3299
+ /**
3300
+ * Moves a cipher into an organization, adds it to collections, and calls the share_cipher API.
3301
+ */
3302
+ share_cipher(
3303
+ cipher_view: CipherView,
3304
+ organization_id: OrganizationId,
3305
+ collection_ids: CollectionId[],
3306
+ original_cipher_view?: CipherView | null,
3307
+ ): Promise<CipherView>;
3308
+ /**
3309
+ * Moves a group of ciphers into an organization, adds them to collections, and calls the
3310
+ * share_ciphers API.
3311
+ */
3312
+ share_ciphers_bulk(
3313
+ cipher_views: CipherView[],
3314
+ organization_id: OrganizationId,
3315
+ collection_ids: CollectionId[],
3316
+ ): Promise<CipherView[]>;
3317
+ /**
3318
+ * Soft-deletes the [Cipher] with the matching [CipherId] from the server.
3319
+ */
3320
+ soft_delete(cipher_id: CipherId): Promise<void>;
3321
+ /**
3322
+ * Soft-deletes all [Cipher] objects for the given [CipherId]s from the server.
3323
+ */
3324
+ soft_delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
3325
+ /**
3326
+ * Adds the cipher matched by [CipherId] to any number of collections on the server.
3327
+ */
3328
+ update_collection(
3329
+ cipher_id: CipherId,
3330
+ collection_ids: CollectionId[],
3331
+ is_admin: boolean,
3332
+ ): Promise<CipherView>;
3333
+ }
3334
+
3335
+ export class CollectionViewNodeItem {
3336
+ private constructor();
3337
+ free(): void;
3338
+ [Symbol.dispose](): void;
3339
+ get_ancestors(): AncestorMap;
3340
+ get_children(): CollectionView[];
3341
+ get_item(): CollectionView;
3342
+ get_parent(): CollectionView | undefined;
3343
+ }
3344
+
3345
+ export class CollectionViewTree {
3346
+ private constructor();
3347
+ free(): void;
3348
+ [Symbol.dispose](): void;
3349
+ get_flat_items(): CollectionViewNodeItem[];
3350
+ get_item_for_view(collection_view: CollectionView): CollectionViewNodeItem | undefined;
3351
+ get_root_items(): CollectionViewNodeItem[];
3352
+ }
3353
+
3354
+ export class CollectionsClient {
3355
+ private constructor();
3356
+ free(): void;
3357
+ [Symbol.dispose](): void;
3358
+ decrypt(collection: Collection): CollectionView;
3359
+ decrypt_list(collections: Collection[]): CollectionView[];
3360
+ /**
3361
+ *
3362
+ * Returns the vector of CollectionView objects in a tree structure based on its implemented
3363
+ * path().
3364
+ */
3365
+ get_collection_tree(collections: CollectionView[]): CollectionViewTree;
3366
+ }
3367
+
3368
+ /**
3369
+ * A client for the crypto operations.
3370
+ */
3371
+ export class CryptoClient {
3372
+ private constructor();
3373
+ free(): void;
3374
+ [Symbol.dispose](): void;
3375
+ /**
3376
+ * A stop gap-solution for decrypting with the local user data key, until the WASM client's
3377
+ * password generator history encryption and email forwarders encryption is fully migrated to
3378
+ * SDK.
3379
+ */
3380
+ decrypt_with_local_user_data_key(encrypted_plaintext: string): string;
3381
+ /**
3382
+ * A stop gap-solution for encrypting with the local user data key, until the WASM client's
3383
+ * password generator history encryption and email forwarders encryption is fully migrated to
3384
+ * SDK.
3385
+ */
3386
+ encrypt_with_local_user_data_key(plaintext: string): string;
3387
+ /**
3388
+ * Protects the current user key with the provided PIN. The result can be stored and later
3389
+ * used to initialize another client instance by using the PIN and the PIN key with
3390
+ * `initialize_user_crypto`.
3391
+ */
3392
+ enroll_pin(pin: string): EnrollPinResponse;
3393
+ /**
3394
+ * Protects the current user key with the provided PIN. The result can be stored and later
3395
+ * used to initialize another client instance by using the PIN and the PIN key with
3396
+ * `initialize_user_crypto`. The provided pin is encrypted with the user key.
3397
+ */
3398
+ enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
3399
+ /**
3400
+ * Takes a raw key and returns the corresponding key id. This is used for the biometrics
3401
+ * subsystem and should be removed after moving over biometric management to the SDK.
3402
+ */
3403
+ static get_key_id_for_symmetric_key(key: Uint8Array): Uint8Array | undefined;
3404
+ /**
3405
+ * ⚠️⚠️⚠️ HAZMAT WARNING: DO NOT USE THIS ⚠️⚠️⚠️
3406
+ *
3407
+ * Get the uses's decrypted encryption key. Note: It's very important
3408
+ * to keep this key safe, as it can be used to decrypt all of the user's data. It is
3409
+ * only permitted to use for a transition period where side effects such as biometrics
3410
+ * and never-lock are set from within the client code.
3411
+ */
3412
+ get_user_encryption_key(): Promise<B64>;
3413
+ /**
3414
+ * Creates a rotated set of account keys for the current state
3415
+ */
3416
+ get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
3417
+ /**
3418
+ * Initialization method for the organization crypto. Needs to be called after
3419
+ * `initialize_user_crypto` but before any other crypto operations.
3420
+ */
3421
+ initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
3422
+ /**
3423
+ * Initialization method for the user crypto. Needs to be called before any other crypto
3424
+ * operations.
3425
+ */
3426
+ initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
3427
+ /**
3428
+ * Generates a new key pair and encrypts the private key with the provided user key.
3429
+ * Crypto initialization not required.
3430
+ */
3431
+ make_key_pair(user_key: B64): MakeKeyPairResponse;
3432
+ /**
3433
+ * Makes a new signing key pair and signs the public key for the user
3434
+ */
3435
+ make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
3436
+ /**
3437
+ * Create the data necessary to update the user's kdf settings. The user's encryption key is
3438
+ * re-encrypted for the password under the new kdf settings. This returns the re-encrypted
3439
+ * user key and the new password hash but does not update sdk state.
3440
+ */
3441
+ make_update_kdf(password: string, kdf: Kdf): Promise<UpdateKdfResponse>;
3442
+ /**
3443
+ * Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
3444
+ * This is a stop-gap solution, until initialization of the SDK is used.
3445
+ */
3446
+ unseal_password_protected_key_envelope(pin: string, envelope: string): Uint8Array;
3447
+ /**
3448
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
3449
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
3450
+ * Crypto initialization not required.
3451
+ */
3452
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
3453
+ }
3454
+
3455
+ export class ExporterClient {
3456
+ private constructor();
3457
+ free(): void;
3458
+ [Symbol.dispose](): void;
3459
+ /**
3460
+ * Credential Exchange Format (CXF)
3461
+ *
3462
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
3463
+ *
3464
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
3465
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
3466
+ */
3467
+ export_cxf(account: Account, ciphers: Cipher[]): string;
3468
+ export_organization_vault(
3469
+ collections: Collection[],
3470
+ ciphers: Cipher[],
3471
+ format: ExportFormat,
3472
+ ): string;
3473
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): Promise<string>;
3474
+ /**
3475
+ * Credential Exchange Format (CXF)
3476
+ *
3477
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
3478
+ *
3479
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
3480
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
3481
+ */
3482
+ import_cxf(payload: string): Cipher[];
3483
+ }
3484
+
3485
+ /**
3486
+ * Represents the type of a [FieldView].
3487
+ */
3488
+ export enum FieldType {
3489
+ /**
3490
+ * Text field
3491
+ */
3492
+ Text = 0,
3493
+ /**
3494
+ * Hidden text field
3495
+ */
3496
+ Hidden = 1,
3497
+ /**
3498
+ * Boolean field
3499
+ */
3500
+ Boolean = 2,
3501
+ /**
3502
+ * Linked field
3503
+ */
3504
+ Linked = 3,
3505
+ }
3506
+
3507
+ /**
3508
+ * WASM client for reading Flight Recorder logs.
3509
+ *
3510
+ * The underlying buffer is global (initialized in [`init_sdk`](crate::init_sdk)),
3511
+ * so this client is a stateless handle for WASM access.
3512
+ */
3513
+ export class FlightRecorderClient {
3514
+ free(): void;
3515
+ [Symbol.dispose](): void;
3516
+ /**
3517
+ * Get the current event count without reading event contents.
3518
+ */
3519
+ count(): number;
3520
+ /**
3521
+ * Create a new `FlightRecorderClient`.
3522
+ */
3523
+ constructor();
3524
+ /**
3525
+ * Read all events currently in the Flight Recorder buffer.
3526
+ */
3527
+ read(): FlightRecorderEvent[];
3528
+ }
3529
+
3530
+ /**
3531
+ * Wrapper for folder specific functionality.
3532
+ */
3533
+ export class FoldersClient {
3534
+ private constructor();
3535
+ free(): void;
3536
+ [Symbol.dispose](): void;
3537
+ /**
3538
+ * Create a new [Folder] and save it to the server.
3539
+ */
3540
+ create(request: FolderAddEditRequest): Promise<FolderView>;
3541
+ /**
3542
+ * Encrypt a [Folder] to [FolderView].
3543
+ */
3544
+ decrypt(folder: Folder): FolderView;
3545
+ /**
3546
+ * Decrypt a list of [Folder]s to a list of [FolderView]s.
3547
+ */
3548
+ decrypt_list(folders: Folder[]): FolderView[];
3549
+ /**
3550
+ * Edit the [Folder] and save it to the server.
3551
+ */
3552
+ edit(folder_id: FolderId, request: FolderAddEditRequest): Promise<FolderView>;
3553
+ /**
3554
+ * Encrypt a [FolderView] to a [Folder].
3555
+ */
3556
+ encrypt(folder_view: FolderView): Folder;
3557
+ /**
3558
+ * Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
3559
+ */
3560
+ get(folder_id: FolderId): Promise<FolderView>;
3561
+ /**
3562
+ * Get all folders from state and decrypt them to a list of [FolderView].
3563
+ */
3564
+ list(): Promise<FolderView[]>;
3565
+ }
3566
+
3567
+ export class GeneratorClient {
3568
+ private constructor();
3569
+ free(): void;
3570
+ [Symbol.dispose](): void;
3571
+ /**
3572
+ * Generates a random passphrase.
3573
+ * A passphrase is a combination of random words separated by a character.
3574
+ * An example of passphrase is `correct horse battery staple`.
3575
+ *
3576
+ * The number of words and their case, the word separator, and the inclusion of
3577
+ * a number in the passphrase can be customized using the `input` parameter.
3578
+ *
3579
+ * # Examples
3580
+ *
3581
+ * ```
3582
+ * use bitwarden_core::Client;
3583
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
3584
+ *
3585
+ * async fn test() -> Result<(), PassphraseError> {
3586
+ * let input = PassphraseGeneratorRequest {
3587
+ * num_words: 4,
3588
+ * ..Default::default()
3589
+ * };
3590
+ * let passphrase = Client::new(None).generator().passphrase(input).unwrap();
3591
+ * println!("{}", passphrase);
3592
+ * Ok(())
3593
+ * }
3594
+ * ```
3595
+ */
3596
+ passphrase(input: PassphraseGeneratorRequest): string;
3597
+ /**
3598
+ * Generates a random password.
3599
+ *
3600
+ * The character sets and password length can be customized using the `input` parameter.
3601
+ *
3602
+ * # Examples
3603
+ *
3604
+ * ```
3605
+ * use bitwarden_core::Client;
3606
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
3607
+ *
3608
+ * async fn test() -> Result<(), PassphraseError> {
3609
+ * let input = PasswordGeneratorRequest {
3610
+ * lowercase: true,
3611
+ * uppercase: true,
3612
+ * numbers: true,
3613
+ * length: 20,
3614
+ * ..Default::default()
3615
+ * };
3616
+ * let password = Client::new(None).generator().password(input).unwrap();
3617
+ * println!("{}", password);
3618
+ * Ok(())
3619
+ * }
3620
+ * ```
3621
+ */
3622
+ password(input: PasswordGeneratorRequest): string;
3623
+ }
3624
+
3625
+ export enum IdentityLinkedIdType {
3626
+ Title = 400,
3627
+ MiddleName = 401,
3628
+ Address1 = 402,
3629
+ Address2 = 403,
3630
+ Address3 = 404,
3631
+ City = 405,
3632
+ State = 406,
3633
+ PostalCode = 407,
3634
+ Country = 408,
3635
+ Company = 409,
3636
+ Email = 410,
3637
+ Phone = 411,
3638
+ Ssn = 412,
3639
+ Username = 413,
3640
+ PassportNumber = 414,
3641
+ LicenseNumber = 415,
3642
+ FirstName = 416,
3643
+ LastName = 417,
3644
+ FullName = 418,
3645
+ }
3646
+
3647
+ /**
3648
+ * An untyped IPC message received from another endpoint.
3649
+ */
3650
+ export class IncomingMessage {
3651
+ free(): void;
3652
+ [Symbol.dispose](): void;
3653
+ /**
3654
+ * Create an incoming IPC message from raw payload bytes.
3655
+ */
3656
+ constructor(payload: Uint8Array, destination: Endpoint, source: Source, topic?: string | null);
3657
+ /**
3658
+ * Try to parse the payload as JSON.
3659
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
3660
+ */
3661
+ parse_payload_as_json(): any;
3662
+ /**
3663
+ * Destination endpoint that received this message.
3664
+ */
3665
+ destination: Endpoint;
3666
+ /**
3667
+ * Serialized payload bytes.
3668
+ */
3669
+ payload: Uint8Array;
3670
+ /**
3671
+ * Source that sent this message, with per-variant metadata.
3672
+ */
3673
+ source: Source;
3674
+ /**
3675
+ * Optional topic used for routing/dispatch.
3676
+ */
3677
+ get topic(): string | undefined;
3678
+ /**
3679
+ * Optional topic used for routing/dispatch.
3680
+ */
3681
+ set topic(value: string | null | undefined);
3682
+ }
3683
+
3684
+ /**
3685
+ * JavaScript wrapper around the IPC client. For more information, see the
3686
+ * [`IpcClient`] trait documentation.
3687
+ */
3688
+ export class IpcClient {
3689
+ private constructor();
3690
+ free(): void;
3691
+ [Symbol.dispose](): void;
3692
+ isRunning(): boolean;
3693
+ /**
3694
+ * Create a new `IpcClient` instance with a client-managed session repository for saving
3695
+ * sessions using State Provider.
3696
+ */
3697
+ static newWithClientManagedSessions(
3698
+ communication_provider: IpcCommunicationBackend,
3699
+ session_repository: IpcSessionRepository,
3700
+ ): IpcClient;
3701
+ /**
3702
+ * Create a new `IpcClient` instance with an in-memory session repository for saving
3703
+ * sessions within the SDK.
3704
+ */
3705
+ static newWithSdkInMemorySessions(communication_provider: IpcCommunicationBackend): IpcClient;
3706
+ send(message: OutgoingMessage): Promise<void>;
3707
+ start(abort_signal?: AbortSignal | null): Promise<void>;
3708
+ subscribe(): Promise<IpcClientSubscription>;
3709
+ }
3710
+
3711
+ /**
3712
+ * JavaScript wrapper around the IPC client subscription. For more information, see the
3713
+ * [IpcClientSubscription](crate::IpcClientSubscription) documentation.
3714
+ */
3715
+ export class IpcClientSubscription {
3716
+ private constructor();
3717
+ free(): void;
3718
+ [Symbol.dispose](): void;
3719
+ receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
3720
+ }
3721
+
3722
+ /**
3723
+ * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
3724
+ */
3725
+ export class IpcCommunicationBackend {
3726
+ free(): void;
3727
+ [Symbol.dispose](): void;
3728
+ /**
3729
+ * Creates a new instance of the JavaScript communication backend.
3730
+ */
3731
+ constructor(sender: IpcCommunicationBackendSender);
3732
+ /**
3733
+ * Used by JavaScript to provide an incoming message to the IPC framework.
3734
+ */
3735
+ receive(message: IncomingMessage): void;
3736
+ }
3737
+
3
3738
  export enum LogLevel {
4
3739
  Trace = 0,
5
3740
  Debug = 1,
@@ -7,224 +3742,675 @@ export enum LogLevel {
7
3742
  Warn = 3,
8
3743
  Error = 4,
9
3744
  }
10
- export interface InitUserCryptoRequest {
3745
+
3746
+ /**
3747
+ * Client for authenticating Bitwarden users.
3748
+ *
3749
+ * Handles unauthenticated operations to obtain access tokens from the Identity API.
3750
+ * After successful authentication, use the returned tokens to create an authenticated core client.
3751
+ *
3752
+ * # Lifecycle
3753
+ *
3754
+ * 1. Create `LoginClient` via `AuthClient`
3755
+ * 2. Call login method
3756
+ * 3. Use returned tokens with authenticated core client
3757
+ *
3758
+ * # Password Login Example
3759
+ *
3760
+ * ```rust,no_run
3761
+ * # use bitwarden_auth::{AuthClient, login::login_via_password::PasswordLoginRequest};
3762
+ * # use bitwarden_auth::login::models::{LoginRequest, LoginDeviceRequest, LoginResponse};
3763
+ * # use bitwarden_core::{Client, ClientSettings, DeviceType};
3764
+ * # async fn example(email: String, password: String) -> Result<(), Box<dyn std::error::Error>> {
3765
+ * // Create auth client
3766
+ * let client = Client::new(None);
3767
+ * let auth_client = AuthClient::new(client);
3768
+ *
3769
+ * // Configure client settings and create login client
3770
+ * let settings = ClientSettings {
3771
+ * identity_url: "https://identity.bitwarden.com".to_string(),
3772
+ * api_url: "https://api.bitwarden.com".to_string(),
3773
+ * user_agent: "MyApp/1.0".to_string(),
3774
+ * device_type: DeviceType::SDK,
3775
+ * device_identifier: None,
3776
+ * bitwarden_client_version: None,
3777
+ * bitwarden_package_type: None,
3778
+ * };
3779
+ * let login_client = auth_client.login(settings);
3780
+ *
3781
+ * // Get user's KDF config
3782
+ * let prelogin = login_client.get_password_prelogin(email.clone()).await?;
3783
+ *
3784
+ * // Login with credentials
3785
+ * let response = login_client.login_via_password(PasswordLoginRequest {
3786
+ * login_request: LoginRequest {
3787
+ * client_id: "connector".to_string(),
3788
+ * device: LoginDeviceRequest {
3789
+ * device_type: DeviceType::SDK,
3790
+ * device_identifier: "device-id".to_string(),
3791
+ * device_name: "My Device".to_string(),
3792
+ * device_push_token: None,
3793
+ * },
3794
+ * },
3795
+ * email,
3796
+ * password,
3797
+ * prelogin_response: prelogin,
3798
+ * }).await?;
3799
+ *
3800
+ * // Use tokens from response for authenticated requests
3801
+ * match response {
3802
+ * LoginResponse::Authenticated(success) => {
3803
+ * let access_token = success.access_token;
3804
+ * // Use access_token for authenticated requests
3805
+ * }
3806
+ * }
3807
+ * # Ok(())
3808
+ * # }
3809
+ * ```
3810
+ */
3811
+ export class LoginClient {
3812
+ private constructor();
3813
+ free(): void;
3814
+ [Symbol.dispose](): void;
3815
+ /**
3816
+ * Retrieves the data required before authenticating with a password.
3817
+ * This includes the user's KDF configuration needed to properly derive the master key.
3818
+ */
3819
+ get_password_prelogin(email: string): Promise<PasswordPreloginResponse>;
3820
+ /**
3821
+ * Authenticates a user via email and master password.
3822
+ *
3823
+ * Derives the master password hash using KDF settings from prelogin, then sends
3824
+ * the authentication request to obtain access tokens and vault keys.
3825
+ */
3826
+ login_via_password(request: PasswordLoginRequest): Promise<LoginResponse>;
3827
+ }
3828
+
3829
+ export enum LoginLinkedIdType {
3830
+ Username = 100,
3831
+ Password = 101,
3832
+ }
3833
+
3834
+ /**
3835
+ * An untyped IPC message to be sent to another endpoint.
3836
+ */
3837
+ export class OutgoingMessage {
3838
+ free(): void;
3839
+ [Symbol.dispose](): void;
11
3840
  /**
12
- * The user\'s KDF parameters, as received from the prelogin request
3841
+ * Create an outgoing IPC message from raw payload bytes.
13
3842
  */
14
- kdfParams: Kdf;
3843
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
15
3844
  /**
16
- * The user\'s email address
3845
+ * Create a new message and encode the payload as JSON.
17
3846
  */
18
- email: string;
3847
+ static new_json_payload(
3848
+ payload: any,
3849
+ destination: Endpoint,
3850
+ topic?: string | null,
3851
+ ): OutgoingMessage;
19
3852
  /**
20
- * The user\'s encrypted private key
3853
+ * Destination endpoint for this message.
21
3854
  */
22
- privateKey: string;
3855
+ destination: Endpoint;
23
3856
  /**
24
- * The initialization method to use
3857
+ * Serialized payload bytes.
25
3858
  */
26
- method: InitUserCryptoMethod;
3859
+ payload: Uint8Array;
3860
+ /**
3861
+ * Optional topic used for routing/dispatch.
3862
+ */
3863
+ get topic(): string | undefined;
3864
+ /**
3865
+ * Optional topic used for routing/dispatch.
3866
+ */
3867
+ set topic(value: string | null | undefined);
27
3868
  }
28
3869
 
29
- export type InitUserCryptoMethod =
30
- | { password: { password: string; user_key: string } }
31
- | { decryptedKey: { decrypted_user_key: string } }
32
- | { pin: { pin: string; pin_protected_user_key: EncString } }
33
- | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
34
- | {
35
- deviceKey: {
36
- device_key: string;
37
- protected_device_private_key: EncString;
38
- device_protected_user_key: AsymmetricEncString;
39
- };
40
- }
41
- | { keyConnector: { master_key: string; user_key: string } };
42
-
43
- export type AuthRequestMethod =
44
- | { userKey: { protected_user_key: AsymmetricEncString } }
45
- | { masterKey: { protected_master_key: AsymmetricEncString; auth_request_key: EncString } };
46
-
47
- export interface InitOrgCryptoRequest {
3870
+ /**
3871
+ * The main entry point for the Bitwarden SDK in WebAssembly environments
3872
+ */
3873
+ export class PasswordManagerClient {
3874
+ free(): void;
3875
+ [Symbol.dispose](): void;
48
3876
  /**
49
- * The encryption keys for all the organizations the user is a part of
3877
+ * Auth related operations.
3878
+ */
3879
+ auth(): AuthClient;
3880
+ /**
3881
+ * Crypto related operations.
3882
+ */
3883
+ crypto(): CryptoClient;
3884
+ /**
3885
+ * Test method, echoes back the input
3886
+ */
3887
+ echo(msg: string): string;
3888
+ /**
3889
+ * Exporter related operations.
3890
+ */
3891
+ exporters(): ExporterClient;
3892
+ /**
3893
+ * Constructs a specific client for generating passwords and passphrases
3894
+ */
3895
+ generator(): GeneratorClient;
3896
+ /**
3897
+ * Test method, calls http endpoint
3898
+ */
3899
+ http_get(url: string): Promise<string>;
3900
+ /**
3901
+ * Initialize a new instance of the SDK client
3902
+ */
3903
+ constructor(token_provider: any, settings?: ClientSettings | null);
3904
+ /**
3905
+ * Constructs a specific client for platform-specific functionality
3906
+ */
3907
+ platform(): PlatformClient;
3908
+ /**
3909
+ * Send related operations.
3910
+ */
3911
+ sends(): SendClient;
3912
+ /**
3913
+ * Test method, always throws an error
3914
+ */
3915
+ throw(msg: string): void;
3916
+ /**
3917
+ * User crypto management related operations.
3918
+ */
3919
+ user_crypto_management(): UserCryptoManagementClient;
3920
+ /**
3921
+ * Vault item related operations.
50
3922
  */
51
- organizationKeys: Map<Uuid, AsymmetricEncString>;
3923
+ vault(): VaultClient;
3924
+ /**
3925
+ * Returns the current SDK version
3926
+ */
3927
+ version(): string;
52
3928
  }
53
3929
 
54
- export type DeviceType =
55
- | "Android"
56
- | "iOS"
57
- | "ChromeExtension"
58
- | "FirefoxExtension"
59
- | "OperaExtension"
60
- | "EdgeExtension"
61
- | "WindowsDesktop"
62
- | "MacOsDesktop"
63
- | "LinuxDesktop"
64
- | "ChromeBrowser"
65
- | "FirefoxBrowser"
66
- | "OperaBrowser"
67
- | "EdgeBrowser"
68
- | "IEBrowser"
69
- | "UnknownBrowser"
70
- | "AndroidAmazon"
71
- | "UWP"
72
- | "SafariBrowser"
73
- | "VivaldiBrowser"
74
- | "VivaldiExtension"
75
- | "SafariExtension"
76
- | "SDK"
77
- | "Server"
78
- | "WindowsCLI"
79
- | "MacOsCLI"
80
- | "LinuxCLI";
3930
+ export class PlatformClient {
3931
+ private constructor();
3932
+ free(): void;
3933
+ [Symbol.dispose](): void;
3934
+ /**
3935
+ * Load feature flags into the client
3936
+ */
3937
+ load_flags(flags: FeatureFlags): Promise<void>;
3938
+ state(): StateClient;
3939
+ }
81
3940
 
82
3941
  /**
83
- * Basic client behavior settings. These settings specify the various targets and behavior of the
84
- * Bitwarden Client. They are optional and uneditable once the client is initialized.
85
- *
86
- * Defaults to
87
- *
88
- * ```
89
- * # use bitwarden_core::{ClientSettings, DeviceType};
90
- * let settings = ClientSettings {
91
- * identity_url: \"https://identity.bitwarden.com\".to_string(),
92
- * api_url: \"https://api.bitwarden.com\".to_string(),
93
- * user_agent: \"Bitwarden Rust-SDK\".to_string(),
94
- * device_type: DeviceType::SDK,
95
- * };
96
- * let default = ClientSettings::default();
97
- * ```
3942
+ * This module represents a stopgap solution to provide access to primitive crypto functions for JS
3943
+ * clients. It is not intended to be used outside of the JS clients and this pattern should not be
3944
+ * proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
3945
+ * responsible for state and keys.
98
3946
  */
99
- export interface ClientSettings {
3947
+ export class PureCrypto {
3948
+ private constructor();
3949
+ free(): void;
3950
+ [Symbol.dispose](): void;
100
3951
  /**
101
- * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
3952
+ * Decapsulates (decrypts) a symmetric key using an decapsulation-key/private-key in PKCS8
3953
+ * DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
3954
+ * recipient.
102
3955
  */
103
- identityUrl?: string;
3956
+ static decapsulate_key_unsigned(
3957
+ encapsulated_key: string,
3958
+ decapsulation_key: Uint8Array,
3959
+ ): Uint8Array;
3960
+ static decrypt_user_key_with_master_key(
3961
+ encrypted_user_key: string,
3962
+ master_key: Uint8Array,
3963
+ ): Uint8Array;
3964
+ static decrypt_user_key_with_master_password(
3965
+ encrypted_user_key: string,
3966
+ master_password: string,
3967
+ email: string,
3968
+ kdf: Kdf,
3969
+ ): Uint8Array;
104
3970
  /**
105
- * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
3971
+ * Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
106
3972
  */
107
- apiUrl?: string;
3973
+ static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
108
3974
  /**
109
- * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
3975
+ * Encapsulates (encrypts) a symmetric key using an public-key/encapsulation-key
3976
+ * in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
3977
+ * the sender's authenticity cannot be verified by the recipient.
110
3978
  */
111
- userAgent?: string;
3979
+ static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
3980
+ static encrypt_user_key_with_master_password(
3981
+ user_key: Uint8Array,
3982
+ master_password: string,
3983
+ email: string,
3984
+ kdf: Kdf,
3985
+ ): string;
112
3986
  /**
113
- * Device type to send to Bitwarden. Defaults to SDK
3987
+ * Returns the algorithm used for the given verifying key.
114
3988
  */
115
- deviceType?: DeviceType;
3989
+ static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
3990
+ static make_user_key_aes256_cbc_hmac(): Uint8Array;
3991
+ static make_user_key_xchacha20_poly1305(): Uint8Array;
3992
+ /**
3993
+ * Generates a cryptographically secure random number between the given min and max
3994
+ * (inclusive).
3995
+ */
3996
+ static random_number(min: number, max: number): number;
3997
+ /**
3998
+ * Decrypts data using RSAES-OAEP with SHA-1
3999
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
4000
+ */
4001
+ static rsa_decrypt_data(encrypted_data: Uint8Array, private_key: Uint8Array): Uint8Array;
4002
+ /**
4003
+ * Encrypts data using RSAES-OAEP with SHA-1
4004
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
4005
+ */
4006
+ static rsa_encrypt_data(plain_data: Uint8Array, public_key: Uint8Array): Uint8Array;
4007
+ /**
4008
+ * Given a decrypted private RSA key PKCS8 DER this
4009
+ * returns the corresponding public RSA key in DER format.
4010
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
4011
+ */
4012
+ static rsa_extract_public_key(private_key: Uint8Array): Uint8Array;
4013
+ /**
4014
+ * Generates a new RSA key pair and returns the private key
4015
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
4016
+ */
4017
+ static rsa_generate_keypair(): Uint8Array;
4018
+ /**
4019
+ * DEPRECATED: Use `symmetric_decrypt_string` instead.
4020
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
4021
+ */
4022
+ static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
4023
+ /**
4024
+ * DEPRECATED: Use `symmetric_decrypt_filedata` instead.
4025
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
4026
+ */
4027
+ static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
4028
+ static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
4029
+ static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
4030
+ static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
4031
+ /**
4032
+ * DEPRECATED: Only used by send keys
4033
+ */
4034
+ static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
4035
+ static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
4036
+ static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
4037
+ /**
4038
+ * Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
4039
+ * wrapping key.
4040
+ */
4041
+ static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
4042
+ /**
4043
+ * Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
4044
+ * wrapping key.
4045
+ */
4046
+ static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
4047
+ /**
4048
+ * Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
4049
+ * unwrapped key as a serialized byte array.
4050
+ */
4051
+ static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
4052
+ /**
4053
+ * For a given signing identity (verifying key), this function verifies that the signing
4054
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
4055
+ * that the signing identity has the intent to receive messages encrypted to the public
4056
+ * key.
4057
+ */
4058
+ static verify_and_unwrap_signed_public_key(
4059
+ signed_public_key: Uint8Array,
4060
+ verifying_key: Uint8Array,
4061
+ ): Uint8Array;
4062
+ /**
4063
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
4064
+ * the corresponding verifying key.
4065
+ */
4066
+ static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
4067
+ /**
4068
+ * Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
4069
+ * key,
4070
+ */
4071
+ static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
4072
+ /**
4073
+ * Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
4074
+ * key. Note: Usually, a public key is - by definition - public, so this should not be
4075
+ * used. The specific use-case for this function is to enable rotateable key sets, where
4076
+ * the "public key" is not public, with the intent of preventing the server from being able
4077
+ * to overwrite the user key unlocked by the rotateable keyset.
4078
+ */
4079
+ static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
4080
+ /**
4081
+ * Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
4082
+ * as an EncString.
4083
+ */
4084
+ static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
116
4085
  }
117
4086
 
118
- export type AsymmetricEncString = string;
119
-
120
- export type EncString = string;
121
-
122
4087
  /**
123
- * Key Derivation Function for Bitwarden Account
124
- *
125
- * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
126
- * Enum represents all the possible KDFs.
4088
+ * Client for initializing a user account.
127
4089
  */
128
- export type Kdf =
129
- | { pBKDF2: { iterations: NonZeroU32 } }
130
- | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
131
-
132
- export interface Folder {
133
- id: Uuid | undefined;
134
- name: EncString;
135
- revisionDate: DateTime<Utc>;
4090
+ export class RegistrationClient {
4091
+ private constructor();
4092
+ free(): void;
4093
+ [Symbol.dispose](): void;
4094
+ /**
4095
+ * Initializes a new cryptographic state for a user and posts it to the server;
4096
+ * enrolls the user to master password unlock.
4097
+ */
4098
+ post_keys_for_jit_password_registration(
4099
+ request: JitMasterPasswordRegistrationRequest,
4100
+ ): Promise<JitMasterPasswordRegistrationResponse>;
4101
+ /**
4102
+ * Initializes a new cryptographic state for a user and posts it to the server; enrolls the
4103
+ * user to key connector unlock.
4104
+ */
4105
+ post_keys_for_key_connector_registration(
4106
+ key_connector_url: string,
4107
+ sso_org_identifier: string,
4108
+ ): Promise<KeyConnectorRegistrationResult>;
4109
+ /**
4110
+ * Initializes a new cryptographic state for a user and posts it to the server; enrolls in
4111
+ * admin password reset and finally enrolls the user to TDE unlock.
4112
+ */
4113
+ post_keys_for_tde_registration(request: TdeRegistrationRequest): Promise<TdeRegistrationResponse>;
136
4114
  }
137
4115
 
138
- export interface FolderView {
139
- id: Uuid | undefined;
140
- name: string;
141
- revisionDate: DateTime<Utc>;
4116
+ export enum RsaError {
4117
+ Decryption = 0,
4118
+ Encryption = 1,
4119
+ KeyParse = 2,
4120
+ KeySerialize = 3,
142
4121
  }
143
4122
 
144
- export type Uuid = string;
4123
+ export enum SecureNoteType {
4124
+ Generic = 0,
4125
+ }
145
4126
 
146
4127
  /**
147
- * RFC3339 compliant date-time string.
148
- * @typeParam T - Not used in JavaScript.
4128
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
149
4129
  */
150
- export type DateTime<T = unknown> = string;
4130
+ export class SendAccessClient {
4131
+ private constructor();
4132
+ free(): void;
4133
+ [Symbol.dispose](): void;
4134
+ /**
4135
+ * Requests a new send access token.
4136
+ */
4137
+ request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
4138
+ }
151
4139
 
152
- /**
153
- * UTC date-time string. Not used in JavaScript.
154
- */
155
- export type Utc = unknown;
4140
+ export class SendClient {
4141
+ private constructor();
4142
+ free(): void;
4143
+ [Symbol.dispose](): void;
4144
+ /**
4145
+ * Create a new [Send] and save it to the server.
4146
+ */
4147
+ create(request: SendAddRequest): Promise<SendView>;
4148
+ /**
4149
+ * Edit the [Send] and save it to the server.
4150
+ */
4151
+ edit(send_id: SendId, request: SendEditRequest): Promise<SendView>;
4152
+ /**
4153
+ * Get a specific [Send] by its ID from state and decrypt it to a [SendView].
4154
+ */
4155
+ get(send_id: SendId): Promise<SendView>;
4156
+ /**
4157
+ * Get all sends from state and decrypt them to a list of [SendView].
4158
+ */
4159
+ list(): Promise<SendView[]>;
4160
+ }
156
4161
 
157
4162
  /**
158
- * An integer that is known not to equal zero.
4163
+ * JavaScript wrapper for ServerCommunicationConfigClient
4164
+ *
4165
+ * This provides TypeScript access to the server communication configuration client,
4166
+ * allowing clients to check bootstrap requirements and retrieve cookies for HTTP requests.
159
4167
  */
160
- export type NonZeroU32 = number;
161
-
162
- export class BitwardenClient {
4168
+ export class ServerCommunicationConfigClient {
163
4169
  free(): void;
4170
+ [Symbol.dispose](): void;
164
4171
  /**
165
- * @param {ClientSettings | undefined} [settings]
166
- * @param {LogLevel | undefined} [log_level]
4172
+ * Acquires a cookie from the platform and saves it to the repository
4173
+ *
4174
+ * This method calls the platform API to trigger cookie acquisition (e.g., browser
4175
+ * redirect to IdP), then validates and stores the acquired cookie in the repository.
4176
+ *
4177
+ * # Arguments
4178
+ *
4179
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
4180
+ *
4181
+ * # Errors
4182
+ *
4183
+ * Returns an error if:
4184
+ * - Cookie acquisition was cancelled by the user
4185
+ * - Server configuration doesn't support SSO cookies (Direct bootstrap)
4186
+ * - Acquired cookie name doesn't match expected name
4187
+ * - Repository operations fail
167
4188
  */
168
- constructor(settings?: ClientSettings, log_level?: LogLevel);
4189
+ acquireCookie(hostname: string): Promise<void>;
169
4190
  /**
170
- * Test method, echoes back the input
171
- * @param {string} msg
172
- * @returns {string}
4191
+ * Returns all cookies that should be included in requests to this server
4192
+ *
4193
+ * Returns an array of [cookie_name, cookie_value] pairs.
4194
+ *
4195
+ * # Arguments
4196
+ *
4197
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
173
4198
  */
174
- echo(msg: string): string;
4199
+ cookies(hostname: string): Promise<any>;
175
4200
  /**
176
- * @returns {string}
4201
+ * Retrieves the server communication configuration for a hostname
4202
+ *
4203
+ * If no configuration exists, returns a default Direct bootstrap configuration.
4204
+ *
4205
+ * # Arguments
4206
+ *
4207
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
4208
+ *
4209
+ * # Errors
4210
+ *
4211
+ * Returns an error if the repository fails to retrieve the configuration.
177
4212
  */
178
- version(): string;
4213
+ getConfig(hostname: string): Promise<ServerCommunicationConfig>;
179
4214
  /**
180
- * @param {string} msg
4215
+ * Determines if cookie bootstrapping is needed for this hostname
4216
+ *
4217
+ * # Arguments
4218
+ *
4219
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
181
4220
  */
182
- throw(msg: string): void;
4221
+ needsBootstrap(hostname: string): Promise<boolean>;
183
4222
  /**
184
- * Test method, calls http endpoint
185
- * @param {string} url
186
- * @returns {Promise<string>}
4223
+ * Creates a new ServerCommunicationConfigClient with a JavaScript repository and platform API
4224
+ *
4225
+ * The repository should be backed by StateProvider (or equivalent
4226
+ * storage mechanism) for persistence.
4227
+ *
4228
+ * # Arguments
4229
+ *
4230
+ * * `repository` - JavaScript implementation of the repository interface
4231
+ * * `platform_api` - JavaScript implementation of the platform API interface
187
4232
  */
188
- http_get(url: string): Promise<string>;
4233
+ constructor(
4234
+ repository: ServerCommunicationConfigRepository,
4235
+ platform_api: ServerCommunicationConfigPlatformApi,
4236
+ );
189
4237
  /**
190
- * @returns {ClientCrypto}
4238
+ * Sets the server communication configuration for a hostname
4239
+ *
4240
+ * This method saves the provided communication configuration to the repository.
4241
+ * Typically called when receiving the `/api/config` response from the server.
4242
+ * Previously acquired cookies are preserved automatically.
4243
+ *
4244
+ * # Arguments
4245
+ *
4246
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
4247
+ * * `request` - The server communication configuration to store
4248
+ *
4249
+ * # Errors
4250
+ *
4251
+ * Returns an error if the repository save operation fails
191
4252
  */
192
- crypto(): ClientCrypto;
4253
+ setCommunicationType(hostname: string, request: SetCommunicationTypeRequest): Promise<void>;
4254
+ }
4255
+
4256
+ export class StateClient {
4257
+ private constructor();
4258
+ free(): void;
4259
+ [Symbol.dispose](): void;
4260
+ register_cipher_repository(cipher_repository: any): void;
4261
+ register_client_managed_repositories(repositories: Repositories): void;
4262
+ register_folder_repository(store: any): void;
4263
+ }
4264
+
4265
+ export class TotpClient {
4266
+ private constructor();
4267
+ free(): void;
4268
+ [Symbol.dispose](): void;
193
4269
  /**
194
- * @returns {ClientVault}
4270
+ * Generates a TOTP code from a provided key
4271
+ *
4272
+ * # Arguments
4273
+ * - `key` - Can be:
4274
+ * - A base32 encoded string
4275
+ * - OTP Auth URI
4276
+ * - Steam URI
4277
+ * - `time_ms` - Optional timestamp in milliseconds
195
4278
  */
196
- vault(): ClientVault;
4279
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
4280
+ }
4281
+
4282
+ export enum UriMatchType {
4283
+ Domain = 0,
4284
+ Host = 1,
4285
+ StartsWith = 2,
4286
+ Exact = 3,
4287
+ RegularExpression = 4,
4288
+ Never = 5,
197
4289
  }
198
- export class ClientCrypto {
4290
+
4291
+ /**
4292
+ * Client for managing the cryptographic machinery of a user account, including key-rotation.
4293
+ */
4294
+ export class UserCryptoManagementClient {
4295
+ private constructor();
199
4296
  free(): void;
4297
+ [Symbol.dispose](): void;
200
4298
  /**
201
- * Initialization method for the user crypto. Needs to be called before any other crypto
202
- * operations.
203
- * @param {InitUserCryptoRequest} req
204
- * @returns {Promise<void>}
4299
+ * Fetches the emergency access public keys for V1 emergency access memberships for the user.
4300
+ * These have to be trusted manually be the user before rotating.
205
4301
  */
206
- initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
4302
+ get_untrusted_emergency_access_public_keys(): Promise<V1EmergencyAccessMembership[]>;
207
4303
  /**
208
- * Initialization method for the organization crypto. Needs to be called after
209
- * `initialize_user_crypto` but before any other crypto operations.
210
- * @param {InitOrgCryptoRequest} req
211
- * @returns {Promise<void>}
4304
+ * Fetches the organization public keys for V1 organization memberships for the user for
4305
+ * organizations for which reset password is enrolled.
4306
+ * These have to be trusted manually be the user before rotating.
212
4307
  */
213
- initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
214
- }
215
- export class ClientFolders {
216
- free(): void;
4308
+ get_untrusted_organization_public_keys(): Promise<V1OrganizationMembership[]>;
217
4309
  /**
218
- * Decrypt folder
219
- * @param {Folder} folder
220
- * @returns {FolderView}
4310
+ * Migrates an initialized account to Key Connector unlock.
4311
+ *
4312
+ * Requires the client to be unlocked so the current user key is available in memory.
221
4313
  */
222
- decrypt(folder: Folder): FolderView;
4314
+ migrate_to_key_connector(key_connector_url: string): Promise<void>;
4315
+ /**
4316
+ * Combines a password change and user key rotation into a single request.
4317
+ */
4318
+ password_change_and_rotate_user_keys(
4319
+ request: PasswordChangeAndRotateUserKeysRequest,
4320
+ ): Promise<void>;
4321
+ /**
4322
+ * Rotates the user's encryption keys without a password change.
4323
+ */
4324
+ rotate_user_keys(request: RotateUserKeysRequest): Promise<void>;
223
4325
  }
224
- export class ClientVault {
4326
+
4327
+ export class VaultClient {
4328
+ private constructor();
225
4329
  free(): void;
4330
+ [Symbol.dispose](): void;
4331
+ /**
4332
+ * Attachment related operations.
4333
+ */
4334
+ attachments(): AttachmentsClient;
4335
+ /**
4336
+ * Cipher risk evaluation operations.
4337
+ */
4338
+ cipher_risk(): CipherRiskClient;
4339
+ /**
4340
+ * Cipher related operations.
4341
+ */
4342
+ ciphers(): CiphersClient;
226
4343
  /**
227
- * @returns {ClientFolders}
4344
+ * Collection related operations.
228
4345
  */
229
- folders(): ClientFolders;
4346
+ collections(): CollectionsClient;
4347
+ /**
4348
+ * Folder related operations.
4349
+ */
4350
+ folders(): FoldersClient;
4351
+ /**
4352
+ * TOTP related operations.
4353
+ */
4354
+ totp(): TotpClient;
230
4355
  }
4356
+
4357
+ /**
4358
+ * Generate a new SSH key pair
4359
+ *
4360
+ * # Arguments
4361
+ * - `key_algorithm` - The algorithm to use for the key pair
4362
+ *
4363
+ * # Returns
4364
+ * - `Ok(SshKey)` if the key was successfully generated
4365
+ * - `Err(KeyGenerationError)` if the key could not be generated
4366
+ */
4367
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
4368
+
4369
+ /**
4370
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
4371
+ * to an OpenSSH private key with public key and fingerprint
4372
+ *
4373
+ * # Arguments
4374
+ * - `imported_key` - The private key to convert
4375
+ * - `password` - The password to use for decrypting the key
4376
+ *
4377
+ * # Returns
4378
+ * - `Ok(SshKey)` if the key was successfully coneverted
4379
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
4380
+ * - `Err(WrongPassword)` if the password provided is incorrect
4381
+ * - `Err(ParsingError)` if the key could not be parsed
4382
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
4383
+ */
4384
+ export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
4385
+
4386
+ /**
4387
+ * Initialize the SDK. Must be called before using any other API.
4388
+ * Only the first invocation has effect; subsequent calls are ignored.
4389
+ *
4390
+ * - `log_level`: Minimum level for console output. Defaults to `Info`.
4391
+ * - `flight_recorder_level`: Minimum level for the flight recorder. Defaults to `Info`.
4392
+ * - `flight_recorder_buffer_size`: Ring-buffer capacity for the flight recorder. Defaults to 1000.
4393
+ * Pass `0` to disable the flight recorder entirely.
4394
+ */
4395
+ export function init_sdk(
4396
+ log_level?: LogLevel | null,
4397
+ flight_recorder_level?: LogLevel | null,
4398
+ flight_recorder_buffer_size?: number | null,
4399
+ ): void;
4400
+
4401
+ /**
4402
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
4403
+ */
4404
+ export function ipcRegisterDiscoverHandler(
4405
+ ipc_client: IpcClient,
4406
+ response: DiscoverResponse,
4407
+ ): Promise<void>;
4408
+
4409
+ /**
4410
+ * Sends a DiscoverRequest to the specified destination and returns the response.
4411
+ */
4412
+ export function ipcRequestDiscover(
4413
+ ipc_client: IpcClient,
4414
+ destination: Endpoint,
4415
+ abort_signal?: AbortSignal | null,
4416
+ ): Promise<DiscoverResponse>;