@bitwarden/sdk-internal 0.2.0-main.43 → 0.2.0-main.430

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