@bitwarden/sdk-internal 0.2.0-main.36 → 0.2.0-main.361

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,6 +1,110 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function generate_ssh_key(key_algorithm: KeyAlgorithm): GenerateSshKeyResult;
3
+ export function set_log_level(level: LogLevel): void;
4
+ export function init_sdk(log_level?: LogLevel | null): void;
5
+ /**
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
14
+ */
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
+ /**
33
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
34
+ */
35
+ export function ipcRegisterDiscoverHandler(
36
+ ipc_client: IpcClient,
37
+ response: DiscoverResponse,
38
+ ): Promise<void>;
39
+ /**
40
+ * Sends a DiscoverRequest to the specified destination and returns the response.
41
+ */
42
+ export function ipcRequestDiscover(
43
+ ipc_client: IpcClient,
44
+ destination: Endpoint,
45
+ abort_signal?: AbortSignal | null,
46
+ ): Promise<DiscoverResponse>;
47
+ export enum CardLinkedIdType {
48
+ CardholderName = 300,
49
+ ExpMonth = 301,
50
+ ExpYear = 302,
51
+ Code = 303,
52
+ Brand = 304,
53
+ Number = 305,
54
+ }
55
+ export enum CipherRepromptType {
56
+ None = 0,
57
+ Password = 1,
58
+ }
59
+ export enum CipherType {
60
+ Login = 1,
61
+ SecureNote = 2,
62
+ Card = 3,
63
+ Identity = 4,
64
+ SshKey = 5,
65
+ }
66
+ /**
67
+ * Represents the type of a [FieldView].
68
+ */
69
+ export enum FieldType {
70
+ /**
71
+ * Text field
72
+ */
73
+ Text = 0,
74
+ /**
75
+ * Hidden text field
76
+ */
77
+ Hidden = 1,
78
+ /**
79
+ * Boolean field
80
+ */
81
+ Boolean = 2,
82
+ /**
83
+ * Linked field
84
+ */
85
+ Linked = 3,
86
+ }
87
+ export enum IdentityLinkedIdType {
88
+ Title = 400,
89
+ MiddleName = 401,
90
+ Address1 = 402,
91
+ Address2 = 403,
92
+ Address3 = 404,
93
+ City = 405,
94
+ State = 406,
95
+ PostalCode = 407,
96
+ Country = 408,
97
+ Company = 409,
98
+ Email = 410,
99
+ Phone = 411,
100
+ Ssn = 412,
101
+ Username = 413,
102
+ PassportNumber = 414,
103
+ LicenseNumber = 415,
104
+ FirstName = 416,
105
+ LastName = 417,
106
+ FullName = 418,
107
+ }
4
108
  export enum LogLevel {
5
109
  Trace = 0,
6
110
  Debug = 1,
@@ -8,7 +112,258 @@ export enum LogLevel {
8
112
  Warn = 3,
9
113
  Error = 4,
10
114
  }
115
+ export enum LoginLinkedIdType {
116
+ Username = 100,
117
+ Password = 101,
118
+ }
119
+ export enum SecureNoteType {
120
+ Generic = 0,
121
+ }
122
+ export enum UriMatchType {
123
+ Domain = 0,
124
+ Host = 1,
125
+ StartsWith = 2,
126
+ Exact = 3,
127
+ RegularExpression = 4,
128
+ Never = 5,
129
+ }
130
+
131
+ import { Tagged } from "type-fest";
132
+
133
+ /**
134
+ * A string that **MUST** be a valid UUID.
135
+ *
136
+ * Never create or cast to this type directly, use the `uuid<T>()` function instead.
137
+ */
138
+ export type Uuid = unknown;
139
+
140
+ /**
141
+ * RFC3339 compliant date-time string.
142
+ * @typeParam T - Not used in JavaScript.
143
+ */
144
+ export type DateTime<T = unknown> = string;
145
+
146
+ /**
147
+ * UTC date-time string. Not used in JavaScript.
148
+ */
149
+ export type Utc = unknown;
150
+
151
+ /**
152
+ * An integer that is known not to equal zero.
153
+ */
154
+ export type NonZeroU32 = number;
155
+
156
+ export interface Repository<T> {
157
+ get(id: string): Promise<T | null>;
158
+ list(): Promise<T[]>;
159
+ set(id: string, value: T): Promise<void>;
160
+ remove(id: string): Promise<void>;
161
+ }
162
+
163
+ export interface TokenProvider {
164
+ get_access_token(): Promise<string | undefined>;
165
+ }
166
+
167
+ /**
168
+ * Active feature flags for the SDK.
169
+ */
170
+ export interface FeatureFlags extends Map<string, boolean> {}
171
+
172
+ export interface Repositories {
173
+ cipher: Repository<Cipher> | null;
174
+ folder: Repository<Folder> | null;
175
+ }
176
+
177
+ export interface IndexedDbConfiguration {
178
+ db_name: string;
179
+ }
180
+
181
+ export interface TestError extends Error {
182
+ name: "TestError";
183
+ }
184
+
185
+ export function isTestError(error: any): error is TestError;
186
+
187
+ /**
188
+ * Represents the possible, expected errors that can occur when requesting a send access token.
189
+ */
190
+ export type SendAccessTokenApiErrorResponse =
191
+ | {
192
+ error: "invalid_request";
193
+ error_description?: string;
194
+ send_access_error_type?: SendAccessTokenInvalidRequestError;
195
+ }
196
+ | {
197
+ error: "invalid_grant";
198
+ error_description?: string;
199
+ send_access_error_type?: SendAccessTokenInvalidGrantError;
200
+ }
201
+ | { error: "invalid_client"; error_description?: string }
202
+ | { error: "unauthorized_client"; error_description?: string }
203
+ | { error: "unsupported_grant_type"; error_description?: string }
204
+ | { error: "invalid_scope"; error_description?: string }
205
+ | { error: "invalid_target"; error_description?: string };
206
+
207
+ /**
208
+ * Invalid grant errors - typically due to invalid credentials.
209
+ */
210
+ export type SendAccessTokenInvalidGrantError =
211
+ | "send_id_invalid"
212
+ | "password_hash_b64_invalid"
213
+ | "email_invalid"
214
+ | "otp_invalid"
215
+ | "otp_generation_failed"
216
+ | "unknown";
217
+
218
+ /**
219
+ * Invalid request errors - typically due to missing parameters.
220
+ */
221
+ export type SendAccessTokenInvalidRequestError =
222
+ | "send_id_required"
223
+ | "password_hash_b64_required"
224
+ | "email_required"
225
+ | "email_and_otp_required_otp_sent"
226
+ | "unknown";
227
+
228
+ /**
229
+ * Any unexpected error that occurs when making requests to identity. This could be
230
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
231
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
232
+ * unexpected body or status. Used when decoding the server\'s error payload into
233
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
234
+ * available.
235
+ */
236
+ export type UnexpectedIdentityError = string;
237
+
238
+ /**
239
+ * Represents errors that can occur when requesting a send access token.
240
+ * It includes expected and unexpected API errors.
241
+ */
242
+ export type SendAccessTokenError =
243
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
244
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
245
+
246
+ /**
247
+ * A send access token which can be used to access a send.
248
+ */
249
+ export interface SendAccessTokenResponse {
250
+ /**
251
+ * The actual token string.
252
+ */
253
+ token: string;
254
+ /**
255
+ * The timestamp in milliseconds when the token expires.
256
+ */
257
+ expiresAt: number;
258
+ }
259
+
260
+ /**
261
+ * A request structure for requesting a send access token from the API.
262
+ */
263
+ export interface SendAccessTokenRequest {
264
+ /**
265
+ * The id of the send for which the access token is requested.
266
+ */
267
+ sendId: string;
268
+ /**
269
+ * The optional send access credentials.
270
+ */
271
+ sendAccessCredentials?: SendAccessCredentials;
272
+ }
273
+
274
+ /**
275
+ * The credentials used for send access requests.
276
+ */
277
+ export type SendAccessCredentials =
278
+ | SendPasswordCredentials
279
+ | SendEmailCredentials
280
+ | SendEmailOtpCredentials;
281
+
282
+ /**
283
+ * Credentials for getting a send access token using an email and OTP.
284
+ */
285
+ export interface SendEmailOtpCredentials {
286
+ /**
287
+ * The email address to which the OTP will be sent.
288
+ */
289
+ email: string;
290
+ /**
291
+ * The one-time password (OTP) that the user has received via email.
292
+ */
293
+ otp: string;
294
+ }
295
+
296
+ /**
297
+ * Credentials for sending an OTP to the user\'s email address.
298
+ * This is used when the send requires email verification with an OTP.
299
+ */
300
+ export interface SendEmailCredentials {
301
+ /**
302
+ * The email address to which the OTP will be sent.
303
+ */
304
+ email: string;
305
+ }
306
+
307
+ /**
308
+ * Credentials for sending password secured access requests.
309
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
310
+ * struct.
311
+ */
312
+ export interface SendPasswordCredentials {
313
+ /**
314
+ * A Base64-encoded hash of the password protecting the send.
315
+ */
316
+ passwordHashB64: string;
317
+ }
318
+
319
+ /**
320
+ * NewType wrapper for `CollectionId`
321
+ */
322
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
323
+
324
+ export interface Collection {
325
+ id: CollectionId | undefined;
326
+ organizationId: OrganizationId;
327
+ name: EncString;
328
+ externalId: string | undefined;
329
+ hidePasswords: boolean;
330
+ readOnly: boolean;
331
+ manage: boolean;
332
+ defaultUserCollectionEmail: string | undefined;
333
+ type: CollectionType;
334
+ }
335
+
336
+ export interface CollectionView {
337
+ id: CollectionId | undefined;
338
+ organizationId: OrganizationId;
339
+ name: string;
340
+ externalId: string | undefined;
341
+ hidePasswords: boolean;
342
+ readOnly: boolean;
343
+ manage: boolean;
344
+ type: CollectionType;
345
+ }
346
+
347
+ /**
348
+ * Type of collection
349
+ */
350
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
351
+
352
+ export interface CollectionDecryptError extends Error {
353
+ name: "CollectionDecryptError";
354
+ variant: "Crypto";
355
+ }
356
+
357
+ export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
358
+
359
+ /**
360
+ * State used for initializing the user cryptographic state.
361
+ */
11
362
  export interface InitUserCryptoRequest {
363
+ /**
364
+ * The user\'s ID.
365
+ */
366
+ userId: UserId | undefined;
12
367
  /**
13
368
  * The user\'s KDF parameters, as received from the prelogin request
14
369
  */
@@ -20,216 +375,1473 @@ export interface InitUserCryptoRequest {
20
375
  /**
21
376
  * The user\'s encrypted private key
22
377
  */
23
- privateKey: string;
378
+ privateKey: EncString;
379
+ /**
380
+ * The user\'s signing key
381
+ */
382
+ signingKey: EncString | undefined;
383
+ /**
384
+ * The user\'s security state
385
+ */
386
+ securityState: SignedSecurityState | undefined;
24
387
  /**
25
388
  * The initialization method to use
26
389
  */
27
390
  method: InitUserCryptoMethod;
28
391
  }
29
392
 
393
+ /**
394
+ * The crypto method used to initialize the user cryptographic state.
395
+ */
30
396
  export type InitUserCryptoMethod =
31
- | { password: { password: string; user_key: string } }
397
+ | { password: { password: string; user_key: EncString } }
398
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
32
399
  | { decryptedKey: { decrypted_user_key: string } }
33
400
  | { pin: { pin: string; pin_protected_user_key: EncString } }
34
- | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
401
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
402
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
35
403
  | {
36
404
  deviceKey: {
37
405
  device_key: string;
38
406
  protected_device_private_key: EncString;
39
- device_protected_user_key: AsymmetricEncString;
407
+ device_protected_user_key: UnsignedSharedKey;
40
408
  };
41
409
  }
42
- | { keyConnector: { master_key: string; user_key: string } };
410
+ | { keyConnector: { master_key: B64; user_key: EncString } };
43
411
 
412
+ /**
413
+ * Auth requests supports multiple initialization methods.
414
+ */
44
415
  export type AuthRequestMethod =
45
- | { userKey: { protected_user_key: AsymmetricEncString } }
46
- | { masterKey: { protected_master_key: AsymmetricEncString; auth_request_key: EncString } };
416
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
417
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
47
418
 
419
+ /**
420
+ * Represents the request to initialize the user\'s organizational cryptographic state.
421
+ */
48
422
  export interface InitOrgCryptoRequest {
49
423
  /**
50
424
  * The encryption keys for all the organizations the user is a part of
51
425
  */
52
- organizationKeys: Map<Uuid, AsymmetricEncString>;
426
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
53
427
  }
54
428
 
55
- export interface CoreError extends Error {
56
- name: "CoreError";
57
- variant:
58
- | "MissingFieldError"
59
- | "VaultLocked"
60
- | "NotAuthenticated"
61
- | "AccessTokenInvalid"
62
- | "InvalidResponse"
63
- | "Crypto"
64
- | "IdentityFail"
65
- | "Reqwest"
66
- | "Serde"
67
- | "Io"
68
- | "InvalidBase64"
69
- | "Chrono"
70
- | "ResponseContent"
71
- | "ValidationError"
72
- | "InvalidStateFileVersion"
73
- | "InvalidStateFile"
74
- | "Internal"
75
- | "EncryptionSettings";
76
- }
77
-
78
- export function isCoreError(error: any): error is CoreError;
429
+ /**
430
+ * Response from the `update_kdf` function
431
+ */
432
+ export interface UpdateKdfResponse {
433
+ /**
434
+ * The authentication data for the new KDF setting
435
+ */
436
+ masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
437
+ /**
438
+ * The unlock data for the new KDF setting
439
+ */
440
+ masterPasswordUnlockData: MasterPasswordUnlockData;
441
+ /**
442
+ * The authentication data for the KDF setting prior to the change
443
+ */
444
+ oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
445
+ }
79
446
 
80
- export interface EncryptionSettingsError extends Error {
81
- name: "EncryptionSettingsError";
82
- variant: "Crypto" | "InvalidBase64" | "VaultLocked" | "InvalidPrivateKey" | "MissingPrivateKey";
447
+ /**
448
+ * Response from the `update_password` function
449
+ */
450
+ export interface UpdatePasswordResponse {
451
+ /**
452
+ * Hash of the new password
453
+ */
454
+ passwordHash: B64;
455
+ /**
456
+ * User key, encrypted with the new password
457
+ */
458
+ newKey: EncString;
83
459
  }
84
460
 
85
- export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
461
+ /**
462
+ * Request for deriving a pin protected user key
463
+ */
464
+ export interface EnrollPinResponse {
465
+ /**
466
+ * [UserKey] protected by PIN
467
+ */
468
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
469
+ /**
470
+ * PIN protected by [UserKey]
471
+ */
472
+ userKeyEncryptedPin: EncString;
473
+ }
86
474
 
87
- export type DeviceType =
88
- | "Android"
89
- | "iOS"
90
- | "ChromeExtension"
91
- | "FirefoxExtension"
92
- | "OperaExtension"
93
- | "EdgeExtension"
94
- | "WindowsDesktop"
95
- | "MacOsDesktop"
96
- | "LinuxDesktop"
97
- | "ChromeBrowser"
98
- | "FirefoxBrowser"
99
- | "OperaBrowser"
100
- | "EdgeBrowser"
101
- | "IEBrowser"
102
- | "UnknownBrowser"
103
- | "AndroidAmazon"
104
- | "UWP"
105
- | "SafariBrowser"
106
- | "VivaldiBrowser"
107
- | "VivaldiExtension"
108
- | "SafariExtension"
109
- | "SDK"
110
- | "Server"
111
- | "WindowsCLI"
112
- | "MacOsCLI"
113
- | "LinuxCLI";
475
+ /**
476
+ * Request for deriving a pin protected user key
477
+ */
478
+ export interface DerivePinKeyResponse {
479
+ /**
480
+ * [UserKey] protected by PIN
481
+ */
482
+ pinProtectedUserKey: EncString;
483
+ /**
484
+ * PIN protected by [UserKey]
485
+ */
486
+ encryptedPin: EncString;
487
+ }
114
488
 
115
489
  /**
116
- * Basic client behavior settings. These settings specify the various targets and behavior of the
117
- * Bitwarden Client. They are optional and uneditable once the client is initialized.
118
- *
119
- * Defaults to
120
- *
121
- * ```
122
- * # use bitwarden_core::{ClientSettings, DeviceType};
123
- * let settings = ClientSettings {
124
- * identity_url: \"https://identity.bitwarden.com\".to_string(),
125
- * api_url: \"https://api.bitwarden.com\".to_string(),
126
- * user_agent: \"Bitwarden Rust-SDK\".to_string(),
127
- * device_type: DeviceType::SDK,
128
- * };
129
- * let default = ClientSettings::default();
130
- * ```
490
+ * Request for migrating an account from password to key connector.
131
491
  */
132
- export interface ClientSettings {
492
+ export interface DeriveKeyConnectorRequest {
133
493
  /**
134
- * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
494
+ * Encrypted user key, used to validate the master key
135
495
  */
136
- identityUrl?: string;
496
+ userKeyEncrypted: EncString;
137
497
  /**
138
- * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
498
+ * The user\'s master password
499
+ */
500
+ password: string;
501
+ /**
502
+ * The KDF parameters used to derive the master key
503
+ */
504
+ kdf: Kdf;
505
+ /**
506
+ * The user\'s email address
507
+ */
508
+ email: string;
509
+ }
510
+
511
+ /**
512
+ * Response from the `make_key_pair` function
513
+ */
514
+ export interface MakeKeyPairResponse {
515
+ /**
516
+ * The user\'s public key
517
+ */
518
+ userPublicKey: B64;
519
+ /**
520
+ * User\'s private key, encrypted with the user key
521
+ */
522
+ userKeyEncryptedPrivateKey: EncString;
523
+ }
524
+
525
+ /**
526
+ * Request for `verify_asymmetric_keys`.
527
+ */
528
+ export interface VerifyAsymmetricKeysRequest {
529
+ /**
530
+ * The user\'s user key
531
+ */
532
+ userKey: B64;
533
+ /**
534
+ * The user\'s public key
535
+ */
536
+ userPublicKey: B64;
537
+ /**
538
+ * User\'s private key, encrypted with the user key
539
+ */
540
+ userKeyEncryptedPrivateKey: EncString;
541
+ }
542
+
543
+ /**
544
+ * Response for `verify_asymmetric_keys`.
545
+ */
546
+ export interface VerifyAsymmetricKeysResponse {
547
+ /**
548
+ * Whether the user\'s private key was decryptable by the user key.
549
+ */
550
+ privateKeyDecryptable: boolean;
551
+ /**
552
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
553
+ */
554
+ validPrivateKey: boolean;
555
+ }
556
+
557
+ /**
558
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
559
+ */
560
+ export interface UserCryptoV2KeysResponse {
561
+ /**
562
+ * User key
563
+ */
564
+ userKey: B64;
565
+ /**
566
+ * Wrapped private key
567
+ */
568
+ privateKey: EncString;
569
+ /**
570
+ * Public key
571
+ */
572
+ publicKey: B64;
573
+ /**
574
+ * The user\'s public key, signed by the signing key
575
+ */
576
+ signedPublicKey: SignedPublicKey;
577
+ /**
578
+ * Signing key, encrypted with the user\'s symmetric key
579
+ */
580
+ signingKey: EncString;
581
+ /**
582
+ * Base64 encoded verifying key
583
+ */
584
+ verifyingKey: B64;
585
+ /**
586
+ * The user\'s signed security state
587
+ */
588
+ securityState: SignedSecurityState;
589
+ /**
590
+ * The security state\'s version
591
+ */
592
+ securityVersion: number;
593
+ }
594
+
595
+ /**
596
+ * Represents the data required to unlock with the master password.
597
+ */
598
+ export interface MasterPasswordUnlockData {
599
+ /**
600
+ * The key derivation function used to derive the master key
601
+ */
602
+ kdf: Kdf;
603
+ /**
604
+ * The master key wrapped user key
605
+ */
606
+ masterKeyWrappedUserKey: EncString;
607
+ /**
608
+ * The salt used in the KDF, typically the user\'s email
609
+ */
610
+ salt: string;
611
+ }
612
+
613
+ /**
614
+ * Represents the data required to authenticate with the master password.
615
+ */
616
+ export interface MasterPasswordAuthenticationData {
617
+ kdf: Kdf;
618
+ salt: string;
619
+ masterPasswordAuthenticationHash: B64;
620
+ }
621
+
622
+ export type SignedSecurityState = string;
623
+
624
+ /**
625
+ * NewType wrapper for `UserId`
626
+ */
627
+ export type UserId = Tagged<Uuid, "UserId">;
628
+
629
+ /**
630
+ * NewType wrapper for `OrganizationId`
631
+ */
632
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
633
+
634
+ export interface MasterPasswordError extends Error {
635
+ name: "MasterPasswordError";
636
+ variant:
637
+ | "EncryptionKeyMalformed"
638
+ | "KdfMalformed"
639
+ | "InvalidKdfConfiguration"
640
+ | "MissingField"
641
+ | "Crypto";
642
+ }
643
+
644
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
645
+
646
+ export interface DeriveKeyConnectorError extends Error {
647
+ name: "DeriveKeyConnectorError";
648
+ variant: "WrongPassword" | "Crypto";
649
+ }
650
+
651
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
652
+
653
+ export interface EnrollAdminPasswordResetError extends Error {
654
+ name: "EnrollAdminPasswordResetError";
655
+ variant: "Crypto";
656
+ }
657
+
658
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
659
+
660
+ export interface CryptoClientError extends Error {
661
+ name: "CryptoClientError";
662
+ variant: "NotAuthenticated" | "Crypto" | "InvalidKdfSettings" | "PasswordProtectedKeyEnvelope";
663
+ }
664
+
665
+ export function isCryptoClientError(error: any): error is CryptoClientError;
666
+
667
+ export interface StatefulCryptoError extends Error {
668
+ name: "StatefulCryptoError";
669
+ variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
670
+ }
671
+
672
+ export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
673
+
674
+ export interface EncryptionSettingsError extends Error {
675
+ name: "EncryptionSettingsError";
676
+ variant:
677
+ | "Crypto"
678
+ | "InvalidPrivateKey"
679
+ | "InvalidSigningKey"
680
+ | "InvalidSecurityState"
681
+ | "MissingPrivateKey"
682
+ | "UserIdAlreadySet"
683
+ | "WrongPin";
684
+ }
685
+
686
+ export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
687
+
688
+ export type DeviceType =
689
+ | "Android"
690
+ | "iOS"
691
+ | "ChromeExtension"
692
+ | "FirefoxExtension"
693
+ | "OperaExtension"
694
+ | "EdgeExtension"
695
+ | "WindowsDesktop"
696
+ | "MacOsDesktop"
697
+ | "LinuxDesktop"
698
+ | "ChromeBrowser"
699
+ | "FirefoxBrowser"
700
+ | "OperaBrowser"
701
+ | "EdgeBrowser"
702
+ | "IEBrowser"
703
+ | "UnknownBrowser"
704
+ | "AndroidAmazon"
705
+ | "UWP"
706
+ | "SafariBrowser"
707
+ | "VivaldiBrowser"
708
+ | "VivaldiExtension"
709
+ | "SafariExtension"
710
+ | "SDK"
711
+ | "Server"
712
+ | "WindowsCLI"
713
+ | "MacOsCLI"
714
+ | "LinuxCLI"
715
+ | "DuckDuckGoBrowser";
716
+
717
+ /**
718
+ * Basic client behavior settings. These settings specify the various targets and behavior of the
719
+ * Bitwarden Client. They are optional and uneditable once the client is initialized.
720
+ *
721
+ * Defaults to
722
+ *
723
+ * ```
724
+ * # use bitwarden_core::{ClientSettings, DeviceType};
725
+ * let settings = ClientSettings {
726
+ * identity_url: \"https://identity.bitwarden.com\".to_string(),
727
+ * api_url: \"https://api.bitwarden.com\".to_string(),
728
+ * user_agent: \"Bitwarden Rust-SDK\".to_string(),
729
+ * device_type: DeviceType::SDK,
730
+ * bitwarden_client_version: None,
731
+ * };
732
+ * let default = ClientSettings::default();
733
+ * ```
734
+ */
735
+ export interface ClientSettings {
736
+ /**
737
+ * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
738
+ */
739
+ identityUrl?: string;
740
+ /**
741
+ * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
742
+ */
743
+ apiUrl?: string;
744
+ /**
745
+ * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
746
+ */
747
+ userAgent?: string;
748
+ /**
749
+ * Device type to send to Bitwarden. Defaults to SDK
750
+ */
751
+ deviceType?: DeviceType;
752
+ /**
753
+ * Bitwarden Client Version to send to Bitwarden.
754
+ */
755
+ bitwardenClientVersion?: string | undefined;
756
+ }
757
+
758
+ export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
759
+
760
+ export type EncString = Tagged<string, "EncString">;
761
+
762
+ export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
763
+
764
+ export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
765
+
766
+ /**
767
+ * The type of key / signature scheme used for signing and verifying.
768
+ */
769
+ export type SignatureAlgorithm = "ed25519";
770
+
771
+ /**
772
+ * Key Derivation Function for Bitwarden Account
773
+ *
774
+ * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
775
+ * Enum represents all the possible KDFs.
776
+ */
777
+ export type Kdf =
778
+ | { pBKDF2: { iterations: NonZeroU32 } }
779
+ | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
780
+
781
+ export interface CryptoError extends Error {
782
+ name: "CryptoError";
783
+ variant:
784
+ | "InvalidKey"
785
+ | "InvalidMac"
786
+ | "MacNotProvided"
787
+ | "KeyDecrypt"
788
+ | "InvalidKeyLen"
789
+ | "InvalidUtf8String"
790
+ | "MissingKey"
791
+ | "MissingField"
792
+ | "MissingKeyId"
793
+ | "ReadOnlyKeyStore"
794
+ | "InsufficientKdfParameters"
795
+ | "EncString"
796
+ | "Rsa"
797
+ | "Fingerprint"
798
+ | "Argon"
799
+ | "ZeroNumber"
800
+ | "OperationNotSupported"
801
+ | "WrongKeyType"
802
+ | "WrongCoseKeyId"
803
+ | "InvalidNonceLength"
804
+ | "InvalidPadding"
805
+ | "Signature"
806
+ | "Encoding";
807
+ }
808
+
809
+ export function isCryptoError(error: any): error is CryptoError;
810
+
811
+ /**
812
+ * Base64 encoded data
813
+ *
814
+ * Is indifferent about padding when decoding, but always produces padding when encoding.
815
+ */
816
+ export type B64 = string;
817
+
818
+ /**
819
+ * Temporary struct to hold metadata related to current account
820
+ *
821
+ * Eventually the SDK itself should have this state and we get rid of this struct.
822
+ */
823
+ export interface Account {
824
+ id: Uuid;
825
+ email: string;
826
+ name: string | undefined;
827
+ }
828
+
829
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
830
+
831
+ export interface ExportError extends Error {
832
+ name: "ExportError";
833
+ variant:
834
+ | "MissingField"
835
+ | "NotAuthenticated"
836
+ | "Csv"
837
+ | "Cxf"
838
+ | "Json"
839
+ | "EncryptedJson"
840
+ | "BitwardenCrypto"
841
+ | "Cipher";
842
+ }
843
+
844
+ export function isExportError(error: any): error is ExportError;
845
+
846
+ export type UsernameGeneratorRequest =
847
+ | { word: { capitalize: boolean; include_number: boolean } }
848
+ | { subaddress: { type: AppendType; email: string } }
849
+ | { catchall: { type: AppendType; domain: string } }
850
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
851
+
852
+ /**
853
+ * Configures the email forwarding service to use.
854
+ * For instructions on how to configure each service, see the documentation:
855
+ * <https://bitwarden.com/help/generator/#username-types>
856
+ */
857
+ export type ForwarderServiceType =
858
+ | { addyIo: { api_token: string; domain: string; base_url: string } }
859
+ | { duckDuckGo: { token: string } }
860
+ | { firefox: { api_token: string } }
861
+ | { fastmail: { api_token: string } }
862
+ | { forwardEmail: { api_token: string; domain: string } }
863
+ | { simpleLogin: { api_key: string; base_url: string } };
864
+
865
+ export type AppendType = "random" | { websiteName: { website: string } };
866
+
867
+ export interface UsernameError extends Error {
868
+ name: "UsernameError";
869
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
870
+ }
871
+
872
+ export function isUsernameError(error: any): error is UsernameError;
873
+
874
+ /**
875
+ * Password generator request options.
876
+ */
877
+ export interface PasswordGeneratorRequest {
878
+ /**
879
+ * Include lowercase characters (a-z).
880
+ */
881
+ lowercase: boolean;
882
+ /**
883
+ * Include uppercase characters (A-Z).
884
+ */
885
+ uppercase: boolean;
886
+ /**
887
+ * Include numbers (0-9).
888
+ */
889
+ numbers: boolean;
890
+ /**
891
+ * Include special characters: ! @ # $ % ^ & *
892
+ */
893
+ special: boolean;
894
+ /**
895
+ * The length of the generated password.
896
+ * Note that the password length must be greater than the sum of all the minimums.
897
+ */
898
+ length: number;
899
+ /**
900
+ * When set to true, the generated password will not contain ambiguous characters.
901
+ * The ambiguous characters are: I, O, l, 0, 1
902
+ */
903
+ avoidAmbiguous: boolean;
904
+ /**
905
+ * The minimum number of lowercase characters in the generated password.
906
+ * When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
907
+ */
908
+ minLowercase: number | undefined;
909
+ /**
910
+ * The minimum number of uppercase characters in the generated password.
911
+ * When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
912
+ */
913
+ minUppercase: number | undefined;
914
+ /**
915
+ * The minimum number of numbers in the generated password.
916
+ * When set, the value must be between 1 and 9. This value is ignored if numbers is false.
917
+ */
918
+ minNumber: number | undefined;
919
+ /**
920
+ * The minimum number of special characters in the generated password.
921
+ * When set, the value must be between 1 and 9. This value is ignored if special is false.
922
+ */
923
+ minSpecial: number | undefined;
924
+ }
925
+
926
+ export interface PasswordError extends Error {
927
+ name: "PasswordError";
928
+ variant: "NoCharacterSetEnabled" | "InvalidLength";
929
+ }
930
+
931
+ export function isPasswordError(error: any): error is PasswordError;
932
+
933
+ /**
934
+ * Passphrase generator request options.
935
+ */
936
+ export interface PassphraseGeneratorRequest {
937
+ /**
938
+ * Number of words in the generated passphrase.
939
+ * This value must be between 3 and 20.
940
+ */
941
+ numWords: number;
942
+ /**
943
+ * Character separator between words in the generated passphrase. The value cannot be empty.
944
+ */
945
+ wordSeparator: string;
946
+ /**
947
+ * When set to true, capitalize the first letter of each word in the generated passphrase.
948
+ */
949
+ capitalize: boolean;
950
+ /**
951
+ * When set to true, include a number at the end of one of the words in the generated
952
+ * passphrase.
953
+ */
954
+ includeNumber: boolean;
955
+ }
956
+
957
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
958
+
959
+ export interface DiscoverResponse {
960
+ version: string;
961
+ }
962
+
963
+ export type Endpoint =
964
+ | { Web: { id: number } }
965
+ | "BrowserForeground"
966
+ | "BrowserBackground"
967
+ | "DesktopRenderer"
968
+ | "DesktopMain";
969
+
970
+ export interface IpcCommunicationBackendSender {
971
+ send(message: OutgoingMessage): Promise<void>;
972
+ }
973
+
974
+ export interface ChannelError extends Error {
975
+ name: "ChannelError";
976
+ }
977
+
978
+ export function isChannelError(error: any): error is ChannelError;
979
+
980
+ export interface DeserializeError extends Error {
981
+ name: "DeserializeError";
982
+ }
983
+
984
+ export function isDeserializeError(error: any): error is DeserializeError;
985
+
986
+ export interface RequestError extends Error {
987
+ name: "RequestError";
988
+ variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
989
+ }
990
+
991
+ export function isRequestError(error: any): error is RequestError;
992
+
993
+ export interface TypedReceiveError extends Error {
994
+ name: "TypedReceiveError";
995
+ variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
996
+ }
997
+
998
+ export function isTypedReceiveError(error: any): error is TypedReceiveError;
999
+
1000
+ export interface ReceiveError extends Error {
1001
+ name: "ReceiveError";
1002
+ variant: "Channel" | "Timeout" | "Cancelled";
1003
+ }
1004
+
1005
+ export function isReceiveError(error: any): error is ReceiveError;
1006
+
1007
+ export interface SubscribeError extends Error {
1008
+ name: "SubscribeError";
1009
+ variant: "NotStarted";
1010
+ }
1011
+
1012
+ export function isSubscribeError(error: any): error is SubscribeError;
1013
+
1014
+ export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
1015
+
1016
+ export interface SshKeyExportError extends Error {
1017
+ name: "SshKeyExportError";
1018
+ variant: "KeyConversion";
1019
+ }
1020
+
1021
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1022
+
1023
+ export interface SshKeyImportError extends Error {
1024
+ name: "SshKeyImportError";
1025
+ variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
1026
+ }
1027
+
1028
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
1029
+
1030
+ export interface KeyGenerationError extends Error {
1031
+ name: "KeyGenerationError";
1032
+ variant: "KeyGeneration" | "KeyConversion";
1033
+ }
1034
+
1035
+ export function isKeyGenerationError(error: any): error is KeyGenerationError;
1036
+
1037
+ export interface DatabaseError extends Error {
1038
+ name: "DatabaseError";
1039
+ variant: "UnsupportedConfiguration" | "ThreadBoundRunner" | "Serialization" | "JS" | "Internal";
1040
+ }
1041
+
1042
+ export function isDatabaseError(error: any): error is DatabaseError;
1043
+
1044
+ export interface StateRegistryError extends Error {
1045
+ name: "StateRegistryError";
1046
+ variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
1047
+ }
1048
+
1049
+ export function isStateRegistryError(error: any): error is StateRegistryError;
1050
+
1051
+ export interface CallError extends Error {
1052
+ name: "CallError";
1053
+ }
1054
+
1055
+ export function isCallError(error: any): error is CallError;
1056
+
1057
+ /**
1058
+ * NewType wrapper for `CipherId`
1059
+ */
1060
+ export type CipherId = Tagged<Uuid, "CipherId">;
1061
+
1062
+ export interface EncryptionContext {
1063
+ /**
1064
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
1065
+ * Organization-owned ciphers
1066
+ */
1067
+ encryptedFor: UserId;
1068
+ cipher: Cipher;
1069
+ }
1070
+
1071
+ export interface Cipher {
1072
+ id: CipherId | undefined;
1073
+ organizationId: OrganizationId | undefined;
1074
+ folderId: FolderId | undefined;
1075
+ collectionIds: CollectionId[];
1076
+ /**
1077
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
1078
+ * Cipher.
1079
+ */
1080
+ key: EncString | undefined;
1081
+ name: EncString;
1082
+ notes: EncString | undefined;
1083
+ type: CipherType;
1084
+ login: Login | undefined;
1085
+ identity: Identity | undefined;
1086
+ card: Card | undefined;
1087
+ secureNote: SecureNote | undefined;
1088
+ sshKey: SshKey | undefined;
1089
+ favorite: boolean;
1090
+ reprompt: CipherRepromptType;
1091
+ organizationUseTotp: boolean;
1092
+ edit: boolean;
1093
+ permissions: CipherPermissions | undefined;
1094
+ viewPassword: boolean;
1095
+ localData: LocalData | undefined;
1096
+ attachments: Attachment[] | undefined;
1097
+ fields: Field[] | undefined;
1098
+ passwordHistory: PasswordHistory[] | undefined;
1099
+ creationDate: DateTime<Utc>;
1100
+ deletedDate: DateTime<Utc> | undefined;
1101
+ revisionDate: DateTime<Utc>;
1102
+ archivedDate: DateTime<Utc> | undefined;
1103
+ }
1104
+
1105
+ export interface CipherView {
1106
+ id: CipherId | undefined;
1107
+ organizationId: OrganizationId | undefined;
1108
+ folderId: FolderId | undefined;
1109
+ collectionIds: CollectionId[];
1110
+ /**
1111
+ * Temporary, required to support re-encrypting existing items.
1112
+ */
1113
+ key: EncString | undefined;
1114
+ name: string;
1115
+ notes: string | undefined;
1116
+ type: CipherType;
1117
+ login: LoginView | undefined;
1118
+ identity: IdentityView | undefined;
1119
+ card: CardView | undefined;
1120
+ secureNote: SecureNoteView | undefined;
1121
+ sshKey: SshKeyView | undefined;
1122
+ favorite: boolean;
1123
+ reprompt: CipherRepromptType;
1124
+ organizationUseTotp: boolean;
1125
+ edit: boolean;
1126
+ permissions: CipherPermissions | undefined;
1127
+ viewPassword: boolean;
1128
+ localData: LocalDataView | undefined;
1129
+ attachments: AttachmentView[] | undefined;
1130
+ fields: FieldView[] | undefined;
1131
+ passwordHistory: PasswordHistoryView[] | undefined;
1132
+ creationDate: DateTime<Utc>;
1133
+ deletedDate: DateTime<Utc> | undefined;
1134
+ revisionDate: DateTime<Utc>;
1135
+ archivedDate: DateTime<Utc> | undefined;
1136
+ }
1137
+
1138
+ export type CipherListViewType =
1139
+ | { login: LoginListView }
1140
+ | "secureNote"
1141
+ | { card: CardListView }
1142
+ | "identity"
1143
+ | "sshKey";
1144
+
1145
+ /**
1146
+ * Available fields on a cipher and can be copied from a the list view in the UI.
1147
+ */
1148
+ export type CopyableCipherFields =
1149
+ | "LoginUsername"
1150
+ | "LoginPassword"
1151
+ | "LoginTotp"
1152
+ | "CardNumber"
1153
+ | "CardSecurityCode"
1154
+ | "IdentityUsername"
1155
+ | "IdentityEmail"
1156
+ | "IdentityPhone"
1157
+ | "IdentityAddress"
1158
+ | "SshKey"
1159
+ | "SecureNotes";
1160
+
1161
+ export interface CipherListView {
1162
+ id: CipherId | undefined;
1163
+ organizationId: OrganizationId | undefined;
1164
+ folderId: FolderId | undefined;
1165
+ collectionIds: CollectionId[];
1166
+ /**
1167
+ * Temporary, required to support calculating TOTP from CipherListView.
1168
+ */
1169
+ key: EncString | undefined;
1170
+ name: string;
1171
+ subtitle: string;
1172
+ type: CipherListViewType;
1173
+ favorite: boolean;
1174
+ reprompt: CipherRepromptType;
1175
+ organizationUseTotp: boolean;
1176
+ edit: boolean;
1177
+ permissions: CipherPermissions | undefined;
1178
+ viewPassword: boolean;
1179
+ /**
1180
+ * The number of attachments
1181
+ */
1182
+ attachments: number;
1183
+ /**
1184
+ * Indicates if the cipher has old attachments that need to be re-uploaded
1185
+ */
1186
+ hasOldAttachments: boolean;
1187
+ creationDate: DateTime<Utc>;
1188
+ deletedDate: DateTime<Utc> | undefined;
1189
+ revisionDate: DateTime<Utc>;
1190
+ archivedDate: DateTime<Utc> | undefined;
1191
+ /**
1192
+ * Hints for the presentation layer for which fields can be copied.
1193
+ */
1194
+ copyableFields: CopyableCipherFields[];
1195
+ localData: LocalDataView | undefined;
1196
+ }
1197
+
1198
+ /**
1199
+ * Represents the result of decrypting a list of ciphers.
1200
+ *
1201
+ * This struct contains two vectors: `successes` and `failures`.
1202
+ * `successes` contains the decrypted `CipherListView` objects,
1203
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
1204
+ */
1205
+ export interface DecryptCipherListResult {
1206
+ /**
1207
+ * The decrypted `CipherListView` objects.
1208
+ */
1209
+ successes: CipherListView[];
1210
+ /**
1211
+ * The original `Cipher` objects that failed to decrypt.
1212
+ */
1213
+ failures: Cipher[];
1214
+ }
1215
+
1216
+ /**
1217
+ * Request to add a cipher.
1218
+ */
1219
+ export interface CipherCreateRequest {
1220
+ organizationId: OrganizationId | undefined;
1221
+ folderId: FolderId | undefined;
1222
+ name: string;
1223
+ notes: string | undefined;
1224
+ favorite: boolean;
1225
+ reprompt: CipherRepromptType;
1226
+ type: CipherViewType;
1227
+ fields: FieldView[];
1228
+ }
1229
+
1230
+ /**
1231
+ * Request to edit a cipher.
1232
+ */
1233
+ export interface CipherEditRequest {
1234
+ id: CipherId;
1235
+ organizationId: OrganizationId | undefined;
1236
+ folderId: FolderId | undefined;
1237
+ favorite: boolean;
1238
+ reprompt: CipherRepromptType;
1239
+ name: string;
1240
+ notes: string | undefined;
1241
+ fields: FieldView[];
1242
+ type: CipherViewType;
1243
+ revisionDate: DateTime<Utc>;
1244
+ archivedDate: DateTime<Utc> | undefined;
1245
+ attachments: AttachmentView[];
1246
+ key: EncString | undefined;
1247
+ }
1248
+
1249
+ export interface Field {
1250
+ name: EncString | undefined;
1251
+ value: EncString | undefined;
1252
+ type: FieldType;
1253
+ linkedId: LinkedIdType | undefined;
1254
+ }
1255
+
1256
+ export interface FieldView {
1257
+ name: string | undefined;
1258
+ value: string | undefined;
1259
+ type: FieldType;
1260
+ linkedId: LinkedIdType | undefined;
1261
+ }
1262
+
1263
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
1264
+
1265
+ export interface LoginUri {
1266
+ uri: EncString | undefined;
1267
+ match: UriMatchType | undefined;
1268
+ uriChecksum: EncString | undefined;
1269
+ }
1270
+
1271
+ export interface LoginUriView {
1272
+ uri: string | undefined;
1273
+ match: UriMatchType | undefined;
1274
+ uriChecksum: string | undefined;
1275
+ }
1276
+
1277
+ export interface Fido2Credential {
1278
+ credentialId: EncString;
1279
+ keyType: EncString;
1280
+ keyAlgorithm: EncString;
1281
+ keyCurve: EncString;
1282
+ keyValue: EncString;
1283
+ rpId: EncString;
1284
+ userHandle: EncString | undefined;
1285
+ userName: EncString | undefined;
1286
+ counter: EncString;
1287
+ rpName: EncString | undefined;
1288
+ userDisplayName: EncString | undefined;
1289
+ discoverable: EncString;
1290
+ creationDate: DateTime<Utc>;
1291
+ }
1292
+
1293
+ export interface Fido2CredentialListView {
1294
+ credentialId: string;
1295
+ rpId: string;
1296
+ userHandle: string | undefined;
1297
+ userName: string | undefined;
1298
+ userDisplayName: string | undefined;
1299
+ counter: string;
1300
+ }
1301
+
1302
+ export interface Fido2CredentialView {
1303
+ credentialId: string;
1304
+ keyType: string;
1305
+ keyAlgorithm: string;
1306
+ keyCurve: string;
1307
+ keyValue: EncString;
1308
+ rpId: string;
1309
+ userHandle: string | undefined;
1310
+ userName: string | undefined;
1311
+ counter: string;
1312
+ rpName: string | undefined;
1313
+ userDisplayName: string | undefined;
1314
+ discoverable: string;
1315
+ creationDate: DateTime<Utc>;
1316
+ }
1317
+
1318
+ export interface Fido2CredentialFullView {
1319
+ credentialId: string;
1320
+ keyType: string;
1321
+ keyAlgorithm: string;
1322
+ keyCurve: string;
1323
+ keyValue: string;
1324
+ rpId: string;
1325
+ userHandle: string | undefined;
1326
+ userName: string | undefined;
1327
+ counter: string;
1328
+ rpName: string | undefined;
1329
+ userDisplayName: string | undefined;
1330
+ discoverable: string;
1331
+ creationDate: DateTime<Utc>;
1332
+ }
1333
+
1334
+ export interface Fido2CredentialNewView {
1335
+ credentialId: string;
1336
+ keyType: string;
1337
+ keyAlgorithm: string;
1338
+ keyCurve: string;
1339
+ rpId: string;
1340
+ userHandle: string | undefined;
1341
+ userName: string | undefined;
1342
+ counter: string;
1343
+ rpName: string | undefined;
1344
+ userDisplayName: string | undefined;
1345
+ creationDate: DateTime<Utc>;
1346
+ }
1347
+
1348
+ export interface Login {
1349
+ username: EncString | undefined;
1350
+ password: EncString | undefined;
1351
+ passwordRevisionDate: DateTime<Utc> | undefined;
1352
+ uris: LoginUri[] | undefined;
1353
+ totp: EncString | undefined;
1354
+ autofillOnPageLoad: boolean | undefined;
1355
+ fido2Credentials: Fido2Credential[] | undefined;
1356
+ }
1357
+
1358
+ export interface LoginView {
1359
+ username: string | undefined;
1360
+ password: string | undefined;
1361
+ passwordRevisionDate: DateTime<Utc> | undefined;
1362
+ uris: LoginUriView[] | undefined;
1363
+ totp: string | undefined;
1364
+ autofillOnPageLoad: boolean | undefined;
1365
+ fido2Credentials: Fido2Credential[] | undefined;
1366
+ }
1367
+
1368
+ export interface LoginListView {
1369
+ fido2Credentials: Fido2CredentialListView[] | undefined;
1370
+ hasFido2: boolean;
1371
+ username: string | undefined;
1372
+ /**
1373
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
1374
+ */
1375
+ totp: EncString | undefined;
1376
+ uris: LoginUriView[] | undefined;
1377
+ }
1378
+
1379
+ export interface SecureNote {
1380
+ type: SecureNoteType;
1381
+ }
1382
+
1383
+ export interface SecureNoteView {
1384
+ type: SecureNoteType;
1385
+ }
1386
+
1387
+ /**
1388
+ * Request to add or edit a folder.
1389
+ */
1390
+ export interface FolderAddEditRequest {
1391
+ /**
1392
+ * The new name of the folder.
1393
+ */
1394
+ name: string;
1395
+ }
1396
+
1397
+ /**
1398
+ * NewType wrapper for `FolderId`
1399
+ */
1400
+ export type FolderId = Tagged<Uuid, "FolderId">;
1401
+
1402
+ export interface Folder {
1403
+ id: FolderId | undefined;
1404
+ name: EncString;
1405
+ revisionDate: DateTime<Utc>;
1406
+ }
1407
+
1408
+ export interface FolderView {
1409
+ id: FolderId | undefined;
1410
+ name: string;
1411
+ revisionDate: DateTime<Utc>;
1412
+ }
1413
+
1414
+ export interface AncestorMap {
1415
+ ancestors: Map<CollectionId, string>;
1416
+ }
1417
+
1418
+ export interface DecryptError extends Error {
1419
+ name: "DecryptError";
1420
+ variant: "Crypto";
1421
+ }
1422
+
1423
+ export function isDecryptError(error: any): error is DecryptError;
1424
+
1425
+ export interface EncryptError extends Error {
1426
+ name: "EncryptError";
1427
+ variant: "Crypto" | "MissingUserId";
1428
+ }
1429
+
1430
+ export function isEncryptError(error: any): error is EncryptError;
1431
+
1432
+ export interface TotpResponse {
1433
+ /**
1434
+ * Generated TOTP code
1435
+ */
1436
+ code: string;
1437
+ /**
1438
+ * Time period
1439
+ */
1440
+ period: number;
1441
+ }
1442
+
1443
+ export interface TotpError extends Error {
1444
+ name: "TotpError";
1445
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1446
+ }
1447
+
1448
+ export function isTotpError(error: any): error is TotpError;
1449
+
1450
+ export interface PasswordHistoryView {
1451
+ password: string;
1452
+ lastUsedDate: DateTime<Utc>;
1453
+ }
1454
+
1455
+ export interface PasswordHistory {
1456
+ password: EncString;
1457
+ lastUsedDate: DateTime<Utc>;
1458
+ }
1459
+
1460
+ export interface GetFolderError extends Error {
1461
+ name: "GetFolderError";
1462
+ variant: "ItemNotFound" | "Crypto" | "Repository";
1463
+ }
1464
+
1465
+ export function isGetFolderError(error: any): error is GetFolderError;
1466
+
1467
+ export interface EditFolderError extends Error {
1468
+ name: "EditFolderError";
1469
+ variant:
1470
+ | "ItemNotFound"
1471
+ | "Crypto"
1472
+ | "Api"
1473
+ | "VaultParse"
1474
+ | "MissingField"
1475
+ | "Repository"
1476
+ | "Uuid";
1477
+ }
1478
+
1479
+ export function isEditFolderError(error: any): error is EditFolderError;
1480
+
1481
+ export interface CreateFolderError extends Error {
1482
+ name: "CreateFolderError";
1483
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
1484
+ }
1485
+
1486
+ export function isCreateFolderError(error: any): error is CreateFolderError;
1487
+
1488
+ export interface SshKeyView {
1489
+ /**
1490
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
1491
+ */
1492
+ privateKey: string;
1493
+ /**
1494
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
1495
+ */
1496
+ publicKey: string;
1497
+ /**
1498
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
1499
+ */
1500
+ fingerprint: string;
1501
+ }
1502
+
1503
+ export interface SshKey {
1504
+ /**
1505
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
139
1506
  */
140
- apiUrl?: string;
1507
+ privateKey: EncString;
141
1508
  /**
142
- * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
1509
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
143
1510
  */
144
- userAgent?: string;
1511
+ publicKey: EncString;
145
1512
  /**
146
- * Device type to send to Bitwarden. Defaults to SDK
1513
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
147
1514
  */
148
- deviceType?: DeviceType;
1515
+ fingerprint: EncString;
1516
+ }
1517
+
1518
+ export interface LocalDataView {
1519
+ lastUsedDate: DateTime<Utc> | undefined;
1520
+ lastLaunched: DateTime<Utc> | undefined;
1521
+ }
1522
+
1523
+ export interface LocalData {
1524
+ lastUsedDate: DateTime<Utc> | undefined;
1525
+ lastLaunched: DateTime<Utc> | undefined;
149
1526
  }
150
1527
 
151
- export type AsymmetricEncString = string;
1528
+ export interface IdentityView {
1529
+ title: string | undefined;
1530
+ firstName: string | undefined;
1531
+ middleName: string | undefined;
1532
+ lastName: string | undefined;
1533
+ address1: string | undefined;
1534
+ address2: string | undefined;
1535
+ address3: string | undefined;
1536
+ city: string | undefined;
1537
+ state: string | undefined;
1538
+ postalCode: string | undefined;
1539
+ country: string | undefined;
1540
+ company: string | undefined;
1541
+ email: string | undefined;
1542
+ phone: string | undefined;
1543
+ ssn: string | undefined;
1544
+ username: string | undefined;
1545
+ passportNumber: string | undefined;
1546
+ licenseNumber: string | undefined;
1547
+ }
152
1548
 
153
- export type EncString = string;
1549
+ export interface Identity {
1550
+ title: EncString | undefined;
1551
+ firstName: EncString | undefined;
1552
+ middleName: EncString | undefined;
1553
+ lastName: EncString | undefined;
1554
+ address1: EncString | undefined;
1555
+ address2: EncString | undefined;
1556
+ address3: EncString | undefined;
1557
+ city: EncString | undefined;
1558
+ state: EncString | undefined;
1559
+ postalCode: EncString | undefined;
1560
+ country: EncString | undefined;
1561
+ company: EncString | undefined;
1562
+ email: EncString | undefined;
1563
+ phone: EncString | undefined;
1564
+ ssn: EncString | undefined;
1565
+ username: EncString | undefined;
1566
+ passportNumber: EncString | undefined;
1567
+ licenseNumber: EncString | undefined;
1568
+ }
154
1569
 
155
1570
  /**
156
- * Key Derivation Function for Bitwarden Account
157
- *
158
- * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
159
- * Enum represents all the possible KDFs.
1571
+ * Represents the inner data of a cipher view.
160
1572
  */
161
- export type Kdf =
162
- | { pBKDF2: { iterations: NonZeroU32 } }
163
- | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
1573
+ export type CipherViewType =
1574
+ | { login: LoginView }
1575
+ | { card: CardView }
1576
+ | { identity: IdentityView }
1577
+ | { secureNote: SecureNoteView }
1578
+ | { sshKey: SshKeyView };
164
1579
 
165
- export interface GenerateSshKeyResult {
166
- private_key: string;
167
- public_key: string;
168
- key_fingerprint: string;
1580
+ export interface CipherPermissions {
1581
+ delete: boolean;
1582
+ restore: boolean;
169
1583
  }
170
1584
 
171
- export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
172
-
173
- export interface KeyGenerationError extends Error {
174
- name: "KeyGenerationError";
175
- variant: "KeyGenerationError" | "KeyConversionError";
1585
+ export interface GetCipherError extends Error {
1586
+ name: "GetCipherError";
1587
+ variant: "ItemNotFound" | "Crypto" | "RepositoryError";
176
1588
  }
177
1589
 
178
- export function isKeyGenerationError(error: any): error is KeyGenerationError;
1590
+ export function isGetCipherError(error: any): error is GetCipherError;
179
1591
 
180
- export interface Folder {
181
- id: Uuid | undefined;
182
- name: EncString;
183
- revisionDate: DateTime<Utc>;
1592
+ export interface EditCipherError extends Error {
1593
+ name: "EditCipherError";
1594
+ variant:
1595
+ | "ItemNotFound"
1596
+ | "Crypto"
1597
+ | "Api"
1598
+ | "VaultParse"
1599
+ | "MissingField"
1600
+ | "NotAuthenticated"
1601
+ | "Repository"
1602
+ | "Uuid";
184
1603
  }
185
1604
 
186
- export interface FolderView {
187
- id: Uuid | undefined;
188
- name: string;
189
- revisionDate: DateTime<Utc>;
190
- }
1605
+ export function isEditCipherError(error: any): error is EditCipherError;
191
1606
 
192
- export interface TestError extends Error {
193
- name: "TestError";
1607
+ export interface CreateCipherError extends Error {
1608
+ name: "CreateCipherError";
1609
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
194
1610
  }
195
1611
 
196
- export function isTestError(error: any): error is TestError;
1612
+ export function isCreateCipherError(error: any): error is CreateCipherError;
197
1613
 
198
- export type Uuid = string;
1614
+ export interface CipherError extends Error {
1615
+ name: "CipherError";
1616
+ variant: "MissingField" | "Crypto" | "Encrypt" | "AttachmentsWithoutKeys";
1617
+ }
1618
+
1619
+ export function isCipherError(error: any): error is CipherError;
199
1620
 
200
1621
  /**
201
- * RFC3339 compliant date-time string.
202
- * @typeParam T - Not used in JavaScript.
1622
+ * Minimal CardView only including the needed details for list views
203
1623
  */
204
- export type DateTime<T = unknown> = string;
1624
+ export interface CardListView {
1625
+ /**
1626
+ * The brand of the card, e.g. Visa, Mastercard, etc.
1627
+ */
1628
+ brand: string | undefined;
1629
+ }
1630
+
1631
+ export interface CardView {
1632
+ cardholderName: string | undefined;
1633
+ expMonth: string | undefined;
1634
+ expYear: string | undefined;
1635
+ code: string | undefined;
1636
+ brand: string | undefined;
1637
+ number: string | undefined;
1638
+ }
1639
+
1640
+ export interface Card {
1641
+ cardholderName: EncString | undefined;
1642
+ expMonth: EncString | undefined;
1643
+ expYear: EncString | undefined;
1644
+ code: EncString | undefined;
1645
+ brand: EncString | undefined;
1646
+ number: EncString | undefined;
1647
+ }
205
1648
 
1649
+ export interface DecryptFileError extends Error {
1650
+ name: "DecryptFileError";
1651
+ variant: "Decrypt" | "Io";
1652
+ }
1653
+
1654
+ export function isDecryptFileError(error: any): error is DecryptFileError;
1655
+
1656
+ export interface EncryptFileError extends Error {
1657
+ name: "EncryptFileError";
1658
+ variant: "Encrypt" | "Io";
1659
+ }
1660
+
1661
+ export function isEncryptFileError(error: any): error is EncryptFileError;
1662
+
1663
+ export interface AttachmentView {
1664
+ id: string | undefined;
1665
+ url: string | undefined;
1666
+ size: string | undefined;
1667
+ sizeName: string | undefined;
1668
+ fileName: string | undefined;
1669
+ key: EncString | undefined;
1670
+ /**
1671
+ * The decrypted attachmentkey in base64 format.
1672
+ *
1673
+ * **TEMPORARY FIELD**: This field is a temporary workaround to provide
1674
+ * decrypted attachment keys to the TypeScript client during the migration
1675
+ * process. It will be removed once the encryption/decryption logic is
1676
+ * fully migrated to the SDK.
1677
+ *
1678
+ * **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
1679
+ *
1680
+ * Do not rely on this field for long-term use.
1681
+ */
1682
+ decryptedKey: string | undefined;
1683
+ }
1684
+
1685
+ export interface Attachment {
1686
+ id: string | undefined;
1687
+ url: string | undefined;
1688
+ size: string | undefined;
1689
+ /**
1690
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1691
+ */
1692
+ sizeName: string | undefined;
1693
+ fileName: EncString | undefined;
1694
+ key: EncString | undefined;
1695
+ }
1696
+
1697
+ export class AttachmentsClient {
1698
+ private constructor();
1699
+ free(): void;
1700
+ decrypt_buffer(
1701
+ cipher: Cipher,
1702
+ attachment: AttachmentView,
1703
+ encrypted_buffer: Uint8Array,
1704
+ ): Uint8Array;
1705
+ }
206
1706
  /**
207
- * UTC date-time string. Not used in JavaScript.
1707
+ * Subclient containing auth functionality.
208
1708
  */
209
- export type Utc = unknown;
210
-
1709
+ export class AuthClient {
1710
+ private constructor();
1711
+ free(): void;
1712
+ /**
1713
+ * Client for send access functionality
1714
+ */
1715
+ send_access(): SendAccessClient;
1716
+ }
211
1717
  /**
212
- * An integer that is known not to equal zero.
1718
+ * The main entry point for the Bitwarden SDK in WebAssembly environments
213
1719
  */
214
- export type NonZeroU32 = number;
215
-
216
1720
  export class BitwardenClient {
217
1721
  free(): void;
218
- constructor(settings?: ClientSettings, log_level?: LogLevel);
1722
+ /**
1723
+ * Initialize a new instance of the SDK client
1724
+ */
1725
+ constructor(token_provider: any, settings?: ClientSettings | null);
219
1726
  /**
220
1727
  * Test method, echoes back the input
221
1728
  */
222
1729
  echo(msg: string): string;
1730
+ /**
1731
+ * Returns the current SDK version
1732
+ */
223
1733
  version(): string;
224
- throw(msg: string): Promise<void>;
1734
+ /**
1735
+ * Test method, always throws an error
1736
+ */
1737
+ throw(msg: string): void;
225
1738
  /**
226
1739
  * Test method, calls http endpoint
227
1740
  */
228
1741
  http_get(url: string): Promise<string>;
229
- crypto(): ClientCrypto;
230
- vault(): ClientVault;
1742
+ /**
1743
+ * Auth related operations.
1744
+ */
1745
+ auth(): AuthClient;
1746
+ /**
1747
+ * Crypto related operations.
1748
+ */
1749
+ crypto(): CryptoClient;
1750
+ /**
1751
+ * Vault item related operations.
1752
+ */
1753
+ vault(): VaultClient;
1754
+ /**
1755
+ * Constructs a specific client for platform-specific functionality
1756
+ */
1757
+ platform(): PlatformClient;
1758
+ /**
1759
+ * Constructs a specific client for generating passwords and passphrases
1760
+ */
1761
+ generator(): GeneratorClient;
1762
+ /**
1763
+ * Exporter related operations.
1764
+ */
1765
+ exporters(): ExporterClient;
1766
+ }
1767
+ export class CiphersClient {
1768
+ private constructor();
1769
+ free(): void;
1770
+ /**
1771
+ * Create a new [Cipher] and save it to the server.
1772
+ */
1773
+ create(request: CipherCreateRequest): Promise<CipherView>;
1774
+ /**
1775
+ * Edit an existing [Cipher] and save it to the server.
1776
+ */
1777
+ edit(request: CipherEditRequest): Promise<CipherView>;
1778
+ encrypt(cipher_view: CipherView): EncryptionContext;
1779
+ /**
1780
+ * Encrypt a cipher with the provided key. This should only be used when rotating encryption
1781
+ * keys in the Web client.
1782
+ *
1783
+ * Until key rotation is fully implemented in the SDK, this method must be provided the new
1784
+ * symmetric key in base64 format. See PM-23084
1785
+ *
1786
+ * If the cipher has a CipherKey, it will be re-encrypted with the new key.
1787
+ * If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
1788
+ * generated using the new key. Otherwise, the cipher's data will be encrypted with the new
1789
+ * key directly.
1790
+ */
1791
+ encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): EncryptionContext;
1792
+ decrypt(cipher: Cipher): CipherView;
1793
+ decrypt_list(ciphers: Cipher[]): CipherListView[];
1794
+ /**
1795
+ * Decrypt cipher list with failures
1796
+ * Returns both successfully decrypted ciphers and any that failed to decrypt
1797
+ */
1798
+ decrypt_list_with_failures(ciphers: Cipher[]): DecryptCipherListResult;
1799
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
1800
+ /**
1801
+ * Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
1802
+ * Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
1803
+ * TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
1804
+ * encrypting the rest of the CipherView.
1805
+ * TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
1806
+ */
1807
+ set_fido2_credentials(
1808
+ cipher_view: CipherView,
1809
+ fido2_credentials: Fido2CredentialFullView[],
1810
+ ): CipherView;
1811
+ move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
1812
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
1813
+ }
1814
+ export class CollectionViewNodeItem {
1815
+ private constructor();
1816
+ free(): void;
1817
+ get_item(): CollectionView;
1818
+ get_parent(): CollectionView | undefined;
1819
+ get_children(): CollectionView[];
1820
+ get_ancestors(): AncestorMap;
1821
+ }
1822
+ export class CollectionViewTree {
1823
+ private constructor();
1824
+ free(): void;
1825
+ get_item_for_view(collection_view: CollectionView): CollectionViewNodeItem | undefined;
1826
+ get_root_items(): CollectionViewNodeItem[];
1827
+ get_flat_items(): CollectionViewNodeItem[];
1828
+ }
1829
+ export class CollectionsClient {
1830
+ private constructor();
1831
+ free(): void;
1832
+ decrypt(collection: Collection): CollectionView;
1833
+ decrypt_list(collections: Collection[]): CollectionView[];
1834
+ /**
1835
+ *
1836
+ * Returns the vector of CollectionView objects in a tree structure based on its implemented
1837
+ * path().
1838
+ */
1839
+ get_collection_tree(collections: CollectionView[]): CollectionViewTree;
231
1840
  }
232
- export class ClientCrypto {
1841
+ /**
1842
+ * A client for the crypto operations.
1843
+ */
1844
+ export class CryptoClient {
233
1845
  private constructor();
234
1846
  free(): void;
235
1847
  /**
@@ -242,17 +1854,418 @@ export class ClientCrypto {
242
1854
  * `initialize_user_crypto` but before any other crypto operations.
243
1855
  */
244
1856
  initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
1857
+ /**
1858
+ * Generates a new key pair and encrypts the private key with the provided user key.
1859
+ * Crypto initialization not required.
1860
+ */
1861
+ make_key_pair(user_key: B64): MakeKeyPairResponse;
1862
+ /**
1863
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
1864
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
1865
+ * Crypto initialization not required.
1866
+ */
1867
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
1868
+ /**
1869
+ * Makes a new signing key pair and signs the public key for the user
1870
+ */
1871
+ make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
1872
+ /**
1873
+ * Creates a rotated set of account keys for the current state
1874
+ */
1875
+ get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
1876
+ /**
1877
+ * Create the data necessary to update the user's kdf settings. The user's encryption key is
1878
+ * re-encrypted for the password under the new kdf settings. This returns the re-encrypted
1879
+ * user key and the new password hash but does not update sdk state.
1880
+ */
1881
+ make_update_kdf(password: string, kdf: Kdf): UpdateKdfResponse;
1882
+ /**
1883
+ * Protects the current user key with the provided PIN. The result can be stored and later
1884
+ * used to initialize another client instance by using the PIN and the PIN key with
1885
+ * `initialize_user_crypto`.
1886
+ */
1887
+ enroll_pin(pin: string): EnrollPinResponse;
1888
+ /**
1889
+ * Protects the current user key with the provided PIN. The result can be stored and later
1890
+ * used to initialize another client instance by using the PIN and the PIN key with
1891
+ * `initialize_user_crypto`. The provided pin is encrypted with the user key.
1892
+ */
1893
+ enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
1894
+ /**
1895
+ * Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
1896
+ * This is a stop-gap solution, until initialization of the SDK is used.
1897
+ */
1898
+ unseal_password_protected_key_envelope(pin: string, envelope: string): Uint8Array;
245
1899
  }
246
- export class ClientFolders {
1900
+ export class ExporterClient {
1901
+ private constructor();
1902
+ free(): void;
1903
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
1904
+ export_organization_vault(
1905
+ collections: Collection[],
1906
+ ciphers: Cipher[],
1907
+ format: ExportFormat,
1908
+ ): string;
1909
+ /**
1910
+ * Credential Exchange Format (CXF)
1911
+ *
1912
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1913
+ *
1914
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1915
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1916
+ */
1917
+ export_cxf(account: Account, ciphers: Cipher[]): string;
1918
+ /**
1919
+ * Credential Exchange Format (CXF)
1920
+ *
1921
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1922
+ *
1923
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1924
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1925
+ */
1926
+ import_cxf(payload: string): Cipher[];
1927
+ }
1928
+ /**
1929
+ * Wrapper for folder specific functionality.
1930
+ */
1931
+ export class FoldersClient {
247
1932
  private constructor();
248
1933
  free(): void;
249
1934
  /**
250
- * Decrypt folder
1935
+ * Encrypt a [FolderView] to a [Folder].
1936
+ */
1937
+ encrypt(folder_view: FolderView): Folder;
1938
+ /**
1939
+ * Encrypt a [Folder] to [FolderView].
251
1940
  */
252
1941
  decrypt(folder: Folder): FolderView;
1942
+ /**
1943
+ * Decrypt a list of [Folder]s to a list of [FolderView]s.
1944
+ */
1945
+ decrypt_list(folders: Folder[]): FolderView[];
1946
+ /**
1947
+ * Get all folders from state and decrypt them to a list of [FolderView].
1948
+ */
1949
+ list(): Promise<FolderView[]>;
1950
+ /**
1951
+ * Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
1952
+ */
1953
+ get(folder_id: FolderId): Promise<FolderView>;
1954
+ /**
1955
+ * Create a new [Folder] and save it to the server.
1956
+ */
1957
+ create(request: FolderAddEditRequest): Promise<FolderView>;
1958
+ /**
1959
+ * Edit the [Folder] and save it to the server.
1960
+ */
1961
+ edit(folder_id: FolderId, request: FolderAddEditRequest): Promise<FolderView>;
1962
+ }
1963
+ export class GeneratorClient {
1964
+ private constructor();
1965
+ free(): void;
1966
+ /**
1967
+ * Generates a random password.
1968
+ *
1969
+ * The character sets and password length can be customized using the `input` parameter.
1970
+ *
1971
+ * # Examples
1972
+ *
1973
+ * ```
1974
+ * use bitwarden_core::Client;
1975
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
1976
+ *
1977
+ * async fn test() -> Result<(), PassphraseError> {
1978
+ * let input = PasswordGeneratorRequest {
1979
+ * lowercase: true,
1980
+ * uppercase: true,
1981
+ * numbers: true,
1982
+ * length: 20,
1983
+ * ..Default::default()
1984
+ * };
1985
+ * let password = Client::new(None).generator().password(input).unwrap();
1986
+ * println!("{}", password);
1987
+ * Ok(())
1988
+ * }
1989
+ * ```
1990
+ */
1991
+ password(input: PasswordGeneratorRequest): string;
1992
+ /**
1993
+ * Generates a random passphrase.
1994
+ * A passphrase is a combination of random words separated by a character.
1995
+ * An example of passphrase is `correct horse battery staple`.
1996
+ *
1997
+ * The number of words and their case, the word separator, and the inclusion of
1998
+ * a number in the passphrase can be customized using the `input` parameter.
1999
+ *
2000
+ * # Examples
2001
+ *
2002
+ * ```
2003
+ * use bitwarden_core::Client;
2004
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
2005
+ *
2006
+ * async fn test() -> Result<(), PassphraseError> {
2007
+ * let input = PassphraseGeneratorRequest {
2008
+ * num_words: 4,
2009
+ * ..Default::default()
2010
+ * };
2011
+ * let passphrase = Client::new(None).generator().passphrase(input).unwrap();
2012
+ * println!("{}", passphrase);
2013
+ * Ok(())
2014
+ * }
2015
+ * ```
2016
+ */
2017
+ passphrase(input: PassphraseGeneratorRequest): string;
2018
+ }
2019
+ export class IncomingMessage {
2020
+ free(): void;
2021
+ constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
2022
+ /**
2023
+ * Try to parse the payload as JSON.
2024
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
2025
+ */
2026
+ parse_payload_as_json(): any;
2027
+ payload: Uint8Array;
2028
+ destination: Endpoint;
2029
+ source: Endpoint;
2030
+ get topic(): string | undefined;
2031
+ set topic(value: string | null | undefined);
2032
+ }
2033
+ /**
2034
+ * JavaScript wrapper around the IPC client. For more information, see the
2035
+ * [IpcClient] documentation.
2036
+ */
2037
+ export class IpcClient {
2038
+ free(): void;
2039
+ constructor(communication_provider: IpcCommunicationBackend);
2040
+ start(): Promise<void>;
2041
+ isRunning(): Promise<boolean>;
2042
+ send(message: OutgoingMessage): Promise<void>;
2043
+ subscribe(): Promise<IpcClientSubscription>;
2044
+ }
2045
+ /**
2046
+ * JavaScript wrapper around the IPC client subscription. For more information, see the
2047
+ * [IpcClientSubscription](crate::IpcClientSubscription) documentation.
2048
+ */
2049
+ export class IpcClientSubscription {
2050
+ private constructor();
2051
+ free(): void;
2052
+ receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
2053
+ }
2054
+ /**
2055
+ * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
2056
+ */
2057
+ export class IpcCommunicationBackend {
2058
+ free(): void;
2059
+ /**
2060
+ * Creates a new instance of the JavaScript communication backend.
2061
+ */
2062
+ constructor(sender: IpcCommunicationBackendSender);
2063
+ /**
2064
+ * Used by JavaScript to provide an incoming message to the IPC framework.
2065
+ */
2066
+ receive(message: IncomingMessage): void;
2067
+ }
2068
+ export class OutgoingMessage {
2069
+ free(): void;
2070
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
2071
+ /**
2072
+ * Create a new message and encode the payload as JSON.
2073
+ */
2074
+ static new_json_payload(
2075
+ payload: any,
2076
+ destination: Endpoint,
2077
+ topic?: string | null,
2078
+ ): OutgoingMessage;
2079
+ payload: Uint8Array;
2080
+ destination: Endpoint;
2081
+ get topic(): string | undefined;
2082
+ set topic(value: string | null | undefined);
2083
+ }
2084
+ export class PlatformClient {
2085
+ private constructor();
2086
+ free(): void;
2087
+ state(): StateClient;
2088
+ /**
2089
+ * Load feature flags into the client
2090
+ */
2091
+ load_flags(flags: FeatureFlags): void;
2092
+ }
2093
+ /**
2094
+ * This module represents a stopgap solution to provide access to primitive crypto functions for JS
2095
+ * clients. It is not intended to be used outside of the JS clients and this pattern should not be
2096
+ * proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
2097
+ * responsible for state and keys.
2098
+ */
2099
+ export class PureCrypto {
2100
+ private constructor();
2101
+ free(): void;
2102
+ /**
2103
+ * DEPRECATED: Use `symmetric_decrypt_string` instead.
2104
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
2105
+ */
2106
+ static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
2107
+ static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
2108
+ static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
2109
+ /**
2110
+ * DEPRECATED: Use `symmetric_decrypt_filedata` instead.
2111
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
2112
+ */
2113
+ static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
2114
+ static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
2115
+ static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
2116
+ /**
2117
+ * DEPRECATED: Only used by send keys
2118
+ */
2119
+ static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
2120
+ static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
2121
+ static decrypt_user_key_with_master_password(
2122
+ encrypted_user_key: string,
2123
+ master_password: string,
2124
+ email: string,
2125
+ kdf: Kdf,
2126
+ ): Uint8Array;
2127
+ static encrypt_user_key_with_master_password(
2128
+ user_key: Uint8Array,
2129
+ master_password: string,
2130
+ email: string,
2131
+ kdf: Kdf,
2132
+ ): string;
2133
+ static make_user_key_aes256_cbc_hmac(): Uint8Array;
2134
+ static make_user_key_xchacha20_poly1305(): Uint8Array;
2135
+ /**
2136
+ * Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
2137
+ * as an EncString.
2138
+ */
2139
+ static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
2140
+ /**
2141
+ * Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
2142
+ * unwrapped key as a serialized byte array.
2143
+ */
2144
+ static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2145
+ /**
2146
+ * Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
2147
+ * key. Note: Usually, a public key is - by definition - public, so this should not be
2148
+ * used. The specific use-case for this function is to enable rotateable key sets, where
2149
+ * the "public key" is not public, with the intent of preventing the server from being able
2150
+ * to overwrite the user key unlocked by the rotateable keyset.
2151
+ */
2152
+ static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
2153
+ /**
2154
+ * Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
2155
+ * wrapping key.
2156
+ */
2157
+ static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2158
+ /**
2159
+ * Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
2160
+ * key,
2161
+ */
2162
+ static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
2163
+ /**
2164
+ * Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
2165
+ * wrapping key.
2166
+ */
2167
+ static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
2168
+ /**
2169
+ * Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key)
2170
+ * in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
2171
+ * the sender's authenticity cannot be verified by the recipient.
2172
+ */
2173
+ static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
2174
+ /**
2175
+ * Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8
2176
+ * DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
2177
+ * recipient.
2178
+ */
2179
+ static decapsulate_key_unsigned(
2180
+ encapsulated_key: string,
2181
+ decapsulation_key: Uint8Array,
2182
+ ): Uint8Array;
2183
+ /**
2184
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
2185
+ * the corresponding verifying key.
2186
+ */
2187
+ static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
2188
+ /**
2189
+ * Returns the algorithm used for the given verifying key.
2190
+ */
2191
+ static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
2192
+ /**
2193
+ * For a given signing identity (verifying key), this function verifies that the signing
2194
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
2195
+ * that the signing identity has the intent to receive messages encrypted to the public
2196
+ * key.
2197
+ */
2198
+ static verify_and_unwrap_signed_public_key(
2199
+ signed_public_key: Uint8Array,
2200
+ verifying_key: Uint8Array,
2201
+ ): Uint8Array;
2202
+ /**
2203
+ * Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
2204
+ */
2205
+ static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
2206
+ static decrypt_user_key_with_master_key(
2207
+ encrypted_user_key: string,
2208
+ master_key: Uint8Array,
2209
+ ): Uint8Array;
2210
+ }
2211
+ /**
2212
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
2213
+ */
2214
+ export class SendAccessClient {
2215
+ private constructor();
2216
+ free(): void;
2217
+ /**
2218
+ * Requests a new send access token.
2219
+ */
2220
+ request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
2221
+ }
2222
+ export class StateClient {
2223
+ private constructor();
2224
+ free(): void;
2225
+ register_cipher_repository(cipher_repository: any): void;
2226
+ register_folder_repository(store: any): void;
2227
+ register_client_managed_repositories(repositories: Repositories): void;
2228
+ /**
2229
+ * Initialize the database for SDK managed repositories.
2230
+ */
2231
+ initialize_state(configuration: IndexedDbConfiguration): Promise<void>;
2232
+ }
2233
+ export class TotpClient {
2234
+ private constructor();
2235
+ free(): void;
2236
+ /**
2237
+ * Generates a TOTP code from a provided key
2238
+ *
2239
+ * # Arguments
2240
+ * - `key` - Can be:
2241
+ * - A base32 encoded string
2242
+ * - OTP Auth URI
2243
+ * - Steam URI
2244
+ * - `time_ms` - Optional timestamp in milliseconds
2245
+ */
2246
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
253
2247
  }
254
- export class ClientVault {
2248
+ export class VaultClient {
255
2249
  private constructor();
256
2250
  free(): void;
257
- folders(): ClientFolders;
2251
+ /**
2252
+ * Attachment related operations.
2253
+ */
2254
+ attachments(): AttachmentsClient;
2255
+ /**
2256
+ * Cipher related operations.
2257
+ */
2258
+ ciphers(): CiphersClient;
2259
+ /**
2260
+ * Folder related operations.
2261
+ */
2262
+ folders(): FoldersClient;
2263
+ /**
2264
+ * TOTP related operations.
2265
+ */
2266
+ totp(): TotpClient;
2267
+ /**
2268
+ * Collection related operations.
2269
+ */
2270
+ collections(): CollectionsClient;
258
2271
  }