@bitwarden/sdk-internal 0.2.0-main.424 → 0.2.0-main.425

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,16 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Generate a new SSH key pair
5
- *
6
- * # Arguments
7
- * - `key_algorithm` - The algorithm to use for the key pair
8
- *
9
- * # Returns
10
- * - `Ok(SshKey)` if the key was successfully generated
11
- * - `Err(KeyGenerationError)` if the key could not be generated
12
- */
13
- export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
14
3
  /**
15
4
  * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
16
5
  * to an OpenSSH private key with public key and fingerprint
@@ -27,6 +16,17 @@ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
27
16
  * - `Err(UnsupportedKeyType)` if the key type is not supported
28
17
  */
29
18
  export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
19
+ /**
20
+ * Generate a new SSH key pair
21
+ *
22
+ * # Arguments
23
+ * - `key_algorithm` - The algorithm to use for the key pair
24
+ *
25
+ * # Returns
26
+ * - `Ok(SshKey)` if the key was successfully generated
27
+ * - `Err(KeyGenerationError)` if the key could not be generated
28
+ */
29
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
30
30
  export function init_sdk(log_level?: LogLevel | null): void;
31
31
  /**
32
32
  * Sends a DiscoverRequest to the specified destination and returns the response.
@@ -180,43 +180,63 @@ export interface TokenProvider {
180
180
  get_access_token(): Promise<string | undefined>;
181
181
  }
182
182
 
183
- /**
184
- * Active feature flags for the SDK.
185
- */
186
- export interface FeatureFlags extends Map<string, boolean> {}
187
-
188
183
  export interface Repositories {
189
184
  cipher: Repository<Cipher> | null;
190
185
  folder: Repository<Folder> | null;
191
186
  }
192
187
 
188
+ /**
189
+ * Active feature flags for the SDK.
190
+ */
191
+ export interface FeatureFlags extends Map<string, boolean> {}
192
+
193
193
  export interface IndexedDbConfiguration {
194
194
  db_name: string;
195
195
  }
196
196
 
197
197
  /**
198
- * Credentials for getting a send access token using an email and OTP.
198
+ * The credentials used for send access requests.
199
199
  */
200
- export interface SendEmailOtpCredentials {
200
+ export type SendAccessCredentials =
201
+ | SendPasswordCredentials
202
+ | SendEmailOtpCredentials
203
+ | SendEmailCredentials;
204
+
205
+ /**
206
+ * Credentials for sending an OTP to the user\'s email address.
207
+ * This is used when the send requires email verification with an OTP.
208
+ */
209
+ export interface SendEmailCredentials {
201
210
  /**
202
211
  * The email address to which the OTP will be sent.
203
212
  */
204
213
  email: string;
214
+ }
215
+
216
+ /**
217
+ * Credentials for sending password secured access requests.
218
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
219
+ * struct.
220
+ */
221
+ export interface SendPasswordCredentials {
205
222
  /**
206
- * The one-time password (OTP) that the user has received via email.
223
+ * A Base64-encoded hash of the password protecting the send.
207
224
  */
208
- otp: string;
225
+ passwordHashB64: string;
209
226
  }
210
227
 
211
228
  /**
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.
229
+ * Credentials for getting a send access token using an email and OTP.
214
230
  */
215
- export interface SendEmailCredentials {
231
+ export interface SendEmailOtpCredentials {
216
232
  /**
217
233
  * The email address to which the OTP will be sent.
218
234
  */
219
235
  email: string;
236
+ /**
237
+ * The one-time password (OTP) that the user has received via email.
238
+ */
239
+ otp: string;
220
240
  }
221
241
 
222
242
  /**
@@ -234,24 +254,12 @@ export interface SendAccessTokenRequest {
234
254
  }
235
255
 
236
256
  /**
237
- * Credentials for sending password secured access requests.
238
- * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
239
- * struct.
240
- */
241
- export interface SendPasswordCredentials {
242
- /**
243
- * A Base64-encoded hash of the password protecting the send.
244
- */
245
- passwordHashB64: string;
246
- }
247
-
248
- /**
249
- * The credentials used for send access requests.
257
+ * Represents errors that can occur when requesting a send access token.
258
+ * It includes expected and unexpected API errors.
250
259
  */
251
- export type SendAccessCredentials =
252
- | SendPasswordCredentials
253
- | SendEmailOtpCredentials
254
- | SendEmailCredentials;
260
+ export type SendAccessTokenError =
261
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
262
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
255
263
 
256
264
  /**
257
265
  * Any unexpected error that occurs when making requests to identity. This could be
@@ -277,35 +285,6 @@ export interface SendAccessTokenResponse {
277
285
  expiresAt: number;
278
286
  }
279
287
 
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 grant errors - typically due to invalid credentials.
290
- */
291
- export type SendAccessTokenInvalidGrantError =
292
- | "send_id_invalid"
293
- | "password_hash_b64_invalid"
294
- | "email_invalid"
295
- | "otp_invalid"
296
- | "otp_generation_failed"
297
- | "unknown";
298
-
299
- /**
300
- * Invalid request errors - typically due to missing parameters.
301
- */
302
- export type SendAccessTokenInvalidRequestError =
303
- | "send_id_required"
304
- | "password_hash_b64_required"
305
- | "email_required"
306
- | "email_and_otp_required_otp_sent"
307
- | "unknown";
308
-
309
288
  /**
310
289
  * Represents the possible, expected errors that can occur when requesting a send access token.
311
290
  */
@@ -327,9 +306,25 @@ export type SendAccessTokenApiErrorResponse =
327
306
  | { error: "invalid_target"; error_description?: string };
328
307
 
329
308
  /**
330
- * Type of collection
309
+ * Invalid request errors - typically due to missing parameters.
331
310
  */
332
- export type CollectionType = "SharedCollection" | "DefaultUserCollection";
311
+ export type SendAccessTokenInvalidRequestError =
312
+ | "send_id_required"
313
+ | "password_hash_b64_required"
314
+ | "email_required"
315
+ | "email_and_otp_required_otp_sent"
316
+ | "unknown";
317
+
318
+ /**
319
+ * Invalid grant errors - typically due to invalid credentials.
320
+ */
321
+ export type SendAccessTokenInvalidGrantError =
322
+ | "send_id_invalid"
323
+ | "password_hash_b64_invalid"
324
+ | "email_invalid"
325
+ | "otp_invalid"
326
+ | "otp_generation_failed"
327
+ | "unknown";
333
328
 
334
329
  export interface CollectionView {
335
330
  id: CollectionId | undefined;
@@ -359,6 +354,11 @@ export interface Collection {
359
354
  */
360
355
  export type CollectionId = Tagged<Uuid, "CollectionId">;
361
356
 
357
+ /**
358
+ * Type of collection
359
+ */
360
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
361
+
362
362
  export interface CollectionDecryptError extends Error {
363
363
  name: "CollectionDecryptError";
364
364
  variant: "Crypto";
@@ -437,13 +437,6 @@ export function isAccountCryptographyInitializationError(
437
437
  error: any,
438
438
  ): error is AccountCryptographyInitializationError;
439
439
 
440
- export interface CryptoClientError extends Error {
441
- name: "CryptoClientError";
442
- variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
443
- }
444
-
445
- export function isCryptoClientError(error: any): error is CryptoClientError;
446
-
447
440
  /**
448
441
  * Response for `verify_asymmetric_keys`.
449
442
  */
@@ -459,100 +452,79 @@ export interface VerifyAsymmetricKeysResponse {
459
452
  }
460
453
 
461
454
  /**
462
- * Request for deriving a pin protected user key
455
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
463
456
  */
464
- export interface EnrollPinResponse {
457
+ export interface UserCryptoV2KeysResponse {
465
458
  /**
466
- * [UserKey] protected by PIN
459
+ * User key
467
460
  */
468
- pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
461
+ userKey: B64;
469
462
  /**
470
- * PIN protected by [UserKey]
463
+ * Wrapped private key
471
464
  */
472
- userKeyEncryptedPin: EncString;
473
- }
474
-
475
- /**
476
- * Request for `verify_asymmetric_keys`.
477
- */
478
- export interface VerifyAsymmetricKeysRequest {
465
+ privateKey: EncString;
479
466
  /**
480
- * The user\'s user key
467
+ * Public key
481
468
  */
482
- userKey: B64;
469
+ publicKey: B64;
483
470
  /**
484
- * The user\'s public key
471
+ * The user\'s public key, signed by the signing key
485
472
  */
486
- userPublicKey: B64;
473
+ signedPublicKey: SignedPublicKey;
487
474
  /**
488
- * User\'s private key, encrypted with the user key
475
+ * Signing key, encrypted with the user\'s symmetric key
489
476
  */
490
- userKeyEncryptedPrivateKey: EncString;
491
- }
492
-
493
- /**
494
- * Represents the request to initialize the user\'s organizational cryptographic state.
495
- */
496
- export interface InitOrgCryptoRequest {
477
+ signingKey: EncString;
497
478
  /**
498
- * The encryption keys for all the organizations the user is a part of
479
+ * Base64 encoded verifying key
499
480
  */
500
- organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
501
- }
502
-
503
- /**
504
- * Response from the `make_update_password` function
505
- */
506
- export interface UpdatePasswordResponse {
481
+ verifyingKey: B64;
507
482
  /**
508
- * Hash of the new password
483
+ * The user\'s signed security state
509
484
  */
510
- passwordHash: B64;
485
+ securityState: SignedSecurityState;
511
486
  /**
512
- * User key, encrypted with the new password
487
+ * The security state\'s version
513
488
  */
514
- newKey: EncString;
489
+ securityVersion: number;
515
490
  }
516
491
 
517
492
  /**
518
- * The crypto method used to initialize the user cryptographic state.
493
+ * Auth requests supports multiple initialization methods.
519
494
  */
520
- export type InitUserCryptoMethod =
521
- | { password: { password: string; user_key: EncString } }
522
- | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
523
- | { decryptedKey: { decrypted_user_key: string } }
524
- | { pin: { pin: string; pin_protected_user_key: EncString } }
525
- | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
526
- | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
527
- | {
528
- deviceKey: {
529
- device_key: string;
530
- protected_device_private_key: EncString;
531
- device_protected_user_key: UnsignedSharedKey;
532
- };
533
- }
534
- | { keyConnector: { master_key: B64; user_key: EncString } };
495
+ export type AuthRequestMethod =
496
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
497
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
535
498
 
536
499
  /**
537
- * Request for migrating an account from password to key connector.
500
+ * Response from the `make_key_pair` function
538
501
  */
539
- export interface DeriveKeyConnectorRequest {
540
- /**
541
- * Encrypted user key, used to validate the master key
542
- */
543
- userKeyEncrypted: EncString;
502
+ export interface MakeKeyPairResponse {
544
503
  /**
545
- * The user\'s master password
504
+ * The user\'s public key
546
505
  */
547
- password: string;
506
+ userPublicKey: B64;
548
507
  /**
549
- * The KDF parameters used to derive the master key
508
+ * User\'s private key, encrypted with the user key
550
509
  */
551
- kdf: Kdf;
510
+ userKeyEncryptedPrivateKey: EncString;
511
+ }
512
+
513
+ export interface DeriveKeyConnectorError extends Error {
514
+ name: "DeriveKeyConnectorError";
515
+ variant: "WrongPassword" | "Crypto";
516
+ }
517
+
518
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
519
+
520
+ /**
521
+ * Represents the request to initialize the user\'s organizational cryptographic state.
522
+ */
523
+ export interface InitOrgCryptoRequest {
552
524
  /**
553
- * The user\'s email address
525
+ * The encryption keys for all the organizations the user is a part of
554
526
  */
555
- email: string;
527
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
556
528
  }
557
529
 
558
530
  /**
@@ -583,9 +555,48 @@ export interface InitUserCryptoRequest {
583
555
  }
584
556
 
585
557
  /**
586
- * Response from the `make_key_pair` function
558
+ * Request for deriving a pin protected user key
587
559
  */
588
- export interface MakeKeyPairResponse {
560
+ export interface DerivePinKeyResponse {
561
+ /**
562
+ * [UserKey] protected by PIN
563
+ */
564
+ pinProtectedUserKey: EncString;
565
+ /**
566
+ * PIN protected by [UserKey]
567
+ */
568
+ encryptedPin: EncString;
569
+ }
570
+
571
+ export interface CryptoClientError extends Error {
572
+ name: "CryptoClientError";
573
+ variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
574
+ }
575
+
576
+ export function isCryptoClientError(error: any): error is CryptoClientError;
577
+
578
+ /**
579
+ * Response from the `make_update_password` function
580
+ */
581
+ export interface UpdatePasswordResponse {
582
+ /**
583
+ * Hash of the new password
584
+ */
585
+ passwordHash: B64;
586
+ /**
587
+ * User key, encrypted with the new password
588
+ */
589
+ newKey: EncString;
590
+ }
591
+
592
+ /**
593
+ * Request for `verify_asymmetric_keys`.
594
+ */
595
+ export interface VerifyAsymmetricKeysRequest {
596
+ /**
597
+ * The user\'s user key
598
+ */
599
+ userKey: B64;
589
600
  /**
590
601
  * The user\'s public key
591
602
  */
@@ -597,18 +608,23 @@ export interface MakeKeyPairResponse {
597
608
  }
598
609
 
599
610
  /**
600
- * Auth requests supports multiple initialization methods.
611
+ * The crypto method used to initialize the user cryptographic state.
601
612
  */
602
- export type AuthRequestMethod =
603
- | { userKey: { protected_user_key: UnsignedSharedKey } }
604
- | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
605
-
606
- export interface DeriveKeyConnectorError extends Error {
607
- name: "DeriveKeyConnectorError";
608
- variant: "WrongPassword" | "Crypto";
609
- }
610
-
611
- export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
613
+ export type InitUserCryptoMethod =
614
+ | { password: { password: string; user_key: EncString } }
615
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
616
+ | { decryptedKey: { decrypted_user_key: string } }
617
+ | { pin: { pin: string; pin_protected_user_key: EncString } }
618
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
619
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
620
+ | {
621
+ deviceKey: {
622
+ device_key: string;
623
+ protected_device_private_key: EncString;
624
+ device_protected_user_key: UnsignedSharedKey;
625
+ };
626
+ }
627
+ | { keyConnector: { master_key: B64; user_key: EncString } };
612
628
 
613
629
  export interface EnrollAdminPasswordResetError extends Error {
614
630
  name: "EnrollAdminPasswordResetError";
@@ -636,55 +652,39 @@ export interface UpdateKdfResponse {
636
652
  }
637
653
 
638
654
  /**
639
- * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
655
+ * Request for migrating an account from password to key connector.
640
656
  */
641
- export interface UserCryptoV2KeysResponse {
642
- /**
643
- * User key
644
- */
645
- userKey: B64;
646
- /**
647
- * Wrapped private key
648
- */
649
- privateKey: EncString;
650
- /**
651
- * Public key
652
- */
653
- publicKey: B64;
654
- /**
655
- * The user\'s public key, signed by the signing key
656
- */
657
- signedPublicKey: SignedPublicKey;
657
+ export interface DeriveKeyConnectorRequest {
658
658
  /**
659
- * Signing key, encrypted with the user\'s symmetric key
659
+ * Encrypted user key, used to validate the master key
660
660
  */
661
- signingKey: EncString;
661
+ userKeyEncrypted: EncString;
662
662
  /**
663
- * Base64 encoded verifying key
663
+ * The user\'s master password
664
664
  */
665
- verifyingKey: B64;
665
+ password: string;
666
666
  /**
667
- * The user\'s signed security state
667
+ * The KDF parameters used to derive the master key
668
668
  */
669
- securityState: SignedSecurityState;
669
+ kdf: Kdf;
670
670
  /**
671
- * The security state\'s version
671
+ * The user\'s email address
672
672
  */
673
- securityVersion: number;
673
+ email: string;
674
674
  }
675
675
 
676
676
  /**
677
677
  * Request for deriving a pin protected user key
678
678
  */
679
- export interface DerivePinKeyResponse {
679
+ export interface EnrollPinResponse {
680
680
  /**
681
681
  * [UserKey] protected by PIN
682
682
  */
683
- pinProtectedUserKey: EncString;
683
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
684
684
  /**
685
685
  * PIN protected by [UserKey]
686
686
  */
687
- encryptedPin: EncString;
687
+ userKeyEncryptedPin: EncString;
688
688
  }
689
689
 
690
690
  /**
@@ -704,35 +704,6 @@ export interface StatefulCryptoError extends Error {
704
704
 
705
705
  export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
706
706
 
707
- export type DeviceType =
708
- | "Android"
709
- | "iOS"
710
- | "ChromeExtension"
711
- | "FirefoxExtension"
712
- | "OperaExtension"
713
- | "EdgeExtension"
714
- | "WindowsDesktop"
715
- | "MacOsDesktop"
716
- | "LinuxDesktop"
717
- | "ChromeBrowser"
718
- | "FirefoxBrowser"
719
- | "OperaBrowser"
720
- | "EdgeBrowser"
721
- | "IEBrowser"
722
- | "UnknownBrowser"
723
- | "AndroidAmazon"
724
- | "UWP"
725
- | "SafariBrowser"
726
- | "VivaldiBrowser"
727
- | "VivaldiExtension"
728
- | "SafariExtension"
729
- | "SDK"
730
- | "Server"
731
- | "WindowsCLI"
732
- | "MacOsCLI"
733
- | "LinuxCLI"
734
- | "DuckDuckGoBrowser";
735
-
736
707
  /**
737
708
  * Basic client behavior settings. These settings specify the various targets and behavior of the
738
709
  * Bitwarden Client. They are optional and uneditable once the client is initialized.
@@ -774,6 +745,35 @@ export interface ClientSettings {
774
745
  bitwardenClientVersion?: string | undefined;
775
746
  }
776
747
 
748
+ export type DeviceType =
749
+ | "Android"
750
+ | "iOS"
751
+ | "ChromeExtension"
752
+ | "FirefoxExtension"
753
+ | "OperaExtension"
754
+ | "EdgeExtension"
755
+ | "WindowsDesktop"
756
+ | "MacOsDesktop"
757
+ | "LinuxDesktop"
758
+ | "ChromeBrowser"
759
+ | "FirefoxBrowser"
760
+ | "OperaBrowser"
761
+ | "EdgeBrowser"
762
+ | "IEBrowser"
763
+ | "UnknownBrowser"
764
+ | "AndroidAmazon"
765
+ | "UWP"
766
+ | "SafariBrowser"
767
+ | "VivaldiBrowser"
768
+ | "VivaldiExtension"
769
+ | "SafariExtension"
770
+ | "SDK"
771
+ | "Server"
772
+ | "WindowsCLI"
773
+ | "MacOsCLI"
774
+ | "LinuxCLI"
775
+ | "DuckDuckGoBrowser";
776
+
777
777
  export interface EncryptionSettingsError extends Error {
778
778
  name: "EncryptionSettingsError";
779
779
  variant:
@@ -990,12 +990,6 @@ export interface PasswordGeneratorRequest {
990
990
  minSpecial: number | undefined;
991
991
  }
992
992
 
993
- export type UsernameGeneratorRequest =
994
- | { word: { capitalize: boolean; include_number: boolean } }
995
- | { subaddress: { type: AppendType; email: string } }
996
- | { catchall: { type: AppendType; domain: string } }
997
- | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
998
-
999
993
  export type AppendType = "random" | { websiteName: { website: string } };
1000
994
 
1001
995
  /**
@@ -1018,6 +1012,12 @@ export interface UsernameError extends Error {
1018
1012
 
1019
1013
  export function isUsernameError(error: any): error is UsernameError;
1020
1014
 
1015
+ export type UsernameGeneratorRequest =
1016
+ | { word: { capitalize: boolean; include_number: boolean } }
1017
+ | { subaddress: { type: AppendType; email: string } }
1018
+ | { catchall: { type: AppendType; domain: string } }
1019
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
1020
+
1021
1021
  export interface RequestError extends Error {
1022
1022
  name: "RequestError";
1023
1023
  variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
@@ -1147,32 +1147,6 @@ export interface CipherLoginDetails {
1147
1147
  username: string | undefined;
1148
1148
  }
1149
1149
 
1150
- /**
1151
- * Password reuse map wrapper for WASM compatibility.
1152
- */
1153
- export type PasswordReuseMap = Record<string, number>;
1154
-
1155
- /**
1156
- * Options for configuring risk computation.
1157
- */
1158
- export interface CipherRiskOptions {
1159
- /**
1160
- * Pre-computed password reuse map (password → count).
1161
- * If provided, enables reuse detection across ciphers.
1162
- */
1163
- passwordMap?: PasswordReuseMap | undefined;
1164
- /**
1165
- * Whether to check passwords against Have I Been Pwned API.
1166
- * When true, makes network requests to check for exposed passwords.
1167
- */
1168
- checkExposed?: boolean;
1169
- /**
1170
- * Optional HIBP API base URL override. When None, uses the production HIBP URL.
1171
- * Can be used for testing or alternative password breach checking services.
1172
- */
1173
- hibpBaseUrl?: string | undefined;
1174
- }
1175
-
1176
1150
  /**
1177
1151
  * Result of checking password exposure via HIBP API.
1178
1152
  */
@@ -1181,6 +1155,11 @@ export type ExposedPasswordResult =
1181
1155
  | { type: "Found"; value: number }
1182
1156
  | { type: "Error"; value: string };
1183
1157
 
1158
+ /**
1159
+ * Password reuse map wrapper for WASM compatibility.
1160
+ */
1161
+ export type PasswordReuseMap = Record<string, number>;
1162
+
1184
1163
  /**
1185
1164
  * Risk evaluation result for a single cipher.
1186
1165
  */
@@ -1208,6 +1187,27 @@ export interface CipherRiskResult {
1208
1187
  reuse_count: number | undefined;
1209
1188
  }
1210
1189
 
1190
+ /**
1191
+ * Options for configuring risk computation.
1192
+ */
1193
+ export interface CipherRiskOptions {
1194
+ /**
1195
+ * Pre-computed password reuse map (password → count).
1196
+ * If provided, enables reuse detection across ciphers.
1197
+ */
1198
+ passwordMap?: PasswordReuseMap | undefined;
1199
+ /**
1200
+ * Whether to check passwords against Have I Been Pwned API.
1201
+ * When true, makes network requests to check for exposed passwords.
1202
+ */
1203
+ checkExposed?: boolean;
1204
+ /**
1205
+ * Optional HIBP API base URL override. When None, uses the production HIBP URL.
1206
+ * Can be used for testing or alternative password breach checking services.
1207
+ */
1208
+ hibpBaseUrl?: string | undefined;
1209
+ }
1210
+
1211
1211
  export interface PasswordHistoryView {
1212
1212
  password: string;
1213
1213
  lastUsedDate: DateTime<Utc>;
@@ -1240,6 +1240,13 @@ export interface TotpError extends Error {
1240
1240
 
1241
1241
  export function isTotpError(error: any): error is TotpError;
1242
1242
 
1243
+ export interface DecryptError extends Error {
1244
+ name: "DecryptError";
1245
+ variant: "Crypto";
1246
+ }
1247
+
1248
+ export function isDecryptError(error: any): error is DecryptError;
1249
+
1243
1250
  export interface EncryptError extends Error {
1244
1251
  name: "EncryptError";
1245
1252
  variant: "Crypto" | "MissingUserId";
@@ -1247,13 +1254,18 @@ export interface EncryptError extends Error {
1247
1254
 
1248
1255
  export function isEncryptError(error: any): error is EncryptError;
1249
1256
 
1250
- export interface DecryptError extends Error {
1251
- name: "DecryptError";
1252
- variant: "Crypto";
1257
+ export interface Attachment {
1258
+ id: string | undefined;
1259
+ url: string | undefined;
1260
+ size: string | undefined;
1261
+ /**
1262
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1263
+ */
1264
+ sizeName: string | undefined;
1265
+ fileName: EncString | undefined;
1266
+ key: EncString | undefined;
1253
1267
  }
1254
1268
 
1255
- export function isDecryptError(error: any): error is DecryptError;
1256
-
1257
1269
  export interface AttachmentView {
1258
1270
  id: string | undefined;
1259
1271
  url: string | undefined;
@@ -1276,18 +1288,6 @@ export interface AttachmentView {
1276
1288
  decryptedKey: string | undefined;
1277
1289
  }
1278
1290
 
1279
- export interface Attachment {
1280
- id: string | undefined;
1281
- url: string | undefined;
1282
- size: string | undefined;
1283
- /**
1284
- * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1285
- */
1286
- sizeName: string | undefined;
1287
- fileName: EncString | undefined;
1288
- key: EncString | undefined;
1289
- }
1290
-
1291
1291
  export interface LocalDataView {
1292
1292
  lastUsedDate: DateTime<Utc> | undefined;
1293
1293
  lastLaunched: DateTime<Utc> | undefined;
@@ -1347,13 +1347,6 @@ export interface CipherEditRequest {
1347
1347
  key: EncString | undefined;
1348
1348
  }
1349
1349
 
1350
- export interface CreateCipherError extends Error {
1351
- name: "CreateCipherError";
1352
- variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1353
- }
1354
-
1355
- export function isCreateCipherError(error: any): error is CreateCipherError;
1356
-
1357
1350
  /**
1358
1351
  * Request to add a cipher.
1359
1352
  */
@@ -1368,6 +1361,13 @@ export interface CipherCreateRequest {
1368
1361
  fields: FieldView[];
1369
1362
  }
1370
1363
 
1364
+ export interface CreateCipherError extends Error {
1365
+ name: "CreateCipherError";
1366
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1367
+ }
1368
+
1369
+ export function isCreateCipherError(error: any): error is CreateCipherError;
1370
+
1371
1371
  /**
1372
1372
  * Represents the inner data of a cipher view.
1373
1373
  */
@@ -1378,13 +1378,6 @@ export type CipherViewType =
1378
1378
  | { secureNote: SecureNoteView }
1379
1379
  | { sshKey: SshKeyView };
1380
1380
 
1381
- export interface EncryptFileError extends Error {
1382
- name: "EncryptFileError";
1383
- variant: "Encrypt" | "Io";
1384
- }
1385
-
1386
- export function isEncryptFileError(error: any): error is EncryptFileError;
1387
-
1388
1381
  export interface DecryptFileError extends Error {
1389
1382
  name: "DecryptFileError";
1390
1383
  variant: "Decrypt" | "Io";
@@ -1392,19 +1385,25 @@ export interface DecryptFileError extends Error {
1392
1385
 
1393
1386
  export function isDecryptFileError(error: any): error is DecryptFileError;
1394
1387
 
1388
+ export interface EncryptFileError extends Error {
1389
+ name: "EncryptFileError";
1390
+ variant: "Encrypt" | "Io";
1391
+ }
1392
+
1393
+ export function isEncryptFileError(error: any): error is EncryptFileError;
1394
+
1395
1395
  export interface CipherPermissions {
1396
1396
  delete: boolean;
1397
1397
  restore: boolean;
1398
1398
  }
1399
1399
 
1400
- /**
1401
- * Minimal CardView only including the needed details for list views
1402
- */
1403
- export interface CardListView {
1404
- /**
1405
- * The brand of the card, e.g. Visa, Mastercard, etc.
1406
- */
1400
+ export interface CardView {
1401
+ cardholderName: string | undefined;
1402
+ expMonth: string | undefined;
1403
+ expYear: string | undefined;
1404
+ code: string | undefined;
1407
1405
  brand: string | undefined;
1406
+ number: string | undefined;
1408
1407
  }
1409
1408
 
1410
1409
  export interface Card {
@@ -1416,13 +1415,14 @@ export interface Card {
1416
1415
  number: EncString | undefined;
1417
1416
  }
1418
1417
 
1419
- export interface CardView {
1420
- cardholderName: string | undefined;
1421
- expMonth: string | undefined;
1422
- expYear: string | undefined;
1423
- code: string | undefined;
1418
+ /**
1419
+ * Minimal CardView only including the needed details for list views
1420
+ */
1421
+ export interface CardListView {
1422
+ /**
1423
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1424
+ */
1424
1425
  brand: string | undefined;
1425
- number: string | undefined;
1426
1426
  }
1427
1427
 
1428
1428
  export interface Field {
@@ -1439,22 +1439,6 @@ export interface FieldView {
1439
1439
  linkedId: LinkedIdType | undefined;
1440
1440
  }
1441
1441
 
1442
- export interface Login {
1443
- username: EncString | undefined;
1444
- password: EncString | undefined;
1445
- passwordRevisionDate: DateTime<Utc> | undefined;
1446
- uris: LoginUri[] | undefined;
1447
- totp: EncString | undefined;
1448
- autofillOnPageLoad: boolean | undefined;
1449
- fido2Credentials: Fido2Credential[] | undefined;
1450
- }
1451
-
1452
- export interface LoginUri {
1453
- uri: EncString | undefined;
1454
- match: UriMatchType | undefined;
1455
- uriChecksum: EncString | undefined;
1456
- }
1457
-
1458
1442
  export interface Fido2CredentialFullView {
1459
1443
  credentialId: string;
1460
1444
  keyType: string;
@@ -1471,29 +1455,13 @@ export interface Fido2CredentialFullView {
1471
1455
  creationDate: DateTime<Utc>;
1472
1456
  }
1473
1457
 
1474
- export interface LoginListView {
1475
- fido2Credentials: Fido2CredentialListView[] | undefined;
1476
- hasFido2: boolean;
1477
- username: string | undefined;
1478
- /**
1479
- * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
1480
- */
1481
- totp: EncString | undefined;
1482
- uris: LoginUriView[] | undefined;
1483
- }
1484
-
1485
- export interface Fido2CredentialNewView {
1458
+ export interface Fido2CredentialListView {
1486
1459
  credentialId: string;
1487
- keyType: string;
1488
- keyAlgorithm: string;
1489
- keyCurve: string;
1490
1460
  rpId: string;
1491
1461
  userHandle: string | undefined;
1492
1462
  userName: string | undefined;
1493
- counter: string;
1494
- rpName: string | undefined;
1495
1463
  userDisplayName: string | undefined;
1496
- creationDate: DateTime<Utc>;
1464
+ counter: string;
1497
1465
  }
1498
1466
 
1499
1467
  export interface LoginView {
@@ -1506,19 +1474,25 @@ export interface LoginView {
1506
1474
  fido2Credentials: Fido2Credential[] | undefined;
1507
1475
  }
1508
1476
 
1509
- export interface Fido2CredentialListView {
1510
- credentialId: string;
1511
- rpId: string;
1512
- userHandle: string | undefined;
1513
- userName: string | undefined;
1514
- userDisplayName: string | undefined;
1515
- counter: string;
1477
+ export interface LoginListView {
1478
+ fido2Credentials: Fido2CredentialListView[] | undefined;
1479
+ hasFido2: boolean;
1480
+ username: string | undefined;
1481
+ /**
1482
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
1483
+ */
1484
+ totp: EncString | undefined;
1485
+ uris: LoginUriView[] | undefined;
1516
1486
  }
1517
1487
 
1518
- export interface LoginUriView {
1519
- uri: string | undefined;
1520
- match: UriMatchType | undefined;
1521
- uriChecksum: string | undefined;
1488
+ export interface Login {
1489
+ username: EncString | undefined;
1490
+ password: EncString | undefined;
1491
+ passwordRevisionDate: DateTime<Utc> | undefined;
1492
+ uris: LoginUri[] | undefined;
1493
+ totp: EncString | undefined;
1494
+ autofillOnPageLoad: boolean | undefined;
1495
+ fido2Credentials: Fido2Credential[] | undefined;
1522
1496
  }
1523
1497
 
1524
1498
  export interface Fido2Credential {
@@ -1537,6 +1511,32 @@ export interface Fido2Credential {
1537
1511
  creationDate: DateTime<Utc>;
1538
1512
  }
1539
1513
 
1514
+ export interface LoginUri {
1515
+ uri: EncString | undefined;
1516
+ match: UriMatchType | undefined;
1517
+ uriChecksum: EncString | undefined;
1518
+ }
1519
+
1520
+ export interface Fido2CredentialNewView {
1521
+ credentialId: string;
1522
+ keyType: string;
1523
+ keyAlgorithm: string;
1524
+ keyCurve: string;
1525
+ rpId: string;
1526
+ userHandle: string | undefined;
1527
+ userName: string | undefined;
1528
+ counter: string;
1529
+ rpName: string | undefined;
1530
+ userDisplayName: string | undefined;
1531
+ creationDate: DateTime<Utc>;
1532
+ }
1533
+
1534
+ export interface LoginUriView {
1535
+ uri: string | undefined;
1536
+ match: UriMatchType | undefined;
1537
+ uriChecksum: string | undefined;
1538
+ }
1539
+
1540
1540
  export interface Fido2CredentialView {
1541
1541
  credentialId: string;
1542
1542
  keyType: string;
@@ -1553,72 +1553,23 @@ export interface Fido2CredentialView {
1553
1553
  creationDate: DateTime<Utc>;
1554
1554
  }
1555
1555
 
1556
- /**
1557
- * NewType wrapper for `CipherId`
1558
- */
1559
- export type CipherId = Tagged<Uuid, "CipherId">;
1560
-
1561
- /**
1562
- * Represents the result of decrypting a list of ciphers.
1563
- *
1564
- * This struct contains two vectors: `successes` and `failures`.
1565
- * `successes` contains the decrypted `CipherListView` objects,
1566
- * while `failures` contains the original `Cipher` objects that failed to decrypt.
1567
- */
1568
- export interface DecryptCipherListResult {
1569
- /**
1570
- * The decrypted `CipherListView` objects.
1571
- */
1572
- successes: CipherListView[];
1573
- /**
1574
- * The original `Cipher` objects that failed to decrypt.
1575
- */
1576
- failures: Cipher[];
1556
+ export interface CipherError extends Error {
1557
+ name: "CipherError";
1558
+ variant:
1559
+ | "MissingField"
1560
+ | "Crypto"
1561
+ | "Decrypt"
1562
+ | "Encrypt"
1563
+ | "AttachmentsWithoutKeys"
1564
+ | "OrganizationAlreadySet"
1565
+ | "PutShare"
1566
+ | "PutShareMany"
1567
+ | "Repository"
1568
+ | "Chrono"
1569
+ | "SerdeJson";
1577
1570
  }
1578
1571
 
1579
- export type CipherListViewType =
1580
- | { login: LoginListView }
1581
- | "secureNote"
1582
- | { card: CardListView }
1583
- | "identity"
1584
- | "sshKey";
1585
-
1586
- export interface CipherListView {
1587
- id: CipherId | undefined;
1588
- organizationId: OrganizationId | undefined;
1589
- folderId: FolderId | undefined;
1590
- collectionIds: CollectionId[];
1591
- /**
1592
- * Temporary, required to support calculating TOTP from CipherListView.
1593
- */
1594
- key: EncString | undefined;
1595
- name: string;
1596
- subtitle: string;
1597
- type: CipherListViewType;
1598
- favorite: boolean;
1599
- reprompt: CipherRepromptType;
1600
- organizationUseTotp: boolean;
1601
- edit: boolean;
1602
- permissions: CipherPermissions | undefined;
1603
- viewPassword: boolean;
1604
- /**
1605
- * The number of attachments
1606
- */
1607
- attachments: number;
1608
- /**
1609
- * Indicates if the cipher has old attachments that need to be re-uploaded
1610
- */
1611
- hasOldAttachments: boolean;
1612
- creationDate: DateTime<Utc>;
1613
- deletedDate: DateTime<Utc> | undefined;
1614
- revisionDate: DateTime<Utc>;
1615
- archivedDate: DateTime<Utc> | undefined;
1616
- /**
1617
- * Hints for the presentation layer for which fields can be copied.
1618
- */
1619
- copyableFields: CopyableCipherFields[];
1620
- localData: LocalDataView | undefined;
1621
- }
1572
+ export function isCipherError(error: any): error is CipherError;
1622
1573
 
1623
1574
  /**
1624
1575
  * Available fields on a cipher and can be copied from a the list view in the UI.
@@ -1669,33 +1620,31 @@ export interface CipherView {
1669
1620
  archivedDate: DateTime<Utc> | undefined;
1670
1621
  }
1671
1622
 
1672
- export interface EncryptionContext {
1623
+ export type CipherListViewType =
1624
+ | { login: LoginListView }
1625
+ | "secureNote"
1626
+ | { card: CardListView }
1627
+ | "identity"
1628
+ | "sshKey";
1629
+
1630
+ /**
1631
+ * Represents the result of decrypting a list of ciphers.
1632
+ *
1633
+ * This struct contains two vectors: `successes` and `failures`.
1634
+ * `successes` contains the decrypted `CipherListView` objects,
1635
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1636
+ */
1637
+ export interface DecryptCipherListResult {
1673
1638
  /**
1674
- * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1675
- * Organization-owned ciphers
1639
+ * The decrypted `CipherListView` objects.
1676
1640
  */
1677
- encryptedFor: UserId;
1678
- cipher: Cipher;
1679
- }
1680
-
1681
- export interface CipherError extends Error {
1682
- name: "CipherError";
1683
- variant:
1684
- | "MissingField"
1685
- | "Crypto"
1686
- | "Decrypt"
1687
- | "Encrypt"
1688
- | "AttachmentsWithoutKeys"
1689
- | "OrganizationAlreadySet"
1690
- | "PutShare"
1691
- | "PutShareMany"
1692
- | "Repository"
1693
- | "Chrono"
1694
- | "SerdeJson";
1641
+ successes: CipherListView[];
1642
+ /**
1643
+ * The original `Cipher` objects that failed to decrypt.
1644
+ */
1645
+ failures: Cipher[];
1695
1646
  }
1696
1647
 
1697
- export function isCipherError(error: any): error is CipherError;
1698
-
1699
1648
  export interface Cipher {
1700
1649
  id: CipherId | undefined;
1701
1650
  organizationId: OrganizationId | undefined;
@@ -1731,6 +1680,57 @@ export interface Cipher {
1731
1680
  data: string | undefined;
1732
1681
  }
1733
1682
 
1683
+ /**
1684
+ * NewType wrapper for `CipherId`
1685
+ */
1686
+ export type CipherId = Tagged<Uuid, "CipherId">;
1687
+
1688
+ export interface CipherListView {
1689
+ id: CipherId | undefined;
1690
+ organizationId: OrganizationId | undefined;
1691
+ folderId: FolderId | undefined;
1692
+ collectionIds: CollectionId[];
1693
+ /**
1694
+ * Temporary, required to support calculating TOTP from CipherListView.
1695
+ */
1696
+ key: EncString | undefined;
1697
+ name: string;
1698
+ subtitle: string;
1699
+ type: CipherListViewType;
1700
+ favorite: boolean;
1701
+ reprompt: CipherRepromptType;
1702
+ organizationUseTotp: boolean;
1703
+ edit: boolean;
1704
+ permissions: CipherPermissions | undefined;
1705
+ viewPassword: boolean;
1706
+ /**
1707
+ * The number of attachments
1708
+ */
1709
+ attachments: number;
1710
+ /**
1711
+ * Indicates if the cipher has old attachments that need to be re-uploaded
1712
+ */
1713
+ hasOldAttachments: boolean;
1714
+ creationDate: DateTime<Utc>;
1715
+ deletedDate: DateTime<Utc> | undefined;
1716
+ revisionDate: DateTime<Utc>;
1717
+ archivedDate: DateTime<Utc> | undefined;
1718
+ /**
1719
+ * Hints for the presentation layer for which fields can be copied.
1720
+ */
1721
+ copyableFields: CopyableCipherFields[];
1722
+ localData: LocalDataView | undefined;
1723
+ }
1724
+
1725
+ export interface EncryptionContext {
1726
+ /**
1727
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1728
+ * Organization-owned ciphers
1729
+ */
1730
+ encryptedFor: UserId;
1731
+ cipher: Cipher;
1732
+ }
1733
+
1734
1734
  export interface SshKeyView {
1735
1735
  /**
1736
1736
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
@@ -1761,27 +1761,6 @@ export interface SshKey {
1761
1761
  fingerprint: EncString;
1762
1762
  }
1763
1763
 
1764
- export interface Identity {
1765
- title: EncString | undefined;
1766
- firstName: EncString | undefined;
1767
- middleName: EncString | undefined;
1768
- lastName: EncString | undefined;
1769
- address1: EncString | undefined;
1770
- address2: EncString | undefined;
1771
- address3: EncString | undefined;
1772
- city: EncString | undefined;
1773
- state: EncString | undefined;
1774
- postalCode: EncString | undefined;
1775
- country: EncString | undefined;
1776
- company: EncString | undefined;
1777
- email: EncString | undefined;
1778
- phone: EncString | undefined;
1779
- ssn: EncString | undefined;
1780
- username: EncString | undefined;
1781
- passportNumber: EncString | undefined;
1782
- licenseNumber: EncString | undefined;
1783
- }
1784
-
1785
1764
  export interface IdentityView {
1786
1765
  title: string | undefined;
1787
1766
  firstName: string | undefined;
@@ -1803,8 +1782,35 @@ export interface IdentityView {
1803
1782
  licenseNumber: string | undefined;
1804
1783
  }
1805
1784
 
1785
+ export interface Identity {
1786
+ title: EncString | undefined;
1787
+ firstName: EncString | undefined;
1788
+ middleName: EncString | undefined;
1789
+ lastName: EncString | undefined;
1790
+ address1: EncString | undefined;
1791
+ address2: EncString | undefined;
1792
+ address3: EncString | undefined;
1793
+ city: EncString | undefined;
1794
+ state: EncString | undefined;
1795
+ postalCode: EncString | undefined;
1796
+ country: EncString | undefined;
1797
+ company: EncString | undefined;
1798
+ email: EncString | undefined;
1799
+ phone: EncString | undefined;
1800
+ ssn: EncString | undefined;
1801
+ username: EncString | undefined;
1802
+ passportNumber: EncString | undefined;
1803
+ licenseNumber: EncString | undefined;
1804
+ }
1805
+
1806
1806
  export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
1807
1807
 
1808
+ export interface FolderView {
1809
+ id: FolderId | undefined;
1810
+ name: string;
1811
+ revisionDate: DateTime<Utc>;
1812
+ }
1813
+
1808
1814
  export interface Folder {
1809
1815
  id: FolderId | undefined;
1810
1816
  name: EncString;
@@ -1816,12 +1822,6 @@ export interface Folder {
1816
1822
  */
1817
1823
  export type FolderId = Tagged<Uuid, "FolderId">;
1818
1824
 
1819
- export interface FolderView {
1820
- id: FolderId | undefined;
1821
- name: string;
1822
- revisionDate: DateTime<Utc>;
1823
- }
1824
-
1825
1825
  export interface EditFolderError extends Error {
1826
1826
  name: "EditFolderError";
1827
1827
  variant: