@bitwarden/commercial-sdk-internal 0.2.0-main.448 → 0.2.0-main.450

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
  * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
@@ -180,10 +180,6 @@ export interface TokenProvider {
180
180
  get_access_token(): Promise<string | undefined>;
181
181
  }
182
182
 
183
- export interface IndexedDbConfiguration {
184
- db_name: string;
185
- }
186
-
187
183
  export interface Repositories {
188
184
  cipher: Repository<Cipher> | null;
189
185
  folder: Repository<Folder> | null;
@@ -194,6 +190,10 @@ export interface Repositories {
194
190
  */
195
191
  export interface FeatureFlags extends Map<string, boolean> {}
196
192
 
193
+ export interface IndexedDbConfiguration {
194
+ db_name: string;
195
+ }
196
+
197
197
  /**
198
198
  * Credentials for sending an OTP to the user\'s email address.
199
199
  * This is used when the send requires email verification with an OTP.
@@ -205,28 +205,6 @@ export interface SendEmailCredentials {
205
205
  email: string;
206
206
  }
207
207
 
208
- /**
209
- * Credentials for getting a send access token using an email and OTP.
210
- */
211
- export interface SendEmailOtpCredentials {
212
- /**
213
- * The email address to which the OTP will be sent.
214
- */
215
- email: string;
216
- /**
217
- * The one-time password (OTP) that the user has received via email.
218
- */
219
- otp: string;
220
- }
221
-
222
- /**
223
- * The credentials used for send access requests.
224
- */
225
- export type SendAccessCredentials =
226
- | SendPasswordCredentials
227
- | SendEmailOtpCredentials
228
- | SendEmailCredentials;
229
-
230
208
  /**
231
209
  * Credentials for sending password secured access requests.
232
210
  * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
@@ -253,6 +231,28 @@ export interface SendAccessTokenRequest {
253
231
  sendAccessCredentials?: SendAccessCredentials;
254
232
  }
255
233
 
234
+ /**
235
+ * The credentials used for send access requests.
236
+ */
237
+ export type SendAccessCredentials =
238
+ | SendPasswordCredentials
239
+ | SendEmailOtpCredentials
240
+ | SendEmailCredentials;
241
+
242
+ /**
243
+ * Credentials for getting a send access token using an email and OTP.
244
+ */
245
+ export interface SendEmailOtpCredentials {
246
+ /**
247
+ * The email address to which the OTP will be sent.
248
+ */
249
+ email: string;
250
+ /**
251
+ * The one-time password (OTP) that the user has received via email.
252
+ */
253
+ otp: string;
254
+ }
255
+
256
256
  /**
257
257
  * A send access token which can be used to access a send.
258
258
  */
@@ -267,14 +267,6 @@ export interface SendAccessTokenResponse {
267
267
  expiresAt: number;
268
268
  }
269
269
 
270
- /**
271
- * Represents errors that can occur when requesting a send access token.
272
- * It includes expected and unexpected API errors.
273
- */
274
- export type SendAccessTokenError =
275
- | { kind: "unexpected"; data: UnexpectedIdentityError }
276
- | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
277
-
278
270
  /**
279
271
  * Any unexpected error that occurs when making requests to identity. This could be
280
272
  * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
@@ -286,25 +278,12 @@ export type SendAccessTokenError =
286
278
  export type UnexpectedIdentityError = string;
287
279
 
288
280
  /**
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.
281
+ * Represents errors that can occur when requesting a send access token.
282
+ * It includes expected and unexpected API errors.
301
283
  */
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";
284
+ export type SendAccessTokenError =
285
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
286
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
308
287
 
309
288
  /**
310
289
  * Represents the possible, expected errors that can occur when requesting a send access token.
@@ -327,29 +306,25 @@ export type SendAccessTokenApiErrorResponse =
327
306
  | { error: "invalid_target"; error_description?: string };
328
307
 
329
308
  /**
330
- * Result of TDE registration process.
309
+ * Invalid grant errors - typically due to invalid credentials.
331
310
  */
332
- export interface TdeRegistrationResponse {
333
- /**
334
- * The account cryptographic state of the user
335
- */
336
- account_cryptographic_state: WrappedAccountCryptographicState;
337
- /**
338
- * The device key
339
- */
340
- device_key: B64;
341
- /**
342
- * The decrypted user key. This can be used to get the consuming client to an unlocked state.
343
- */
344
- user_key: B64;
345
- }
346
-
347
- export interface RegistrationError extends Error {
348
- name: "RegistrationError";
349
- variant: "Api" | "Crypto";
350
- }
311
+ export type SendAccessTokenInvalidGrantError =
312
+ | "send_id_invalid"
313
+ | "password_hash_b64_invalid"
314
+ | "email_invalid"
315
+ | "otp_invalid"
316
+ | "otp_generation_failed"
317
+ | "unknown";
351
318
 
352
- export function isRegistrationError(error: any): error is RegistrationError;
319
+ /**
320
+ * Invalid request errors - typically due to missing parameters.
321
+ */
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";
353
328
 
354
329
  /**
355
330
  * Request parameters for TDE (Trusted Device Encryption) registration.
@@ -378,36 +353,83 @@ export interface TdeRegistrationRequest {
378
353
  trust_device: boolean;
379
354
  }
380
355
 
356
+ export interface RegistrationError extends Error {
357
+ name: "RegistrationError";
358
+ variant: "KeyConnectorApi" | "Api" | "Crypto";
359
+ }
360
+
361
+ export function isRegistrationError(error: any): error is RegistrationError;
362
+
381
363
  /**
382
- * NewType wrapper for `CollectionId`
364
+ * Result of TDE registration process.
383
365
  */
384
- export type CollectionId = Tagged<Uuid, "CollectionId">;
366
+ export interface TdeRegistrationResponse {
367
+ /**
368
+ * The account cryptographic state of the user
369
+ */
370
+ account_cryptographic_state: WrappedAccountCryptographicState;
371
+ /**
372
+ * The device key
373
+ */
374
+ device_key: B64;
375
+ /**
376
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
377
+ */
378
+ user_key: B64;
379
+ }
385
380
 
386
381
  /**
387
- * Type of collection
382
+ * Result of Key Connector registration process.
388
383
  */
389
- export type CollectionType = "SharedCollection" | "DefaultUserCollection";
384
+ export interface KeyConnectorRegistrationResult {
385
+ /**
386
+ * The account cryptographic state of the user.
387
+ */
388
+ account_cryptographic_state: WrappedAccountCryptographicState;
389
+ /**
390
+ * The key connector key used for unlocking.
391
+ */
392
+ key_connector_key: B64;
393
+ /**
394
+ * The encrypted user key, wrapped with the key connector key.
395
+ */
396
+ key_connector_key_wrapped_user_key: EncString;
397
+ /**
398
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
399
+ */
400
+ user_key: B64;
401
+ }
390
402
 
391
- export interface CollectionView {
403
+ /**
404
+ * NewType wrapper for `CollectionId`
405
+ */
406
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
407
+
408
+ export interface Collection {
392
409
  id: CollectionId | undefined;
393
410
  organizationId: OrganizationId;
394
- name: string;
411
+ name: EncString;
395
412
  externalId: string | undefined;
396
413
  hidePasswords: boolean;
397
414
  readOnly: boolean;
398
415
  manage: boolean;
416
+ defaultUserCollectionEmail: string | undefined;
399
417
  type: CollectionType;
400
418
  }
401
419
 
402
- export interface Collection {
420
+ /**
421
+ * Type of collection
422
+ */
423
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
424
+
425
+ export interface CollectionView {
403
426
  id: CollectionId | undefined;
404
427
  organizationId: OrganizationId;
405
- name: EncString;
428
+ name: string;
406
429
  externalId: string | undefined;
407
430
  hidePasswords: boolean;
408
431
  readOnly: boolean;
409
432
  manage: boolean;
410
- defaultUserCollectionEmail: string | undefined;
411
433
  type: CollectionType;
412
434
  }
413
435
 
@@ -420,27 +442,6 @@ export function isCollectionDecryptError(error: any): error is CollectionDecrypt
420
442
 
421
443
  export type SignedSecurityState = string;
422
444
 
423
- export interface MasterPasswordError extends Error {
424
- name: "MasterPasswordError";
425
- variant:
426
- | "EncryptionKeyMalformed"
427
- | "KdfMalformed"
428
- | "InvalidKdfConfiguration"
429
- | "MissingField"
430
- | "Crypto";
431
- }
432
-
433
- export function isMasterPasswordError(error: any): error is MasterPasswordError;
434
-
435
- /**
436
- * Represents the data required to authenticate with the master password.
437
- */
438
- export interface MasterPasswordAuthenticationData {
439
- kdf: Kdf;
440
- salt: string;
441
- masterPasswordAuthenticationHash: B64;
442
- }
443
-
444
445
  /**
445
446
  * Represents the data required to unlock with the master password.
446
447
  */
@@ -460,19 +461,25 @@ export interface MasterPasswordUnlockData {
460
461
  }
461
462
 
462
463
  /**
463
- * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
464
- * Private keys are protected by the user key.
464
+ * Represents the data required to authenticate with the master password.
465
465
  */
466
- export type WrappedAccountCryptographicState =
467
- | { V1: { private_key: EncString } }
468
- | {
469
- V2: {
470
- private_key: EncString;
471
- signed_public_key: SignedPublicKey | undefined;
472
- signing_key: EncString;
473
- security_state: SignedSecurityState;
474
- };
475
- };
466
+ export interface MasterPasswordAuthenticationData {
467
+ kdf: Kdf;
468
+ salt: string;
469
+ masterPasswordAuthenticationHash: B64;
470
+ }
471
+
472
+ export interface MasterPasswordError extends Error {
473
+ name: "MasterPasswordError";
474
+ variant:
475
+ | "EncryptionKeyMalformed"
476
+ | "KdfMalformed"
477
+ | "InvalidKdfConfiguration"
478
+ | "MissingField"
479
+ | "Crypto";
480
+ }
481
+
482
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
476
483
 
477
484
  export interface AccountCryptographyInitializationError extends Error {
478
485
  name: "AccountCryptographyInitializationError";
@@ -490,43 +497,62 @@ export function isAccountCryptographyInitializationError(
490
497
  ): error is AccountCryptographyInitializationError;
491
498
 
492
499
  /**
493
- * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
500
+ * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
501
+ * Private keys are protected by the user key.
494
502
  */
495
- export interface UserCryptoV2KeysResponse {
496
- /**
497
- * User key
498
- */
499
- userKey: B64;
500
- /**
501
- * Wrapped private key
502
- */
503
- privateKey: EncString;
504
- /**
505
- * Public key
506
- */
507
- publicKey: B64;
508
- /**
509
- * The user\'s public key, signed by the signing key
510
- */
511
- signedPublicKey: SignedPublicKey;
503
+ export type WrappedAccountCryptographicState =
504
+ | { V1: { private_key: EncString } }
505
+ | {
506
+ V2: {
507
+ private_key: EncString;
508
+ signed_public_key: SignedPublicKey | undefined;
509
+ signing_key: EncString;
510
+ security_state: SignedSecurityState;
511
+ };
512
+ };
513
+
514
+ /**
515
+ * Response from the `make_update_password` function
516
+ */
517
+ export interface UpdatePasswordResponse {
512
518
  /**
513
- * Signing key, encrypted with the user\'s symmetric key
519
+ * Hash of the new password
514
520
  */
515
- signingKey: EncString;
521
+ passwordHash: B64;
516
522
  /**
517
- * Base64 encoded verifying key
523
+ * User key, encrypted with the new password
518
524
  */
519
- verifyingKey: B64;
525
+ newKey: EncString;
526
+ }
527
+
528
+ /**
529
+ * Response from the `make_key_pair` function
530
+ */
531
+ export interface MakeKeyPairResponse {
520
532
  /**
521
- * The user\'s signed security state
533
+ * The user\'s public key
522
534
  */
523
- securityState: SignedSecurityState;
535
+ userPublicKey: B64;
524
536
  /**
525
- * The security state\'s version
537
+ * User\'s private key, encrypted with the user key
526
538
  */
527
- securityVersion: number;
539
+ userKeyEncryptedPrivateKey: EncString;
528
540
  }
529
541
 
542
+ export interface EnrollAdminPasswordResetError extends Error {
543
+ name: "EnrollAdminPasswordResetError";
544
+ variant: "Crypto";
545
+ }
546
+
547
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
548
+
549
+ /**
550
+ * Auth requests supports multiple initialization methods.
551
+ */
552
+ export type AuthRequestMethod =
553
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
554
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
555
+
530
556
  /**
531
557
  * Response from the `update_kdf` function
532
558
  */
@@ -545,49 +571,6 @@ export interface UpdateKdfResponse {
545
571
  oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
546
572
  }
547
573
 
548
- /**
549
- * Request for migrating an account from password to key connector.
550
- */
551
- export interface DeriveKeyConnectorRequest {
552
- /**
553
- * Encrypted user key, used to validate the master key
554
- */
555
- userKeyEncrypted: EncString;
556
- /**
557
- * The user\'s master password
558
- */
559
- password: string;
560
- /**
561
- * The KDF parameters used to derive the master key
562
- */
563
- kdf: Kdf;
564
- /**
565
- * The user\'s email address
566
- */
567
- email: string;
568
- }
569
-
570
- /**
571
- * Auth requests supports multiple initialization methods.
572
- */
573
- export type AuthRequestMethod =
574
- | { userKey: { protected_user_key: UnsignedSharedKey } }
575
- | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
576
-
577
- export interface DeriveKeyConnectorError extends Error {
578
- name: "DeriveKeyConnectorError";
579
- variant: "WrongPassword" | "Crypto";
580
- }
581
-
582
- export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
583
-
584
- export interface MakeKeysError extends Error {
585
- name: "MakeKeysError";
586
- variant: "AccountCryptographyInitialization" | "RequestModelCreation" | "Crypto";
587
- }
588
-
589
- export function isMakeKeysError(error: any): error is MakeKeysError;
590
-
591
574
  /**
592
575
  * Request for deriving a pin protected user key
593
576
  */
@@ -603,37 +586,39 @@ export interface EnrollPinResponse {
603
586
  }
604
587
 
605
588
  /**
606
- * The crypto method used to initialize the user cryptographic state.
607
- */
608
- export type InitUserCryptoMethod =
609
- | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
610
- | { decryptedKey: { decrypted_user_key: string } }
611
- | { pin: { pin: string; pin_protected_user_key: EncString } }
612
- | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
613
- | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
614
- | {
615
- deviceKey: {
616
- device_key: string;
617
- protected_device_private_key: EncString;
618
- device_protected_user_key: UnsignedSharedKey;
619
- };
620
- }
621
- | { keyConnector: { master_key: B64; user_key: EncString } };
622
-
623
- /**
624
- * Request for deriving a pin protected user key
589
+ * State used for initializing the user cryptographic state.
625
590
  */
626
- export interface DerivePinKeyResponse {
591
+ export interface InitUserCryptoRequest {
627
592
  /**
628
- * [UserKey] protected by PIN
593
+ * The user\'s ID.
629
594
  */
630
- pinProtectedUserKey: EncString;
595
+ userId: UserId | undefined;
631
596
  /**
632
- * PIN protected by [UserKey]
597
+ * The user\'s KDF parameters, as received from the prelogin request
633
598
  */
634
- encryptedPin: EncString;
599
+ kdfParams: Kdf;
600
+ /**
601
+ * The user\'s email address
602
+ */
603
+ email: string;
604
+ /**
605
+ * The user\'s account cryptographic state, containing their signature and
606
+ * public-key-encryption keys, along with the signed security state, protected by the user key
607
+ */
608
+ accountCryptographicState: WrappedAccountCryptographicState;
609
+ /**
610
+ * The method to decrypt the user\'s account symmetric key (user key)
611
+ */
612
+ method: InitUserCryptoMethod;
613
+ }
614
+
615
+ export interface MakeKeysError extends Error {
616
+ name: "MakeKeysError";
617
+ variant: "AccountCryptographyInitialization" | "RequestModelCreation" | "Crypto";
635
618
  }
636
619
 
620
+ export function isMakeKeysError(error: any): error is MakeKeysError;
621
+
637
622
  /**
638
623
  * Response for `verify_asymmetric_keys`.
639
624
  */
@@ -666,38 +651,44 @@ export interface VerifyAsymmetricKeysRequest {
666
651
  userKeyEncryptedPrivateKey: EncString;
667
652
  }
668
653
 
669
- export interface EnrollAdminPasswordResetError extends Error {
670
- name: "EnrollAdminPasswordResetError";
671
- variant: "Crypto";
672
- }
673
-
674
- export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
654
+ /**
655
+ * The crypto method used to initialize the user cryptographic state.
656
+ */
657
+ export type InitUserCryptoMethod =
658
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
659
+ | { decryptedKey: { decrypted_user_key: string } }
660
+ | { pin: { pin: string; pin_protected_user_key: EncString } }
661
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
662
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
663
+ | {
664
+ deviceKey: {
665
+ device_key: string;
666
+ protected_device_private_key: EncString;
667
+ device_protected_user_key: UnsignedSharedKey;
668
+ };
669
+ }
670
+ | { keyConnector: { master_key: B64; user_key: EncString } };
675
671
 
676
672
  /**
677
- * State used for initializing the user cryptographic state.
673
+ * Request for migrating an account from password to key connector.
678
674
  */
679
- export interface InitUserCryptoRequest {
680
- /**
681
- * The user\'s ID.
682
- */
683
- userId: UserId | undefined;
675
+ export interface DeriveKeyConnectorRequest {
684
676
  /**
685
- * The user\'s KDF parameters, as received from the prelogin request
677
+ * Encrypted user key, used to validate the master key
686
678
  */
687
- kdfParams: Kdf;
679
+ userKeyEncrypted: EncString;
688
680
  /**
689
- * The user\'s email address
681
+ * The user\'s master password
690
682
  */
691
- email: string;
683
+ password: string;
692
684
  /**
693
- * The user\'s account cryptographic state, containing their signature and
694
- * public-key-encryption keys, along with the signed security state, protected by the user key
685
+ * The KDF parameters used to derive the master key
695
686
  */
696
- accountCryptographicState: WrappedAccountCryptographicState;
687
+ kdf: Kdf;
697
688
  /**
698
- * The method to decrypt the user\'s account symmetric key (user key)
689
+ * The user\'s email address
699
690
  */
700
- method: InitUserCryptoMethod;
691
+ email: string;
701
692
  }
702
693
 
703
694
  /**
@@ -711,33 +702,50 @@ export interface InitOrgCryptoRequest {
711
702
  }
712
703
 
713
704
  /**
714
- * Response from the `make_update_password` function
705
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
715
706
  */
716
- export interface UpdatePasswordResponse {
707
+ export interface UserCryptoV2KeysResponse {
717
708
  /**
718
- * Hash of the new password
709
+ * User key
719
710
  */
720
- passwordHash: B64;
711
+ userKey: B64;
721
712
  /**
722
- * User key, encrypted with the new password
713
+ * Wrapped private key
723
714
  */
724
- newKey: EncString;
725
- }
726
-
727
- /**
728
- * Response from the `make_key_pair` function
729
- */
730
- export interface MakeKeyPairResponse {
715
+ privateKey: EncString;
731
716
  /**
732
- * The user\'s public key
717
+ * Public key
733
718
  */
734
- userPublicKey: B64;
719
+ publicKey: B64;
735
720
  /**
736
- * User\'s private key, encrypted with the user key
721
+ * The user\'s public key, signed by the signing key
737
722
  */
738
- userKeyEncryptedPrivateKey: EncString;
723
+ signedPublicKey: SignedPublicKey;
724
+ /**
725
+ * Signing key, encrypted with the user\'s symmetric key
726
+ */
727
+ signingKey: EncString;
728
+ /**
729
+ * Base64 encoded verifying key
730
+ */
731
+ verifyingKey: B64;
732
+ /**
733
+ * The user\'s signed security state
734
+ */
735
+ securityState: SignedSecurityState;
736
+ /**
737
+ * The security state\'s version
738
+ */
739
+ securityVersion: number;
740
+ }
741
+
742
+ export interface DeriveKeyConnectorError extends Error {
743
+ name: "DeriveKeyConnectorError";
744
+ variant: "WrongPassword" | "Crypto";
739
745
  }
740
746
 
747
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
748
+
741
749
  export interface CryptoClientError extends Error {
742
750
  name: "CryptoClientError";
743
751
  variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
@@ -745,6 +753,20 @@ export interface CryptoClientError extends Error {
745
753
 
746
754
  export function isCryptoClientError(error: any): error is CryptoClientError;
747
755
 
756
+ /**
757
+ * Request for deriving a pin protected user key
758
+ */
759
+ export interface DerivePinKeyResponse {
760
+ /**
761
+ * [UserKey] protected by PIN
762
+ */
763
+ pinProtectedUserKey: EncString;
764
+ /**
765
+ * PIN protected by [UserKey]
766
+ */
767
+ encryptedPin: EncString;
768
+ }
769
+
748
770
  /**
749
771
  * NewType wrapper for `OrganizationId`
750
772
  */
@@ -993,8 +1015,6 @@ export interface ExportError extends Error {
993
1015
 
994
1016
  export function isExportError(error: any): error is ExportError;
995
1017
 
996
- export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
997
-
998
1018
  /**
999
1019
  * Passphrase generator request options.
1000
1020
  */
@@ -1019,6 +1039,8 @@ export interface PassphraseGeneratorRequest {
1019
1039
  includeNumber: boolean;
1020
1040
  }
1021
1041
 
1042
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
1043
+
1022
1044
  /**
1023
1045
  * Password generator request options.
1024
1046
  */
@@ -1167,12 +1189,12 @@ export type Endpoint =
1167
1189
  | "DesktopRenderer"
1168
1190
  | "DesktopMain";
1169
1191
 
1170
- export interface KeyGenerationError extends Error {
1171
- name: "KeyGenerationError";
1172
- variant: "KeyGeneration" | "KeyConversion";
1192
+ export interface SshKeyExportError extends Error {
1193
+ name: "SshKeyExportError";
1194
+ variant: "KeyConversion";
1173
1195
  }
1174
1196
 
1175
- export function isKeyGenerationError(error: any): error is KeyGenerationError;
1197
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1176
1198
 
1177
1199
  export interface SshKeyImportError extends Error {
1178
1200
  name: "SshKeyImportError";
@@ -1181,12 +1203,12 @@ export interface SshKeyImportError extends Error {
1181
1203
 
1182
1204
  export function isSshKeyImportError(error: any): error is SshKeyImportError;
1183
1205
 
1184
- export interface SshKeyExportError extends Error {
1185
- name: "SshKeyExportError";
1186
- variant: "KeyConversion";
1206
+ export interface KeyGenerationError extends Error {
1207
+ name: "KeyGenerationError";
1208
+ variant: "KeyGeneration" | "KeyConversion";
1187
1209
  }
1188
1210
 
1189
- export function isSshKeyExportError(error: any): error is SshKeyExportError;
1211
+ export function isKeyGenerationError(error: any): error is KeyGenerationError;
1190
1212
 
1191
1213
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
1192
1214
 
@@ -1217,6 +1239,11 @@ export interface CipherRiskError extends Error {
1217
1239
 
1218
1240
  export function isCipherRiskError(error: any): error is CipherRiskError;
1219
1241
 
1242
+ /**
1243
+ * Password reuse map wrapper for WASM compatibility.
1244
+ */
1245
+ export type PasswordReuseMap = Record<string, number>;
1246
+
1220
1247
  /**
1221
1248
  * Risk evaluation result for a single cipher.
1222
1249
  */
@@ -1244,29 +1271,6 @@ export interface CipherRiskResult {
1244
1271
  reuse_count: number | undefined;
1245
1272
  }
1246
1273
 
1247
- /**
1248
- * Login cipher data needed for risk evaluation.
1249
- */
1250
- export interface CipherLoginDetails {
1251
- /**
1252
- * Cipher ID to identify which cipher in results.
1253
- */
1254
- id: CipherId;
1255
- /**
1256
- * The decrypted password to evaluate.
1257
- */
1258
- password: string;
1259
- /**
1260
- * Username or email (login ciphers only have one field).
1261
- */
1262
- username: string | undefined;
1263
- }
1264
-
1265
- /**
1266
- * Password reuse map wrapper for WASM compatibility.
1267
- */
1268
- export type PasswordReuseMap = Record<string, number>;
1269
-
1270
1274
  /**
1271
1275
  * Options for configuring risk computation.
1272
1276
  */
@@ -1296,6 +1300,24 @@ export type ExposedPasswordResult =
1296
1300
  | { type: "Found"; value: number }
1297
1301
  | { type: "Error"; value: string };
1298
1302
 
1303
+ /**
1304
+ * Login cipher data needed for risk evaluation.
1305
+ */
1306
+ export interface CipherLoginDetails {
1307
+ /**
1308
+ * Cipher ID to identify which cipher in results.
1309
+ */
1310
+ id: CipherId;
1311
+ /**
1312
+ * The decrypted password to evaluate.
1313
+ */
1314
+ password: string;
1315
+ /**
1316
+ * Username or email (login ciphers only have one field).
1317
+ */
1318
+ username: string | undefined;
1319
+ }
1320
+
1299
1321
  export interface PasswordHistory {
1300
1322
  password: EncString;
1301
1323
  lastUsedDate: DateTime<Utc>;
@@ -1310,13 +1332,6 @@ export interface AncestorMap {
1310
1332
  ancestors: Map<CollectionId, string>;
1311
1333
  }
1312
1334
 
1313
- export interface TotpError extends Error {
1314
- name: "TotpError";
1315
- variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1316
- }
1317
-
1318
- export function isTotpError(error: any): error is TotpError;
1319
-
1320
1335
  export interface TotpResponse {
1321
1336
  /**
1322
1337
  * Generated TOTP code
@@ -1328,6 +1343,13 @@ export interface TotpResponse {
1328
1343
  period: number;
1329
1344
  }
1330
1345
 
1346
+ export interface TotpError extends Error {
1347
+ name: "TotpError";
1348
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1349
+ }
1350
+
1351
+ export function isTotpError(error: any): error is TotpError;
1352
+
1331
1353
  export interface DecryptError extends Error {
1332
1354
  name: "DecryptError";
1333
1355
  variant: "Crypto";
@@ -1342,18 +1364,6 @@ export interface EncryptError extends Error {
1342
1364
 
1343
1365
  export function isEncryptError(error: any): error is EncryptError;
1344
1366
 
1345
- export interface Attachment {
1346
- id: string | undefined;
1347
- url: string | undefined;
1348
- size: string | undefined;
1349
- /**
1350
- * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1351
- */
1352
- sizeName: string | undefined;
1353
- fileName: EncString | undefined;
1354
- key: EncString | undefined;
1355
- }
1356
-
1357
1367
  export interface AttachmentView {
1358
1368
  id: string | undefined;
1359
1369
  url: string | undefined;
@@ -1376,6 +1386,18 @@ export interface AttachmentView {
1376
1386
  decryptedKey: string | undefined;
1377
1387
  }
1378
1388
 
1389
+ export interface Attachment {
1390
+ id: string | undefined;
1391
+ url: string | undefined;
1392
+ size: string | undefined;
1393
+ /**
1394
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1395
+ */
1396
+ sizeName: string | undefined;
1397
+ fileName: EncString | undefined;
1398
+ key: EncString | undefined;
1399
+ }
1400
+
1379
1401
  export interface LocalDataView {
1380
1402
  lastUsedDate: DateTime<Utc> | undefined;
1381
1403
  lastLaunched: DateTime<Utc> | undefined;
@@ -1386,11 +1408,11 @@ export interface LocalData {
1386
1408
  lastLaunched: DateTime<Utc> | undefined;
1387
1409
  }
1388
1410
 
1389
- export interface SecureNoteView {
1411
+ export interface SecureNote {
1390
1412
  type: SecureNoteType;
1391
1413
  }
1392
1414
 
1393
- export interface SecureNote {
1415
+ export interface SecureNoteView {
1394
1416
  type: SecureNoteType;
1395
1417
  }
1396
1418
 
@@ -1545,7 +1567,17 @@ export interface CardView {
1545
1567
  expYear: string | undefined;
1546
1568
  code: string | undefined;
1547
1569
  brand: string | undefined;
1548
- number: string | undefined;
1570
+ number: string | undefined;
1571
+ }
1572
+
1573
+ /**
1574
+ * Minimal CardView only including the needed details for list views
1575
+ */
1576
+ export interface CardListView {
1577
+ /**
1578
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1579
+ */
1580
+ brand: string | undefined;
1549
1581
  }
1550
1582
 
1551
1583
  export interface Card {
@@ -1557,14 +1589,11 @@ export interface Card {
1557
1589
  number: EncString | undefined;
1558
1590
  }
1559
1591
 
1560
- /**
1561
- * Minimal CardView only including the needed details for list views
1562
- */
1563
- export interface CardListView {
1564
- /**
1565
- * The brand of the card, e.g. Visa, Mastercard, etc.
1566
- */
1567
- brand: string | undefined;
1592
+ export interface Field {
1593
+ name: EncString | undefined;
1594
+ value: EncString | undefined;
1595
+ type: FieldType;
1596
+ linkedId: LinkedIdType | undefined;
1568
1597
  }
1569
1598
 
1570
1599
  export interface FieldView {
@@ -1574,26 +1603,27 @@ export interface FieldView {
1574
1603
  linkedId: LinkedIdType | undefined;
1575
1604
  }
1576
1605
 
1577
- export interface Field {
1578
- name: EncString | undefined;
1579
- value: EncString | undefined;
1580
- type: FieldType;
1581
- linkedId: LinkedIdType | undefined;
1606
+ export interface LoginView {
1607
+ username: string | undefined;
1608
+ password: string | undefined;
1609
+ passwordRevisionDate: DateTime<Utc> | undefined;
1610
+ uris: LoginUriView[] | undefined;
1611
+ totp: string | undefined;
1612
+ autofillOnPageLoad: boolean | undefined;
1613
+ fido2Credentials: Fido2Credential[] | undefined;
1582
1614
  }
1583
1615
 
1584
- export interface Fido2CredentialView {
1616
+ export interface Fido2CredentialNewView {
1585
1617
  credentialId: string;
1586
1618
  keyType: string;
1587
1619
  keyAlgorithm: string;
1588
1620
  keyCurve: string;
1589
- keyValue: EncString;
1590
1621
  rpId: string;
1591
1622
  userHandle: string | undefined;
1592
1623
  userName: string | undefined;
1593
1624
  counter: string;
1594
1625
  rpName: string | undefined;
1595
1626
  userDisplayName: string | undefined;
1596
- discoverable: string;
1597
1627
  creationDate: DateTime<Utc>;
1598
1628
  }
1599
1629
 
@@ -1624,19 +1654,10 @@ export interface LoginListView {
1624
1654
  uris: LoginUriView[] | undefined;
1625
1655
  }
1626
1656
 
1627
- export interface Fido2CredentialListView {
1628
- credentialId: string;
1629
- rpId: string;
1630
- userHandle: string | undefined;
1631
- userName: string | undefined;
1632
- userDisplayName: string | undefined;
1633
- counter: string;
1634
- }
1635
-
1636
- export interface LoginUriView {
1637
- uri: string | undefined;
1657
+ export interface LoginUri {
1658
+ uri: EncString | undefined;
1638
1659
  match: UriMatchType | undefined;
1639
- uriChecksum: string | undefined;
1660
+ uriChecksum: EncString | undefined;
1640
1661
  }
1641
1662
 
1642
1663
  export interface Fido2Credential {
@@ -1655,36 +1676,22 @@ export interface Fido2Credential {
1655
1676
  creationDate: DateTime<Utc>;
1656
1677
  }
1657
1678
 
1658
- export interface LoginUri {
1659
- uri: EncString | undefined;
1660
- match: UriMatchType | undefined;
1661
- uriChecksum: EncString | undefined;
1662
- }
1663
-
1664
- export interface Fido2CredentialNewView {
1679
+ export interface Fido2CredentialView {
1665
1680
  credentialId: string;
1666
1681
  keyType: string;
1667
1682
  keyAlgorithm: string;
1668
1683
  keyCurve: string;
1684
+ keyValue: EncString;
1669
1685
  rpId: string;
1670
1686
  userHandle: string | undefined;
1671
1687
  userName: string | undefined;
1672
1688
  counter: string;
1673
1689
  rpName: string | undefined;
1674
1690
  userDisplayName: string | undefined;
1691
+ discoverable: string;
1675
1692
  creationDate: DateTime<Utc>;
1676
1693
  }
1677
1694
 
1678
- export interface LoginView {
1679
- username: string | undefined;
1680
- password: string | undefined;
1681
- passwordRevisionDate: DateTime<Utc> | undefined;
1682
- uris: LoginUriView[] | undefined;
1683
- totp: string | undefined;
1684
- autofillOnPageLoad: boolean | undefined;
1685
- fido2Credentials: Fido2Credential[] | undefined;
1686
- }
1687
-
1688
1695
  export interface Login {
1689
1696
  username: EncString | undefined;
1690
1697
  password: EncString | undefined;
@@ -1695,6 +1702,93 @@ export interface Login {
1695
1702
  fido2Credentials: Fido2Credential[] | undefined;
1696
1703
  }
1697
1704
 
1705
+ export interface Fido2CredentialListView {
1706
+ credentialId: string;
1707
+ rpId: string;
1708
+ userHandle: string | undefined;
1709
+ userName: string | undefined;
1710
+ userDisplayName: string | undefined;
1711
+ counter: string;
1712
+ }
1713
+
1714
+ export interface LoginUriView {
1715
+ uri: string | undefined;
1716
+ match: UriMatchType | undefined;
1717
+ uriChecksum: string | undefined;
1718
+ }
1719
+
1720
+ export interface Cipher {
1721
+ id: CipherId | undefined;
1722
+ organizationId: OrganizationId | undefined;
1723
+ folderId: FolderId | undefined;
1724
+ collectionIds: CollectionId[];
1725
+ /**
1726
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1727
+ * Cipher.
1728
+ */
1729
+ key: EncString | undefined;
1730
+ name: EncString;
1731
+ notes: EncString | undefined;
1732
+ type: CipherType;
1733
+ login: Login | undefined;
1734
+ identity: Identity | undefined;
1735
+ card: Card | undefined;
1736
+ secureNote: SecureNote | undefined;
1737
+ sshKey: SshKey | undefined;
1738
+ favorite: boolean;
1739
+ reprompt: CipherRepromptType;
1740
+ organizationUseTotp: boolean;
1741
+ edit: boolean;
1742
+ permissions: CipherPermissions | undefined;
1743
+ viewPassword: boolean;
1744
+ localData: LocalData | undefined;
1745
+ attachments: Attachment[] | undefined;
1746
+ fields: Field[] | undefined;
1747
+ passwordHistory: PasswordHistory[] | undefined;
1748
+ creationDate: DateTime<Utc>;
1749
+ deletedDate: DateTime<Utc> | undefined;
1750
+ revisionDate: DateTime<Utc>;
1751
+ archivedDate: DateTime<Utc> | undefined;
1752
+ data: string | undefined;
1753
+ }
1754
+
1755
+ export interface EncryptionContext {
1756
+ /**
1757
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1758
+ * Organization-owned ciphers
1759
+ */
1760
+ encryptedFor: UserId;
1761
+ cipher: Cipher;
1762
+ }
1763
+
1764
+ /**
1765
+ * Available fields on a cipher and can be copied from a the list view in the UI.
1766
+ */
1767
+ export type CopyableCipherFields =
1768
+ | "LoginUsername"
1769
+ | "LoginPassword"
1770
+ | "LoginTotp"
1771
+ | "CardNumber"
1772
+ | "CardSecurityCode"
1773
+ | "IdentityUsername"
1774
+ | "IdentityEmail"
1775
+ | "IdentityPhone"
1776
+ | "IdentityAddress"
1777
+ | "SshKey"
1778
+ | "SecureNotes";
1779
+
1780
+ /**
1781
+ * NewType wrapper for `CipherId`
1782
+ */
1783
+ export type CipherId = Tagged<Uuid, "CipherId">;
1784
+
1785
+ export type CipherListViewType =
1786
+ | { login: LoginListView }
1787
+ | "secureNote"
1788
+ | { card: CardListView }
1789
+ | "identity"
1790
+ | "sshKey";
1791
+
1698
1792
  export interface CipherView {
1699
1793
  id: CipherId | undefined;
1700
1794
  organizationId: OrganizationId | undefined;
@@ -1728,15 +1822,6 @@ export interface CipherView {
1728
1822
  archivedDate: DateTime<Utc> | undefined;
1729
1823
  }
1730
1824
 
1731
- export interface EncryptionContext {
1732
- /**
1733
- * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1734
- * Organization-owned ciphers
1735
- */
1736
- encryptedFor: UserId;
1737
- cipher: Cipher;
1738
- }
1739
-
1740
1825
  export interface CipherError extends Error {
1741
1826
  name: "CipherError";
1742
1827
  variant:
@@ -1754,11 +1839,6 @@ export interface CipherError extends Error {
1754
1839
 
1755
1840
  export function isCipherError(error: any): error is CipherError;
1756
1841
 
1757
- /**
1758
- * NewType wrapper for `CipherId`
1759
- */
1760
- export type CipherId = Tagged<Uuid, "CipherId">;
1761
-
1762
1842
  export interface CipherListView {
1763
1843
  id: CipherId | undefined;
1764
1844
  organizationId: OrganizationId | undefined;
@@ -1796,41 +1876,6 @@ export interface CipherListView {
1796
1876
  localData: LocalDataView | undefined;
1797
1877
  }
1798
1878
 
1799
- export interface Cipher {
1800
- id: CipherId | undefined;
1801
- organizationId: OrganizationId | undefined;
1802
- folderId: FolderId | undefined;
1803
- collectionIds: CollectionId[];
1804
- /**
1805
- * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1806
- * Cipher.
1807
- */
1808
- key: EncString | undefined;
1809
- name: EncString;
1810
- notes: EncString | undefined;
1811
- type: CipherType;
1812
- login: Login | undefined;
1813
- identity: Identity | undefined;
1814
- card: Card | undefined;
1815
- secureNote: SecureNote | undefined;
1816
- sshKey: SshKey | undefined;
1817
- favorite: boolean;
1818
- reprompt: CipherRepromptType;
1819
- organizationUseTotp: boolean;
1820
- edit: boolean;
1821
- permissions: CipherPermissions | undefined;
1822
- viewPassword: boolean;
1823
- localData: LocalData | undefined;
1824
- attachments: Attachment[] | undefined;
1825
- fields: Field[] | undefined;
1826
- passwordHistory: PasswordHistory[] | undefined;
1827
- creationDate: DateTime<Utc>;
1828
- deletedDate: DateTime<Utc> | undefined;
1829
- revisionDate: DateTime<Utc>;
1830
- archivedDate: DateTime<Utc> | undefined;
1831
- data: string | undefined;
1832
- }
1833
-
1834
1879
  /**
1835
1880
  * Represents the result of decrypting a list of ciphers.
1836
1881
  *
@@ -1849,57 +1894,34 @@ export interface DecryptCipherListResult {
1849
1894
  failures: Cipher[];
1850
1895
  }
1851
1896
 
1852
- /**
1853
- * Available fields on a cipher and can be copied from a the list view in the UI.
1854
- */
1855
- export type CopyableCipherFields =
1856
- | "LoginUsername"
1857
- | "LoginPassword"
1858
- | "LoginTotp"
1859
- | "CardNumber"
1860
- | "CardSecurityCode"
1861
- | "IdentityUsername"
1862
- | "IdentityEmail"
1863
- | "IdentityPhone"
1864
- | "IdentityAddress"
1865
- | "SshKey"
1866
- | "SecureNotes";
1867
-
1868
- export type CipherListViewType =
1869
- | { login: LoginListView }
1870
- | "secureNote"
1871
- | { card: CardListView }
1872
- | "identity"
1873
- | "sshKey";
1874
-
1875
- export interface SshKeyView {
1897
+ export interface SshKey {
1876
1898
  /**
1877
1899
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1878
1900
  */
1879
- privateKey: string;
1901
+ privateKey: EncString;
1880
1902
  /**
1881
1903
  * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1882
1904
  */
1883
- publicKey: string;
1905
+ publicKey: EncString;
1884
1906
  /**
1885
1907
  * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1886
1908
  */
1887
- fingerprint: string;
1909
+ fingerprint: EncString;
1888
1910
  }
1889
1911
 
1890
- export interface SshKey {
1912
+ export interface SshKeyView {
1891
1913
  /**
1892
1914
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1893
1915
  */
1894
- privateKey: EncString;
1916
+ privateKey: string;
1895
1917
  /**
1896
1918
  * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1897
1919
  */
1898
- publicKey: EncString;
1920
+ publicKey: string;
1899
1921
  /**
1900
1922
  * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1901
1923
  */
1902
- fingerprint: EncString;
1924
+ fingerprint: string;
1903
1925
  }
1904
1926
 
1905
1927
  export interface Identity {
@@ -1946,11 +1968,6 @@ export interface IdentityView {
1946
1968
 
1947
1969
  export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
1948
1970
 
1949
- /**
1950
- * NewType wrapper for `FolderId`
1951
- */
1952
- export type FolderId = Tagged<Uuid, "FolderId">;
1953
-
1954
1971
  export interface Folder {
1955
1972
  id: FolderId | undefined;
1956
1973
  name: EncString;
@@ -1963,6 +1980,11 @@ export interface FolderView {
1963
1980
  revisionDate: DateTime<Utc>;
1964
1981
  }
1965
1982
 
1983
+ /**
1984
+ * NewType wrapper for `FolderId`
1985
+ */
1986
+ export type FolderId = Tagged<Uuid, "FolderId">;
1987
+
1966
1988
  export interface EditFolderError extends Error {
1967
1989
  name: "EditFolderError";
1968
1990
  variant:
@@ -2713,6 +2735,15 @@ export class RegistrationClient {
2713
2735
  * admin password reset and finally enrolls the user to TDE unlock.
2714
2736
  */
2715
2737
  post_keys_for_tde_registration(request: TdeRegistrationRequest): Promise<TdeRegistrationResponse>;
2738
+ /**
2739
+ * Initializes a new cryptographic state for a user and posts it to the server; enrolls the
2740
+ * user to key connector unlock.
2741
+ */
2742
+ post_keys_for_key_connector_registration(
2743
+ key_connector_url: string,
2744
+ sso_org_identifier: string,
2745
+ user_id: UserId,
2746
+ ): Promise<KeyConnectorRegistrationResult>;
2716
2747
  }
2717
2748
  /**
2718
2749
  * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.