@bitwarden/sdk-internal 0.2.0-main.41 → 0.2.0-main.410

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,6 +1,109 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function generate_ssh_key(key_algorithm: KeyAlgorithm): GenerateSshKeyResult;
3
+ export function init_sdk(log_level?: LogLevel | null): void;
4
+ /**
5
+ * Generate a new SSH key pair
6
+ *
7
+ * # Arguments
8
+ * - `key_algorithm` - The algorithm to use for the key pair
9
+ *
10
+ * # Returns
11
+ * - `Ok(SshKey)` if the key was successfully generated
12
+ * - `Err(KeyGenerationError)` if the key could not be generated
13
+ */
14
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
15
+ /**
16
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
17
+ * to an OpenSSH private key with public key and fingerprint
18
+ *
19
+ * # Arguments
20
+ * - `imported_key` - The private key to convert
21
+ * - `password` - The password to use for decrypting the key
22
+ *
23
+ * # Returns
24
+ * - `Ok(SshKey)` if the key was successfully coneverted
25
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
26
+ * - `Err(WrongPassword)` if the password provided is incorrect
27
+ * - `Err(ParsingError)` if the key could not be parsed
28
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
29
+ */
30
+ export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
31
+ /**
32
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
33
+ */
34
+ export function ipcRegisterDiscoverHandler(
35
+ ipc_client: IpcClient,
36
+ response: DiscoverResponse,
37
+ ): Promise<void>;
38
+ /**
39
+ * Sends a DiscoverRequest to the specified destination and returns the response.
40
+ */
41
+ export function ipcRequestDiscover(
42
+ ipc_client: IpcClient,
43
+ destination: Endpoint,
44
+ abort_signal?: AbortSignal | null,
45
+ ): Promise<DiscoverResponse>;
46
+ export enum CardLinkedIdType {
47
+ CardholderName = 300,
48
+ ExpMonth = 301,
49
+ ExpYear = 302,
50
+ Code = 303,
51
+ Brand = 304,
52
+ Number = 305,
53
+ }
54
+ export enum CipherRepromptType {
55
+ None = 0,
56
+ Password = 1,
57
+ }
58
+ export enum CipherType {
59
+ Login = 1,
60
+ SecureNote = 2,
61
+ Card = 3,
62
+ Identity = 4,
63
+ SshKey = 5,
64
+ }
65
+ /**
66
+ * Represents the type of a [FieldView].
67
+ */
68
+ export enum FieldType {
69
+ /**
70
+ * Text field
71
+ */
72
+ Text = 0,
73
+ /**
74
+ * Hidden text field
75
+ */
76
+ Hidden = 1,
77
+ /**
78
+ * Boolean field
79
+ */
80
+ Boolean = 2,
81
+ /**
82
+ * Linked field
83
+ */
84
+ Linked = 3,
85
+ }
86
+ export enum IdentityLinkedIdType {
87
+ Title = 400,
88
+ MiddleName = 401,
89
+ Address1 = 402,
90
+ Address2 = 403,
91
+ Address3 = 404,
92
+ City = 405,
93
+ State = 406,
94
+ PostalCode = 407,
95
+ Country = 408,
96
+ Company = 409,
97
+ Email = 410,
98
+ Phone = 411,
99
+ Ssn = 412,
100
+ Username = 413,
101
+ PassportNumber = 414,
102
+ LicenseNumber = 415,
103
+ FirstName = 416,
104
+ LastName = 417,
105
+ FullName = 418,
106
+ }
4
107
  export enum LogLevel {
5
108
  Trace = 0,
6
109
  Debug = 1,
@@ -8,7 +111,269 @@ export enum LogLevel {
8
111
  Warn = 3,
9
112
  Error = 4,
10
113
  }
114
+ export enum LoginLinkedIdType {
115
+ Username = 100,
116
+ Password = 101,
117
+ }
118
+ export enum RsaError {
119
+ Decryption = 0,
120
+ Encryption = 1,
121
+ KeyParse = 2,
122
+ KeySerialize = 3,
123
+ }
124
+ export enum SecureNoteType {
125
+ Generic = 0,
126
+ }
127
+ export enum UriMatchType {
128
+ Domain = 0,
129
+ Host = 1,
130
+ StartsWith = 2,
131
+ Exact = 3,
132
+ RegularExpression = 4,
133
+ Never = 5,
134
+ }
135
+
136
+ /**
137
+ * @deprecated Use PasswordManagerClient instead
138
+ */
139
+ export type BitwardenClient = PasswordManagerClient;
140
+
141
+ import { Tagged } from "type-fest";
142
+
143
+ /**
144
+ * A string that **MUST** be a valid UUID.
145
+ *
146
+ * Never create or cast to this type directly, use the `uuid<T>()` function instead.
147
+ */
148
+ export type Uuid = unknown;
149
+
150
+ /**
151
+ * RFC3339 compliant date-time string.
152
+ * @typeParam T - Not used in JavaScript.
153
+ */
154
+ export type DateTime<T = unknown> = string;
155
+
156
+ /**
157
+ * UTC date-time string. Not used in JavaScript.
158
+ */
159
+ export type Utc = unknown;
160
+
161
+ /**
162
+ * An integer that is known not to equal zero.
163
+ */
164
+ export type NonZeroU32 = number;
165
+
166
+ export interface Repository<T> {
167
+ get(id: string): Promise<T | null>;
168
+ list(): Promise<T[]>;
169
+ set(id: string, value: T): Promise<void>;
170
+ remove(id: string): Promise<void>;
171
+ }
172
+
173
+ export interface TokenProvider {
174
+ get_access_token(): Promise<string | undefined>;
175
+ }
176
+
177
+ /**
178
+ * Active feature flags for the SDK.
179
+ */
180
+ export interface FeatureFlags extends Map<string, boolean> {}
181
+
182
+ export interface Repositories {
183
+ cipher: Repository<Cipher> | null;
184
+ folder: Repository<Folder> | null;
185
+ }
186
+
187
+ export interface IndexedDbConfiguration {
188
+ db_name: string;
189
+ }
190
+
191
+ export interface TestError extends Error {
192
+ name: "TestError";
193
+ }
194
+
195
+ export function isTestError(error: any): error is TestError;
196
+
197
+ /**
198
+ * Represents the possible, expected errors that can occur when requesting a send access token.
199
+ */
200
+ export type SendAccessTokenApiErrorResponse =
201
+ | {
202
+ error: "invalid_request";
203
+ error_description?: string;
204
+ send_access_error_type?: SendAccessTokenInvalidRequestError;
205
+ }
206
+ | {
207
+ error: "invalid_grant";
208
+ error_description?: string;
209
+ send_access_error_type?: SendAccessTokenInvalidGrantError;
210
+ }
211
+ | { error: "invalid_client"; error_description?: string }
212
+ | { error: "unauthorized_client"; error_description?: string }
213
+ | { error: "unsupported_grant_type"; error_description?: string }
214
+ | { error: "invalid_scope"; error_description?: string }
215
+ | { error: "invalid_target"; error_description?: string };
216
+
217
+ /**
218
+ * Invalid grant errors - typically due to invalid credentials.
219
+ */
220
+ export type SendAccessTokenInvalidGrantError =
221
+ | "send_id_invalid"
222
+ | "password_hash_b64_invalid"
223
+ | "email_invalid"
224
+ | "otp_invalid"
225
+ | "otp_generation_failed"
226
+ | "unknown";
227
+
228
+ /**
229
+ * Invalid request errors - typically due to missing parameters.
230
+ */
231
+ export type SendAccessTokenInvalidRequestError =
232
+ | "send_id_required"
233
+ | "password_hash_b64_required"
234
+ | "email_required"
235
+ | "email_and_otp_required_otp_sent"
236
+ | "unknown";
237
+
238
+ /**
239
+ * Any unexpected error that occurs when making requests to identity. This could be
240
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
241
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
242
+ * unexpected body or status. Used when decoding the server\'s error payload into
243
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
244
+ * available.
245
+ */
246
+ export type UnexpectedIdentityError = string;
247
+
248
+ /**
249
+ * Represents errors that can occur when requesting a send access token.
250
+ * It includes expected and unexpected API errors.
251
+ */
252
+ export type SendAccessTokenError =
253
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
254
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
255
+
256
+ /**
257
+ * A send access token which can be used to access a send.
258
+ */
259
+ export interface SendAccessTokenResponse {
260
+ /**
261
+ * The actual token string.
262
+ */
263
+ token: string;
264
+ /**
265
+ * The timestamp in milliseconds when the token expires.
266
+ */
267
+ expiresAt: number;
268
+ }
269
+
270
+ /**
271
+ * A request structure for requesting a send access token from the API.
272
+ */
273
+ export interface SendAccessTokenRequest {
274
+ /**
275
+ * The id of the send for which the access token is requested.
276
+ */
277
+ sendId: string;
278
+ /**
279
+ * The optional send access credentials.
280
+ */
281
+ sendAccessCredentials?: SendAccessCredentials;
282
+ }
283
+
284
+ /**
285
+ * The credentials used for send access requests.
286
+ */
287
+ export type SendAccessCredentials =
288
+ | SendPasswordCredentials
289
+ | SendEmailOtpCredentials
290
+ | SendEmailCredentials;
291
+
292
+ /**
293
+ * Credentials for getting a send access token using an email and OTP.
294
+ */
295
+ export interface SendEmailOtpCredentials {
296
+ /**
297
+ * The email address to which the OTP will be sent.
298
+ */
299
+ email: string;
300
+ /**
301
+ * The one-time password (OTP) that the user has received via email.
302
+ */
303
+ otp: string;
304
+ }
305
+
306
+ /**
307
+ * Credentials for sending an OTP to the user\'s email address.
308
+ * This is used when the send requires email verification with an OTP.
309
+ */
310
+ export interface SendEmailCredentials {
311
+ /**
312
+ * The email address to which the OTP will be sent.
313
+ */
314
+ email: string;
315
+ }
316
+
317
+ /**
318
+ * Credentials for sending password secured access requests.
319
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
320
+ * struct.
321
+ */
322
+ export interface SendPasswordCredentials {
323
+ /**
324
+ * A Base64-encoded hash of the password protecting the send.
325
+ */
326
+ passwordHashB64: string;
327
+ }
328
+
329
+ /**
330
+ * NewType wrapper for `CollectionId`
331
+ */
332
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
333
+
334
+ export interface Collection {
335
+ id: CollectionId | undefined;
336
+ organizationId: OrganizationId;
337
+ name: EncString;
338
+ externalId: string | undefined;
339
+ hidePasswords: boolean;
340
+ readOnly: boolean;
341
+ manage: boolean;
342
+ defaultUserCollectionEmail: string | undefined;
343
+ type: CollectionType;
344
+ }
345
+
346
+ export interface CollectionView {
347
+ id: CollectionId | undefined;
348
+ organizationId: OrganizationId;
349
+ name: string;
350
+ externalId: string | undefined;
351
+ hidePasswords: boolean;
352
+ readOnly: boolean;
353
+ manage: boolean;
354
+ type: CollectionType;
355
+ }
356
+
357
+ /**
358
+ * Type of collection
359
+ */
360
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
361
+
362
+ export interface CollectionDecryptError extends Error {
363
+ name: "CollectionDecryptError";
364
+ variant: "Crypto";
365
+ }
366
+
367
+ export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
368
+
369
+ /**
370
+ * State used for initializing the user cryptographic state.
371
+ */
11
372
  export interface InitUserCryptoRequest {
373
+ /**
374
+ * The user\'s ID.
375
+ */
376
+ userId: UserId | undefined;
12
377
  /**
13
378
  * The user\'s KDF parameters, as received from the prelogin request
14
379
  */
@@ -18,66 +383,169 @@ export interface InitUserCryptoRequest {
18
383
  */
19
384
  email: string;
20
385
  /**
21
- * The user\'s encrypted private key
386
+ * The user\'s account cryptographic state, containing their signature and
387
+ * public-key-encryption keys, along with the signed security state, protected by the user key
22
388
  */
23
- privateKey: string;
389
+ accountCryptographicState: WrappedAccountCryptographicState;
24
390
  /**
25
- * The initialization method to use
391
+ * The method to decrypt the user\'s account symmetric key (user key)
26
392
  */
27
393
  method: InitUserCryptoMethod;
28
394
  }
29
395
 
396
+ /**
397
+ * The crypto method used to initialize the user cryptographic state.
398
+ */
30
399
  export type InitUserCryptoMethod =
31
- | { password: { password: string; user_key: string } }
400
+ | { password: { password: string; user_key: EncString } }
401
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
32
402
  | { decryptedKey: { decrypted_user_key: string } }
33
403
  | { pin: { pin: string; pin_protected_user_key: EncString } }
34
- | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
404
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
405
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
35
406
  | {
36
407
  deviceKey: {
37
408
  device_key: string;
38
409
  protected_device_private_key: EncString;
39
- device_protected_user_key: AsymmetricEncString;
410
+ device_protected_user_key: UnsignedSharedKey;
40
411
  };
41
412
  }
42
- | { keyConnector: { master_key: string; user_key: string } };
413
+ | { keyConnector: { master_key: B64; user_key: EncString } };
43
414
 
415
+ /**
416
+ * Auth requests supports multiple initialization methods.
417
+ */
44
418
  export type AuthRequestMethod =
45
- | { userKey: { protected_user_key: AsymmetricEncString } }
46
- | { masterKey: { protected_master_key: AsymmetricEncString; auth_request_key: EncString } };
419
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
420
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
47
421
 
422
+ /**
423
+ * Represents the request to initialize the user\'s organizational cryptographic state.
424
+ */
48
425
  export interface InitOrgCryptoRequest {
49
426
  /**
50
427
  * The encryption keys for all the organizations the user is a part of
51
428
  */
52
- organizationKeys: Map<Uuid, AsymmetricEncString>;
429
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
430
+ }
431
+
432
+ /**
433
+ * Response from the `update_kdf` function
434
+ */
435
+ export interface UpdateKdfResponse {
436
+ /**
437
+ * The authentication data for the new KDF setting
438
+ */
439
+ masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
440
+ /**
441
+ * The unlock data for the new KDF setting
442
+ */
443
+ masterPasswordUnlockData: MasterPasswordUnlockData;
444
+ /**
445
+ * The authentication data for the KDF setting prior to the change
446
+ */
447
+ oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
448
+ }
449
+
450
+ /**
451
+ * Response from the `make_update_password` function
452
+ */
453
+ export interface UpdatePasswordResponse {
454
+ /**
455
+ * Hash of the new password
456
+ */
457
+ passwordHash: B64;
458
+ /**
459
+ * User key, encrypted with the new password
460
+ */
461
+ newKey: EncString;
462
+ }
463
+
464
+ /**
465
+ * Request for deriving a pin protected user key
466
+ */
467
+ export interface EnrollPinResponse {
468
+ /**
469
+ * [UserKey] protected by PIN
470
+ */
471
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
472
+ /**
473
+ * PIN protected by [UserKey]
474
+ */
475
+ userKeyEncryptedPin: EncString;
476
+ }
477
+
478
+ /**
479
+ * Request for deriving a pin protected user key
480
+ */
481
+ export interface DerivePinKeyResponse {
482
+ /**
483
+ * [UserKey] protected by PIN
484
+ */
485
+ pinProtectedUserKey: EncString;
486
+ /**
487
+ * PIN protected by [UserKey]
488
+ */
489
+ encryptedPin: EncString;
490
+ }
491
+
492
+ /**
493
+ * Request for migrating an account from password to key connector.
494
+ */
495
+ export interface DeriveKeyConnectorRequest {
496
+ /**
497
+ * Encrypted user key, used to validate the master key
498
+ */
499
+ userKeyEncrypted: EncString;
500
+ /**
501
+ * The user\'s master password
502
+ */
503
+ password: string;
504
+ /**
505
+ * The KDF parameters used to derive the master key
506
+ */
507
+ kdf: Kdf;
508
+ /**
509
+ * The user\'s email address
510
+ */
511
+ email: string;
53
512
  }
54
513
 
514
+ /**
515
+ * Response from the `make_key_pair` function
516
+ */
55
517
  export interface MakeKeyPairResponse {
56
518
  /**
57
519
  * The user\'s public key
58
520
  */
59
- userPublicKey: string;
521
+ userPublicKey: B64;
60
522
  /**
61
523
  * User\'s private key, encrypted with the user key
62
524
  */
63
525
  userKeyEncryptedPrivateKey: EncString;
64
526
  }
65
527
 
528
+ /**
529
+ * Request for `verify_asymmetric_keys`.
530
+ */
66
531
  export interface VerifyAsymmetricKeysRequest {
67
532
  /**
68
533
  * The user\'s user key
69
534
  */
70
- userKey: string;
535
+ userKey: B64;
71
536
  /**
72
537
  * The user\'s public key
73
538
  */
74
- userPublicKey: string;
539
+ userPublicKey: B64;
75
540
  /**
76
541
  * User\'s private key, encrypted with the user key
77
542
  */
78
543
  userKeyEncryptedPrivateKey: EncString;
79
544
  }
80
545
 
546
+ /**
547
+ * Response for `verify_asymmetric_keys`.
548
+ */
81
549
  export interface VerifyAsymmetricKeysResponse {
82
550
  /**
83
551
  * Whether the user\'s private key was decryptable by the user key.
@@ -89,45 +557,172 @@ export interface VerifyAsymmetricKeysResponse {
89
557
  validPrivateKey: boolean;
90
558
  }
91
559
 
92
- export interface CoreError extends Error {
93
- name: "CoreError";
94
- variant:
95
- | "MissingFieldError"
96
- | "VaultLocked"
97
- | "NotAuthenticated"
98
- | "AccessTokenInvalid"
99
- | "InvalidResponse"
100
- | "Crypto"
101
- | "IdentityFail"
102
- | "Reqwest"
103
- | "Serde"
104
- | "Io"
105
- | "InvalidBase64"
106
- | "Chrono"
107
- | "ResponseContent"
108
- | "ValidationError"
109
- | "InvalidStateFileVersion"
110
- | "InvalidStateFile"
111
- | "Internal"
112
- | "EncryptionSettings";
560
+ /**
561
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
562
+ */
563
+ export interface UserCryptoV2KeysResponse {
564
+ /**
565
+ * User key
566
+ */
567
+ userKey: B64;
568
+ /**
569
+ * Wrapped private key
570
+ */
571
+ privateKey: EncString;
572
+ /**
573
+ * Public key
574
+ */
575
+ publicKey: B64;
576
+ /**
577
+ * The user\'s public key, signed by the signing key
578
+ */
579
+ signedPublicKey: SignedPublicKey;
580
+ /**
581
+ * Signing key, encrypted with the user\'s symmetric key
582
+ */
583
+ signingKey: EncString;
584
+ /**
585
+ * Base64 encoded verifying key
586
+ */
587
+ verifyingKey: B64;
588
+ /**
589
+ * The user\'s signed security state
590
+ */
591
+ securityState: SignedSecurityState;
592
+ /**
593
+ * The security state\'s version
594
+ */
595
+ securityVersion: number;
113
596
  }
114
597
 
115
- export function isCoreError(error: any): error is CoreError;
598
+ /**
599
+ * Represents the data required to unlock with the master password.
600
+ */
601
+ export interface MasterPasswordUnlockData {
602
+ /**
603
+ * The key derivation function used to derive the master key
604
+ */
605
+ kdf: Kdf;
606
+ /**
607
+ * The master key wrapped user key
608
+ */
609
+ masterKeyWrappedUserKey: EncString;
610
+ /**
611
+ * The salt used in the KDF, typically the user\'s email
612
+ */
613
+ salt: string;
614
+ }
116
615
 
117
- export interface EncryptionSettingsError extends Error {
118
- name: "EncryptionSettingsError";
119
- variant: "Crypto" | "InvalidBase64" | "VaultLocked" | "InvalidPrivateKey" | "MissingPrivateKey";
616
+ /**
617
+ * Represents the data required to authenticate with the master password.
618
+ */
619
+ export interface MasterPasswordAuthenticationData {
620
+ kdf: Kdf;
621
+ salt: string;
622
+ masterPasswordAuthenticationHash: B64;
120
623
  }
121
624
 
122
- export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
625
+ export type SignedSecurityState = string;
123
626
 
124
- export type DeviceType =
125
- | "Android"
126
- | "iOS"
127
- | "ChromeExtension"
128
- | "FirefoxExtension"
129
- | "OperaExtension"
130
- | "EdgeExtension"
627
+ /**
628
+ * NewType wrapper for `UserId`
629
+ */
630
+ export type UserId = Tagged<Uuid, "UserId">;
631
+
632
+ /**
633
+ * NewType wrapper for `OrganizationId`
634
+ */
635
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
636
+
637
+ export interface MasterPasswordError extends Error {
638
+ name: "MasterPasswordError";
639
+ variant:
640
+ | "EncryptionKeyMalformed"
641
+ | "KdfMalformed"
642
+ | "InvalidKdfConfiguration"
643
+ | "MissingField"
644
+ | "Crypto";
645
+ }
646
+
647
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
648
+
649
+ export interface DeriveKeyConnectorError extends Error {
650
+ name: "DeriveKeyConnectorError";
651
+ variant: "WrongPassword" | "Crypto";
652
+ }
653
+
654
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
655
+
656
+ export interface EnrollAdminPasswordResetError extends Error {
657
+ name: "EnrollAdminPasswordResetError";
658
+ variant: "Crypto";
659
+ }
660
+
661
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
662
+
663
+ export interface CryptoClientError extends Error {
664
+ name: "CryptoClientError";
665
+ variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
666
+ }
667
+
668
+ export function isCryptoClientError(error: any): error is CryptoClientError;
669
+
670
+ /**
671
+ * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
672
+ * Private keys are protected by the user key.
673
+ */
674
+ export type WrappedAccountCryptographicState =
675
+ | { V1: { private_key: EncString } }
676
+ | {
677
+ V2: {
678
+ private_key: EncString;
679
+ signed_public_key: SignedPublicKey | undefined;
680
+ signing_key: EncString;
681
+ security_state: SignedSecurityState;
682
+ };
683
+ };
684
+
685
+ export interface AccountCryptographyInitializationError extends Error {
686
+ name: "AccountCryptographyInitializationError";
687
+ variant:
688
+ | "WrongUserKeyType"
689
+ | "WrongUserKey"
690
+ | "CorruptData"
691
+ | "TamperedData"
692
+ | "KeyStoreAlreadyInitialized"
693
+ | "GenericCrypto";
694
+ }
695
+
696
+ export function isAccountCryptographyInitializationError(
697
+ error: any,
698
+ ): error is AccountCryptographyInitializationError;
699
+
700
+ export interface StatefulCryptoError extends Error {
701
+ name: "StatefulCryptoError";
702
+ variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
703
+ }
704
+
705
+ export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
706
+
707
+ export interface EncryptionSettingsError extends Error {
708
+ name: "EncryptionSettingsError";
709
+ variant:
710
+ | "Crypto"
711
+ | "CryptoInitialization"
712
+ | "MissingPrivateKey"
713
+ | "UserIdAlreadySet"
714
+ | "WrongPin";
715
+ }
716
+
717
+ export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
718
+
719
+ export type DeviceType =
720
+ | "Android"
721
+ | "iOS"
722
+ | "ChromeExtension"
723
+ | "FirefoxExtension"
724
+ | "OperaExtension"
725
+ | "EdgeExtension"
131
726
  | "WindowsDesktop"
132
727
  | "MacOsDesktop"
133
728
  | "LinuxDesktop"
@@ -147,7 +742,8 @@ export type DeviceType =
147
742
  | "Server"
148
743
  | "WindowsCLI"
149
744
  | "MacOsCLI"
150
- | "LinuxCLI";
745
+ | "LinuxCLI"
746
+ | "DuckDuckGoBrowser";
151
747
 
152
748
  /**
153
749
  * Basic client behavior settings. These settings specify the various targets and behavior of the
@@ -162,6 +758,7 @@ export type DeviceType =
162
758
  * api_url: \"https://api.bitwarden.com\".to_string(),
163
759
  * user_agent: \"Bitwarden Rust-SDK\".to_string(),
164
760
  * device_type: DeviceType::SDK,
761
+ * bitwarden_client_version: None,
165
762
  * };
166
763
  * let default = ClientSettings::default();
167
764
  * ```
@@ -183,11 +780,26 @@ export interface ClientSettings {
183
780
  * Device type to send to Bitwarden. Defaults to SDK
184
781
  */
185
782
  deviceType?: DeviceType;
783
+ /**
784
+ * Bitwarden Client Version to send to Bitwarden.
785
+ */
786
+ bitwardenClientVersion?: string | undefined;
186
787
  }
187
788
 
188
- export type AsymmetricEncString = string;
789
+ export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
189
790
 
190
- export type EncString = string;
791
+ export type EncString = Tagged<string, "EncString">;
792
+
793
+ export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
794
+
795
+ export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
796
+
797
+ export type DataEnvelope = Tagged<string, "DataEnvelope">;
798
+
799
+ /**
800
+ * The type of key / signature scheme used for signing and verifying.
801
+ */
802
+ export type SignatureAlgorithm = "ed25519";
191
803
 
192
804
  /**
193
805
  * Key Derivation Function for Bitwarden Account
@@ -199,108 +811,1746 @@ export type Kdf =
199
811
  | { pBKDF2: { iterations: NonZeroU32 } }
200
812
  | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
201
813
 
202
- export interface GenerateSshKeyResult {
203
- private_key: string;
204
- public_key: string;
205
- key_fingerprint: string;
814
+ export interface CryptoError extends Error {
815
+ name: "CryptoError";
816
+ variant:
817
+ | "InvalidKey"
818
+ | "InvalidMac"
819
+ | "MacNotProvided"
820
+ | "KeyDecrypt"
821
+ | "InvalidKeyLen"
822
+ | "InvalidUtf8String"
823
+ | "MissingKey"
824
+ | "MissingField"
825
+ | "MissingKeyId"
826
+ | "KeyOperationNotSupported"
827
+ | "ReadOnlyKeyStore"
828
+ | "InvalidKeyStoreOperation"
829
+ | "InsufficientKdfParameters"
830
+ | "EncString"
831
+ | "Rsa"
832
+ | "Fingerprint"
833
+ | "Argon"
834
+ | "ZeroNumber"
835
+ | "OperationNotSupported"
836
+ | "WrongKeyType"
837
+ | "WrongCoseKeyId"
838
+ | "InvalidNonceLength"
839
+ | "InvalidPadding"
840
+ | "Signature"
841
+ | "Encoding";
842
+ }
843
+
844
+ export function isCryptoError(error: any): error is CryptoError;
845
+
846
+ /**
847
+ * Base64 encoded data
848
+ *
849
+ * Is indifferent about padding when decoding, but always produces padding when encoding.
850
+ */
851
+ export type B64 = string;
852
+
853
+ /**
854
+ * Temporary struct to hold metadata related to current account
855
+ *
856
+ * Eventually the SDK itself should have this state and we get rid of this struct.
857
+ */
858
+ export interface Account {
859
+ id: Uuid;
860
+ email: string;
861
+ name: string | undefined;
862
+ }
863
+
864
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
865
+
866
+ export interface ExportError extends Error {
867
+ name: "ExportError";
868
+ variant:
869
+ | "MissingField"
870
+ | "NotAuthenticated"
871
+ | "Csv"
872
+ | "Cxf"
873
+ | "Json"
874
+ | "EncryptedJson"
875
+ | "BitwardenCrypto"
876
+ | "Cipher";
877
+ }
878
+
879
+ export function isExportError(error: any): error is ExportError;
880
+
881
+ export type UsernameGeneratorRequest =
882
+ | { word: { capitalize: boolean; include_number: boolean } }
883
+ | { subaddress: { type: AppendType; email: string } }
884
+ | { catchall: { type: AppendType; domain: string } }
885
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
886
+
887
+ /**
888
+ * Configures the email forwarding service to use.
889
+ * For instructions on how to configure each service, see the documentation:
890
+ * <https://bitwarden.com/help/generator/#username-types>
891
+ */
892
+ export type ForwarderServiceType =
893
+ | { addyIo: { api_token: string; domain: string; base_url: string } }
894
+ | { duckDuckGo: { token: string } }
895
+ | { firefox: { api_token: string } }
896
+ | { fastmail: { api_token: string } }
897
+ | { forwardEmail: { api_token: string; domain: string } }
898
+ | { simpleLogin: { api_key: string; base_url: string } };
899
+
900
+ export type AppendType = "random" | { websiteName: { website: string } };
901
+
902
+ export interface UsernameError extends Error {
903
+ name: "UsernameError";
904
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
905
+ }
906
+
907
+ export function isUsernameError(error: any): error is UsernameError;
908
+
909
+ /**
910
+ * Password generator request options.
911
+ */
912
+ export interface PasswordGeneratorRequest {
913
+ /**
914
+ * Include lowercase characters (a-z).
915
+ */
916
+ lowercase: boolean;
917
+ /**
918
+ * Include uppercase characters (A-Z).
919
+ */
920
+ uppercase: boolean;
921
+ /**
922
+ * Include numbers (0-9).
923
+ */
924
+ numbers: boolean;
925
+ /**
926
+ * Include special characters: ! @ # $ % ^ & *
927
+ */
928
+ special: boolean;
929
+ /**
930
+ * The length of the generated password.
931
+ * Note that the password length must be greater than the sum of all the minimums.
932
+ */
933
+ length: number;
934
+ /**
935
+ * When set to true, the generated password will not contain ambiguous characters.
936
+ * The ambiguous characters are: I, O, l, 0, 1
937
+ */
938
+ avoidAmbiguous: boolean;
939
+ /**
940
+ * The minimum number of lowercase characters in the generated password.
941
+ * When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
942
+ */
943
+ minLowercase: number | undefined;
944
+ /**
945
+ * The minimum number of uppercase characters in the generated password.
946
+ * When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
947
+ */
948
+ minUppercase: number | undefined;
949
+ /**
950
+ * The minimum number of numbers in the generated password.
951
+ * When set, the value must be between 1 and 9. This value is ignored if numbers is false.
952
+ */
953
+ minNumber: number | undefined;
954
+ /**
955
+ * The minimum number of special characters in the generated password.
956
+ * When set, the value must be between 1 and 9. This value is ignored if special is false.
957
+ */
958
+ minSpecial: number | undefined;
959
+ }
960
+
961
+ export interface PasswordError extends Error {
962
+ name: "PasswordError";
963
+ variant: "NoCharacterSetEnabled" | "InvalidLength";
964
+ }
965
+
966
+ export function isPasswordError(error: any): error is PasswordError;
967
+
968
+ /**
969
+ * Passphrase generator request options.
970
+ */
971
+ export interface PassphraseGeneratorRequest {
972
+ /**
973
+ * Number of words in the generated passphrase.
974
+ * This value must be between 3 and 20.
975
+ */
976
+ numWords: number;
977
+ /**
978
+ * Character separator between words in the generated passphrase. The value cannot be empty.
979
+ */
980
+ wordSeparator: string;
981
+ /**
982
+ * When set to true, capitalize the first letter of each word in the generated passphrase.
983
+ */
984
+ capitalize: boolean;
985
+ /**
986
+ * When set to true, include a number at the end of one of the words in the generated
987
+ * passphrase.
988
+ */
989
+ includeNumber: boolean;
990
+ }
991
+
992
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
993
+
994
+ export interface DiscoverResponse {
995
+ version: string;
996
+ }
997
+
998
+ export type Endpoint =
999
+ | { Web: { id: number } }
1000
+ | "BrowserForeground"
1001
+ | "BrowserBackground"
1002
+ | "DesktopRenderer"
1003
+ | "DesktopMain";
1004
+
1005
+ export interface IpcCommunicationBackendSender {
1006
+ send(message: OutgoingMessage): Promise<void>;
1007
+ }
1008
+
1009
+ export interface IpcSessionRepository {
1010
+ get(endpoint: Endpoint): Promise<any | undefined>;
1011
+ save(endpoint: Endpoint, session: any): Promise<void>;
1012
+ remove(endpoint: Endpoint): Promise<void>;
1013
+ }
1014
+
1015
+ export interface ChannelError extends Error {
1016
+ name: "ChannelError";
1017
+ }
1018
+
1019
+ export function isChannelError(error: any): error is ChannelError;
1020
+
1021
+ export interface DeserializeError extends Error {
1022
+ name: "DeserializeError";
1023
+ }
1024
+
1025
+ export function isDeserializeError(error: any): error is DeserializeError;
1026
+
1027
+ export interface RequestError extends Error {
1028
+ name: "RequestError";
1029
+ variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
1030
+ }
1031
+
1032
+ export function isRequestError(error: any): error is RequestError;
1033
+
1034
+ export interface TypedReceiveError extends Error {
1035
+ name: "TypedReceiveError";
1036
+ variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
1037
+ }
1038
+
1039
+ export function isTypedReceiveError(error: any): error is TypedReceiveError;
1040
+
1041
+ export interface ReceiveError extends Error {
1042
+ name: "ReceiveError";
1043
+ variant: "Channel" | "Timeout" | "Cancelled";
1044
+ }
1045
+
1046
+ export function isReceiveError(error: any): error is ReceiveError;
1047
+
1048
+ export interface SubscribeError extends Error {
1049
+ name: "SubscribeError";
1050
+ variant: "NotStarted";
206
1051
  }
207
1052
 
1053
+ export function isSubscribeError(error: any): error is SubscribeError;
1054
+
208
1055
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
209
1056
 
1057
+ export interface SshKeyExportError extends Error {
1058
+ name: "SshKeyExportError";
1059
+ variant: "KeyConversion";
1060
+ }
1061
+
1062
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1063
+
1064
+ export interface SshKeyImportError extends Error {
1065
+ name: "SshKeyImportError";
1066
+ variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
1067
+ }
1068
+
1069
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
1070
+
210
1071
  export interface KeyGenerationError extends Error {
211
1072
  name: "KeyGenerationError";
212
- variant: "KeyGenerationError" | "KeyConversionError";
1073
+ variant: "KeyGeneration" | "KeyConversion";
213
1074
  }
214
1075
 
215
1076
  export function isKeyGenerationError(error: any): error is KeyGenerationError;
216
1077
 
217
- export interface Folder {
218
- id: Uuid | undefined;
219
- name: EncString;
220
- revisionDate: DateTime<Utc>;
1078
+ export interface DatabaseError extends Error {
1079
+ name: "DatabaseError";
1080
+ variant: "UnsupportedConfiguration" | "ThreadBoundRunner" | "Serialization" | "JS" | "Internal";
221
1081
  }
222
1082
 
223
- export interface FolderView {
224
- id: Uuid | undefined;
225
- name: string;
226
- revisionDate: DateTime<Utc>;
227
- }
1083
+ export function isDatabaseError(error: any): error is DatabaseError;
228
1084
 
229
- export interface TestError extends Error {
230
- name: "TestError";
1085
+ export interface StateRegistryError extends Error {
1086
+ name: "StateRegistryError";
1087
+ variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
231
1088
  }
232
1089
 
233
- export function isTestError(error: any): error is TestError;
1090
+ export function isStateRegistryError(error: any): error is StateRegistryError;
234
1091
 
235
- export type Uuid = string;
1092
+ export interface CallError extends Error {
1093
+ name: "CallError";
1094
+ }
236
1095
 
237
- /**
238
- * RFC3339 compliant date-time string.
239
- * @typeParam T - Not used in JavaScript.
240
- */
241
- export type DateTime<T = unknown> = string;
1096
+ export function isCallError(error: any): error is CallError;
242
1097
 
243
1098
  /**
244
- * UTC date-time string. Not used in JavaScript.
1099
+ * NewType wrapper for `CipherId`
245
1100
  */
246
- export type Utc = unknown;
1101
+ export type CipherId = Tagged<Uuid, "CipherId">;
1102
+
1103
+ export interface EncryptionContext {
1104
+ /**
1105
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1106
+ * Organization-owned ciphers
1107
+ */
1108
+ encryptedFor: UserId;
1109
+ cipher: Cipher;
1110
+ }
1111
+
1112
+ export interface Cipher {
1113
+ id: CipherId | undefined;
1114
+ organizationId: OrganizationId | undefined;
1115
+ folderId: FolderId | undefined;
1116
+ collectionIds: CollectionId[];
1117
+ /**
1118
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1119
+ * Cipher.
1120
+ */
1121
+ key: EncString | undefined;
1122
+ name: EncString;
1123
+ notes: EncString | undefined;
1124
+ type: CipherType;
1125
+ login: Login | undefined;
1126
+ identity: Identity | undefined;
1127
+ card: Card | undefined;
1128
+ secureNote: SecureNote | undefined;
1129
+ sshKey: SshKey | undefined;
1130
+ favorite: boolean;
1131
+ reprompt: CipherRepromptType;
1132
+ organizationUseTotp: boolean;
1133
+ edit: boolean;
1134
+ permissions: CipherPermissions | undefined;
1135
+ viewPassword: boolean;
1136
+ localData: LocalData | undefined;
1137
+ attachments: Attachment[] | undefined;
1138
+ fields: Field[] | undefined;
1139
+ passwordHistory: PasswordHistory[] | undefined;
1140
+ creationDate: DateTime<Utc>;
1141
+ deletedDate: DateTime<Utc> | undefined;
1142
+ revisionDate: DateTime<Utc>;
1143
+ archivedDate: DateTime<Utc> | undefined;
1144
+ data: string | undefined;
1145
+ }
1146
+
1147
+ export interface CipherView {
1148
+ id: CipherId | undefined;
1149
+ organizationId: OrganizationId | undefined;
1150
+ folderId: FolderId | undefined;
1151
+ collectionIds: CollectionId[];
1152
+ /**
1153
+ * Temporary, required to support re-encrypting existing items.
1154
+ */
1155
+ key: EncString | undefined;
1156
+ name: string;
1157
+ notes: string | undefined;
1158
+ type: CipherType;
1159
+ login: LoginView | undefined;
1160
+ identity: IdentityView | undefined;
1161
+ card: CardView | undefined;
1162
+ secureNote: SecureNoteView | undefined;
1163
+ sshKey: SshKeyView | undefined;
1164
+ favorite: boolean;
1165
+ reprompt: CipherRepromptType;
1166
+ organizationUseTotp: boolean;
1167
+ edit: boolean;
1168
+ permissions: CipherPermissions | undefined;
1169
+ viewPassword: boolean;
1170
+ localData: LocalDataView | undefined;
1171
+ attachments: AttachmentView[] | undefined;
1172
+ fields: FieldView[] | undefined;
1173
+ passwordHistory: PasswordHistoryView[] | undefined;
1174
+ creationDate: DateTime<Utc>;
1175
+ deletedDate: DateTime<Utc> | undefined;
1176
+ revisionDate: DateTime<Utc>;
1177
+ archivedDate: DateTime<Utc> | undefined;
1178
+ }
1179
+
1180
+ export type CipherListViewType =
1181
+ | { login: LoginListView }
1182
+ | "secureNote"
1183
+ | { card: CardListView }
1184
+ | "identity"
1185
+ | "sshKey";
247
1186
 
248
1187
  /**
249
- * An integer that is known not to equal zero.
1188
+ * Available fields on a cipher and can be copied from a the list view in the UI.
250
1189
  */
251
- export type NonZeroU32 = number;
1190
+ export type CopyableCipherFields =
1191
+ | "LoginUsername"
1192
+ | "LoginPassword"
1193
+ | "LoginTotp"
1194
+ | "CardNumber"
1195
+ | "CardSecurityCode"
1196
+ | "IdentityUsername"
1197
+ | "IdentityEmail"
1198
+ | "IdentityPhone"
1199
+ | "IdentityAddress"
1200
+ | "SshKey"
1201
+ | "SecureNotes";
252
1202
 
253
- export class BitwardenClient {
254
- free(): void;
255
- constructor(settings?: ClientSettings, log_level?: LogLevel);
1203
+ export interface CipherListView {
1204
+ id: CipherId | undefined;
1205
+ organizationId: OrganizationId | undefined;
1206
+ folderId: FolderId | undefined;
1207
+ collectionIds: CollectionId[];
256
1208
  /**
257
- * Test method, echoes back the input
1209
+ * Temporary, required to support calculating TOTP from CipherListView.
258
1210
  */
259
- echo(msg: string): string;
260
- version(): string;
261
- throw(msg: string): Promise<void>;
1211
+ key: EncString | undefined;
1212
+ name: string;
1213
+ subtitle: string;
1214
+ type: CipherListViewType;
1215
+ favorite: boolean;
1216
+ reprompt: CipherRepromptType;
1217
+ organizationUseTotp: boolean;
1218
+ edit: boolean;
1219
+ permissions: CipherPermissions | undefined;
1220
+ viewPassword: boolean;
262
1221
  /**
263
- * Test method, calls http endpoint
1222
+ * The number of attachments
264
1223
  */
265
- http_get(url: string): Promise<string>;
266
- crypto(): ClientCrypto;
267
- vault(): ClientVault;
268
- }
269
- export class ClientCrypto {
270
- private constructor();
271
- free(): void;
1224
+ attachments: number;
272
1225
  /**
273
- * Initialization method for the user crypto. Needs to be called before any other crypto
274
- * operations.
1226
+ * Indicates if the cipher has old attachments that need to be re-uploaded
275
1227
  */
276
- initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
1228
+ hasOldAttachments: boolean;
1229
+ creationDate: DateTime<Utc>;
1230
+ deletedDate: DateTime<Utc> | undefined;
1231
+ revisionDate: DateTime<Utc>;
1232
+ archivedDate: DateTime<Utc> | undefined;
277
1233
  /**
278
- * Initialization method for the organization crypto. Needs to be called after
279
- * `initialize_user_crypto` but before any other crypto operations.
1234
+ * Hints for the presentation layer for which fields can be copied.
280
1235
  */
281
- initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
1236
+ copyableFields: CopyableCipherFields[];
1237
+ localData: LocalDataView | undefined;
1238
+ }
1239
+
1240
+ /**
1241
+ * Represents the result of decrypting a list of ciphers.
1242
+ *
1243
+ * This struct contains two vectors: `successes` and `failures`.
1244
+ * `successes` contains the decrypted `CipherListView` objects,
1245
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1246
+ */
1247
+ export interface DecryptCipherListResult {
282
1248
  /**
283
- * Generates a new key pair and encrypts the private key with the provided user key.
284
- * Crypto initialization not required.
1249
+ * The decrypted `CipherListView` objects.
285
1250
  */
286
- make_key_pair(user_key: string): MakeKeyPairResponse;
1251
+ successes: CipherListView[];
287
1252
  /**
288
- * Verifies a user's asymmetric keys by decrypting the private key with the provided user
289
- * key. Returns if the private key is decryptable and if it is a valid matching key.
290
- * Crypto initialization not required.
1253
+ * The original `Cipher` objects that failed to decrypt.
291
1254
  */
292
- verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
1255
+ failures: Cipher[];
293
1256
  }
294
- export class ClientFolders {
295
- private constructor();
296
- free(): void;
1257
+
1258
+ /**
1259
+ * Request to add a cipher.
1260
+ */
1261
+ export interface CipherCreateRequest {
1262
+ organizationId: OrganizationId | undefined;
1263
+ folderId: FolderId | undefined;
1264
+ name: string;
1265
+ notes: string | undefined;
1266
+ favorite: boolean;
1267
+ reprompt: CipherRepromptType;
1268
+ type: CipherViewType;
1269
+ fields: FieldView[];
1270
+ }
1271
+
1272
+ /**
1273
+ * Request to edit a cipher.
1274
+ */
1275
+ export interface CipherEditRequest {
1276
+ id: CipherId;
1277
+ organizationId: OrganizationId | undefined;
1278
+ folderId: FolderId | undefined;
1279
+ favorite: boolean;
1280
+ reprompt: CipherRepromptType;
1281
+ name: string;
1282
+ notes: string | undefined;
1283
+ fields: FieldView[];
1284
+ type: CipherViewType;
1285
+ revisionDate: DateTime<Utc>;
1286
+ archivedDate: DateTime<Utc> | undefined;
1287
+ attachments: AttachmentView[];
1288
+ key: EncString | undefined;
1289
+ }
1290
+
1291
+ export interface Field {
1292
+ name: EncString | undefined;
1293
+ value: EncString | undefined;
1294
+ type: FieldType;
1295
+ linkedId: LinkedIdType | undefined;
1296
+ }
1297
+
1298
+ export interface FieldView {
1299
+ name: string | undefined;
1300
+ value: string | undefined;
1301
+ type: FieldType;
1302
+ linkedId: LinkedIdType | undefined;
1303
+ }
1304
+
1305
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
1306
+
1307
+ export interface LoginUri {
1308
+ uri: EncString | undefined;
1309
+ match: UriMatchType | undefined;
1310
+ uriChecksum: EncString | undefined;
1311
+ }
1312
+
1313
+ export interface LoginUriView {
1314
+ uri: string | undefined;
1315
+ match: UriMatchType | undefined;
1316
+ uriChecksum: string | undefined;
1317
+ }
1318
+
1319
+ export interface Fido2Credential {
1320
+ credentialId: EncString;
1321
+ keyType: EncString;
1322
+ keyAlgorithm: EncString;
1323
+ keyCurve: EncString;
1324
+ keyValue: EncString;
1325
+ rpId: EncString;
1326
+ userHandle: EncString | undefined;
1327
+ userName: EncString | undefined;
1328
+ counter: EncString;
1329
+ rpName: EncString | undefined;
1330
+ userDisplayName: EncString | undefined;
1331
+ discoverable: EncString;
1332
+ creationDate: DateTime<Utc>;
1333
+ }
1334
+
1335
+ export interface Fido2CredentialListView {
1336
+ credentialId: string;
1337
+ rpId: string;
1338
+ userHandle: string | undefined;
1339
+ userName: string | undefined;
1340
+ userDisplayName: string | undefined;
1341
+ counter: string;
1342
+ }
1343
+
1344
+ export interface Fido2CredentialView {
1345
+ credentialId: string;
1346
+ keyType: string;
1347
+ keyAlgorithm: string;
1348
+ keyCurve: string;
1349
+ keyValue: EncString;
1350
+ rpId: string;
1351
+ userHandle: string | undefined;
1352
+ userName: string | undefined;
1353
+ counter: string;
1354
+ rpName: string | undefined;
1355
+ userDisplayName: string | undefined;
1356
+ discoverable: string;
1357
+ creationDate: DateTime<Utc>;
1358
+ }
1359
+
1360
+ export interface Fido2CredentialFullView {
1361
+ credentialId: string;
1362
+ keyType: string;
1363
+ keyAlgorithm: string;
1364
+ keyCurve: string;
1365
+ keyValue: string;
1366
+ rpId: string;
1367
+ userHandle: string | undefined;
1368
+ userName: string | undefined;
1369
+ counter: string;
1370
+ rpName: string | undefined;
1371
+ userDisplayName: string | undefined;
1372
+ discoverable: string;
1373
+ creationDate: DateTime<Utc>;
1374
+ }
1375
+
1376
+ export interface Fido2CredentialNewView {
1377
+ credentialId: string;
1378
+ keyType: string;
1379
+ keyAlgorithm: string;
1380
+ keyCurve: string;
1381
+ rpId: string;
1382
+ userHandle: string | undefined;
1383
+ userName: string | undefined;
1384
+ counter: string;
1385
+ rpName: string | undefined;
1386
+ userDisplayName: string | undefined;
1387
+ creationDate: DateTime<Utc>;
1388
+ }
1389
+
1390
+ export interface Login {
1391
+ username: EncString | undefined;
1392
+ password: EncString | undefined;
1393
+ passwordRevisionDate: DateTime<Utc> | undefined;
1394
+ uris: LoginUri[] | undefined;
1395
+ totp: EncString | undefined;
1396
+ autofillOnPageLoad: boolean | undefined;
1397
+ fido2Credentials: Fido2Credential[] | undefined;
1398
+ }
1399
+
1400
+ export interface LoginView {
1401
+ username: string | undefined;
1402
+ password: string | undefined;
1403
+ passwordRevisionDate: DateTime<Utc> | undefined;
1404
+ uris: LoginUriView[] | undefined;
1405
+ totp: string | undefined;
1406
+ autofillOnPageLoad: boolean | undefined;
1407
+ fido2Credentials: Fido2Credential[] | undefined;
1408
+ }
1409
+
1410
+ export interface LoginListView {
1411
+ fido2Credentials: Fido2CredentialListView[] | undefined;
1412
+ hasFido2: boolean;
1413
+ username: string | undefined;
297
1414
  /**
298
- * Decrypt folder
1415
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
299
1416
  */
300
- decrypt(folder: Folder): FolderView;
1417
+ totp: EncString | undefined;
1418
+ uris: LoginUriView[] | undefined;
301
1419
  }
302
- export class ClientVault {
303
- private constructor();
304
- free(): void;
305
- folders(): ClientFolders;
1420
+
1421
+ export interface SecureNote {
1422
+ type: SecureNoteType;
1423
+ }
1424
+
1425
+ export interface SecureNoteView {
1426
+ type: SecureNoteType;
1427
+ }
1428
+
1429
+ /**
1430
+ * Result of checking password exposure via HIBP API.
1431
+ */
1432
+ export type ExposedPasswordResult =
1433
+ | { type: "NotChecked" }
1434
+ | { type: "Found"; value: number }
1435
+ | { type: "Error"; value: string };
1436
+
1437
+ /**
1438
+ * Login cipher data needed for risk evaluation.
1439
+ */
1440
+ export interface CipherLoginDetails {
1441
+ /**
1442
+ * Cipher ID to identify which cipher in results.
1443
+ */
1444
+ id: CipherId;
1445
+ /**
1446
+ * The decrypted password to evaluate.
1447
+ */
1448
+ password: string;
1449
+ /**
1450
+ * Username or email (login ciphers only have one field).
1451
+ */
1452
+ username: string | undefined;
1453
+ }
1454
+
1455
+ /**
1456
+ * Password reuse map wrapper for WASM compatibility.
1457
+ */
1458
+ export type PasswordReuseMap = Record<string, number>;
1459
+
1460
+ /**
1461
+ * Options for configuring risk computation.
1462
+ */
1463
+ export interface CipherRiskOptions {
1464
+ /**
1465
+ * Pre-computed password reuse map (password → count).
1466
+ * If provided, enables reuse detection across ciphers.
1467
+ */
1468
+ passwordMap?: PasswordReuseMap | undefined;
1469
+ /**
1470
+ * Whether to check passwords against Have I Been Pwned API.
1471
+ * When true, makes network requests to check for exposed passwords.
1472
+ */
1473
+ checkExposed?: boolean;
1474
+ /**
1475
+ * Optional HIBP API base URL override. When None, uses the production HIBP URL.
1476
+ * Can be used for testing or alternative password breach checking services.
1477
+ */
1478
+ hibpBaseUrl?: string | undefined;
1479
+ }
1480
+
1481
+ /**
1482
+ * Risk evaluation result for a single cipher.
1483
+ */
1484
+ export interface CipherRiskResult {
1485
+ /**
1486
+ * Cipher ID matching the input CipherLoginDetails.
1487
+ */
1488
+ id: CipherId;
1489
+ /**
1490
+ * Password strength score from 0 (weakest) to 4 (strongest).
1491
+ * Calculated using zxcvbn with cipher-specific context.
1492
+ */
1493
+ password_strength: number;
1494
+ /**
1495
+ * Result of checking password exposure via HIBP API.
1496
+ * - `NotChecked`: check_exposed was false, or password was empty
1497
+ * - `Found(n)`: Successfully checked, found in n breaches
1498
+ * - `Error(msg)`: HIBP API request failed for this cipher with the given error message
1499
+ */
1500
+ exposed_result: ExposedPasswordResult;
1501
+ /**
1502
+ * Number of times this password appears in the provided password_map.
1503
+ * None if not found or if no password_map was provided.
1504
+ */
1505
+ reuse_count: number | undefined;
1506
+ }
1507
+
1508
+ /**
1509
+ * Request to add or edit a folder.
1510
+ */
1511
+ export interface FolderAddEditRequest {
1512
+ /**
1513
+ * The new name of the folder.
1514
+ */
1515
+ name: string;
1516
+ }
1517
+
1518
+ /**
1519
+ * NewType wrapper for `FolderId`
1520
+ */
1521
+ export type FolderId = Tagged<Uuid, "FolderId">;
1522
+
1523
+ export interface Folder {
1524
+ id: FolderId | undefined;
1525
+ name: EncString;
1526
+ revisionDate: DateTime<Utc>;
1527
+ }
1528
+
1529
+ export interface FolderView {
1530
+ id: FolderId | undefined;
1531
+ name: string;
1532
+ revisionDate: DateTime<Utc>;
1533
+ }
1534
+
1535
+ export interface AncestorMap {
1536
+ ancestors: Map<CollectionId, string>;
1537
+ }
1538
+
1539
+ export interface DecryptError extends Error {
1540
+ name: "DecryptError";
1541
+ variant: "Crypto";
1542
+ }
1543
+
1544
+ export function isDecryptError(error: any): error is DecryptError;
1545
+
1546
+ export interface EncryptError extends Error {
1547
+ name: "EncryptError";
1548
+ variant: "Crypto" | "MissingUserId";
1549
+ }
1550
+
1551
+ export function isEncryptError(error: any): error is EncryptError;
1552
+
1553
+ export interface TotpResponse {
1554
+ /**
1555
+ * Generated TOTP code
1556
+ */
1557
+ code: string;
1558
+ /**
1559
+ * Time period
1560
+ */
1561
+ period: number;
1562
+ }
1563
+
1564
+ export interface TotpError extends Error {
1565
+ name: "TotpError";
1566
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1567
+ }
1568
+
1569
+ export function isTotpError(error: any): error is TotpError;
1570
+
1571
+ export interface PasswordHistoryView {
1572
+ password: string;
1573
+ lastUsedDate: DateTime<Utc>;
1574
+ }
1575
+
1576
+ export interface PasswordHistory {
1577
+ password: EncString;
1578
+ lastUsedDate: DateTime<Utc>;
1579
+ }
1580
+
1581
+ export interface GetFolderError extends Error {
1582
+ name: "GetFolderError";
1583
+ variant: "ItemNotFound" | "Crypto" | "Repository";
1584
+ }
1585
+
1586
+ export function isGetFolderError(error: any): error is GetFolderError;
1587
+
1588
+ export interface EditFolderError extends Error {
1589
+ name: "EditFolderError";
1590
+ variant:
1591
+ | "ItemNotFound"
1592
+ | "Crypto"
1593
+ | "Api"
1594
+ | "VaultParse"
1595
+ | "MissingField"
1596
+ | "Repository"
1597
+ | "Uuid";
1598
+ }
1599
+
1600
+ export function isEditFolderError(error: any): error is EditFolderError;
1601
+
1602
+ export interface CreateFolderError extends Error {
1603
+ name: "CreateFolderError";
1604
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
1605
+ }
1606
+
1607
+ export function isCreateFolderError(error: any): error is CreateFolderError;
1608
+
1609
+ export interface CipherRiskError extends Error {
1610
+ name: "CipherRiskError";
1611
+ variant: "Reqwest";
1612
+ }
1613
+
1614
+ export function isCipherRiskError(error: any): error is CipherRiskError;
1615
+
1616
+ export interface SshKeyView {
1617
+ /**
1618
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1619
+ */
1620
+ privateKey: string;
1621
+ /**
1622
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1623
+ */
1624
+ publicKey: string;
1625
+ /**
1626
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1627
+ */
1628
+ fingerprint: string;
1629
+ }
1630
+
1631
+ export interface SshKey {
1632
+ /**
1633
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1634
+ */
1635
+ privateKey: EncString;
1636
+ /**
1637
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1638
+ */
1639
+ publicKey: EncString;
1640
+ /**
1641
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1642
+ */
1643
+ fingerprint: EncString;
1644
+ }
1645
+
1646
+ export interface LocalDataView {
1647
+ lastUsedDate: DateTime<Utc> | undefined;
1648
+ lastLaunched: DateTime<Utc> | undefined;
1649
+ }
1650
+
1651
+ export interface LocalData {
1652
+ lastUsedDate: DateTime<Utc> | undefined;
1653
+ lastLaunched: DateTime<Utc> | undefined;
1654
+ }
1655
+
1656
+ export interface IdentityView {
1657
+ title: string | undefined;
1658
+ firstName: string | undefined;
1659
+ middleName: string | undefined;
1660
+ lastName: string | undefined;
1661
+ address1: string | undefined;
1662
+ address2: string | undefined;
1663
+ address3: string | undefined;
1664
+ city: string | undefined;
1665
+ state: string | undefined;
1666
+ postalCode: string | undefined;
1667
+ country: string | undefined;
1668
+ company: string | undefined;
1669
+ email: string | undefined;
1670
+ phone: string | undefined;
1671
+ ssn: string | undefined;
1672
+ username: string | undefined;
1673
+ passportNumber: string | undefined;
1674
+ licenseNumber: string | undefined;
1675
+ }
1676
+
1677
+ export interface Identity {
1678
+ title: EncString | undefined;
1679
+ firstName: EncString | undefined;
1680
+ middleName: EncString | undefined;
1681
+ lastName: EncString | undefined;
1682
+ address1: EncString | undefined;
1683
+ address2: EncString | undefined;
1684
+ address3: EncString | undefined;
1685
+ city: EncString | undefined;
1686
+ state: EncString | undefined;
1687
+ postalCode: EncString | undefined;
1688
+ country: EncString | undefined;
1689
+ company: EncString | undefined;
1690
+ email: EncString | undefined;
1691
+ phone: EncString | undefined;
1692
+ ssn: EncString | undefined;
1693
+ username: EncString | undefined;
1694
+ passportNumber: EncString | undefined;
1695
+ licenseNumber: EncString | undefined;
1696
+ }
1697
+
1698
+ /**
1699
+ * Represents the inner data of a cipher view.
1700
+ */
1701
+ export type CipherViewType =
1702
+ | { login: LoginView }
1703
+ | { card: CardView }
1704
+ | { identity: IdentityView }
1705
+ | { secureNote: SecureNoteView }
1706
+ | { sshKey: SshKeyView };
1707
+
1708
+ export interface CipherPermissions {
1709
+ delete: boolean;
1710
+ restore: boolean;
1711
+ }
1712
+
1713
+ export interface GetCipherError extends Error {
1714
+ name: "GetCipherError";
1715
+ variant: "ItemNotFound" | "Crypto" | "RepositoryError";
1716
+ }
1717
+
1718
+ export function isGetCipherError(error: any): error is GetCipherError;
1719
+
1720
+ export interface EditCipherError extends Error {
1721
+ name: "EditCipherError";
1722
+ variant:
1723
+ | "ItemNotFound"
1724
+ | "Crypto"
1725
+ | "Api"
1726
+ | "VaultParse"
1727
+ | "MissingField"
1728
+ | "NotAuthenticated"
1729
+ | "Repository"
1730
+ | "Uuid";
1731
+ }
1732
+
1733
+ export function isEditCipherError(error: any): error is EditCipherError;
1734
+
1735
+ export interface CreateCipherError extends Error {
1736
+ name: "CreateCipherError";
1737
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1738
+ }
1739
+
1740
+ export function isCreateCipherError(error: any): error is CreateCipherError;
1741
+
1742
+ export interface CipherError extends Error {
1743
+ name: "CipherError";
1744
+ variant:
1745
+ | "MissingField"
1746
+ | "Crypto"
1747
+ | "Decrypt"
1748
+ | "Encrypt"
1749
+ | "AttachmentsWithoutKeys"
1750
+ | "OrganizationAlreadySet"
1751
+ | "PutShare"
1752
+ | "PutShareMany"
1753
+ | "Repository"
1754
+ | "Chrono"
1755
+ | "SerdeJson";
1756
+ }
1757
+
1758
+ export function isCipherError(error: any): error is CipherError;
1759
+
1760
+ /**
1761
+ * Minimal CardView only including the needed details for list views
1762
+ */
1763
+ export interface CardListView {
1764
+ /**
1765
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1766
+ */
1767
+ brand: string | undefined;
1768
+ }
1769
+
1770
+ export interface CardView {
1771
+ cardholderName: string | undefined;
1772
+ expMonth: string | undefined;
1773
+ expYear: string | undefined;
1774
+ code: string | undefined;
1775
+ brand: string | undefined;
1776
+ number: string | undefined;
1777
+ }
1778
+
1779
+ export interface Card {
1780
+ cardholderName: EncString | undefined;
1781
+ expMonth: EncString | undefined;
1782
+ expYear: EncString | undefined;
1783
+ code: EncString | undefined;
1784
+ brand: EncString | undefined;
1785
+ number: EncString | undefined;
1786
+ }
1787
+
1788
+ export interface DecryptFileError extends Error {
1789
+ name: "DecryptFileError";
1790
+ variant: "Decrypt" | "Io";
1791
+ }
1792
+
1793
+ export function isDecryptFileError(error: any): error is DecryptFileError;
1794
+
1795
+ export interface EncryptFileError extends Error {
1796
+ name: "EncryptFileError";
1797
+ variant: "Encrypt" | "Io";
1798
+ }
1799
+
1800
+ export function isEncryptFileError(error: any): error is EncryptFileError;
1801
+
1802
+ export interface AttachmentView {
1803
+ id: string | undefined;
1804
+ url: string | undefined;
1805
+ size: string | undefined;
1806
+ sizeName: string | undefined;
1807
+ fileName: string | undefined;
1808
+ key: EncString | undefined;
1809
+ /**
1810
+ * The decrypted attachmentkey in base64 format.
1811
+ *
1812
+ * **TEMPORARY FIELD**: This field is a temporary workaround to provide
1813
+ * decrypted attachment keys to the TypeScript client during the migration
1814
+ * process. It will be removed once the encryption/decryption logic is
1815
+ * fully migrated to the SDK.
1816
+ *
1817
+ * **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
1818
+ *
1819
+ * Do not rely on this field for long-term use.
1820
+ */
1821
+ decryptedKey: string | undefined;
1822
+ }
1823
+
1824
+ export interface Attachment {
1825
+ id: string | undefined;
1826
+ url: string | undefined;
1827
+ size: string | undefined;
1828
+ /**
1829
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1830
+ */
1831
+ sizeName: string | undefined;
1832
+ fileName: EncString | undefined;
1833
+ key: EncString | undefined;
1834
+ }
1835
+
1836
+ export class AttachmentsClient {
1837
+ private constructor();
1838
+ free(): void;
1839
+ [Symbol.dispose](): void;
1840
+ decrypt_buffer(
1841
+ cipher: Cipher,
1842
+ attachment: AttachmentView,
1843
+ encrypted_buffer: Uint8Array,
1844
+ ): Uint8Array;
1845
+ }
1846
+ /**
1847
+ * Subclient containing auth functionality.
1848
+ */
1849
+ export class AuthClient {
1850
+ private constructor();
1851
+ free(): void;
1852
+ [Symbol.dispose](): void;
1853
+ /**
1854
+ * Client for identity functionality
1855
+ */
1856
+ identity(): IdentityClient;
1857
+ /**
1858
+ * Client for send access functionality
1859
+ */
1860
+ send_access(): SendAccessClient;
1861
+ /**
1862
+ * Client for initializing user account cryptography and unlock methods after JIT provisioning
1863
+ */
1864
+ registration(): RegistrationClient;
1865
+ }
1866
+ /**
1867
+ * Client for evaluating credential risk for login ciphers.
1868
+ */
1869
+ export class CipherRiskClient {
1870
+ private constructor();
1871
+ free(): void;
1872
+ [Symbol.dispose](): void;
1873
+ /**
1874
+ * Build password reuse map for a list of login ciphers.
1875
+ *
1876
+ * Returns a map where keys are passwords and values are the number of times
1877
+ * each password appears in the provided list. This map can be passed to `compute_risk()`
1878
+ * to enable password reuse detection.
1879
+ */
1880
+ password_reuse_map(login_details: CipherLoginDetails[]): PasswordReuseMap;
1881
+ /**
1882
+ * Evaluate security risks for multiple login ciphers concurrently.
1883
+ *
1884
+ * For each cipher:
1885
+ * 1. Calculates password strength (0-4) using zxcvbn with cipher-specific context
1886
+ * 2. Optionally checks if the password has been exposed via Have I Been Pwned API
1887
+ * 3. Counts how many times the password is reused in the provided `password_map`
1888
+ *
1889
+ * Returns a vector of `CipherRisk` results, one for each input cipher.
1890
+ *
1891
+ * ## HIBP Check Results (`exposed_result` field)
1892
+ *
1893
+ * The `exposed_result` field uses the `ExposedPasswordResult` enum with three possible states:
1894
+ * - `NotChecked`: Password exposure check was not performed because:
1895
+ * - `check_exposed` option was `false`, or
1896
+ * - Password was empty
1897
+ * - `Found(n)`: Successfully checked via HIBP API, password appears in `n` data breaches
1898
+ * - `Error(msg)`: HIBP API request failed with error message `msg`
1899
+ *
1900
+ * # Errors
1901
+ *
1902
+ * This method only returns `Err` for internal logic failures. HIBP API errors are
1903
+ * captured per-cipher in the `exposed_result` field as `ExposedPasswordResult::Error(msg)`.
1904
+ */
1905
+ compute_risk(
1906
+ login_details: CipherLoginDetails[],
1907
+ options: CipherRiskOptions,
1908
+ ): Promise<CipherRiskResult[]>;
1909
+ }
1910
+ export class CiphersClient {
1911
+ private constructor();
1912
+ free(): void;
1913
+ [Symbol.dispose](): void;
1914
+ /**
1915
+ * Create a new [Cipher] and save it to the server.
1916
+ */
1917
+ create(request: CipherCreateRequest): Promise<CipherView>;
1918
+ /**
1919
+ * Edit an existing [Cipher] and save it to the server.
1920
+ */
1921
+ edit(request: CipherEditRequest): Promise<CipherView>;
1922
+ /**
1923
+ * Moves a cipher into an organization, adds it to collections, and calls the share_cipher API.
1924
+ */
1925
+ share_cipher(
1926
+ cipher_view: CipherView,
1927
+ organization_id: OrganizationId,
1928
+ collection_ids: CollectionId[],
1929
+ original_cipher?: Cipher | null,
1930
+ ): Promise<Cipher>;
1931
+ /**
1932
+ * Moves a group of ciphers into an organization, adds them to collections, and calls the
1933
+ * share_ciphers API.
1934
+ */
1935
+ share_ciphers_bulk(
1936
+ cipher_views: CipherView[],
1937
+ organization_id: OrganizationId,
1938
+ collection_ids: CollectionId[],
1939
+ ): Promise<Cipher[]>;
1940
+ encrypt(cipher_view: CipherView): EncryptionContext;
1941
+ /**
1942
+ * Encrypt a cipher with the provided key. This should only be used when rotating encryption
1943
+ * keys in the Web client.
1944
+ *
1945
+ * Until key rotation is fully implemented in the SDK, this method must be provided the new
1946
+ * symmetric key in base64 format. See PM-23084
1947
+ *
1948
+ * If the cipher has a CipherKey, it will be re-encrypted with the new key.
1949
+ * If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
1950
+ * generated using the new key. Otherwise, the cipher's data will be encrypted with the new
1951
+ * key directly.
1952
+ */
1953
+ encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): EncryptionContext;
1954
+ decrypt(cipher: Cipher): CipherView;
1955
+ decrypt_list(ciphers: Cipher[]): CipherListView[];
1956
+ /**
1957
+ * Decrypt cipher list with failures
1958
+ * Returns both successfully decrypted ciphers and any that failed to decrypt
1959
+ */
1960
+ decrypt_list_with_failures(ciphers: Cipher[]): DecryptCipherListResult;
1961
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
1962
+ /**
1963
+ * Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
1964
+ * Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
1965
+ * TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
1966
+ * encrypting the rest of the CipherView.
1967
+ * TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
1968
+ */
1969
+ set_fido2_credentials(
1970
+ cipher_view: CipherView,
1971
+ fido2_credentials: Fido2CredentialFullView[],
1972
+ ): CipherView;
1973
+ move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
1974
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
1975
+ }
1976
+ export class CollectionViewNodeItem {
1977
+ private constructor();
1978
+ free(): void;
1979
+ [Symbol.dispose](): void;
1980
+ get_item(): CollectionView;
1981
+ get_parent(): CollectionView | undefined;
1982
+ get_children(): CollectionView[];
1983
+ get_ancestors(): AncestorMap;
1984
+ }
1985
+ export class CollectionViewTree {
1986
+ private constructor();
1987
+ free(): void;
1988
+ [Symbol.dispose](): void;
1989
+ get_item_for_view(collection_view: CollectionView): CollectionViewNodeItem | undefined;
1990
+ get_root_items(): CollectionViewNodeItem[];
1991
+ get_flat_items(): CollectionViewNodeItem[];
1992
+ }
1993
+ export class CollectionsClient {
1994
+ private constructor();
1995
+ free(): void;
1996
+ [Symbol.dispose](): void;
1997
+ decrypt(collection: Collection): CollectionView;
1998
+ decrypt_list(collections: Collection[]): CollectionView[];
1999
+ /**
2000
+ *
2001
+ * Returns the vector of CollectionView objects in a tree structure based on its implemented
2002
+ * path().
2003
+ */
2004
+ get_collection_tree(collections: CollectionView[]): CollectionViewTree;
2005
+ }
2006
+ /**
2007
+ * A client for the crypto operations.
2008
+ */
2009
+ export class CryptoClient {
2010
+ private constructor();
2011
+ free(): void;
2012
+ [Symbol.dispose](): void;
2013
+ /**
2014
+ * Initialization method for the user crypto. Needs to be called before any other crypto
2015
+ * operations.
2016
+ */
2017
+ initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
2018
+ /**
2019
+ * Initialization method for the organization crypto. Needs to be called after
2020
+ * `initialize_user_crypto` but before any other crypto operations.
2021
+ */
2022
+ initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
2023
+ /**
2024
+ * Generates a new key pair and encrypts the private key with the provided user key.
2025
+ * Crypto initialization not required.
2026
+ */
2027
+ make_key_pair(user_key: B64): MakeKeyPairResponse;
2028
+ /**
2029
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
2030
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
2031
+ * Crypto initialization not required.
2032
+ */
2033
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
2034
+ /**
2035
+ * Makes a new signing key pair and signs the public key for the user
2036
+ */
2037
+ make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
2038
+ /**
2039
+ * Creates a rotated set of account keys for the current state
2040
+ */
2041
+ get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
2042
+ /**
2043
+ * Create the data necessary to update the user's kdf settings. The user's encryption key is
2044
+ * re-encrypted for the password under the new kdf settings. This returns the re-encrypted
2045
+ * user key and the new password hash but does not update sdk state.
2046
+ */
2047
+ make_update_kdf(password: string, kdf: Kdf): UpdateKdfResponse;
2048
+ /**
2049
+ * Protects the current user key with the provided PIN. The result can be stored and later
2050
+ * used to initialize another client instance by using the PIN and the PIN key with
2051
+ * `initialize_user_crypto`.
2052
+ */
2053
+ enroll_pin(pin: string): EnrollPinResponse;
2054
+ /**
2055
+ * Protects the current user key with the provided PIN. The result can be stored and later
2056
+ * used to initialize another client instance by using the PIN and the PIN key with
2057
+ * `initialize_user_crypto`. The provided pin is encrypted with the user key.
2058
+ */
2059
+ enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
2060
+ /**
2061
+ * Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
2062
+ * This is a stop-gap solution, until initialization of the SDK is used.
2063
+ */
2064
+ unseal_password_protected_key_envelope(pin: string, envelope: string): Uint8Array;
2065
+ }
2066
+ export class ExporterClient {
2067
+ private constructor();
2068
+ free(): void;
2069
+ [Symbol.dispose](): void;
2070
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
2071
+ export_organization_vault(
2072
+ collections: Collection[],
2073
+ ciphers: Cipher[],
2074
+ format: ExportFormat,
2075
+ ): string;
2076
+ /**
2077
+ * Credential Exchange Format (CXF)
2078
+ *
2079
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
2080
+ *
2081
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
2082
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
2083
+ */
2084
+ export_cxf(account: Account, ciphers: Cipher[]): string;
2085
+ /**
2086
+ * Credential Exchange Format (CXF)
2087
+ *
2088
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
2089
+ *
2090
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
2091
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
2092
+ */
2093
+ import_cxf(payload: string): Cipher[];
2094
+ }
2095
+ /**
2096
+ * Wrapper for folder specific functionality.
2097
+ */
2098
+ export class FoldersClient {
2099
+ private constructor();
2100
+ free(): void;
2101
+ [Symbol.dispose](): void;
2102
+ /**
2103
+ * Encrypt a [FolderView] to a [Folder].
2104
+ */
2105
+ encrypt(folder_view: FolderView): Folder;
2106
+ /**
2107
+ * Encrypt a [Folder] to [FolderView].
2108
+ */
2109
+ decrypt(folder: Folder): FolderView;
2110
+ /**
2111
+ * Decrypt a list of [Folder]s to a list of [FolderView]s.
2112
+ */
2113
+ decrypt_list(folders: Folder[]): FolderView[];
2114
+ /**
2115
+ * Get all folders from state and decrypt them to a list of [FolderView].
2116
+ */
2117
+ list(): Promise<FolderView[]>;
2118
+ /**
2119
+ * Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
2120
+ */
2121
+ get(folder_id: FolderId): Promise<FolderView>;
2122
+ /**
2123
+ * Create a new [Folder] and save it to the server.
2124
+ */
2125
+ create(request: FolderAddEditRequest): Promise<FolderView>;
2126
+ /**
2127
+ * Edit the [Folder] and save it to the server.
2128
+ */
2129
+ edit(folder_id: FolderId, request: FolderAddEditRequest): Promise<FolderView>;
2130
+ }
2131
+ export class GeneratorClient {
2132
+ private constructor();
2133
+ free(): void;
2134
+ [Symbol.dispose](): void;
2135
+ /**
2136
+ * Generates a random password.
2137
+ *
2138
+ * The character sets and password length can be customized using the `input` parameter.
2139
+ *
2140
+ * # Examples
2141
+ *
2142
+ * ```
2143
+ * use bitwarden_core::Client;
2144
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
2145
+ *
2146
+ * async fn test() -> Result<(), PassphraseError> {
2147
+ * let input = PasswordGeneratorRequest {
2148
+ * lowercase: true,
2149
+ * uppercase: true,
2150
+ * numbers: true,
2151
+ * length: 20,
2152
+ * ..Default::default()
2153
+ * };
2154
+ * let password = Client::new(None).generator().password(input).unwrap();
2155
+ * println!("{}", password);
2156
+ * Ok(())
2157
+ * }
2158
+ * ```
2159
+ */
2160
+ password(input: PasswordGeneratorRequest): string;
2161
+ /**
2162
+ * Generates a random passphrase.
2163
+ * A passphrase is a combination of random words separated by a character.
2164
+ * An example of passphrase is `correct horse battery staple`.
2165
+ *
2166
+ * The number of words and their case, the word separator, and the inclusion of
2167
+ * a number in the passphrase can be customized using the `input` parameter.
2168
+ *
2169
+ * # Examples
2170
+ *
2171
+ * ```
2172
+ * use bitwarden_core::Client;
2173
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
2174
+ *
2175
+ * async fn test() -> Result<(), PassphraseError> {
2176
+ * let input = PassphraseGeneratorRequest {
2177
+ * num_words: 4,
2178
+ * ..Default::default()
2179
+ * };
2180
+ * let passphrase = Client::new(None).generator().passphrase(input).unwrap();
2181
+ * println!("{}", passphrase);
2182
+ * Ok(())
2183
+ * }
2184
+ * ```
2185
+ */
2186
+ passphrase(input: PassphraseGeneratorRequest): string;
2187
+ }
2188
+ /**
2189
+ * The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
2190
+ */
2191
+ export class IdentityClient {
2192
+ private constructor();
2193
+ free(): void;
2194
+ [Symbol.dispose](): void;
2195
+ }
2196
+ export class IncomingMessage {
2197
+ free(): void;
2198
+ [Symbol.dispose](): void;
2199
+ constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
2200
+ /**
2201
+ * Try to parse the payload as JSON.
2202
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
2203
+ */
2204
+ parse_payload_as_json(): any;
2205
+ payload: Uint8Array;
2206
+ destination: Endpoint;
2207
+ source: Endpoint;
2208
+ get topic(): string | undefined;
2209
+ set topic(value: string | null | undefined);
2210
+ }
2211
+ /**
2212
+ * JavaScript wrapper around the IPC client. For more information, see the
2213
+ * [IpcClient] documentation.
2214
+ */
2215
+ export class IpcClient {
2216
+ private constructor();
2217
+ free(): void;
2218
+ [Symbol.dispose](): void;
2219
+ /**
2220
+ * Create a new `IpcClient` instance with an in-memory session repository for saving
2221
+ * sessions within the SDK.
2222
+ */
2223
+ static newWithSdkInMemorySessions(communication_provider: IpcCommunicationBackend): IpcClient;
2224
+ /**
2225
+ * Create a new `IpcClient` instance with a client-managed session repository for saving
2226
+ * sessions using State Provider.
2227
+ */
2228
+ static newWithClientManagedSessions(
2229
+ communication_provider: IpcCommunicationBackend,
2230
+ session_repository: IpcSessionRepository,
2231
+ ): IpcClient;
2232
+ start(): Promise<void>;
2233
+ isRunning(): Promise<boolean>;
2234
+ send(message: OutgoingMessage): Promise<void>;
2235
+ subscribe(): Promise<IpcClientSubscription>;
2236
+ }
2237
+ /**
2238
+ * JavaScript wrapper around the IPC client subscription. For more information, see the
2239
+ * [IpcClientSubscription](crate::IpcClientSubscription) documentation.
2240
+ */
2241
+ export class IpcClientSubscription {
2242
+ private constructor();
2243
+ free(): void;
2244
+ [Symbol.dispose](): void;
2245
+ receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
2246
+ }
2247
+ /**
2248
+ * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
2249
+ */
2250
+ export class IpcCommunicationBackend {
2251
+ free(): void;
2252
+ [Symbol.dispose](): void;
2253
+ /**
2254
+ * Creates a new instance of the JavaScript communication backend.
2255
+ */
2256
+ constructor(sender: IpcCommunicationBackendSender);
2257
+ /**
2258
+ * Used by JavaScript to provide an incoming message to the IPC framework.
2259
+ */
2260
+ receive(message: IncomingMessage): void;
2261
+ }
2262
+ export class OutgoingMessage {
2263
+ free(): void;
2264
+ [Symbol.dispose](): void;
2265
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
2266
+ /**
2267
+ * Create a new message and encode the payload as JSON.
2268
+ */
2269
+ static new_json_payload(
2270
+ payload: any,
2271
+ destination: Endpoint,
2272
+ topic?: string | null,
2273
+ ): OutgoingMessage;
2274
+ payload: Uint8Array;
2275
+ destination: Endpoint;
2276
+ get topic(): string | undefined;
2277
+ set topic(value: string | null | undefined);
2278
+ }
2279
+ /**
2280
+ * The main entry point for the Bitwarden SDK in WebAssembly environments
2281
+ */
2282
+ export class PasswordManagerClient {
2283
+ free(): void;
2284
+ [Symbol.dispose](): void;
2285
+ /**
2286
+ * Initialize a new instance of the SDK client
2287
+ */
2288
+ constructor(token_provider: any, settings?: ClientSettings | null);
2289
+ /**
2290
+ * Test method, echoes back the input
2291
+ */
2292
+ echo(msg: string): string;
2293
+ /**
2294
+ * Returns the current SDK version
2295
+ */
2296
+ version(): string;
2297
+ /**
2298
+ * Test method, always throws an error
2299
+ */
2300
+ throw(msg: string): void;
2301
+ /**
2302
+ * Test method, calls http endpoint
2303
+ */
2304
+ http_get(url: string): Promise<string>;
2305
+ /**
2306
+ * Auth related operations.
2307
+ */
2308
+ auth(): AuthClient;
2309
+ /**
2310
+ * Crypto related operations.
2311
+ */
2312
+ crypto(): CryptoClient;
2313
+ /**
2314
+ * Vault item related operations.
2315
+ */
2316
+ vault(): VaultClient;
2317
+ /**
2318
+ * Constructs a specific client for platform-specific functionality
2319
+ */
2320
+ platform(): PlatformClient;
2321
+ /**
2322
+ * Constructs a specific client for generating passwords and passphrases
2323
+ */
2324
+ generator(): GeneratorClient;
2325
+ /**
2326
+ * Exporter related operations.
2327
+ */
2328
+ exporters(): ExporterClient;
2329
+ }
2330
+ export class PlatformClient {
2331
+ private constructor();
2332
+ free(): void;
2333
+ [Symbol.dispose](): void;
2334
+ state(): StateClient;
2335
+ /**
2336
+ * Load feature flags into the client
2337
+ */
2338
+ load_flags(flags: FeatureFlags): void;
2339
+ }
2340
+ /**
2341
+ * This module represents a stopgap solution to provide access to primitive crypto functions for JS
2342
+ * clients. It is not intended to be used outside of the JS clients and this pattern should not be
2343
+ * proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
2344
+ * responsible for state and keys.
2345
+ */
2346
+ export class PureCrypto {
2347
+ private constructor();
2348
+ free(): void;
2349
+ [Symbol.dispose](): void;
2350
+ /**
2351
+ * DEPRECATED: Use `symmetric_decrypt_string` instead.
2352
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
2353
+ */
2354
+ static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
2355
+ static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
2356
+ static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
2357
+ /**
2358
+ * DEPRECATED: Use `symmetric_decrypt_filedata` instead.
2359
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
2360
+ */
2361
+ static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
2362
+ static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
2363
+ static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
2364
+ /**
2365
+ * DEPRECATED: Only used by send keys
2366
+ */
2367
+ static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
2368
+ static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
2369
+ static decrypt_user_key_with_master_password(
2370
+ encrypted_user_key: string,
2371
+ master_password: string,
2372
+ email: string,
2373
+ kdf: Kdf,
2374
+ ): Uint8Array;
2375
+ static encrypt_user_key_with_master_password(
2376
+ user_key: Uint8Array,
2377
+ master_password: string,
2378
+ email: string,
2379
+ kdf: Kdf,
2380
+ ): string;
2381
+ static make_user_key_aes256_cbc_hmac(): Uint8Array;
2382
+ static make_user_key_xchacha20_poly1305(): Uint8Array;
2383
+ /**
2384
+ * Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
2385
+ * as an EncString.
2386
+ */
2387
+ static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
2388
+ /**
2389
+ * Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
2390
+ * unwrapped key as a serialized byte array.
2391
+ */
2392
+ static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2393
+ /**
2394
+ * Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
2395
+ * key. Note: Usually, a public key is - by definition - public, so this should not be
2396
+ * used. The specific use-case for this function is to enable rotateable key sets, where
2397
+ * the "public key" is not public, with the intent of preventing the server from being able
2398
+ * to overwrite the user key unlocked by the rotateable keyset.
2399
+ */
2400
+ static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
2401
+ /**
2402
+ * Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
2403
+ * wrapping key.
2404
+ */
2405
+ static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2406
+ /**
2407
+ * Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
2408
+ * key,
2409
+ */
2410
+ static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
2411
+ /**
2412
+ * Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
2413
+ * wrapping key.
2414
+ */
2415
+ static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2416
+ /**
2417
+ * Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key)
2418
+ * in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
2419
+ * the sender's authenticity cannot be verified by the recipient.
2420
+ */
2421
+ static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
2422
+ /**
2423
+ * Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8
2424
+ * DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
2425
+ * recipient.
2426
+ */
2427
+ static decapsulate_key_unsigned(
2428
+ encapsulated_key: string,
2429
+ decapsulation_key: Uint8Array,
2430
+ ): Uint8Array;
2431
+ /**
2432
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
2433
+ * the corresponding verifying key.
2434
+ */
2435
+ static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
2436
+ /**
2437
+ * Returns the algorithm used for the given verifying key.
2438
+ */
2439
+ static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
2440
+ /**
2441
+ * For a given signing identity (verifying key), this function verifies that the signing
2442
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
2443
+ * that the signing identity has the intent to receive messages encrypted to the public
2444
+ * key.
2445
+ */
2446
+ static verify_and_unwrap_signed_public_key(
2447
+ signed_public_key: Uint8Array,
2448
+ verifying_key: Uint8Array,
2449
+ ): Uint8Array;
2450
+ /**
2451
+ * Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
2452
+ */
2453
+ static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
2454
+ static decrypt_user_key_with_master_key(
2455
+ encrypted_user_key: string,
2456
+ master_key: Uint8Array,
2457
+ ): Uint8Array;
2458
+ /**
2459
+ * Given a decrypted private RSA key PKCS8 DER this
2460
+ * returns the corresponding public RSA key in DER format.
2461
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
2462
+ */
2463
+ static rsa_extract_public_key(private_key: Uint8Array): Uint8Array;
2464
+ /**
2465
+ * Generates a new RSA key pair and returns the private key
2466
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
2467
+ */
2468
+ static rsa_generate_keypair(): Uint8Array;
2469
+ /**
2470
+ * Decrypts data using RSAES-OAEP with SHA-1
2471
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
2472
+ */
2473
+ static rsa_decrypt_data(encrypted_data: Uint8Array, private_key: Uint8Array): Uint8Array;
2474
+ /**
2475
+ * Encrypts data using RSAES-OAEP with SHA-1
2476
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
2477
+ */
2478
+ static rsa_encrypt_data(plain_data: Uint8Array, public_key: Uint8Array): Uint8Array;
2479
+ }
2480
+ /**
2481
+ * Client for initializing a user account.
2482
+ */
2483
+ export class RegistrationClient {
2484
+ private constructor();
2485
+ free(): void;
2486
+ [Symbol.dispose](): void;
2487
+ }
2488
+ /**
2489
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
2490
+ */
2491
+ export class SendAccessClient {
2492
+ private constructor();
2493
+ free(): void;
2494
+ [Symbol.dispose](): void;
2495
+ /**
2496
+ * Requests a new send access token.
2497
+ */
2498
+ request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
2499
+ }
2500
+ export class StateClient {
2501
+ private constructor();
2502
+ free(): void;
2503
+ [Symbol.dispose](): void;
2504
+ register_cipher_repository(cipher_repository: any): void;
2505
+ register_folder_repository(store: any): void;
2506
+ register_client_managed_repositories(repositories: Repositories): void;
2507
+ /**
2508
+ * Initialize the database for SDK managed repositories.
2509
+ */
2510
+ initialize_state(configuration: IndexedDbConfiguration): Promise<void>;
2511
+ }
2512
+ export class TotpClient {
2513
+ private constructor();
2514
+ free(): void;
2515
+ [Symbol.dispose](): void;
2516
+ /**
2517
+ * Generates a TOTP code from a provided key
2518
+ *
2519
+ * # Arguments
2520
+ * - `key` - Can be:
2521
+ * - A base32 encoded string
2522
+ * - OTP Auth URI
2523
+ * - Steam URI
2524
+ * - `time_ms` - Optional timestamp in milliseconds
2525
+ */
2526
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
2527
+ }
2528
+ export class VaultClient {
2529
+ private constructor();
2530
+ free(): void;
2531
+ [Symbol.dispose](): void;
2532
+ /**
2533
+ * Attachment related operations.
2534
+ */
2535
+ attachments(): AttachmentsClient;
2536
+ /**
2537
+ * Cipher related operations.
2538
+ */
2539
+ ciphers(): CiphersClient;
2540
+ /**
2541
+ * Folder related operations.
2542
+ */
2543
+ folders(): FoldersClient;
2544
+ /**
2545
+ * TOTP related operations.
2546
+ */
2547
+ totp(): TotpClient;
2548
+ /**
2549
+ * Collection related operations.
2550
+ */
2551
+ collections(): CollectionsClient;
2552
+ /**
2553
+ * Cipher risk evaluation operations.
2554
+ */
2555
+ cipher_risk(): CipherRiskClient;
306
2556
  }