@bitwarden/sdk-internal 0.2.0-main.67 → 0.2.0-main.670

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