@bitwarden/sdk-internal 0.2.0-main.64 → 0.2.0-main.641

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