@bitwarden/sdk-internal 0.2.0-main.62 → 0.2.0-main.620

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