@bitwarden/sdk-internal 0.2.0-main.420 → 0.2.0-main.421

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,5 +1,16 @@
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;
3
14
  /**
4
15
  * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
5
16
  * to an OpenSSH private key with public key and fingerprint
@@ -16,17 +27,6 @@
16
27
  * - `Err(UnsupportedKeyType)` if the key type is not supported
17
28
  */
18
29
  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,55 +180,43 @@ export interface TokenProvider {
180
180
  get_access_token(): Promise<string | undefined>;
181
181
  }
182
182
 
183
- export interface Repositories {
184
- cipher: Repository<Cipher> | null;
185
- folder: Repository<Folder> | null;
186
- }
187
-
188
183
  /**
189
184
  * Active feature flags for the SDK.
190
185
  */
191
186
  export interface FeatureFlags extends Map<string, boolean> {}
192
187
 
188
+ export interface Repositories {
189
+ cipher: Repository<Cipher> | null;
190
+ folder: Repository<Folder> | null;
191
+ }
192
+
193
193
  export interface IndexedDbConfiguration {
194
194
  db_name: string;
195
195
  }
196
196
 
197
197
  /**
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.
198
+ * Credentials for getting a send access token using an email and OTP.
200
199
  */
201
- export interface SendEmailCredentials {
200
+ export interface SendEmailOtpCredentials {
202
201
  /**
203
202
  * The email address to which the OTP will be sent.
204
203
  */
205
204
  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 {
214
205
  /**
215
- * A Base64-encoded hash of the password protecting the send.
206
+ * The one-time password (OTP) that the user has received via email.
216
207
  */
217
- passwordHashB64: string;
208
+ otp: string;
218
209
  }
219
210
 
220
211
  /**
221
- * Credentials for getting a send access token using an email and OTP.
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.
222
214
  */
223
- export interface SendEmailOtpCredentials {
215
+ export interface SendEmailCredentials {
224
216
  /**
225
217
  * The email address to which the OTP will be sent.
226
218
  */
227
219
  email: string;
228
- /**
229
- * The one-time password (OTP) that the user has received via email.
230
- */
231
- otp: string;
232
220
  }
233
221
 
234
222
  /**
@@ -245,6 +233,18 @@ export interface SendAccessTokenRequest {
245
233
  sendAccessCredentials?: SendAccessCredentials;
246
234
  }
247
235
 
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
  */
@@ -296,6 +296,16 @@ export type SendAccessTokenInvalidGrantError =
296
296
  | "otp_generation_failed"
297
297
  | "unknown";
298
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
+
299
309
  /**
300
310
  * Represents the possible, expected errors that can occur when requesting a send access token.
301
311
  */
@@ -317,48 +327,38 @@ export type SendAccessTokenApiErrorResponse =
317
327
  | { error: "invalid_target"; error_description?: string };
318
328
 
319
329
  /**
320
- * Invalid request errors - typically due to missing parameters.
330
+ * Type of collection
321
331
  */
322
- export type SendAccessTokenInvalidRequestError =
323
- | "send_id_required"
324
- | "password_hash_b64_required"
325
- | "email_required"
326
- | "email_and_otp_required_otp_sent"
327
- | "unknown";
332
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
328
333
 
329
- export interface Collection {
334
+ export interface CollectionView {
330
335
  id: CollectionId | undefined;
331
336
  organizationId: OrganizationId;
332
- name: EncString;
337
+ name: string;
333
338
  externalId: string | undefined;
334
339
  hidePasswords: boolean;
335
340
  readOnly: boolean;
336
341
  manage: boolean;
337
- defaultUserCollectionEmail: string | undefined;
338
342
  type: CollectionType;
339
343
  }
340
344
 
341
- /**
342
- * Type of collection
343
- */
344
- export type CollectionType = "SharedCollection" | "DefaultUserCollection";
345
-
346
- /**
347
- * NewType wrapper for `CollectionId`
348
- */
349
- export type CollectionId = Tagged<Uuid, "CollectionId">;
350
-
351
- export interface CollectionView {
345
+ export interface Collection {
352
346
  id: CollectionId | undefined;
353
347
  organizationId: OrganizationId;
354
- name: string;
348
+ name: EncString;
355
349
  externalId: string | undefined;
356
350
  hidePasswords: boolean;
357
351
  readOnly: boolean;
358
352
  manage: boolean;
353
+ defaultUserCollectionEmail: string | undefined;
359
354
  type: CollectionType;
360
355
  }
361
356
 
357
+ /**
358
+ * NewType wrapper for `CollectionId`
359
+ */
360
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
361
+
362
362
  export interface CollectionDecryptError extends Error {
363
363
  name: "CollectionDecryptError";
364
364
  variant: "Crypto";
@@ -368,15 +368,18 @@ export function isCollectionDecryptError(error: any): error is CollectionDecrypt
368
368
 
369
369
  export type SignedSecurityState = string;
370
370
 
371
- /**
372
- * Represents the data required to authenticate with the master password.
373
- */
374
- export interface MasterPasswordAuthenticationData {
375
- kdf: Kdf;
376
- salt: string;
377
- masterPasswordAuthenticationHash: B64;
371
+ export interface MasterPasswordError extends Error {
372
+ name: "MasterPasswordError";
373
+ variant:
374
+ | "EncryptionKeyMalformed"
375
+ | "KdfMalformed"
376
+ | "InvalidKdfConfiguration"
377
+ | "MissingField"
378
+ | "Crypto";
378
379
  }
379
380
 
381
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
382
+
380
383
  /**
381
384
  * Represents the data required to unlock with the master password.
382
385
  */
@@ -395,17 +398,29 @@ export interface MasterPasswordUnlockData {
395
398
  salt: string;
396
399
  }
397
400
 
398
- export interface MasterPasswordError extends Error {
399
- name: "MasterPasswordError";
400
- variant:
401
- | "EncryptionKeyMalformed"
402
- | "KdfMalformed"
403
- | "InvalidKdfConfiguration"
404
- | "MissingField"
405
- | "Crypto";
401
+ /**
402
+ * Represents the data required to authenticate with the master password.
403
+ */
404
+ export interface MasterPasswordAuthenticationData {
405
+ kdf: Kdf;
406
+ salt: string;
407
+ masterPasswordAuthenticationHash: B64;
406
408
  }
407
409
 
408
- export function isMasterPasswordError(error: any): error is MasterPasswordError;
410
+ /**
411
+ * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
412
+ * Private keys are protected by the user key.
413
+ */
414
+ export type WrappedAccountCryptographicState =
415
+ | { V1: { private_key: EncString } }
416
+ | {
417
+ V2: {
418
+ private_key: EncString;
419
+ signed_public_key: SignedPublicKey | undefined;
420
+ signing_key: EncString;
421
+ security_state: SignedSecurityState;
422
+ };
423
+ };
409
424
 
410
425
  export interface AccountCryptographyInitializationError extends Error {
411
426
  name: "AccountCryptographyInitializationError";
@@ -422,20 +437,12 @@ export function isAccountCryptographyInitializationError(
422
437
  error: any,
423
438
  ): error is AccountCryptographyInitializationError;
424
439
 
425
- /**
426
- * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
427
- * Private keys are protected by the user key.
428
- */
429
- export type WrappedAccountCryptographicState =
430
- | { V1: { private_key: EncString } }
431
- | {
432
- V2: {
433
- private_key: EncString;
434
- signed_public_key: SignedPublicKey | undefined;
435
- signing_key: EncString;
436
- security_state: SignedSecurityState;
437
- };
438
- };
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;
439
446
 
440
447
  /**
441
448
  * Response for `verify_asymmetric_keys`.
@@ -465,45 +472,46 @@ export interface EnrollPinResponse {
465
472
  userKeyEncryptedPin: EncString;
466
473
  }
467
474
 
468
- export interface DeriveKeyConnectorError extends Error {
469
- name: "DeriveKeyConnectorError";
470
- variant: "WrongPassword" | "Crypto";
471
- }
472
-
473
- export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
474
-
475
- export interface EnrollAdminPasswordResetError extends Error {
476
- name: "EnrollAdminPasswordResetError";
477
- variant: "Crypto";
478
- }
479
-
480
- export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
481
-
482
475
  /**
483
- * State used for initializing the user cryptographic state.
476
+ * Request for `verify_asymmetric_keys`.
484
477
  */
485
- export interface InitUserCryptoRequest {
478
+ export interface VerifyAsymmetricKeysRequest {
486
479
  /**
487
- * The user\'s ID.
480
+ * The user\'s user key
488
481
  */
489
- userId: UserId | undefined;
482
+ userKey: B64;
490
483
  /**
491
- * The user\'s KDF parameters, as received from the prelogin request
484
+ * The user\'s public key
492
485
  */
493
- kdfParams: Kdf;
486
+ userPublicKey: B64;
494
487
  /**
495
- * The user\'s email address
488
+ * User\'s private key, encrypted with the user key
496
489
  */
497
- email: string;
490
+ userKeyEncryptedPrivateKey: EncString;
491
+ }
492
+
493
+ /**
494
+ * Represents the request to initialize the user\'s organizational cryptographic state.
495
+ */
496
+ export interface InitOrgCryptoRequest {
498
497
  /**
499
- * The user\'s account cryptographic state, containing their signature and
500
- * public-key-encryption keys, along with the signed security state, protected by the user key
498
+ * The encryption keys for all the organizations the user is a part of
501
499
  */
502
- accountCryptographicState: WrappedAccountCryptographicState;
500
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
501
+ }
502
+
503
+ /**
504
+ * Response from the `make_update_password` function
505
+ */
506
+ export interface UpdatePasswordResponse {
503
507
  /**
504
- * The method to decrypt the user\'s account symmetric key (user key)
508
+ * Hash of the new password
505
509
  */
506
- method: InitUserCryptoMethod;
510
+ passwordHash: B64;
511
+ /**
512
+ * User key, encrypted with the new password
513
+ */
514
+ newKey: EncString;
507
515
  }
508
516
 
509
517
  /**
@@ -525,41 +533,90 @@ export type InitUserCryptoMethod =
525
533
  }
526
534
  | { keyConnector: { master_key: B64; user_key: EncString } };
527
535
 
528
- export interface CryptoClientError extends Error {
529
- name: "CryptoClientError";
530
- variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
531
- }
532
-
533
- export function isCryptoClientError(error: any): error is CryptoClientError;
534
-
535
536
  /**
536
- * Response from the `make_key_pair` function
537
+ * Request for migrating an account from password to key connector.
537
538
  */
538
- export interface MakeKeyPairResponse {
539
+ export interface DeriveKeyConnectorRequest {
539
540
  /**
540
- * The user\'s public key
541
+ * Encrypted user key, used to validate the master key
541
542
  */
542
- userPublicKey: B64;
543
+ userKeyEncrypted: EncString;
543
544
  /**
544
- * User\'s private key, encrypted with the user key
545
+ * The user\'s master password
545
546
  */
546
- userKeyEncryptedPrivateKey: EncString;
547
- }
548
-
547
+ password: string;
548
+ /**
549
+ * The KDF parameters used to derive the master key
550
+ */
551
+ kdf: Kdf;
552
+ /**
553
+ * The user\'s email address
554
+ */
555
+ email: string;
556
+ }
557
+
549
558
  /**
550
- * Response from the `make_update_password` function
559
+ * State used for initializing the user cryptographic state.
551
560
  */
552
- export interface UpdatePasswordResponse {
561
+ export interface InitUserCryptoRequest {
553
562
  /**
554
- * Hash of the new password
563
+ * The user\'s ID.
555
564
  */
556
- passwordHash: B64;
565
+ userId: UserId | undefined;
557
566
  /**
558
- * User key, encrypted with the new password
567
+ * The user\'s KDF parameters, as received from the prelogin request
559
568
  */
560
- newKey: EncString;
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 {
589
+ /**
590
+ * The user\'s public key
591
+ */
592
+ userPublicKey: B64;
593
+ /**
594
+ * User\'s private key, encrypted with the user key
595
+ */
596
+ userKeyEncryptedPrivateKey: EncString;
597
+ }
598
+
599
+ /**
600
+ * Auth requests supports multiple initialization methods.
601
+ */
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";
561
616
  }
562
617
 
618
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
619
+
563
620
  /**
564
621
  * Response from the `update_kdf` function
565
622
  */
@@ -616,13 +673,6 @@ export interface UserCryptoV2KeysResponse {
616
673
  securityVersion: number;
617
674
  }
618
675
 
619
- /**
620
- * Auth requests supports multiple initialization methods.
621
- */
622
- export type AuthRequestMethod =
623
- | { userKey: { protected_user_key: UnsignedSharedKey } }
624
- | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
625
-
626
676
  /**
627
677
  * Request for deriving a pin protected user key
628
678
  */
@@ -637,56 +687,6 @@ export interface DerivePinKeyResponse {
637
687
  encryptedPin: EncString;
638
688
  }
639
689
 
640
- /**
641
- * Represents the request to initialize the user\'s organizational cryptographic state.
642
- */
643
- export interface InitOrgCryptoRequest {
644
- /**
645
- * The encryption keys for all the organizations the user is a part of
646
- */
647
- organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
648
- }
649
-
650
- /**
651
- * Request for migrating an account from password to key connector.
652
- */
653
- export interface DeriveKeyConnectorRequest {
654
- /**
655
- * Encrypted user key, used to validate the master key
656
- */
657
- userKeyEncrypted: EncString;
658
- /**
659
- * The user\'s master password
660
- */
661
- password: string;
662
- /**
663
- * The KDF parameters used to derive the master key
664
- */
665
- kdf: Kdf;
666
- /**
667
- * The user\'s email address
668
- */
669
- email: string;
670
- }
671
-
672
- /**
673
- * Request for `verify_asymmetric_keys`.
674
- */
675
- export interface VerifyAsymmetricKeysRequest {
676
- /**
677
- * The user\'s user key
678
- */
679
- userKey: B64;
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
- }
689
-
690
690
  /**
691
691
  * NewType wrapper for `OrganizationId`
692
692
  */
@@ -963,20 +963,13 @@ export interface PasswordGeneratorRequest {
963
963
  minSpecial: number | undefined;
964
964
  }
965
965
 
966
- export type AppendType = "random" | { websiteName: { website: string } };
967
-
968
966
  export type UsernameGeneratorRequest =
969
967
  | { word: { capitalize: boolean; include_number: boolean } }
970
968
  | { subaddress: { type: AppendType; email: string } }
971
969
  | { catchall: { type: AppendType; domain: string } }
972
970
  | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
973
971
 
974
- export interface UsernameError extends Error {
975
- name: "UsernameError";
976
- variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
977
- }
978
-
979
- export function isUsernameError(error: any): error is UsernameError;
972
+ export type AppendType = "random" | { websiteName: { website: string } };
980
973
 
981
974
  /**
982
975
  * Configures the email forwarding service to use.
@@ -991,6 +984,13 @@ export type ForwarderServiceType =
991
984
  | { forwardEmail: { api_token: string; domain: string } }
992
985
  | { simpleLogin: { api_key: string; base_url: string } };
993
986
 
987
+ export interface UsernameError extends Error {
988
+ name: "UsernameError";
989
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
990
+ }
991
+
992
+ export function isUsernameError(error: any): error is UsernameError;
993
+
994
994
  export interface RequestError extends Error {
995
995
  name: "RequestError";
996
996
  variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
@@ -1052,6 +1052,13 @@ export type Endpoint =
1052
1052
  | "DesktopRenderer"
1053
1053
  | "DesktopMain";
1054
1054
 
1055
+ export interface SshKeyExportError extends Error {
1056
+ name: "SshKeyExportError";
1057
+ variant: "KeyConversion";
1058
+ }
1059
+
1060
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1061
+
1055
1062
  export interface KeyGenerationError extends Error {
1056
1063
  name: "KeyGenerationError";
1057
1064
  variant: "KeyGeneration" | "KeyConversion";
@@ -1066,13 +1073,6 @@ export interface SshKeyImportError extends Error {
1066
1073
 
1067
1074
  export function isSshKeyImportError(error: any): error is SshKeyImportError;
1068
1075
 
1069
- export interface SshKeyExportError extends Error {
1070
- name: "SshKeyExportError";
1071
- variant: "KeyConversion";
1072
- }
1073
-
1074
- export function isSshKeyExportError(error: any): error is SshKeyExportError;
1075
-
1076
1076
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
1077
1077
 
1078
1078
  export interface DatabaseError extends Error {
@@ -1103,12 +1103,22 @@ export interface CipherRiskError extends Error {
1103
1103
  export function isCipherRiskError(error: any): error is CipherRiskError;
1104
1104
 
1105
1105
  /**
1106
- * Result of checking password exposure via HIBP API.
1106
+ * Login cipher data needed for risk evaluation.
1107
1107
  */
1108
- export type ExposedPasswordResult =
1109
- | { type: "NotChecked" }
1110
- | { type: "Found"; value: number }
1111
- | { type: "Error"; value: string };
1108
+ export interface CipherLoginDetails {
1109
+ /**
1110
+ * Cipher ID to identify which cipher in results.
1111
+ */
1112
+ id: CipherId;
1113
+ /**
1114
+ * The decrypted password to evaluate.
1115
+ */
1116
+ password: string;
1117
+ /**
1118
+ * Username or email (login ciphers only have one field).
1119
+ */
1120
+ username: string | undefined;
1121
+ }
1112
1122
 
1113
1123
  /**
1114
1124
  * Password reuse map wrapper for WASM compatibility.
@@ -1137,22 +1147,12 @@ export interface CipherRiskOptions {
1137
1147
  }
1138
1148
 
1139
1149
  /**
1140
- * Login cipher data needed for risk evaluation.
1150
+ * Result of checking password exposure via HIBP API.
1141
1151
  */
1142
- export interface CipherLoginDetails {
1143
- /**
1144
- * Cipher ID to identify which cipher in results.
1145
- */
1146
- id: CipherId;
1147
- /**
1148
- * The decrypted password to evaluate.
1149
- */
1150
- password: string;
1151
- /**
1152
- * Username or email (login ciphers only have one field).
1153
- */
1154
- username: string | undefined;
1155
- }
1152
+ export type ExposedPasswordResult =
1153
+ | { type: "NotChecked" }
1154
+ | { type: "Found"; value: number }
1155
+ | { type: "Error"; value: string };
1156
1156
 
1157
1157
  /**
1158
1158
  * Risk evaluation result for a single cipher.
@@ -1195,13 +1195,6 @@ export interface AncestorMap {
1195
1195
  ancestors: Map<CollectionId, string>;
1196
1196
  }
1197
1197
 
1198
- export interface TotpError extends Error {
1199
- name: "TotpError";
1200
- variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1201
- }
1202
-
1203
- export function isTotpError(error: any): error is TotpError;
1204
-
1205
1198
  export interface TotpResponse {
1206
1199
  /**
1207
1200
  * Generated TOTP code
@@ -1213,12 +1206,12 @@ export interface TotpResponse {
1213
1206
  period: number;
1214
1207
  }
1215
1208
 
1216
- export interface DecryptError extends Error {
1217
- name: "DecryptError";
1218
- variant: "Crypto";
1209
+ export interface TotpError extends Error {
1210
+ name: "TotpError";
1211
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1219
1212
  }
1220
1213
 
1221
- export function isDecryptError(error: any): error is DecryptError;
1214
+ export function isTotpError(error: any): error is TotpError;
1222
1215
 
1223
1216
  export interface EncryptError extends Error {
1224
1217
  name: "EncryptError";
@@ -1227,18 +1220,13 @@ export interface EncryptError extends Error {
1227
1220
 
1228
1221
  export function isEncryptError(error: any): error is EncryptError;
1229
1222
 
1230
- export interface Attachment {
1231
- id: string | undefined;
1232
- url: string | undefined;
1233
- size: string | undefined;
1234
- /**
1235
- * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1236
- */
1237
- sizeName: string | undefined;
1238
- fileName: EncString | undefined;
1239
- key: EncString | undefined;
1223
+ export interface DecryptError extends Error {
1224
+ name: "DecryptError";
1225
+ variant: "Crypto";
1240
1226
  }
1241
1227
 
1228
+ export function isDecryptError(error: any): error is DecryptError;
1229
+
1242
1230
  export interface AttachmentView {
1243
1231
  id: string | undefined;
1244
1232
  url: string | undefined;
@@ -1261,12 +1249,24 @@ export interface AttachmentView {
1261
1249
  decryptedKey: string | undefined;
1262
1250
  }
1263
1251
 
1264
- export interface LocalData {
1252
+ export interface Attachment {
1253
+ id: string | undefined;
1254
+ url: string | undefined;
1255
+ size: string | undefined;
1256
+ /**
1257
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1258
+ */
1259
+ sizeName: string | undefined;
1260
+ fileName: EncString | undefined;
1261
+ key: EncString | undefined;
1262
+ }
1263
+
1264
+ export interface LocalDataView {
1265
1265
  lastUsedDate: DateTime<Utc> | undefined;
1266
1266
  lastLaunched: DateTime<Utc> | undefined;
1267
1267
  }
1268
1268
 
1269
- export interface LocalDataView {
1269
+ export interface LocalData {
1270
1270
  lastUsedDate: DateTime<Utc> | undefined;
1271
1271
  lastLaunched: DateTime<Utc> | undefined;
1272
1272
  }
@@ -1320,6 +1320,13 @@ export interface CipherEditRequest {
1320
1320
  key: EncString | undefined;
1321
1321
  }
1322
1322
 
1323
+ export interface CreateCipherError extends Error {
1324
+ name: "CreateCipherError";
1325
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1326
+ }
1327
+
1328
+ export function isCreateCipherError(error: any): error is CreateCipherError;
1329
+
1323
1330
  /**
1324
1331
  * Request to add a cipher.
1325
1332
  */
@@ -1334,13 +1341,6 @@ export interface CipherCreateRequest {
1334
1341
  fields: FieldView[];
1335
1342
  }
1336
1343
 
1337
- export interface CreateCipherError extends Error {
1338
- name: "CreateCipherError";
1339
- variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1340
- }
1341
-
1342
- export function isCreateCipherError(error: any): error is CreateCipherError;
1343
-
1344
1344
  /**
1345
1345
  * Represents the inner data of a cipher view.
1346
1346
  */
@@ -1351,13 +1351,6 @@ export type CipherViewType =
1351
1351
  | { secureNote: SecureNoteView }
1352
1352
  | { sshKey: SshKeyView };
1353
1353
 
1354
- export interface DecryptFileError extends Error {
1355
- name: "DecryptFileError";
1356
- variant: "Decrypt" | "Io";
1357
- }
1358
-
1359
- export function isDecryptFileError(error: any): error is DecryptFileError;
1360
-
1361
1354
  export interface EncryptFileError extends Error {
1362
1355
  name: "EncryptFileError";
1363
1356
  variant: "Encrypt" | "Io";
@@ -1365,20 +1358,18 @@ export interface EncryptFileError extends Error {
1365
1358
 
1366
1359
  export function isEncryptFileError(error: any): error is EncryptFileError;
1367
1360
 
1361
+ export interface DecryptFileError extends Error {
1362
+ name: "DecryptFileError";
1363
+ variant: "Decrypt" | "Io";
1364
+ }
1365
+
1366
+ export function isDecryptFileError(error: any): error is DecryptFileError;
1367
+
1368
1368
  export interface CipherPermissions {
1369
1369
  delete: boolean;
1370
1370
  restore: boolean;
1371
1371
  }
1372
1372
 
1373
- export interface Card {
1374
- cardholderName: EncString | undefined;
1375
- expMonth: EncString | undefined;
1376
- expYear: EncString | undefined;
1377
- code: EncString | undefined;
1378
- brand: EncString | undefined;
1379
- number: EncString | undefined;
1380
- }
1381
-
1382
1373
  /**
1383
1374
  * Minimal CardView only including the needed details for list views
1384
1375
  */
@@ -1389,6 +1380,15 @@ export interface CardListView {
1389
1380
  brand: string | undefined;
1390
1381
  }
1391
1382
 
1383
+ export interface Card {
1384
+ cardholderName: EncString | undefined;
1385
+ expMonth: EncString | undefined;
1386
+ expYear: EncString | undefined;
1387
+ code: EncString | undefined;
1388
+ brand: EncString | undefined;
1389
+ number: EncString | undefined;
1390
+ }
1391
+
1392
1392
  export interface CardView {
1393
1393
  cardholderName: string | undefined;
1394
1394
  expMonth: string | undefined;
@@ -1398,35 +1398,34 @@ export interface CardView {
1398
1398
  number: string | undefined;
1399
1399
  }
1400
1400
 
1401
- export interface FieldView {
1402
- name: string | undefined;
1403
- value: string | undefined;
1401
+ export interface Field {
1402
+ name: EncString | undefined;
1403
+ value: EncString | undefined;
1404
1404
  type: FieldType;
1405
1405
  linkedId: LinkedIdType | undefined;
1406
1406
  }
1407
1407
 
1408
- export interface Field {
1409
- name: EncString | undefined;
1410
- value: EncString | undefined;
1408
+ export interface FieldView {
1409
+ name: string | undefined;
1410
+ value: string | undefined;
1411
1411
  type: FieldType;
1412
1412
  linkedId: LinkedIdType | undefined;
1413
1413
  }
1414
1414
 
1415
- export interface LoginListView {
1416
- fido2Credentials: Fido2CredentialListView[] | undefined;
1417
- hasFido2: boolean;
1418
- username: string | undefined;
1419
- /**
1420
- * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
1421
- */
1415
+ export interface Login {
1416
+ username: EncString | undefined;
1417
+ password: EncString | undefined;
1418
+ passwordRevisionDate: DateTime<Utc> | undefined;
1419
+ uris: LoginUri[] | undefined;
1422
1420
  totp: EncString | undefined;
1423
- uris: LoginUriView[] | undefined;
1421
+ autofillOnPageLoad: boolean | undefined;
1422
+ fido2Credentials: Fido2Credential[] | undefined;
1424
1423
  }
1425
1424
 
1426
- export interface LoginUriView {
1427
- uri: string | undefined;
1425
+ export interface LoginUri {
1426
+ uri: EncString | undefined;
1428
1427
  match: UriMatchType | undefined;
1429
- uriChecksum: string | undefined;
1428
+ uriChecksum: EncString | undefined;
1430
1429
  }
1431
1430
 
1432
1431
  export interface Fido2CredentialFullView {
@@ -1445,39 +1444,29 @@ export interface Fido2CredentialFullView {
1445
1444
  creationDate: DateTime<Utc>;
1446
1445
  }
1447
1446
 
1448
- export interface Login {
1449
- username: EncString | undefined;
1450
- password: EncString | undefined;
1451
- passwordRevisionDate: DateTime<Utc> | undefined;
1452
- uris: LoginUri[] | undefined;
1447
+ export interface LoginListView {
1448
+ fido2Credentials: Fido2CredentialListView[] | undefined;
1449
+ hasFido2: boolean;
1450
+ username: string | undefined;
1451
+ /**
1452
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
1453
+ */
1453
1454
  totp: EncString | undefined;
1454
- autofillOnPageLoad: boolean | undefined;
1455
- fido2Credentials: Fido2Credential[] | undefined;
1456
- }
1457
-
1458
- export interface Fido2Credential {
1459
- credentialId: EncString;
1460
- keyType: EncString;
1461
- keyAlgorithm: EncString;
1462
- keyCurve: EncString;
1463
- keyValue: EncString;
1464
- rpId: EncString;
1465
- userHandle: EncString | undefined;
1466
- userName: EncString | undefined;
1467
- counter: EncString;
1468
- rpName: EncString | undefined;
1469
- userDisplayName: EncString | undefined;
1470
- discoverable: EncString;
1471
- creationDate: DateTime<Utc>;
1455
+ uris: LoginUriView[] | undefined;
1472
1456
  }
1473
1457
 
1474
- export interface Fido2CredentialListView {
1458
+ export interface Fido2CredentialNewView {
1475
1459
  credentialId: string;
1460
+ keyType: string;
1461
+ keyAlgorithm: string;
1462
+ keyCurve: string;
1476
1463
  rpId: string;
1477
1464
  userHandle: string | undefined;
1478
1465
  userName: string | undefined;
1479
- userDisplayName: string | undefined;
1480
1466
  counter: string;
1467
+ rpName: string | undefined;
1468
+ userDisplayName: string | undefined;
1469
+ creationDate: DateTime<Utc>;
1481
1470
  }
1482
1471
 
1483
1472
  export interface LoginView {
@@ -1490,17 +1479,34 @@ export interface LoginView {
1490
1479
  fido2Credentials: Fido2Credential[] | undefined;
1491
1480
  }
1492
1481
 
1493
- export interface Fido2CredentialNewView {
1482
+ export interface Fido2CredentialListView {
1494
1483
  credentialId: string;
1495
- keyType: string;
1496
- keyAlgorithm: string;
1497
- keyCurve: string;
1498
1484
  rpId: string;
1499
1485
  userHandle: string | undefined;
1500
1486
  userName: string | undefined;
1501
- counter: string;
1502
- rpName: string | undefined;
1503
1487
  userDisplayName: string | undefined;
1488
+ counter: string;
1489
+ }
1490
+
1491
+ export interface LoginUriView {
1492
+ uri: string | undefined;
1493
+ match: UriMatchType | undefined;
1494
+ uriChecksum: string | undefined;
1495
+ }
1496
+
1497
+ export interface Fido2Credential {
1498
+ credentialId: EncString;
1499
+ keyType: EncString;
1500
+ keyAlgorithm: EncString;
1501
+ keyCurve: EncString;
1502
+ keyValue: EncString;
1503
+ rpId: EncString;
1504
+ userHandle: EncString | undefined;
1505
+ userName: EncString | undefined;
1506
+ counter: EncString;
1507
+ rpName: EncString | undefined;
1508
+ userDisplayName: EncString | undefined;
1509
+ discoverable: EncString;
1504
1510
  creationDate: DateTime<Utc>;
1505
1511
  }
1506
1512
 
@@ -1520,61 +1526,27 @@ export interface Fido2CredentialView {
1520
1526
  creationDate: DateTime<Utc>;
1521
1527
  }
1522
1528
 
1523
- export interface LoginUri {
1524
- uri: EncString | undefined;
1525
- match: UriMatchType | undefined;
1526
- uriChecksum: EncString | undefined;
1527
- }
1528
-
1529
1529
  /**
1530
- * Available fields on a cipher and can be copied from a the list view in the UI.
1530
+ * NewType wrapper for `CipherId`
1531
1531
  */
1532
- export type CopyableCipherFields =
1533
- | "LoginUsername"
1534
- | "LoginPassword"
1535
- | "LoginTotp"
1536
- | "CardNumber"
1537
- | "CardSecurityCode"
1538
- | "IdentityUsername"
1539
- | "IdentityEmail"
1540
- | "IdentityPhone"
1541
- | "IdentityAddress"
1542
- | "SshKey"
1543
- | "SecureNotes";
1532
+ export type CipherId = Tagged<Uuid, "CipherId">;
1544
1533
 
1545
- export interface Cipher {
1546
- id: CipherId | undefined;
1547
- organizationId: OrganizationId | undefined;
1548
- folderId: FolderId | undefined;
1549
- collectionIds: CollectionId[];
1534
+ /**
1535
+ * Represents the result of decrypting a list of ciphers.
1536
+ *
1537
+ * This struct contains two vectors: `successes` and `failures`.
1538
+ * `successes` contains the decrypted `CipherListView` objects,
1539
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1540
+ */
1541
+ export interface DecryptCipherListResult {
1550
1542
  /**
1551
- * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1552
- * Cipher.
1543
+ * The decrypted `CipherListView` objects.
1553
1544
  */
1554
- key: EncString | undefined;
1555
- name: EncString;
1556
- notes: EncString | undefined;
1557
- type: CipherType;
1558
- login: Login | undefined;
1559
- identity: Identity | undefined;
1560
- card: Card | undefined;
1561
- secureNote: SecureNote | undefined;
1562
- sshKey: SshKey | undefined;
1563
- favorite: boolean;
1564
- reprompt: CipherRepromptType;
1565
- organizationUseTotp: boolean;
1566
- edit: boolean;
1567
- permissions: CipherPermissions | undefined;
1568
- viewPassword: boolean;
1569
- localData: LocalData | undefined;
1570
- attachments: Attachment[] | undefined;
1571
- fields: Field[] | undefined;
1572
- passwordHistory: PasswordHistory[] | undefined;
1573
- creationDate: DateTime<Utc>;
1574
- deletedDate: DateTime<Utc> | undefined;
1575
- revisionDate: DateTime<Utc>;
1576
- archivedDate: DateTime<Utc> | undefined;
1577
- data: string | undefined;
1545
+ successes: CipherListView[];
1546
+ /**
1547
+ * The original `Cipher` objects that failed to decrypt.
1548
+ */
1549
+ failures: Cipher[];
1578
1550
  }
1579
1551
 
1580
1552
  export type CipherListViewType =
@@ -1584,33 +1556,6 @@ export type CipherListViewType =
1584
1556
  | "identity"
1585
1557
  | "sshKey";
1586
1558
 
1587
- export interface CipherError extends Error {
1588
- name: "CipherError";
1589
- variant:
1590
- | "MissingField"
1591
- | "Crypto"
1592
- | "Decrypt"
1593
- | "Encrypt"
1594
- | "AttachmentsWithoutKeys"
1595
- | "OrganizationAlreadySet"
1596
- | "PutShare"
1597
- | "PutShareMany"
1598
- | "Repository"
1599
- | "Chrono"
1600
- | "SerdeJson";
1601
- }
1602
-
1603
- export function isCipherError(error: any): error is CipherError;
1604
-
1605
- export interface EncryptionContext {
1606
- /**
1607
- * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1608
- * Organization-owned ciphers
1609
- */
1610
- encryptedFor: UserId;
1611
- cipher: Cipher;
1612
- }
1613
-
1614
1559
  export interface CipherListView {
1615
1560
  id: CipherId | undefined;
1616
1561
  organizationId: OrganizationId | undefined;
@@ -1649,27 +1594,20 @@ export interface CipherListView {
1649
1594
  }
1650
1595
 
1651
1596
  /**
1652
- * Represents the result of decrypting a list of ciphers.
1653
- *
1654
- * This struct contains two vectors: `successes` and `failures`.
1655
- * `successes` contains the decrypted `CipherListView` objects,
1656
- * while `failures` contains the original `Cipher` objects that failed to decrypt.
1657
- */
1658
- export interface DecryptCipherListResult {
1659
- /**
1660
- * The decrypted `CipherListView` objects.
1661
- */
1662
- successes: CipherListView[];
1663
- /**
1664
- * The original `Cipher` objects that failed to decrypt.
1665
- */
1666
- failures: Cipher[];
1667
- }
1668
-
1669
- /**
1670
- * NewType wrapper for `CipherId`
1597
+ * Available fields on a cipher and can be copied from a the list view in the UI.
1671
1598
  */
1672
- export type CipherId = Tagged<Uuid, "CipherId">;
1599
+ export type CopyableCipherFields =
1600
+ | "LoginUsername"
1601
+ | "LoginPassword"
1602
+ | "LoginTotp"
1603
+ | "CardNumber"
1604
+ | "CardSecurityCode"
1605
+ | "IdentityUsername"
1606
+ | "IdentityEmail"
1607
+ | "IdentityPhone"
1608
+ | "IdentityAddress"
1609
+ | "SshKey"
1610
+ | "SecureNotes";
1673
1611
 
1674
1612
  export interface CipherView {
1675
1613
  id: CipherId | undefined;
@@ -1704,34 +1642,96 @@ export interface CipherView {
1704
1642
  archivedDate: DateTime<Utc> | undefined;
1705
1643
  }
1706
1644
 
1707
- export interface SshKey {
1645
+ export interface EncryptionContext {
1646
+ /**
1647
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1648
+ * Organization-owned ciphers
1649
+ */
1650
+ encryptedFor: UserId;
1651
+ cipher: Cipher;
1652
+ }
1653
+
1654
+ export interface CipherError extends Error {
1655
+ name: "CipherError";
1656
+ variant:
1657
+ | "MissingField"
1658
+ | "Crypto"
1659
+ | "Decrypt"
1660
+ | "Encrypt"
1661
+ | "AttachmentsWithoutKeys"
1662
+ | "OrganizationAlreadySet"
1663
+ | "PutShare"
1664
+ | "PutShareMany"
1665
+ | "Repository"
1666
+ | "Chrono"
1667
+ | "SerdeJson";
1668
+ }
1669
+
1670
+ export function isCipherError(error: any): error is CipherError;
1671
+
1672
+ export interface Cipher {
1673
+ id: CipherId | undefined;
1674
+ organizationId: OrganizationId | undefined;
1675
+ folderId: FolderId | undefined;
1676
+ collectionIds: CollectionId[];
1677
+ /**
1678
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1679
+ * Cipher.
1680
+ */
1681
+ key: EncString | undefined;
1682
+ name: EncString;
1683
+ notes: EncString | undefined;
1684
+ type: CipherType;
1685
+ login: Login | undefined;
1686
+ identity: Identity | undefined;
1687
+ card: Card | undefined;
1688
+ secureNote: SecureNote | undefined;
1689
+ sshKey: SshKey | undefined;
1690
+ favorite: boolean;
1691
+ reprompt: CipherRepromptType;
1692
+ organizationUseTotp: boolean;
1693
+ edit: boolean;
1694
+ permissions: CipherPermissions | undefined;
1695
+ viewPassword: boolean;
1696
+ localData: LocalData | undefined;
1697
+ attachments: Attachment[] | undefined;
1698
+ fields: Field[] | undefined;
1699
+ passwordHistory: PasswordHistory[] | undefined;
1700
+ creationDate: DateTime<Utc>;
1701
+ deletedDate: DateTime<Utc> | undefined;
1702
+ revisionDate: DateTime<Utc>;
1703
+ archivedDate: DateTime<Utc> | undefined;
1704
+ data: string | undefined;
1705
+ }
1706
+
1707
+ export interface SshKeyView {
1708
1708
  /**
1709
1709
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1710
1710
  */
1711
- privateKey: EncString;
1711
+ privateKey: string;
1712
1712
  /**
1713
1713
  * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1714
1714
  */
1715
- publicKey: EncString;
1715
+ publicKey: string;
1716
1716
  /**
1717
1717
  * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1718
1718
  */
1719
- fingerprint: EncString;
1719
+ fingerprint: string;
1720
1720
  }
1721
1721
 
1722
- export interface SshKeyView {
1722
+ export interface SshKey {
1723
1723
  /**
1724
1724
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1725
1725
  */
1726
- privateKey: string;
1726
+ privateKey: EncString;
1727
1727
  /**
1728
1728
  * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1729
1729
  */
1730
- publicKey: string;
1730
+ publicKey: EncString;
1731
1731
  /**
1732
1732
  * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1733
1733
  */
1734
- fingerprint: string;
1734
+ fingerprint: EncString;
1735
1735
  }
1736
1736
 
1737
1737
  export interface Identity {
@@ -1778,9 +1778,9 @@ export interface IdentityView {
1778
1778
 
1779
1779
  export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
1780
1780
 
1781
- export interface FolderView {
1781
+ export interface Folder {
1782
1782
  id: FolderId | undefined;
1783
- name: string;
1783
+ name: EncString;
1784
1784
  revisionDate: DateTime<Utc>;
1785
1785
  }
1786
1786
 
@@ -1789,9 +1789,9 @@ export interface FolderView {
1789
1789
  */
1790
1790
  export type FolderId = Tagged<Uuid, "FolderId">;
1791
1791
 
1792
- export interface Folder {
1792
+ export interface FolderView {
1793
1793
  id: FolderId | undefined;
1794
- name: EncString;
1794
+ name: string;
1795
1795
  revisionDate: DateTime<Utc>;
1796
1796
  }
1797
1797
 
@@ -1809,13 +1809,6 @@ export interface EditFolderError extends Error {
1809
1809
 
1810
1810
  export function isEditFolderError(error: any): error is EditFolderError;
1811
1811
 
1812
- export interface CreateFolderError extends Error {
1813
- name: "CreateFolderError";
1814
- variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
1815
- }
1816
-
1817
- export function isCreateFolderError(error: any): error is CreateFolderError;
1818
-
1819
1812
  /**
1820
1813
  * Request to add or edit a folder.
1821
1814
  */
@@ -1826,6 +1819,13 @@ export interface FolderAddEditRequest {
1826
1819
  name: string;
1827
1820
  }
1828
1821
 
1822
+ export interface CreateFolderError extends Error {
1823
+ name: "CreateFolderError";
1824
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
1825
+ }
1826
+
1827
+ export function isCreateFolderError(error: any): error is CreateFolderError;
1828
+
1829
1829
  export interface GetFolderError extends Error {
1830
1830
  name: "GetFolderError";
1831
1831
  variant: "ItemNotFound" | "Crypto" | "Repository";