@bitwarden/sdk-internal 0.2.0-main.20 → 0.2.0-main.201

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,10 +1,80 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function set_log_level(level: LogLevel): void;
4
+ export function init_sdk(log_level?: LogLevel | null): void;
3
5
  /**
4
- * @param {KeyAlgorithm} key_algorithm
5
- * @returns {GenerateSshKeyResult}
6
+ * Generate a new SSH key pair
7
+ *
8
+ * # Arguments
9
+ * - `key_algorithm` - The algorithm to use for the key pair
10
+ *
11
+ * # Returns
12
+ * - `Ok(SshKey)` if the key was successfully generated
13
+ * - `Err(KeyGenerationError)` if the key could not be generated
6
14
  */
7
- export function generate_ssh_key(key_algorithm: KeyAlgorithm): GenerateSshKeyResult;
15
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
16
+ /**
17
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
18
+ * to an OpenSSH private key with public key and fingerprint
19
+ *
20
+ * # Arguments
21
+ * - `imported_key` - The private key to convert
22
+ * - `password` - The password to use for decrypting the key
23
+ *
24
+ * # Returns
25
+ * - `Ok(SshKey)` if the key was successfully coneverted
26
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
27
+ * - `Err(WrongPassword)` if the password provided is incorrect
28
+ * - `Err(ParsingError)` if the key could not be parsed
29
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
30
+ */
31
+ export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
32
+ export enum CardLinkedIdType {
33
+ CardholderName = 300,
34
+ ExpMonth = 301,
35
+ ExpYear = 302,
36
+ Code = 303,
37
+ Brand = 304,
38
+ Number = 305,
39
+ }
40
+ export enum CipherRepromptType {
41
+ None = 0,
42
+ Password = 1,
43
+ }
44
+ export enum CipherType {
45
+ Login = 1,
46
+ SecureNote = 2,
47
+ Card = 3,
48
+ Identity = 4,
49
+ SshKey = 5,
50
+ }
51
+ export enum FieldType {
52
+ Text = 0,
53
+ Hidden = 1,
54
+ Boolean = 2,
55
+ Linked = 3,
56
+ }
57
+ export enum IdentityLinkedIdType {
58
+ Title = 400,
59
+ MiddleName = 401,
60
+ Address1 = 402,
61
+ Address2 = 403,
62
+ Address3 = 404,
63
+ City = 405,
64
+ State = 406,
65
+ PostalCode = 407,
66
+ Country = 408,
67
+ Company = 409,
68
+ Email = 410,
69
+ Phone = 411,
70
+ Ssn = 412,
71
+ Username = 413,
72
+ PassportNumber = 414,
73
+ LicenseNumber = 415,
74
+ FirstName = 416,
75
+ LastName = 417,
76
+ FullName = 418,
77
+ }
8
78
  export enum LogLevel {
9
79
  Trace = 0,
10
80
  Debug = 1,
@@ -12,7 +82,29 @@ export enum LogLevel {
12
82
  Warn = 3,
13
83
  Error = 4,
14
84
  }
85
+ export enum LoginLinkedIdType {
86
+ Username = 100,
87
+ Password = 101,
88
+ }
89
+ export enum SecureNoteType {
90
+ Generic = 0,
91
+ }
92
+ export enum UriMatchType {
93
+ Domain = 0,
94
+ Host = 1,
95
+ StartsWith = 2,
96
+ Exact = 3,
97
+ RegularExpression = 4,
98
+ Never = 5,
99
+ }
100
+ /**
101
+ * State used for initializing the user cryptographic state.
102
+ */
15
103
  export interface InitUserCryptoRequest {
104
+ /**
105
+ * The user\'s ID.
106
+ */
107
+ userId: Uuid | undefined;
16
108
  /**
17
109
  * The user\'s KDF parameters, as received from the prelogin request
18
110
  */
@@ -24,15 +116,18 @@ export interface InitUserCryptoRequest {
24
116
  /**
25
117
  * The user\'s encrypted private key
26
118
  */
27
- privateKey: string;
119
+ privateKey: EncString;
28
120
  /**
29
121
  * The initialization method to use
30
122
  */
31
123
  method: InitUserCryptoMethod;
32
124
  }
33
125
 
126
+ /**
127
+ * The crypto method used to initialize the user cryptographic state.
128
+ */
34
129
  export type InitUserCryptoMethod =
35
- | { password: { password: string; user_key: string } }
130
+ | { password: { password: string; user_key: EncString } }
36
131
  | { decryptedKey: { decrypted_user_key: string } }
37
132
  | { pin: { pin: string; pin_protected_user_key: EncString } }
38
133
  | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
@@ -40,50 +135,159 @@ export type InitUserCryptoMethod =
40
135
  deviceKey: {
41
136
  device_key: string;
42
137
  protected_device_private_key: EncString;
43
- device_protected_user_key: AsymmetricEncString;
138
+ device_protected_user_key: UnsignedSharedKey;
44
139
  };
45
140
  }
46
- | { keyConnector: { master_key: string; user_key: string } };
141
+ | { keyConnector: { master_key: string; user_key: EncString } };
47
142
 
143
+ /**
144
+ * Auth requests supports multiple initialization methods.
145
+ */
48
146
  export type AuthRequestMethod =
49
- | { userKey: { protected_user_key: AsymmetricEncString } }
50
- | { masterKey: { protected_master_key: AsymmetricEncString; auth_request_key: EncString } };
147
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
148
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
51
149
 
150
+ /**
151
+ * Represents the request to initialize the user\'s organizational cryptographic state.
152
+ */
52
153
  export interface InitOrgCryptoRequest {
53
154
  /**
54
155
  * The encryption keys for all the organizations the user is a part of
55
156
  */
56
- organizationKeys: Map<Uuid, AsymmetricEncString>;
157
+ organizationKeys: Map<Uuid, UnsignedSharedKey>;
57
158
  }
58
159
 
59
- export interface CoreError extends Error {
60
- name: "CoreError";
61
- variant:
62
- | "MissingFieldError"
63
- | "VaultLocked"
64
- | "NotAuthenticated"
65
- | "AccessTokenInvalid"
66
- | "InvalidResponse"
67
- | "Crypto"
68
- | "IdentityFail"
69
- | "Reqwest"
70
- | "Serde"
71
- | "Io"
72
- | "InvalidBase64"
73
- | "Chrono"
74
- | "ResponseContent"
75
- | "ValidationError"
76
- | "InvalidStateFileVersion"
77
- | "InvalidStateFile"
78
- | "Internal"
79
- | "EncryptionSettings";
160
+ /**
161
+ * Response from the `update_password` function
162
+ */
163
+ export interface UpdatePasswordResponse {
164
+ /**
165
+ * Hash of the new password
166
+ */
167
+ passwordHash: string;
168
+ /**
169
+ * User key, encrypted with the new password
170
+ */
171
+ newKey: EncString;
80
172
  }
81
173
 
82
- export function isCoreError(error: any): error is CoreError;
174
+ /**
175
+ * Request for deriving a pin protected user key
176
+ */
177
+ export interface DerivePinKeyResponse {
178
+ /**
179
+ * [UserKey] protected by PIN
180
+ */
181
+ pinProtectedUserKey: EncString;
182
+ /**
183
+ * PIN protected by [UserKey]
184
+ */
185
+ encryptedPin: EncString;
186
+ }
187
+
188
+ /**
189
+ * Request for migrating an account from password to key connector.
190
+ */
191
+ export interface DeriveKeyConnectorRequest {
192
+ /**
193
+ * Encrypted user key, used to validate the master key
194
+ */
195
+ userKeyEncrypted: EncString;
196
+ /**
197
+ * The user\'s master password
198
+ */
199
+ password: string;
200
+ /**
201
+ * The KDF parameters used to derive the master key
202
+ */
203
+ kdf: Kdf;
204
+ /**
205
+ * The user\'s email address
206
+ */
207
+ email: string;
208
+ }
209
+
210
+ /**
211
+ * Response from the `make_key_pair` function
212
+ */
213
+ export interface MakeKeyPairResponse {
214
+ /**
215
+ * The user\'s public key
216
+ */
217
+ userPublicKey: string;
218
+ /**
219
+ * User\'s private key, encrypted with the user key
220
+ */
221
+ userKeyEncryptedPrivateKey: EncString;
222
+ }
223
+
224
+ /**
225
+ * Request for `verify_asymmetric_keys`.
226
+ */
227
+ export interface VerifyAsymmetricKeysRequest {
228
+ /**
229
+ * The user\'s user key
230
+ */
231
+ userKey: string;
232
+ /**
233
+ * The user\'s public key
234
+ */
235
+ userPublicKey: string;
236
+ /**
237
+ * User\'s private key, encrypted with the user key
238
+ */
239
+ userKeyEncryptedPrivateKey: EncString;
240
+ }
241
+
242
+ /**
243
+ * Response for `verify_asymmetric_keys`.
244
+ */
245
+ export interface VerifyAsymmetricKeysResponse {
246
+ /**
247
+ * Whether the user\'s private key was decryptable by the user key.
248
+ */
249
+ privateKeyDecryptable: boolean;
250
+ /**
251
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
252
+ */
253
+ validPrivateKey: boolean;
254
+ }
255
+
256
+ /**
257
+ * NewType wrapper for `OrganizationId`
258
+ */
259
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
260
+
261
+ export interface DeriveKeyConnectorError extends Error {
262
+ name: "DeriveKeyConnectorError";
263
+ variant: "WrongPassword" | "Crypto";
264
+ }
265
+
266
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
267
+
268
+ export interface EnrollAdminPasswordResetError extends Error {
269
+ name: "EnrollAdminPasswordResetError";
270
+ variant: "VaultLocked" | "Crypto" | "InvalidBase64";
271
+ }
272
+
273
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
274
+
275
+ export interface CryptoClientError extends Error {
276
+ name: "CryptoClientError";
277
+ variant: "NotAuthenticated" | "VaultLocked" | "Crypto";
278
+ }
279
+
280
+ export function isCryptoClientError(error: any): error is CryptoClientError;
83
281
 
84
282
  export interface EncryptionSettingsError extends Error {
85
283
  name: "EncryptionSettingsError";
86
- variant: "Crypto" | "InvalidBase64" | "VaultLocked" | "InvalidPrivateKey" | "MissingPrivateKey";
284
+ variant:
285
+ | "Crypto"
286
+ | "InvalidBase64"
287
+ | "VaultLocked"
288
+ | "InvalidPrivateKey"
289
+ | "MissingPrivateKey"
290
+ | "UserIdAlreadySetError";
87
291
  }
88
292
 
89
293
  export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
@@ -152,7 +356,7 @@ export interface ClientSettings {
152
356
  deviceType?: DeviceType;
153
357
  }
154
358
 
155
- export type AsymmetricEncString = string;
359
+ export type UnsignedSharedKey = string;
156
360
 
157
361
  export type EncString = string;
158
362
 
@@ -166,14 +370,239 @@ export type Kdf =
166
370
  | { pBKDF2: { iterations: NonZeroU32 } }
167
371
  | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
168
372
 
169
- export interface GenerateSshKeyResult {
170
- private_key: string;
171
- public_key: string;
172
- key_fingerprint: string;
373
+ export interface CryptoError extends Error {
374
+ name: "CryptoError";
375
+ variant:
376
+ | "InvalidKey"
377
+ | "InvalidMac"
378
+ | "MacNotProvided"
379
+ | "KeyDecrypt"
380
+ | "InvalidKeyLen"
381
+ | "InvalidUtf8String"
382
+ | "MissingKey"
383
+ | "MissingField"
384
+ | "MissingKeyId"
385
+ | "ReadOnlyKeyStore"
386
+ | "InsufficientKdfParameters"
387
+ | "EncString"
388
+ | "RsaError"
389
+ | "FingerprintError"
390
+ | "ArgonError"
391
+ | "ZeroNumber"
392
+ | "OperationNotSupported"
393
+ | "WrongKeyType"
394
+ | "InvalidNonceLength";
395
+ }
396
+
397
+ export function isCryptoError(error: any): error is CryptoError;
398
+
399
+ /**
400
+ * Temporary struct to hold metadata related to current account
401
+ *
402
+ * Eventually the SDK itself should have this state and we get rid of this struct.
403
+ */
404
+ export interface Account {
405
+ id: Uuid;
406
+ email: string;
407
+ name: string | undefined;
408
+ }
409
+
410
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
411
+
412
+ export interface ExportError extends Error {
413
+ name: "ExportError";
414
+ variant:
415
+ | "MissingField"
416
+ | "NotAuthenticated"
417
+ | "VaultLocked"
418
+ | "Csv"
419
+ | "CxfError"
420
+ | "Json"
421
+ | "EncryptedJsonError"
422
+ | "BitwardenCryptoError"
423
+ | "CipherError";
173
424
  }
174
425
 
426
+ export function isExportError(error: any): error is ExportError;
427
+
428
+ export type UsernameGeneratorRequest =
429
+ | { word: { capitalize: boolean; include_number: boolean } }
430
+ | { subaddress: { type: AppendType; email: string } }
431
+ | { catchall: { type: AppendType; domain: string } }
432
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
433
+
434
+ /**
435
+ * Configures the email forwarding service to use.
436
+ * For instructions on how to configure each service, see the documentation:
437
+ * <https://bitwarden.com/help/generator/#username-types>
438
+ */
439
+ export type ForwarderServiceType =
440
+ | { addyIo: { api_token: string; domain: string; base_url: string } }
441
+ | { duckDuckGo: { token: string } }
442
+ | { firefox: { api_token: string } }
443
+ | { fastmail: { api_token: string } }
444
+ | { forwardEmail: { api_token: string; domain: string } }
445
+ | { simpleLogin: { api_key: string; base_url: string } };
446
+
447
+ export type AppendType = "random" | { websiteName: { website: string } };
448
+
449
+ export interface UsernameError extends Error {
450
+ name: "UsernameError";
451
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
452
+ }
453
+
454
+ export function isUsernameError(error: any): error is UsernameError;
455
+
456
+ /**
457
+ * Password generator request options.
458
+ */
459
+ export interface PasswordGeneratorRequest {
460
+ /**
461
+ * Include lowercase characters (a-z).
462
+ */
463
+ lowercase: boolean;
464
+ /**
465
+ * Include uppercase characters (A-Z).
466
+ */
467
+ uppercase: boolean;
468
+ /**
469
+ * Include numbers (0-9).
470
+ */
471
+ numbers: boolean;
472
+ /**
473
+ * Include special characters: ! @ # $ % ^ & *
474
+ */
475
+ special: boolean;
476
+ /**
477
+ * The length of the generated password.
478
+ * Note that the password length must be greater than the sum of all the minimums.
479
+ */
480
+ length: number;
481
+ /**
482
+ * When set to true, the generated password will not contain ambiguous characters.
483
+ * The ambiguous characters are: I, O, l, 0, 1
484
+ */
485
+ avoidAmbiguous: boolean;
486
+ /**
487
+ * The minimum number of lowercase characters in the generated password.
488
+ * When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
489
+ */
490
+ minLowercase: number | undefined;
491
+ /**
492
+ * The minimum number of uppercase characters in the generated password.
493
+ * When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
494
+ */
495
+ minUppercase: number | undefined;
496
+ /**
497
+ * The minimum number of numbers in the generated password.
498
+ * When set, the value must be between 1 and 9. This value is ignored if numbers is false.
499
+ */
500
+ minNumber: number | undefined;
501
+ /**
502
+ * The minimum number of special characters in the generated password.
503
+ * When set, the value must be between 1 and 9. This value is ignored if special is false.
504
+ */
505
+ minSpecial: number | undefined;
506
+ }
507
+
508
+ export interface PasswordError extends Error {
509
+ name: "PasswordError";
510
+ variant: "NoCharacterSetEnabled" | "InvalidLength";
511
+ }
512
+
513
+ export function isPasswordError(error: any): error is PasswordError;
514
+
515
+ /**
516
+ * Passphrase generator request options.
517
+ */
518
+ export interface PassphraseGeneratorRequest {
519
+ /**
520
+ * Number of words in the generated passphrase.
521
+ * This value must be between 3 and 20.
522
+ */
523
+ numWords: number;
524
+ /**
525
+ * Character separator between words in the generated passphrase. The value cannot be empty.
526
+ */
527
+ wordSeparator: string;
528
+ /**
529
+ * When set to true, capitalize the first letter of each word in the generated passphrase.
530
+ */
531
+ capitalize: boolean;
532
+ /**
533
+ * When set to true, include a number at the end of one of the words in the generated
534
+ * passphrase.
535
+ */
536
+ includeNumber: boolean;
537
+ }
538
+
539
+ export interface PassphraseError extends Error {
540
+ name: "PassphraseError";
541
+ variant: "InvalidNumWords";
542
+ }
543
+
544
+ export function isPassphraseError(error: any): error is PassphraseError;
545
+
546
+ export type Endpoint =
547
+ | { Web: { id: number } }
548
+ | "BrowserForeground"
549
+ | "BrowserBackground"
550
+ | "DesktopRenderer"
551
+ | "DesktopMain";
552
+
553
+ export interface IpcCommunicationBackendSender {
554
+ send(message: OutgoingMessage): Promise<void>;
555
+ }
556
+
557
+ export interface ChannelError extends Error {
558
+ name: "ChannelError";
559
+ }
560
+
561
+ export function isChannelError(error: any): error is ChannelError;
562
+
563
+ export interface DeserializeError extends Error {
564
+ name: "DeserializeError";
565
+ }
566
+
567
+ export function isDeserializeError(error: any): error is DeserializeError;
568
+
569
+ export interface TypedReceiveError extends Error {
570
+ name: "TypedReceiveError";
571
+ variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
572
+ }
573
+
574
+ export function isTypedReceiveError(error: any): error is TypedReceiveError;
575
+
576
+ export interface ReceiveError extends Error {
577
+ name: "ReceiveError";
578
+ variant: "Channel" | "Timeout" | "Cancelled";
579
+ }
580
+
581
+ export function isReceiveError(error: any): error is ReceiveError;
582
+
583
+ export interface SubscribeError extends Error {
584
+ name: "SubscribeError";
585
+ variant: "NotStarted";
586
+ }
587
+
588
+ export function isSubscribeError(error: any): error is SubscribeError;
589
+
175
590
  export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
176
591
 
592
+ export interface SshKeyExportError extends Error {
593
+ name: "SshKeyExportError";
594
+ variant: "KeyConversionError";
595
+ }
596
+
597
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
598
+
599
+ export interface SshKeyImportError extends Error {
600
+ name: "SshKeyImportError";
601
+ variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
602
+ }
603
+
604
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
605
+
177
606
  export interface KeyGenerationError extends Error {
178
607
  name: "KeyGenerationError";
179
608
  variant: "KeyGenerationError" | "KeyConversionError";
@@ -181,6 +610,241 @@ export interface KeyGenerationError extends Error {
181
610
 
182
611
  export function isKeyGenerationError(error: any): error is KeyGenerationError;
183
612
 
613
+ export interface CallError extends Error {
614
+ name: "CallError";
615
+ }
616
+
617
+ export function isCallError(error: any): error is CallError;
618
+
619
+ export interface EncryptionContext {
620
+ /**
621
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
622
+ * Organization-owned ciphers
623
+ */
624
+ encryptedFor: Uuid;
625
+ cipher: Cipher;
626
+ }
627
+
628
+ export interface Cipher {
629
+ id: Uuid | undefined;
630
+ organizationId: Uuid | undefined;
631
+ folderId: Uuid | undefined;
632
+ collectionIds: Uuid[];
633
+ /**
634
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
635
+ * Cipher.
636
+ */
637
+ key: EncString | undefined;
638
+ name: EncString;
639
+ notes: EncString | undefined;
640
+ type: CipherType;
641
+ login: Login | undefined;
642
+ identity: Identity | undefined;
643
+ card: Card | undefined;
644
+ secureNote: SecureNote | undefined;
645
+ sshKey: SshKey | undefined;
646
+ favorite: boolean;
647
+ reprompt: CipherRepromptType;
648
+ organizationUseTotp: boolean;
649
+ edit: boolean;
650
+ permissions: CipherPermissions | undefined;
651
+ viewPassword: boolean;
652
+ localData: LocalData | undefined;
653
+ attachments: Attachment[] | undefined;
654
+ fields: Field[] | undefined;
655
+ passwordHistory: PasswordHistory[] | undefined;
656
+ creationDate: DateTime<Utc>;
657
+ deletedDate: DateTime<Utc> | undefined;
658
+ revisionDate: DateTime<Utc>;
659
+ }
660
+
661
+ export interface CipherView {
662
+ id: Uuid | undefined;
663
+ organizationId: Uuid | undefined;
664
+ folderId: Uuid | undefined;
665
+ collectionIds: Uuid[];
666
+ /**
667
+ * Temporary, required to support re-encrypting existing items.
668
+ */
669
+ key: EncString | undefined;
670
+ name: string;
671
+ notes: string | undefined;
672
+ type: CipherType;
673
+ login: LoginView | undefined;
674
+ identity: IdentityView | undefined;
675
+ card: CardView | undefined;
676
+ secureNote: SecureNoteView | undefined;
677
+ sshKey: SshKeyView | undefined;
678
+ favorite: boolean;
679
+ reprompt: CipherRepromptType;
680
+ organizationUseTotp: boolean;
681
+ edit: boolean;
682
+ permissions: CipherPermissions | undefined;
683
+ viewPassword: boolean;
684
+ localData: LocalDataView | undefined;
685
+ attachments: AttachmentView[] | undefined;
686
+ fields: FieldView[] | undefined;
687
+ passwordHistory: PasswordHistoryView[] | undefined;
688
+ creationDate: DateTime<Utc>;
689
+ deletedDate: DateTime<Utc> | undefined;
690
+ revisionDate: DateTime<Utc>;
691
+ }
692
+
693
+ export type CipherListViewType =
694
+ | { login: LoginListView }
695
+ | "secureNote"
696
+ | { card: CardListView }
697
+ | "identity"
698
+ | "sshKey";
699
+
700
+ export interface CipherListView {
701
+ id: Uuid | undefined;
702
+ organizationId: Uuid | undefined;
703
+ folderId: Uuid | undefined;
704
+ collectionIds: Uuid[];
705
+ /**
706
+ * Temporary, required to support calculating TOTP from CipherListView.
707
+ */
708
+ key: EncString | undefined;
709
+ name: string;
710
+ subtitle: string;
711
+ type: CipherListViewType;
712
+ favorite: boolean;
713
+ reprompt: CipherRepromptType;
714
+ organizationUseTotp: boolean;
715
+ edit: boolean;
716
+ permissions: CipherPermissions | undefined;
717
+ viewPassword: boolean;
718
+ /**
719
+ * The number of attachments
720
+ */
721
+ attachments: number;
722
+ creationDate: DateTime<Utc>;
723
+ deletedDate: DateTime<Utc> | undefined;
724
+ revisionDate: DateTime<Utc>;
725
+ }
726
+
727
+ export interface Field {
728
+ name: EncString | undefined;
729
+ value: EncString | undefined;
730
+ type: FieldType;
731
+ linkedId: LinkedIdType | undefined;
732
+ }
733
+
734
+ export interface FieldView {
735
+ name: string | undefined;
736
+ value: string | undefined;
737
+ type: FieldType;
738
+ linkedId: LinkedIdType | undefined;
739
+ }
740
+
741
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
742
+
743
+ export interface LoginUri {
744
+ uri: EncString | undefined;
745
+ match: UriMatchType | undefined;
746
+ uriChecksum: EncString | undefined;
747
+ }
748
+
749
+ export interface LoginUriView {
750
+ uri: string | undefined;
751
+ match: UriMatchType | undefined;
752
+ uriChecksum: string | undefined;
753
+ }
754
+
755
+ export interface Fido2Credential {
756
+ credentialId: EncString;
757
+ keyType: EncString;
758
+ keyAlgorithm: EncString;
759
+ keyCurve: EncString;
760
+ keyValue: EncString;
761
+ rpId: EncString;
762
+ userHandle: EncString | undefined;
763
+ userName: EncString | undefined;
764
+ counter: EncString;
765
+ rpName: EncString | undefined;
766
+ userDisplayName: EncString | undefined;
767
+ discoverable: EncString;
768
+ creationDate: DateTime<Utc>;
769
+ }
770
+
771
+ export interface Fido2CredentialListView {
772
+ credentialId: string;
773
+ rpId: string;
774
+ userHandle: string | undefined;
775
+ userName: string | undefined;
776
+ userDisplayName: string | undefined;
777
+ }
778
+
779
+ export interface Fido2CredentialView {
780
+ credentialId: string;
781
+ keyType: string;
782
+ keyAlgorithm: string;
783
+ keyCurve: string;
784
+ keyValue: EncString;
785
+ rpId: string;
786
+ userHandle: string | undefined;
787
+ userName: string | undefined;
788
+ counter: string;
789
+ rpName: string | undefined;
790
+ userDisplayName: string | undefined;
791
+ discoverable: string;
792
+ creationDate: DateTime<Utc>;
793
+ }
794
+
795
+ export interface Fido2CredentialNewView {
796
+ credentialId: string;
797
+ keyType: string;
798
+ keyAlgorithm: string;
799
+ keyCurve: string;
800
+ rpId: string;
801
+ userHandle: string | undefined;
802
+ userName: string | undefined;
803
+ counter: string;
804
+ rpName: string | undefined;
805
+ userDisplayName: string | undefined;
806
+ creationDate: DateTime<Utc>;
807
+ }
808
+
809
+ export interface Login {
810
+ username: EncString | undefined;
811
+ password: EncString | undefined;
812
+ passwordRevisionDate: DateTime<Utc> | undefined;
813
+ uris: LoginUri[] | undefined;
814
+ totp: EncString | undefined;
815
+ autofillOnPageLoad: boolean | undefined;
816
+ fido2Credentials: Fido2Credential[] | undefined;
817
+ }
818
+
819
+ export interface LoginView {
820
+ username: string | undefined;
821
+ password: string | undefined;
822
+ passwordRevisionDate: DateTime<Utc> | undefined;
823
+ uris: LoginUriView[] | undefined;
824
+ totp: string | undefined;
825
+ autofillOnPageLoad: boolean | undefined;
826
+ fido2Credentials: Fido2Credential[] | undefined;
827
+ }
828
+
829
+ export interface LoginListView {
830
+ fido2Credentials: Fido2CredentialListView[] | undefined;
831
+ hasFido2: boolean;
832
+ username: string | undefined;
833
+ /**
834
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
835
+ */
836
+ totp: EncString | undefined;
837
+ uris: LoginUriView[] | undefined;
838
+ }
839
+
840
+ export interface SecureNote {
841
+ type: SecureNoteType;
842
+ }
843
+
844
+ export interface SecureNoteView {
845
+ type: SecureNoteType;
846
+ }
847
+
184
848
  export interface Folder {
185
849
  id: Uuid | undefined;
186
850
  name: EncString;
@@ -193,11 +857,224 @@ export interface FolderView {
193
857
  revisionDate: DateTime<Utc>;
194
858
  }
195
859
 
196
- export interface TestError extends Error {
197
- name: "TestError";
860
+ export interface DecryptError extends Error {
861
+ name: "DecryptError";
862
+ variant: "Crypto" | "VaultLocked";
198
863
  }
199
864
 
200
- export function isTestError(error: any): error is TestError;
865
+ export function isDecryptError(error: any): error is DecryptError;
866
+
867
+ export interface EncryptError extends Error {
868
+ name: "EncryptError";
869
+ variant: "Crypto" | "VaultLocked" | "MissingUserId";
870
+ }
871
+
872
+ export function isEncryptError(error: any): error is EncryptError;
873
+
874
+ export interface TotpResponse {
875
+ /**
876
+ * Generated TOTP code
877
+ */
878
+ code: string;
879
+ /**
880
+ * Time period
881
+ */
882
+ period: number;
883
+ }
884
+
885
+ export interface TotpError extends Error {
886
+ name: "TotpError";
887
+ variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
888
+ }
889
+
890
+ export function isTotpError(error: any): error is TotpError;
891
+
892
+ export interface PasswordHistoryView {
893
+ password: string;
894
+ lastUsedDate: DateTime<Utc>;
895
+ }
896
+
897
+ export interface PasswordHistory {
898
+ password: EncString;
899
+ lastUsedDate: DateTime<Utc>;
900
+ }
901
+
902
+ export interface Collection {
903
+ id: Uuid | undefined;
904
+ organizationId: Uuid;
905
+ name: EncString;
906
+ externalId: string | undefined;
907
+ hidePasswords: boolean;
908
+ readOnly: boolean;
909
+ manage: boolean;
910
+ }
911
+
912
+ export interface SshKeyView {
913
+ /**
914
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
915
+ */
916
+ privateKey: string;
917
+ /**
918
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
919
+ */
920
+ publicKey: string;
921
+ /**
922
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
923
+ */
924
+ fingerprint: string;
925
+ }
926
+
927
+ export interface SshKey {
928
+ /**
929
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
930
+ */
931
+ privateKey: EncString;
932
+ /**
933
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
934
+ */
935
+ publicKey: EncString;
936
+ /**
937
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
938
+ */
939
+ fingerprint: EncString;
940
+ }
941
+
942
+ export interface LocalDataView {
943
+ lastUsedDate: DateTime<Utc> | undefined;
944
+ lastLaunched: DateTime<Utc> | undefined;
945
+ }
946
+
947
+ export interface LocalData {
948
+ lastUsedDate: DateTime<Utc> | undefined;
949
+ lastLaunched: DateTime<Utc> | undefined;
950
+ }
951
+
952
+ export interface IdentityView {
953
+ title: string | undefined;
954
+ firstName: string | undefined;
955
+ middleName: string | undefined;
956
+ lastName: string | undefined;
957
+ address1: string | undefined;
958
+ address2: string | undefined;
959
+ address3: string | undefined;
960
+ city: string | undefined;
961
+ state: string | undefined;
962
+ postalCode: string | undefined;
963
+ country: string | undefined;
964
+ company: string | undefined;
965
+ email: string | undefined;
966
+ phone: string | undefined;
967
+ ssn: string | undefined;
968
+ username: string | undefined;
969
+ passportNumber: string | undefined;
970
+ licenseNumber: string | undefined;
971
+ }
972
+
973
+ export interface Identity {
974
+ title: EncString | undefined;
975
+ firstName: EncString | undefined;
976
+ middleName: EncString | undefined;
977
+ lastName: EncString | undefined;
978
+ address1: EncString | undefined;
979
+ address2: EncString | undefined;
980
+ address3: EncString | undefined;
981
+ city: EncString | undefined;
982
+ state: EncString | undefined;
983
+ postalCode: EncString | undefined;
984
+ country: EncString | undefined;
985
+ company: EncString | undefined;
986
+ email: EncString | undefined;
987
+ phone: EncString | undefined;
988
+ ssn: EncString | undefined;
989
+ username: EncString | undefined;
990
+ passportNumber: EncString | undefined;
991
+ licenseNumber: EncString | undefined;
992
+ }
993
+
994
+ export interface CipherPermissions {
995
+ delete: boolean;
996
+ restore: boolean;
997
+ }
998
+
999
+ export interface CipherError extends Error {
1000
+ name: "CipherError";
1001
+ variant: "MissingFieldError" | "VaultLocked" | "CryptoError" | "AttachmentsWithoutKeys";
1002
+ }
1003
+
1004
+ export function isCipherError(error: any): error is CipherError;
1005
+
1006
+ /**
1007
+ * Minimal CardView only including the needed details for list views
1008
+ */
1009
+ export interface CardListView {
1010
+ /**
1011
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1012
+ */
1013
+ brand: string | undefined;
1014
+ }
1015
+
1016
+ export interface CardView {
1017
+ cardholderName: string | undefined;
1018
+ expMonth: string | undefined;
1019
+ expYear: string | undefined;
1020
+ code: string | undefined;
1021
+ brand: string | undefined;
1022
+ number: string | undefined;
1023
+ }
1024
+
1025
+ export interface Card {
1026
+ cardholderName: EncString | undefined;
1027
+ expMonth: EncString | undefined;
1028
+ expYear: EncString | undefined;
1029
+ code: EncString | undefined;
1030
+ brand: EncString | undefined;
1031
+ number: EncString | undefined;
1032
+ }
1033
+
1034
+ export interface DecryptFileError extends Error {
1035
+ name: "DecryptFileError";
1036
+ variant: "Decrypt" | "Io";
1037
+ }
1038
+
1039
+ export function isDecryptFileError(error: any): error is DecryptFileError;
1040
+
1041
+ export interface EncryptFileError extends Error {
1042
+ name: "EncryptFileError";
1043
+ variant: "Encrypt" | "Io";
1044
+ }
1045
+
1046
+ export function isEncryptFileError(error: any): error is EncryptFileError;
1047
+
1048
+ export interface AttachmentView {
1049
+ id: string | undefined;
1050
+ url: string | undefined;
1051
+ size: string | undefined;
1052
+ sizeName: string | undefined;
1053
+ fileName: string | undefined;
1054
+ key: EncString | undefined;
1055
+ }
1056
+
1057
+ export interface Attachment {
1058
+ id: string | undefined;
1059
+ url: string | undefined;
1060
+ size: string | undefined;
1061
+ /**
1062
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1063
+ */
1064
+ sizeName: string | undefined;
1065
+ fileName: EncString | undefined;
1066
+ key: EncString | undefined;
1067
+ }
1068
+
1069
+ import { Tagged } from "type-fest";
1070
+
1071
+ /**
1072
+ * A string that **MUST** be a valid UUID.
1073
+ *
1074
+ * Never create or cast to this type directly, use the `uuid<T>()` function instead.
1075
+ */
1076
+ // TODO: Uncomment this when the `uuid` crate is used.
1077
+ // export type Uuid = unknown;
201
1078
 
202
1079
  export type Uuid = string;
203
1080
 
@@ -217,73 +1094,356 @@ export type Utc = unknown;
217
1094
  */
218
1095
  export type NonZeroU32 = number;
219
1096
 
1097
+ export interface TestError extends Error {
1098
+ name: "TestError";
1099
+ }
1100
+
1101
+ export function isTestError(error: any): error is TestError;
1102
+
1103
+ export class AttachmentsClient {
1104
+ private constructor();
1105
+ free(): void;
1106
+ decrypt_buffer(
1107
+ cipher: Cipher,
1108
+ attachment: AttachmentView,
1109
+ encrypted_buffer: Uint8Array,
1110
+ ): Uint8Array;
1111
+ }
220
1112
  export class BitwardenClient {
221
1113
  free(): void;
222
- /**
223
- * @param {ClientSettings | undefined} [settings]
224
- * @param {LogLevel | undefined} [log_level]
225
- */
226
- constructor(settings?: ClientSettings, log_level?: LogLevel);
1114
+ constructor(settings?: ClientSettings | null);
227
1115
  /**
228
1116
  * Test method, echoes back the input
229
- * @param {string} msg
230
- * @returns {string}
231
1117
  */
232
1118
  echo(msg: string): string;
233
- /**
234
- * @returns {string}
235
- */
236
1119
  version(): string;
237
- /**
238
- * @param {string} msg
239
- * @returns {Promise<void>}
240
- */
241
- throw(msg: string): Promise<void>;
1120
+ throw(msg: string): void;
242
1121
  /**
243
1122
  * Test method, calls http endpoint
244
- * @param {string} url
245
- * @returns {Promise<string>}
246
1123
  */
247
1124
  http_get(url: string): Promise<string>;
1125
+ crypto(): CryptoClient;
1126
+ vault(): VaultClient;
248
1127
  /**
249
- * @returns {ClientCrypto}
1128
+ * Constructs a specific client for generating passwords and passphrases
250
1129
  */
251
- crypto(): ClientCrypto;
252
- /**
253
- * @returns {ClientVault}
254
- */
255
- vault(): ClientVault;
1130
+ generator(): GeneratorClient;
1131
+ exporters(): ExporterClient;
256
1132
  }
257
- export class ClientCrypto {
1133
+ export class CiphersClient {
1134
+ private constructor();
1135
+ free(): void;
1136
+ encrypt(cipher_view: CipherView): EncryptionContext;
1137
+ decrypt(cipher: Cipher): CipherView;
1138
+ decrypt_list(ciphers: Cipher[]): CipherListView[];
1139
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
1140
+ move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
1141
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
1142
+ }
1143
+ /**
1144
+ * A client for the crypto operations.
1145
+ */
1146
+ export class CryptoClient {
1147
+ private constructor();
258
1148
  free(): void;
259
1149
  /**
260
1150
  * Initialization method for the user crypto. Needs to be called before any other crypto
261
1151
  * operations.
262
- * @param {InitUserCryptoRequest} req
263
- * @returns {Promise<void>}
264
1152
  */
265
1153
  initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
266
1154
  /**
267
1155
  * Initialization method for the organization crypto. Needs to be called after
268
1156
  * `initialize_user_crypto` but before any other crypto operations.
269
- * @param {InitOrgCryptoRequest} req
270
- * @returns {Promise<void>}
271
1157
  */
272
1158
  initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
1159
+ /**
1160
+ * Generates a new key pair and encrypts the private key with the provided user key.
1161
+ * Crypto initialization not required.
1162
+ */
1163
+ make_key_pair(user_key: string): MakeKeyPairResponse;
1164
+ /**
1165
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
1166
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
1167
+ * Crypto initialization not required.
1168
+ */
1169
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
273
1170
  }
274
- export class ClientFolders {
1171
+ export class ExporterClient {
1172
+ private constructor();
275
1173
  free(): void;
1174
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
1175
+ export_organization_vault(
1176
+ collections: Collection[],
1177
+ ciphers: Cipher[],
1178
+ format: ExportFormat,
1179
+ ): string;
276
1180
  /**
277
- * Decrypt folder
278
- * @param {Folder} folder
279
- * @returns {FolderView}
1181
+ * Credential Exchange Format (CXF)
1182
+ *
1183
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1184
+ *
1185
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1186
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
280
1187
  */
1188
+ export_cxf(account: Account, ciphers: Cipher[]): string;
1189
+ /**
1190
+ * Credential Exchange Format (CXF)
1191
+ *
1192
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1193
+ *
1194
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1195
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1196
+ */
1197
+ import_cxf(payload: string): Cipher[];
1198
+ }
1199
+ export class FoldersClient {
1200
+ private constructor();
1201
+ free(): void;
1202
+ encrypt(folder_view: FolderView): Folder;
281
1203
  decrypt(folder: Folder): FolderView;
1204
+ decrypt_list(folders: Folder[]): FolderView[];
1205
+ }
1206
+ export class GeneratorClient {
1207
+ private constructor();
1208
+ free(): void;
1209
+ /**
1210
+ * Generates a random password.
1211
+ *
1212
+ * The character sets and password length can be customized using the `input` parameter.
1213
+ *
1214
+ * # Examples
1215
+ *
1216
+ * ```
1217
+ * use bitwarden_core::Client;
1218
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
1219
+ *
1220
+ * async fn test() -> Result<(), PassphraseError> {
1221
+ * let input = PasswordGeneratorRequest {
1222
+ * lowercase: true,
1223
+ * uppercase: true,
1224
+ * numbers: true,
1225
+ * length: 20,
1226
+ * ..Default::default()
1227
+ * };
1228
+ * let password = Client::new(None).generator().password(input).unwrap();
1229
+ * println!("{}", password);
1230
+ * Ok(())
1231
+ * }
1232
+ * ```
1233
+ */
1234
+ password(input: PasswordGeneratorRequest): string;
1235
+ /**
1236
+ * Generates a random passphrase.
1237
+ * A passphrase is a combination of random words separated by a character.
1238
+ * An example of passphrase is `correct horse battery staple`.
1239
+ *
1240
+ * The number of words and their case, the word separator, and the inclusion of
1241
+ * a number in the passphrase can be customized using the `input` parameter.
1242
+ *
1243
+ * # Examples
1244
+ *
1245
+ * ```
1246
+ * use bitwarden_core::Client;
1247
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
1248
+ *
1249
+ * async fn test() -> Result<(), PassphraseError> {
1250
+ * let input = PassphraseGeneratorRequest {
1251
+ * num_words: 4,
1252
+ * ..Default::default()
1253
+ * };
1254
+ * let passphrase = Client::new(None).generator().passphrase(input).unwrap();
1255
+ * println!("{}", passphrase);
1256
+ * Ok(())
1257
+ * }
1258
+ * ```
1259
+ */
1260
+ passphrase(input: PassphraseGeneratorRequest): string;
282
1261
  }
283
- export class ClientVault {
1262
+ export class IncomingMessage {
1263
+ free(): void;
1264
+ constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
1265
+ /**
1266
+ * Try to parse the payload as JSON.
1267
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
1268
+ */
1269
+ parse_payload_as_json(): any;
1270
+ payload: Uint8Array;
1271
+ destination: Endpoint;
1272
+ source: Endpoint;
1273
+ get topic(): string | undefined;
1274
+ set topic(value: string | null | undefined);
1275
+ }
1276
+ /**
1277
+ * JavaScript wrapper around the IPC client. For more information, see the
1278
+ * [IpcClient] documentation.
1279
+ */
1280
+ export class IpcClient {
284
1281
  free(): void;
1282
+ constructor(communication_provider: IpcCommunicationBackend);
1283
+ start(): Promise<void>;
1284
+ isRunning(): Promise<boolean>;
1285
+ send(message: OutgoingMessage): Promise<void>;
1286
+ subscribe(): Promise<IpcClientSubscription>;
1287
+ }
1288
+ /**
1289
+ * JavaScript wrapper around the IPC client subscription. For more information, see the
1290
+ * [IpcClientSubscription](crate::IpcClientSubscription) documentation.
1291
+ */
1292
+ export class IpcClientSubscription {
1293
+ private constructor();
1294
+ free(): void;
1295
+ receive(abort_signal?: any | null): Promise<IncomingMessage>;
1296
+ }
1297
+ /**
1298
+ * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
1299
+ */
1300
+ export class IpcCommunicationBackend {
1301
+ free(): void;
1302
+ /**
1303
+ * Creates a new instance of the JavaScript communication backend.
1304
+ */
1305
+ constructor(sender: IpcCommunicationBackendSender);
1306
+ /**
1307
+ * Used by JavaScript to provide an incoming message to the IPC framework.
1308
+ */
1309
+ receive(message: IncomingMessage): void;
1310
+ }
1311
+ export class OutgoingMessage {
1312
+ free(): void;
1313
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
1314
+ /**
1315
+ * Create a new message and encode the payload as JSON.
1316
+ */
1317
+ static new_json_payload(
1318
+ payload: any,
1319
+ destination: Endpoint,
1320
+ topic?: string | null,
1321
+ ): OutgoingMessage;
1322
+ payload: Uint8Array;
1323
+ destination: Endpoint;
1324
+ get topic(): string | undefined;
1325
+ set topic(value: string | null | undefined);
1326
+ }
1327
+ /**
1328
+ * This module represents a stopgap solution to provide access to primitive crypto functions for JS
1329
+ * clients. It is not intended to be used outside of the JS clients and this pattern should not be
1330
+ * proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
1331
+ * responsible for state and keys.
1332
+ */
1333
+ export class PureCrypto {
1334
+ private constructor();
1335
+ free(): void;
1336
+ /**
1337
+ * DEPRECATED: Use `symmetric_decrypt_string` instead.
1338
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
1339
+ */
1340
+ static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
1341
+ static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
1342
+ static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
1343
+ /**
1344
+ * DEPRECATED: Use `symmetric_decrypt_filedata` instead.
1345
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
1346
+ */
1347
+ static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
1348
+ static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
1349
+ static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
1350
+ static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
1351
+ static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
1352
+ static decrypt_user_key_with_master_password(
1353
+ encrypted_user_key: string,
1354
+ master_password: string,
1355
+ email: string,
1356
+ kdf: Kdf,
1357
+ ): Uint8Array;
1358
+ static encrypt_user_key_with_master_password(
1359
+ user_key: Uint8Array,
1360
+ master_password: string,
1361
+ email: string,
1362
+ kdf: Kdf,
1363
+ ): string;
1364
+ static make_user_key_aes256_cbc_hmac(): Uint8Array;
1365
+ static make_user_key_xchacha20_poly1305(): Uint8Array;
1366
+ /**
1367
+ * Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
1368
+ * as an EncString.
1369
+ */
1370
+ static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
1371
+ /**
1372
+ * Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
1373
+ * unwrapped key as a serialized byte array.
1374
+ */
1375
+ static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
1376
+ /**
1377
+ * Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
1378
+ * key. Note: Usually, a public key is - by definition - public, so this should not be
1379
+ * used. The specific use-case for this function is to enable rotateable key sets, where
1380
+ * the "public key" is not public, with the intent of preventing the server from being able
1381
+ * to overwrite the user key unlocked by the rotateable keyset.
1382
+ */
1383
+ static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
1384
+ /**
1385
+ * Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
1386
+ * wrapping key.
1387
+ */
1388
+ static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
1389
+ /**
1390
+ * Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
1391
+ * key,
1392
+ */
1393
+ static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
1394
+ /**
1395
+ * Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
1396
+ * wrapping key.
1397
+ */
1398
+ static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
1399
+ /**
1400
+ * Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key)
1401
+ * in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
1402
+ * the sender's authenticity cannot be verified by the recipient.
1403
+ */
1404
+ static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
1405
+ /**
1406
+ * Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8
1407
+ * DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
1408
+ * recipient.
1409
+ */
1410
+ static decapsulate_key_unsigned(
1411
+ encapsulated_key: string,
1412
+ decapsulation_key: Uint8Array,
1413
+ ): Uint8Array;
1414
+ }
1415
+ export class TotpClient {
1416
+ private constructor();
1417
+ free(): void;
1418
+ /**
1419
+ * Generates a TOTP code from a provided key
1420
+ *
1421
+ * # Arguments
1422
+ * - `key` - Can be:
1423
+ * - A base32 encoded string
1424
+ * - OTP Auth URI
1425
+ * - Steam URI
1426
+ * - `time_ms` - Optional timestamp in milliseconds
1427
+ */
1428
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
1429
+ }
1430
+ export class VaultClient {
1431
+ private constructor();
1432
+ free(): void;
1433
+ /**
1434
+ * Attachment related operations.
1435
+ */
1436
+ attachments(): AttachmentsClient;
1437
+ /**
1438
+ * Cipher related operations.
1439
+ */
1440
+ ciphers(): CiphersClient;
1441
+ /**
1442
+ * Folder related operations.
1443
+ */
1444
+ folders(): FoldersClient;
285
1445
  /**
286
- * @returns {ClientFolders}
1446
+ * TOTP related operations.
287
1447
  */
288
- folders(): ClientFolders;
1448
+ totp(): TotpClient;
289
1449
  }