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

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,55 @@ 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
+ * Credentials for sending an OTP to the user\'s email address.
199
+ * This is used when the send requires email verification with an OTP.
199
200
  */
200
- export interface SendEmailOtpCredentials {
201
+ export interface SendEmailCredentials {
201
202
  /**
202
203
  * The email address to which the OTP will be sent.
203
204
  */
204
205
  email: string;
206
+ }
207
+
208
+ /**
209
+ * Credentials for sending password secured access requests.
210
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
211
+ * struct.
212
+ */
213
+ export interface SendPasswordCredentials {
205
214
  /**
206
- * The one-time password (OTP) that the user has received via email.
215
+ * A Base64-encoded hash of the password protecting the send.
207
216
  */
208
- otp: string;
217
+ passwordHashB64: string;
209
218
  }
210
219
 
211
220
  /**
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.
221
+ * Credentials for getting a send access token using an email and OTP.
214
222
  */
215
- export interface SendEmailCredentials {
223
+ export interface SendEmailOtpCredentials {
216
224
  /**
217
225
  * The email address to which the OTP will be sent.
218
226
  */
219
227
  email: string;
228
+ /**
229
+ * The one-time password (OTP) that the user has received via email.
230
+ */
231
+ otp: string;
220
232
  }
221
233
 
222
234
  /**
@@ -233,18 +245,6 @@ export interface SendAccessTokenRequest {
233
245
  sendAccessCredentials?: SendAccessCredentials;
234
246
  }
235
247
 
236
- /**
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
248
  /**
249
249
  * The credentials used for send access requests.
250
250
  */
@@ -253,16 +253,6 @@ export type SendAccessCredentials =
253
253
  | SendEmailOtpCredentials
254
254
  | SendEmailCredentials;
255
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
256
  /**
267
257
  * A send access token which can be used to access a send.
268
258
  */
@@ -286,15 +276,14 @@ export type SendAccessTokenError =
286
276
  | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
287
277
 
288
278
  /**
289
- * Invalid grant errors - typically due to invalid credentials.
279
+ * Any unexpected error that occurs when making requests to identity. This could be
280
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
281
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
282
+ * unexpected body or status. Used when decoding the server\'s error payload into
283
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
284
+ * available.
290
285
  */
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";
286
+ export type UnexpectedIdentityError = string;
298
287
 
299
288
  /**
300
289
  * Invalid request errors - typically due to missing parameters.
@@ -327,9 +316,15 @@ export type SendAccessTokenApiErrorResponse =
327
316
  | { error: "invalid_target"; error_description?: string };
328
317
 
329
318
  /**
330
- * Type of collection
319
+ * Invalid grant errors - typically due to invalid credentials.
331
320
  */
332
- export type CollectionType = "SharedCollection" | "DefaultUserCollection";
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;
@@ -354,6 +349,11 @@ export interface Collection {
354
349
  type: CollectionType;
355
350
  }
356
351
 
352
+ /**
353
+ * Type of collection
354
+ */
355
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
356
+
357
357
  /**
358
358
  * NewType wrapper for `CollectionId`
359
359
  */
@@ -368,18 +368,6 @@ export function isCollectionDecryptError(error: any): error is CollectionDecrypt
368
368
 
369
369
  export type SignedSecurityState = string;
370
370
 
371
- export interface MasterPasswordError extends Error {
372
- name: "MasterPasswordError";
373
- variant:
374
- | "EncryptionKeyMalformed"
375
- | "KdfMalformed"
376
- | "InvalidKdfConfiguration"
377
- | "MissingField"
378
- | "Crypto";
379
- }
380
-
381
- export function isMasterPasswordError(error: any): error is MasterPasswordError;
382
-
383
371
  /**
384
372
  * Represents the data required to unlock with the master password.
385
373
  */
@@ -398,6 +386,18 @@ export interface MasterPasswordUnlockData {
398
386
  salt: string;
399
387
  }
400
388
 
389
+ export interface MasterPasswordError extends Error {
390
+ name: "MasterPasswordError";
391
+ variant:
392
+ | "EncryptionKeyMalformed"
393
+ | "KdfMalformed"
394
+ | "InvalidKdfConfiguration"
395
+ | "MissingField"
396
+ | "Crypto";
397
+ }
398
+
399
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
400
+
401
401
  /**
402
402
  * Represents the data required to authenticate with the master password.
403
403
  */
@@ -444,51 +444,19 @@ export interface CryptoClientError extends Error {
444
444
 
445
445
  export function isCryptoClientError(error: any): error is CryptoClientError;
446
446
 
447
- /**
448
- * Response for `verify_asymmetric_keys`.
449
- */
450
- export interface VerifyAsymmetricKeysResponse {
451
- /**
452
- * Whether the user\'s private key was decryptable by the user key.
453
- */
454
- privateKeyDecryptable: boolean;
455
- /**
456
- * Whether the user\'s private key was a valid RSA key and matched the public key provided.
457
- */
458
- validPrivateKey: boolean;
447
+ export interface EnrollAdminPasswordResetError extends Error {
448
+ name: "EnrollAdminPasswordResetError";
449
+ variant: "Crypto";
459
450
  }
460
451
 
461
- /**
462
- * Request for deriving a pin protected user key
463
- */
464
- export interface EnrollPinResponse {
465
- /**
466
- * [UserKey] protected by PIN
467
- */
468
- pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
469
- /**
470
- * PIN protected by [UserKey]
471
- */
472
- userKeyEncryptedPin: EncString;
473
- }
452
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
474
453
 
475
454
  /**
476
- * Request for `verify_asymmetric_keys`.
455
+ * Auth requests supports multiple initialization methods.
477
456
  */
478
- export interface VerifyAsymmetricKeysRequest {
479
- /**
480
- * The user\'s user key
481
- */
482
- userKey: B64;
483
- /**
484
- * The user\'s public key
485
- */
486
- userPublicKey: B64;
487
- /**
488
- * User\'s private key, encrypted with the user key
489
- */
490
- userKeyEncryptedPrivateKey: EncString;
491
- }
457
+ export type AuthRequestMethod =
458
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
459
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
492
460
 
493
461
  /**
494
462
  * Represents the request to initialize the user\'s organizational cryptographic state.
@@ -500,20 +468,6 @@ export interface InitOrgCryptoRequest {
500
468
  organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
501
469
  }
502
470
 
503
- /**
504
- * Response from the `make_update_password` function
505
- */
506
- export interface UpdatePasswordResponse {
507
- /**
508
- * Hash of the new password
509
- */
510
- passwordHash: B64;
511
- /**
512
- * User key, encrypted with the new password
513
- */
514
- newKey: EncString;
515
- }
516
-
517
471
  /**
518
472
  * The crypto method used to initialize the user cryptographic state.
519
473
  */
@@ -533,6 +487,59 @@ export type InitUserCryptoMethod =
533
487
  }
534
488
  | { keyConnector: { master_key: B64; user_key: EncString } };
535
489
 
490
+ /**
491
+ * Response from the `make_update_password` function
492
+ */
493
+ export interface UpdatePasswordResponse {
494
+ /**
495
+ * Hash of the new password
496
+ */
497
+ passwordHash: B64;
498
+ /**
499
+ * User key, encrypted with the new password
500
+ */
501
+ newKey: EncString;
502
+ }
503
+
504
+ /**
505
+ * Response from the `update_kdf` function
506
+ */
507
+ export interface UpdateKdfResponse {
508
+ /**
509
+ * The authentication data for the new KDF setting
510
+ */
511
+ masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
512
+ /**
513
+ * The unlock data for the new KDF setting
514
+ */
515
+ masterPasswordUnlockData: MasterPasswordUnlockData;
516
+ /**
517
+ * The authentication data for the KDF setting prior to the change
518
+ */
519
+ oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
520
+ }
521
+
522
+ export interface DeriveKeyConnectorError extends Error {
523
+ name: "DeriveKeyConnectorError";
524
+ variant: "WrongPassword" | "Crypto";
525
+ }
526
+
527
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
528
+
529
+ /**
530
+ * Request for deriving a pin protected user key
531
+ */
532
+ export interface EnrollPinResponse {
533
+ /**
534
+ * [UserKey] protected by PIN
535
+ */
536
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
537
+ /**
538
+ * PIN protected by [UserKey]
539
+ */
540
+ userKeyEncryptedPin: EncString;
541
+ }
542
+
536
543
  /**
537
544
  * Request for migrating an account from password to key connector.
538
545
  */
@@ -556,36 +563,13 @@ export interface DeriveKeyConnectorRequest {
556
563
  }
557
564
 
558
565
  /**
559
- * State used for initializing the user cryptographic state.
566
+ * Request for `verify_asymmetric_keys`.
560
567
  */
561
- export interface InitUserCryptoRequest {
568
+ export interface VerifyAsymmetricKeysRequest {
562
569
  /**
563
- * The user\'s ID.
570
+ * The user\'s user key
564
571
  */
565
- userId: UserId | undefined;
566
- /**
567
- * The user\'s KDF parameters, as received from the prelogin request
568
- */
569
- kdfParams: Kdf;
570
- /**
571
- * The user\'s email address
572
- */
573
- email: string;
574
- /**
575
- * The user\'s account cryptographic state, containing their signature and
576
- * public-key-encryption keys, along with the signed security state, protected by the user key
577
- */
578
- accountCryptographicState: WrappedAccountCryptographicState;
579
- /**
580
- * The method to decrypt the user\'s account symmetric key (user key)
581
- */
582
- method: InitUserCryptoMethod;
583
- }
584
-
585
- /**
586
- * Response from the `make_key_pair` function
587
- */
588
- export interface MakeKeyPairResponse {
572
+ userKey: B64;
589
573
  /**
590
574
  * The user\'s public key
591
575
  */
@@ -597,42 +581,31 @@ export interface MakeKeyPairResponse {
597
581
  }
598
582
 
599
583
  /**
600
- * Auth requests supports multiple initialization methods.
584
+ * Response for `verify_asymmetric_keys`.
601
585
  */
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;
612
-
613
- export interface EnrollAdminPasswordResetError extends Error {
614
- name: "EnrollAdminPasswordResetError";
615
- variant: "Crypto";
586
+ export interface VerifyAsymmetricKeysResponse {
587
+ /**
588
+ * Whether the user\'s private key was decryptable by the user key.
589
+ */
590
+ privateKeyDecryptable: boolean;
591
+ /**
592
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
593
+ */
594
+ validPrivateKey: boolean;
616
595
  }
617
596
 
618
- export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
619
-
620
597
  /**
621
- * Response from the `update_kdf` function
598
+ * Request for deriving a pin protected user key
622
599
  */
623
- export interface UpdateKdfResponse {
624
- /**
625
- * The authentication data for the new KDF setting
626
- */
627
- masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
600
+ export interface DerivePinKeyResponse {
628
601
  /**
629
- * The unlock data for the new KDF setting
602
+ * [UserKey] protected by PIN
630
603
  */
631
- masterPasswordUnlockData: MasterPasswordUnlockData;
604
+ pinProtectedUserKey: EncString;
632
605
  /**
633
- * The authentication data for the KDF setting prior to the change
606
+ * PIN protected by [UserKey]
634
607
  */
635
- oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
608
+ encryptedPin: EncString;
636
609
  }
637
610
 
638
611
  /**
@@ -674,29 +647,56 @@ export interface UserCryptoV2KeysResponse {
674
647
  }
675
648
 
676
649
  /**
677
- * Request for deriving a pin protected user key
650
+ * State used for initializing the user cryptographic state.
678
651
  */
679
- export interface DerivePinKeyResponse {
652
+ export interface InitUserCryptoRequest {
680
653
  /**
681
- * [UserKey] protected by PIN
654
+ * The user\'s ID.
682
655
  */
683
- pinProtectedUserKey: EncString;
656
+ userId: UserId | undefined;
684
657
  /**
685
- * PIN protected by [UserKey]
658
+ * The user\'s KDF parameters, as received from the prelogin request
686
659
  */
687
- encryptedPin: EncString;
660
+ kdfParams: Kdf;
661
+ /**
662
+ * The user\'s email address
663
+ */
664
+ email: string;
665
+ /**
666
+ * The user\'s account cryptographic state, containing their signature and
667
+ * public-key-encryption keys, along with the signed security state, protected by the user key
668
+ */
669
+ accountCryptographicState: WrappedAccountCryptographicState;
670
+ /**
671
+ * The method to decrypt the user\'s account symmetric key (user key)
672
+ */
673
+ method: InitUserCryptoMethod;
688
674
  }
689
675
 
690
676
  /**
691
- * NewType wrapper for `OrganizationId`
677
+ * Response from the `make_key_pair` function
692
678
  */
693
- export type OrganizationId = Tagged<Uuid, "OrganizationId">;
679
+ export interface MakeKeyPairResponse {
680
+ /**
681
+ * The user\'s public key
682
+ */
683
+ userPublicKey: B64;
684
+ /**
685
+ * User\'s private key, encrypted with the user key
686
+ */
687
+ userKeyEncryptedPrivateKey: EncString;
688
+ }
694
689
 
695
690
  /**
696
691
  * NewType wrapper for `UserId`
697
692
  */
698
693
  export type UserId = Tagged<Uuid, "UserId">;
699
694
 
695
+ /**
696
+ * NewType wrapper for `OrganizationId`
697
+ */
698
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
699
+
700
700
  export interface StatefulCryptoError extends Error {
701
701
  name: "StatefulCryptoError";
702
702
  variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
@@ -905,8 +905,6 @@ export interface ExportError extends Error {
905
905
 
906
906
  export function isExportError(error: any): error is ExportError;
907
907
 
908
- export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
909
-
910
908
  /**
911
909
  * Passphrase generator request options.
912
910
  */
@@ -931,6 +929,8 @@ export interface PassphraseGeneratorRequest {
931
929
  includeNumber: boolean;
932
930
  }
933
931
 
932
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
933
+
934
934
  export interface PasswordError extends Error {
935
935
  name: "PasswordError";
936
936
  variant: "NoCharacterSetEnabled" | "InvalidLength";
@@ -990,14 +990,21 @@ export interface PasswordGeneratorRequest {
990
990
  minSpecial: number | undefined;
991
991
  }
992
992
 
993
+ export type AppendType = "random" | { websiteName: { website: string } };
994
+
995
+ export interface UsernameError extends Error {
996
+ name: "UsernameError";
997
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
998
+ }
999
+
1000
+ export function isUsernameError(error: any): error is UsernameError;
1001
+
993
1002
  export type UsernameGeneratorRequest =
994
1003
  | { word: { capitalize: boolean; include_number: boolean } }
995
1004
  | { subaddress: { type: AppendType; email: string } }
996
1005
  | { catchall: { type: AppendType; domain: string } }
997
1006
  | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
998
1007
 
999
- export type AppendType = "random" | { websiteName: { website: string } };
1000
-
1001
1008
  /**
1002
1009
  * Configures the email forwarding service to use.
1003
1010
  * For instructions on how to configure each service, see the documentation:
@@ -1011,13 +1018,6 @@ export type ForwarderServiceType =
1011
1018
  | { forwardEmail: { api_token: string; domain: string } }
1012
1019
  | { simpleLogin: { api_key: string; base_url: string } };
1013
1020
 
1014
- export interface UsernameError extends Error {
1015
- name: "UsernameError";
1016
- variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
1017
- }
1018
-
1019
- export function isUsernameError(error: any): error is UsernameError;
1020
-
1021
1021
  export interface RequestError extends Error {
1022
1022
  name: "RequestError";
1023
1023
  variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
@@ -1079,13 +1079,6 @@ export type Endpoint =
1079
1079
  | "DesktopRenderer"
1080
1080
  | "DesktopMain";
1081
1081
 
1082
- export interface SshKeyExportError extends Error {
1083
- name: "SshKeyExportError";
1084
- variant: "KeyConversion";
1085
- }
1086
-
1087
- export function isSshKeyExportError(error: any): error is SshKeyExportError;
1088
-
1089
1082
  export interface KeyGenerationError extends Error {
1090
1083
  name: "KeyGenerationError";
1091
1084
  variant: "KeyGeneration" | "KeyConversion";
@@ -1093,6 +1086,13 @@ export interface KeyGenerationError extends Error {
1093
1086
 
1094
1087
  export function isKeyGenerationError(error: any): error is KeyGenerationError;
1095
1088
 
1089
+ export interface SshKeyExportError extends Error {
1090
+ name: "SshKeyExportError";
1091
+ variant: "KeyConversion";
1092
+ }
1093
+
1094
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1095
+
1096
1096
  export interface SshKeyImportError extends Error {
1097
1097
  name: "SshKeyImportError";
1098
1098
  variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
@@ -1129,6 +1129,33 @@ export interface CipherRiskError extends Error {
1129
1129
 
1130
1130
  export function isCipherRiskError(error: any): error is CipherRiskError;
1131
1131
 
1132
+ /**
1133
+ * Risk evaluation result for a single cipher.
1134
+ */
1135
+ export interface CipherRiskResult {
1136
+ /**
1137
+ * Cipher ID matching the input CipherLoginDetails.
1138
+ */
1139
+ id: CipherId;
1140
+ /**
1141
+ * Password strength score from 0 (weakest) to 4 (strongest).
1142
+ * Calculated using zxcvbn with cipher-specific context.
1143
+ */
1144
+ password_strength: number;
1145
+ /**
1146
+ * Result of checking password exposure via HIBP API.
1147
+ * - `NotChecked`: check_exposed was false, or password was empty
1148
+ * - `Found(n)`: Successfully checked, found in n breaches
1149
+ * - `Error(msg)`: HIBP API request failed for this cipher with the given error message
1150
+ */
1151
+ exposed_result: ExposedPasswordResult;
1152
+ /**
1153
+ * Number of times this password appears in the provided password_map.
1154
+ * None if not found or if no password_map was provided.
1155
+ */
1156
+ reuse_count: number | undefined;
1157
+ }
1158
+
1132
1159
  /**
1133
1160
  * Login cipher data needed for risk evaluation.
1134
1161
  */
@@ -1152,6 +1179,14 @@ export interface CipherLoginDetails {
1152
1179
  */
1153
1180
  export type PasswordReuseMap = Record<string, number>;
1154
1181
 
1182
+ /**
1183
+ * Result of checking password exposure via HIBP API.
1184
+ */
1185
+ export type ExposedPasswordResult =
1186
+ | { type: "NotChecked" }
1187
+ | { type: "Found"; value: number }
1188
+ | { type: "Error"; value: string };
1189
+
1155
1190
  /**
1156
1191
  * Options for configuring risk computation.
1157
1192
  */
@@ -1173,39 +1208,9 @@ export interface CipherRiskOptions {
1173
1208
  hibpBaseUrl?: string | undefined;
1174
1209
  }
1175
1210
 
1176
- /**
1177
- * Result of checking password exposure via HIBP API.
1178
- */
1179
- export type ExposedPasswordResult =
1180
- | { type: "NotChecked" }
1181
- | { type: "Found"; value: number }
1182
- | { type: "Error"; value: string };
1183
-
1184
- /**
1185
- * Risk evaluation result for a single cipher.
1186
- */
1187
- export interface CipherRiskResult {
1188
- /**
1189
- * Cipher ID matching the input CipherLoginDetails.
1190
- */
1191
- id: CipherId;
1192
- /**
1193
- * Password strength score from 0 (weakest) to 4 (strongest).
1194
- * Calculated using zxcvbn with cipher-specific context.
1195
- */
1196
- password_strength: number;
1197
- /**
1198
- * Result of checking password exposure via HIBP API.
1199
- * - `NotChecked`: check_exposed was false, or password was empty
1200
- * - `Found(n)`: Successfully checked, found in n breaches
1201
- * - `Error(msg)`: HIBP API request failed for this cipher with the given error message
1202
- */
1203
- exposed_result: ExposedPasswordResult;
1204
- /**
1205
- * Number of times this password appears in the provided password_map.
1206
- * None if not found or if no password_map was provided.
1207
- */
1208
- reuse_count: number | undefined;
1211
+ export interface PasswordHistory {
1212
+ password: EncString;
1213
+ lastUsedDate: DateTime<Utc>;
1209
1214
  }
1210
1215
 
1211
1216
  export interface PasswordHistoryView {
@@ -1213,15 +1218,17 @@ export interface PasswordHistoryView {
1213
1218
  lastUsedDate: DateTime<Utc>;
1214
1219
  }
1215
1220
 
1216
- export interface PasswordHistory {
1217
- password: EncString;
1218
- lastUsedDate: DateTime<Utc>;
1219
- }
1220
-
1221
1221
  export interface AncestorMap {
1222
1222
  ancestors: Map<CollectionId, string>;
1223
1223
  }
1224
1224
 
1225
+ export interface TotpError extends Error {
1226
+ name: "TotpError";
1227
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1228
+ }
1229
+
1230
+ export function isTotpError(error: any): error is TotpError;
1231
+
1225
1232
  export interface TotpResponse {
1226
1233
  /**
1227
1234
  * Generated TOTP code
@@ -1233,12 +1240,12 @@ export interface TotpResponse {
1233
1240
  period: number;
1234
1241
  }
1235
1242
 
1236
- export interface TotpError extends Error {
1237
- name: "TotpError";
1238
- variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1243
+ export interface DecryptError extends Error {
1244
+ name: "DecryptError";
1245
+ variant: "Crypto";
1239
1246
  }
1240
1247
 
1241
- export function isTotpError(error: any): error is TotpError;
1248
+ export function isDecryptError(error: any): error is DecryptError;
1242
1249
 
1243
1250
  export interface EncryptError extends Error {
1244
1251
  name: "EncryptError";
@@ -1247,13 +1254,6 @@ 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";
1253
- }
1254
-
1255
- export function isDecryptError(error: any): error is DecryptError;
1256
-
1257
1257
  export interface AttachmentView {
1258
1258
  id: string | undefined;
1259
1259
  url: string | undefined;
@@ -1288,12 +1288,12 @@ export interface Attachment {
1288
1288
  key: EncString | undefined;
1289
1289
  }
1290
1290
 
1291
- export interface LocalDataView {
1291
+ export interface LocalData {
1292
1292
  lastUsedDate: DateTime<Utc> | undefined;
1293
1293
  lastLaunched: DateTime<Utc> | undefined;
1294
1294
  }
1295
1295
 
1296
- export interface LocalData {
1296
+ export interface LocalDataView {
1297
1297
  lastUsedDate: DateTime<Utc> | undefined;
1298
1298
  lastLaunched: DateTime<Utc> | undefined;
1299
1299
  }
@@ -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,7 +1361,14 @@ export interface CipherCreateRequest {
1368
1361
  fields: FieldView[];
1369
1362
  }
1370
1363
 
1371
- /**
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
+ /**
1372
1372
  * Represents the inner data of a cipher view.
1373
1373
  */
1374
1374
  export type CipherViewType =
@@ -1397,6 +1397,15 @@ export interface CipherPermissions {
1397
1397
  restore: boolean;
1398
1398
  }
1399
1399
 
1400
+ export interface CardView {
1401
+ cardholderName: string | undefined;
1402
+ expMonth: string | undefined;
1403
+ expYear: string | undefined;
1404
+ code: string | undefined;
1405
+ brand: string | undefined;
1406
+ number: string | undefined;
1407
+ }
1408
+
1400
1409
  /**
1401
1410
  * Minimal CardView only including the needed details for list views
1402
1411
  */
@@ -1416,15 +1425,6 @@ export interface Card {
1416
1425
  number: EncString | undefined;
1417
1426
  }
1418
1427
 
1419
- export interface CardView {
1420
- cardholderName: string | undefined;
1421
- expMonth: string | undefined;
1422
- expYear: string | undefined;
1423
- code: string | undefined;
1424
- brand: string | undefined;
1425
- number: string | undefined;
1426
- }
1427
-
1428
1428
  export interface Field {
1429
1429
  name: EncString | undefined;
1430
1430
  value: EncString | undefined;
@@ -1439,22 +1439,21 @@ 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
1442
  export interface LoginUri {
1453
1443
  uri: EncString | undefined;
1454
1444
  match: UriMatchType | undefined;
1455
1445
  uriChecksum: EncString | undefined;
1456
1446
  }
1457
1447
 
1448
+ export interface Fido2CredentialListView {
1449
+ credentialId: string;
1450
+ rpId: string;
1451
+ userHandle: string | undefined;
1452
+ userName: string | undefined;
1453
+ userDisplayName: string | undefined;
1454
+ counter: string;
1455
+ }
1456
+
1458
1457
  export interface Fido2CredentialFullView {
1459
1458
  credentialId: string;
1460
1459
  keyType: string;
@@ -1471,6 +1470,12 @@ export interface Fido2CredentialFullView {
1471
1470
  creationDate: DateTime<Utc>;
1472
1471
  }
1473
1472
 
1473
+ export interface LoginUriView {
1474
+ uri: string | undefined;
1475
+ match: UriMatchType | undefined;
1476
+ uriChecksum: string | undefined;
1477
+ }
1478
+
1474
1479
  export interface LoginListView {
1475
1480
  fido2Credentials: Fido2CredentialListView[] | undefined;
1476
1481
  hasFido2: boolean;
@@ -1482,17 +1487,19 @@ export interface LoginListView {
1482
1487
  uris: LoginUriView[] | undefined;
1483
1488
  }
1484
1489
 
1485
- export interface Fido2CredentialNewView {
1490
+ export interface Fido2CredentialView {
1486
1491
  credentialId: string;
1487
1492
  keyType: string;
1488
1493
  keyAlgorithm: string;
1489
1494
  keyCurve: string;
1495
+ keyValue: EncString;
1490
1496
  rpId: string;
1491
1497
  userHandle: string | undefined;
1492
1498
  userName: string | undefined;
1493
1499
  counter: string;
1494
1500
  rpName: string | undefined;
1495
1501
  userDisplayName: string | undefined;
1502
+ discoverable: string;
1496
1503
  creationDate: DateTime<Utc>;
1497
1504
  }
1498
1505
 
@@ -1506,19 +1513,28 @@ export interface LoginView {
1506
1513
  fido2Credentials: Fido2Credential[] | undefined;
1507
1514
  }
1508
1515
 
1509
- export interface Fido2CredentialListView {
1516
+ export interface Fido2CredentialNewView {
1510
1517
  credentialId: string;
1518
+ keyType: string;
1519
+ keyAlgorithm: string;
1520
+ keyCurve: string;
1511
1521
  rpId: string;
1512
1522
  userHandle: string | undefined;
1513
1523
  userName: string | undefined;
1514
- userDisplayName: string | undefined;
1515
1524
  counter: string;
1525
+ rpName: string | undefined;
1526
+ userDisplayName: string | undefined;
1527
+ creationDate: DateTime<Utc>;
1516
1528
  }
1517
1529
 
1518
- export interface LoginUriView {
1519
- uri: string | undefined;
1520
- match: UriMatchType | undefined;
1521
- uriChecksum: string | undefined;
1530
+ export interface Login {
1531
+ username: EncString | undefined;
1532
+ password: EncString | undefined;
1533
+ passwordRevisionDate: DateTime<Utc> | undefined;
1534
+ uris: LoginUri[] | undefined;
1535
+ totp: EncString | undefined;
1536
+ autofillOnPageLoad: boolean | undefined;
1537
+ fido2Credentials: Fido2Credential[] | undefined;
1522
1538
  }
1523
1539
 
1524
1540
  export interface Fido2Credential {
@@ -1537,27 +1553,46 @@ export interface Fido2Credential {
1537
1553
  creationDate: DateTime<Utc>;
1538
1554
  }
1539
1555
 
1540
- export interface Fido2CredentialView {
1541
- credentialId: string;
1542
- keyType: string;
1543
- keyAlgorithm: string;
1544
- keyCurve: string;
1545
- keyValue: EncString;
1546
- rpId: string;
1547
- userHandle: string | undefined;
1548
- userName: string | undefined;
1549
- counter: string;
1550
- rpName: string | undefined;
1551
- userDisplayName: string | undefined;
1552
- discoverable: string;
1553
- creationDate: DateTime<Utc>;
1554
- }
1555
-
1556
1556
  /**
1557
1557
  * NewType wrapper for `CipherId`
1558
1558
  */
1559
1559
  export type CipherId = Tagged<Uuid, "CipherId">;
1560
1560
 
1561
+ export interface Cipher {
1562
+ id: CipherId | undefined;
1563
+ organizationId: OrganizationId | undefined;
1564
+ folderId: FolderId | undefined;
1565
+ collectionIds: CollectionId[];
1566
+ /**
1567
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1568
+ * Cipher.
1569
+ */
1570
+ key: EncString | undefined;
1571
+ name: EncString;
1572
+ notes: EncString | undefined;
1573
+ type: CipherType;
1574
+ login: Login | undefined;
1575
+ identity: Identity | undefined;
1576
+ card: Card | undefined;
1577
+ secureNote: SecureNote | undefined;
1578
+ sshKey: SshKey | undefined;
1579
+ favorite: boolean;
1580
+ reprompt: CipherRepromptType;
1581
+ organizationUseTotp: boolean;
1582
+ edit: boolean;
1583
+ permissions: CipherPermissions | undefined;
1584
+ viewPassword: boolean;
1585
+ localData: LocalData | undefined;
1586
+ attachments: Attachment[] | undefined;
1587
+ fields: Field[] | undefined;
1588
+ passwordHistory: PasswordHistory[] | undefined;
1589
+ creationDate: DateTime<Utc>;
1590
+ deletedDate: DateTime<Utc> | undefined;
1591
+ revisionDate: DateTime<Utc>;
1592
+ archivedDate: DateTime<Utc> | undefined;
1593
+ data: string | undefined;
1594
+ }
1595
+
1561
1596
  /**
1562
1597
  * Represents the result of decrypting a list of ciphers.
1563
1598
  *
@@ -1576,6 +1611,33 @@ export interface DecryptCipherListResult {
1576
1611
  failures: Cipher[];
1577
1612
  }
1578
1613
 
1614
+ export interface CipherError extends Error {
1615
+ name: "CipherError";
1616
+ variant:
1617
+ | "MissingField"
1618
+ | "Crypto"
1619
+ | "Decrypt"
1620
+ | "Encrypt"
1621
+ | "AttachmentsWithoutKeys"
1622
+ | "OrganizationAlreadySet"
1623
+ | "PutShare"
1624
+ | "PutShareMany"
1625
+ | "Repository"
1626
+ | "Chrono"
1627
+ | "SerdeJson";
1628
+ }
1629
+
1630
+ export function isCipherError(error: any): error is CipherError;
1631
+
1632
+ export interface EncryptionContext {
1633
+ /**
1634
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1635
+ * Organization-owned ciphers
1636
+ */
1637
+ encryptedFor: UserId;
1638
+ cipher: Cipher;
1639
+ }
1640
+
1579
1641
  export type CipherListViewType =
1580
1642
  | { login: LoginListView }
1581
1643
  | "secureNote"
@@ -1620,22 +1682,6 @@ export interface CipherListView {
1620
1682
  localData: LocalDataView | undefined;
1621
1683
  }
1622
1684
 
1623
- /**
1624
- * Available fields on a cipher and can be copied from a the list view in the UI.
1625
- */
1626
- export type CopyableCipherFields =
1627
- | "LoginUsername"
1628
- | "LoginPassword"
1629
- | "LoginTotp"
1630
- | "CardNumber"
1631
- | "CardSecurityCode"
1632
- | "IdentityUsername"
1633
- | "IdentityEmail"
1634
- | "IdentityPhone"
1635
- | "IdentityAddress"
1636
- | "SshKey"
1637
- | "SecureNotes";
1638
-
1639
1685
  export interface CipherView {
1640
1686
  id: CipherId | undefined;
1641
1687
  organizationId: OrganizationId | undefined;
@@ -1669,67 +1715,21 @@ export interface CipherView {
1669
1715
  archivedDate: DateTime<Utc> | undefined;
1670
1716
  }
1671
1717
 
1672
- export interface EncryptionContext {
1673
- /**
1674
- * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1675
- * Organization-owned ciphers
1676
- */
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";
1695
- }
1696
-
1697
- export function isCipherError(error: any): error is CipherError;
1698
-
1699
- export interface Cipher {
1700
- id: CipherId | undefined;
1701
- organizationId: OrganizationId | undefined;
1702
- folderId: FolderId | undefined;
1703
- collectionIds: CollectionId[];
1704
- /**
1705
- * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1706
- * Cipher.
1707
- */
1708
- key: EncString | undefined;
1709
- name: EncString;
1710
- notes: EncString | undefined;
1711
- type: CipherType;
1712
- login: Login | undefined;
1713
- identity: Identity | undefined;
1714
- card: Card | undefined;
1715
- secureNote: SecureNote | undefined;
1716
- sshKey: SshKey | undefined;
1717
- favorite: boolean;
1718
- reprompt: CipherRepromptType;
1719
- organizationUseTotp: boolean;
1720
- edit: boolean;
1721
- permissions: CipherPermissions | undefined;
1722
- viewPassword: boolean;
1723
- localData: LocalData | undefined;
1724
- attachments: Attachment[] | undefined;
1725
- fields: Field[] | undefined;
1726
- passwordHistory: PasswordHistory[] | undefined;
1727
- creationDate: DateTime<Utc>;
1728
- deletedDate: DateTime<Utc> | undefined;
1729
- revisionDate: DateTime<Utc>;
1730
- archivedDate: DateTime<Utc> | undefined;
1731
- data: string | undefined;
1732
- }
1718
+ /**
1719
+ * Available fields on a cipher and can be copied from a the list view in the UI.
1720
+ */
1721
+ export type CopyableCipherFields =
1722
+ | "LoginUsername"
1723
+ | "LoginPassword"
1724
+ | "LoginTotp"
1725
+ | "CardNumber"
1726
+ | "CardSecurityCode"
1727
+ | "IdentityUsername"
1728
+ | "IdentityEmail"
1729
+ | "IdentityPhone"
1730
+ | "IdentityAddress"
1731
+ | "SshKey"
1732
+ | "SecureNotes";
1733
1733
 
1734
1734
  export interface SshKeyView {
1735
1735
  /**
@@ -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: