@bitwarden/commercial-sdk-internal 0.1.0 → 0.2.0-hotfix.20260302

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