@bitwarden/sdk-internal 0.1.7 → 0.2.0-hotfix.20260302

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,230 +1,3691 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export enum LogLevel {
4
- Trace = 0,
5
- Debug = 1,
6
- Info = 2,
7
- Warn = 3,
8
- Error = 4,
3
+ /**
4
+ * Generate a new SSH key pair
5
+ *
6
+ * # Arguments
7
+ * - `key_algorithm` - The algorithm to use for the key pair
8
+ *
9
+ * # Returns
10
+ * - `Ok(SshKey)` if the key was successfully generated
11
+ * - `Err(KeyGenerationError)` if the key could not be generated
12
+ */
13
+ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
14
+ /**
15
+ * Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
16
+ * to an OpenSSH private key with public key and fingerprint
17
+ *
18
+ * # Arguments
19
+ * - `imported_key` - The private key to convert
20
+ * - `password` - The password to use for decrypting the key
21
+ *
22
+ * # Returns
23
+ * - `Ok(SshKey)` if the key was successfully coneverted
24
+ * - `Err(PasswordRequired)` if the key is encrypted and no password was provided
25
+ * - `Err(WrongPassword)` if the password provided is incorrect
26
+ * - `Err(ParsingError)` if the key could not be parsed
27
+ * - `Err(UnsupportedKeyType)` if the key type is not supported
28
+ */
29
+ export function import_ssh_key(imported_key: string, password?: string | null): 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,
9
53
  }
10
- 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 {
11
69
  /**
12
- * The user\'s KDF parameters, as received from the prelogin request
70
+ * Text field
13
71
  */
14
- kdfParams: Kdf;
72
+ Text = 0,
15
73
  /**
16
- * The user\'s email address
74
+ * Hidden text field
17
75
  */
18
- email: string;
76
+ Hidden = 1,
19
77
  /**
20
- * The user\'s encrypted private key
78
+ * Boolean field
21
79
  */
22
- privateKey: string;
80
+ Boolean = 2,
23
81
  /**
24
- * The initialization method to use
82
+ * Linked field
25
83
  */
26
- 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,
27
134
  }
28
135
 
29
- export type InitUserCryptoMethod =
30
- | { password: { password: string; user_key: string } }
31
- | { decryptedKey: { decrypted_user_key: string } }
32
- | { pin: { pin: string; pin_protected_user_key: EncString } }
33
- | { authRequest: { request_private_key: string; method: AuthRequestMethod } }
34
- | {
35
- deviceKey: {
36
- device_key: string;
37
- protected_device_private_key: EncString;
38
- device_protected_user_key: AsymmetricEncString;
39
- };
40
- }
41
- | { keyConnector: { master_key: string; user_key: string } };
136
+ import { Tagged } from "type-fest";
42
137
 
43
- export type AuthRequestMethod =
44
- | { userKey: { protected_user_key: AsymmetricEncString } }
45
- | { 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;
46
144
 
47
- export interface InitOrgCryptoRequest {
48
- /**
49
- * The encryption keys for all the organizations the user is a part of
50
- */
51
- 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";
52
168
  }
53
169
 
54
- export type DeviceType =
55
- | "Android"
56
- | "iOS"
57
- | "ChromeExtension"
58
- | "FirefoxExtension"
59
- | "OperaExtension"
60
- | "EdgeExtension"
61
- | "WindowsDesktop"
62
- | "MacOsDesktop"
63
- | "LinuxDesktop"
64
- | "ChromeBrowser"
65
- | "FirefoxBrowser"
66
- | "OperaBrowser"
67
- | "EdgeBrowser"
68
- | "IEBrowser"
69
- | "UnknownBrowser"
70
- | "AndroidAmazon"
71
- | "UWP"
72
- | "SafariBrowser"
73
- | "VivaldiBrowser"
74
- | "VivaldiExtension"
75
- | "SafariExtension"
76
- | "SDK"
77
- | "Server"
78
- | "WindowsCLI"
79
- | "MacOsCLI"
80
- | "LinuxCLI";
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 IndexedDbConfiguration {
184
+ db_name: string;
185
+ }
186
+
187
+ export interface Repositories {
188
+ cipher: Repository<Cipher> | null;
189
+ folder: Repository<Folder> | null;
190
+ }
81
191
 
82
192
  /**
83
- * Basic client behavior settings. These settings specify the various targets and behavior of the
84
- * Bitwarden Client. They are optional and uneditable once the client is initialized.
85
- *
86
- * Defaults to
87
- *
88
- * ```
89
- * # use bitwarden_core::{ClientSettings, DeviceType};
90
- * let settings = ClientSettings {
91
- * identity_url: \"https://identity.bitwarden.com\".to_string(),
92
- * api_url: \"https://api.bitwarden.com\".to_string(),
93
- * user_agent: \"Bitwarden Rust-SDK\".to_string(),
94
- * device_type: DeviceType::SDK,
95
- * };
96
- * let default = ClientSettings::default();
97
- * ```
193
+ * Active feature flags for the SDK.
98
194
  */
99
- export interface ClientSettings {
195
+ export interface FeatureFlags extends Map<string, boolean> {}
196
+
197
+ /**
198
+ * Credentials for getting a send access token using an email and OTP.
199
+ */
200
+ export interface SendEmailOtpCredentials {
100
201
  /**
101
- * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
202
+ * The email address to which the OTP will be sent.
102
203
  */
103
- identityUrl?: string;
204
+ email: string;
104
205
  /**
105
- * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
206
+ * The one-time password (OTP) that the user has received via email.
106
207
  */
107
- apiUrl?: string;
208
+ otp: string;
209
+ }
210
+
211
+ /**
212
+ * Credentials for sending an OTP to the user\'s email address.
213
+ * This is used when the send requires email verification with an OTP.
214
+ */
215
+ export interface SendEmailCredentials {
108
216
  /**
109
- * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
217
+ * The email address to which the OTP will be sent.
110
218
  */
111
- userAgent?: string;
219
+ email: string;
220
+ }
221
+
222
+ /**
223
+ * Credentials for sending password secured access requests.
224
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
225
+ * struct.
226
+ */
227
+ export interface SendPasswordCredentials {
112
228
  /**
113
- * Device type to send to Bitwarden. Defaults to SDK
229
+ * A Base64-encoded hash of the password protecting the send.
114
230
  */
115
- deviceType?: DeviceType;
231
+ passwordHashB64: string;
116
232
  }
117
233
 
118
- export type AsymmetricEncString = string;
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.
240
+ */
241
+ sendId: string;
242
+ /**
243
+ * The optional send access credentials.
244
+ */
245
+ sendAccessCredentials?: SendAccessCredentials;
246
+ }
119
247
 
120
- export type EncString = string;
248
+ /**
249
+ * The credentials used for send access requests.
250
+ */
251
+ export type SendAccessCredentials =
252
+ | SendPasswordCredentials
253
+ | SendEmailOtpCredentials
254
+ | SendEmailCredentials;
121
255
 
122
256
  /**
123
- * Key Derivation Function for Bitwarden Account
124
- *
125
- * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
126
- * Enum represents all the possible KDFs.
257
+ * Any unexpected error that occurs when making requests to identity. This could be
258
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
259
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
260
+ * unexpected body or status. Used when decoding the server\'s error payload into
261
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
262
+ * available.
127
263
  */
128
- export type Kdf =
129
- | { pBKDF2: { iterations: NonZeroU32 } }
130
- | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
264
+ export type UnexpectedIdentityError = string;
131
265
 
132
- export interface Folder {
133
- id: Uuid | undefined;
134
- name: EncString;
135
- revisionDate: DateTime<Utc>;
266
+ /**
267
+ * A send access token which can be used to access a send.
268
+ */
269
+ export interface SendAccessTokenResponse {
270
+ /**
271
+ * The actual token string.
272
+ */
273
+ token: string;
274
+ /**
275
+ * The timestamp in milliseconds when the token expires.
276
+ */
277
+ expiresAt: number;
136
278
  }
137
279
 
138
- export interface FolderView {
139
- id: Uuid | undefined;
140
- name: string;
141
- revisionDate: DateTime<Utc>;
142
- }
280
+ /**
281
+ * Represents errors that can occur when requesting a send access token.
282
+ * It includes expected and unexpected API errors.
283
+ */
284
+ export type SendAccessTokenError =
285
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
286
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
143
287
 
144
- export type Uuid = string;
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"
296
+ | "unknown";
145
297
 
146
298
  /**
147
- * RFC3339 compliant date-time string.
148
- * @typeParam T - Not used in JavaScript.
299
+ * Represents the possible, expected errors that can occur when requesting a send access token.
149
300
  */
150
- export type DateTime<T = unknown> = string;
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 };
151
317
 
152
318
  /**
153
- * UTC date-time string. Not used in JavaScript.
319
+ * Invalid grant errors - typically due to invalid credentials.
154
320
  */
155
- export type Utc = unknown;
321
+ export type SendAccessTokenInvalidGrantError =
322
+ | "send_id_invalid"
323
+ | "password_hash_b64_invalid"
324
+ | "otp_invalid"
325
+ | "otp_generation_failed"
326
+ | "unknown";
156
327
 
157
328
  /**
158
- * An integer that is known not to equal zero.
329
+ * Request parameters for SSO JIT master password registration.
159
330
  */
160
- export type NonZeroU32 = number;
331
+ export interface JitMasterPasswordRegistrationRequest {
332
+ /**
333
+ * Organization ID to enroll in
334
+ */
335
+ org_id: OrganizationId;
336
+ /**
337
+ * Organization\'s public key for encrypting the reset password key. This should be verified by
338
+ * the client and not verifying may compromise the security of the user\'s account.
339
+ */
340
+ org_public_key: B64;
341
+ /**
342
+ * Organization SSO identifier
343
+ */
344
+ organization_sso_identifier: string;
345
+ /**
346
+ * User ID for the account being initialized
347
+ */
348
+ user_id: UserId;
349
+ /**
350
+ * Salt for master password hashing, usually email
351
+ */
352
+ salt: string;
353
+ /**
354
+ * Master password for the account
355
+ */
356
+ master_password: string;
357
+ /**
358
+ * Optional hint for the master password
359
+ */
360
+ master_password_hint: string | undefined;
361
+ /**
362
+ * Should enroll user into admin password reset
363
+ */
364
+ reset_password_enroll: boolean;
365
+ }
161
366
 
162
- export class BitwardenClient {
163
- free(): void;
367
+ /**
368
+ * Request parameters for TDE (Trusted Device Encryption) registration.
369
+ */
370
+ export interface TdeRegistrationRequest {
164
371
  /**
165
- * @param {ClientSettings | undefined} [settings]
166
- * @param {LogLevel | undefined} [log_level]
372
+ * Organization ID to enroll in
167
373
  */
168
- constructor(settings?: ClientSettings, log_level?: LogLevel);
374
+ org_id: OrganizationId;
169
375
  /**
170
- * Test method, echoes back the input
171
- * @param {string} msg
172
- * @returns {string}
376
+ * Organization\'s public key for encrypting the reset password key. This should be verified by
377
+ * the client and not verifying may compromise the security of the user\'s account.
173
378
  */
174
- echo(msg: string): string;
379
+ org_public_key: B64;
175
380
  /**
176
- * @returns {string}
381
+ * User ID for the account being initialized
177
382
  */
178
- version(): string;
383
+ user_id: UserId;
179
384
  /**
180
- * @param {string} msg
385
+ * Device identifier for TDE enrollment
181
386
  */
182
- throw(msg: string): void;
387
+ device_identifier: string;
183
388
  /**
184
- * Test method, calls http endpoint
185
- * @param {string} url
186
- * @returns {Promise<string>}
389
+ * Whether to trust this device for TDE
187
390
  */
188
- http_get(url: string): Promise<string>;
391
+ trust_device: boolean;
392
+ }
393
+
394
+ /**
395
+ * Result of Key Connector registration process.
396
+ */
397
+ export interface KeyConnectorRegistrationResult {
398
+ /**
399
+ * The account cryptographic state of the user.
400
+ */
401
+ account_cryptographic_state: WrappedAccountCryptographicState;
189
402
  /**
190
- * @returns {ClientCrypto}
403
+ * The key connector key used for unlocking.
191
404
  */
192
- crypto(): ClientCrypto;
405
+ key_connector_key: B64;
193
406
  /**
194
- * @returns {ClientVault}
407
+ * The encrypted user key, wrapped with the key connector key.
195
408
  */
196
- vault(): ClientVault;
409
+ key_connector_key_wrapped_user_key: EncString;
410
+ /**
411
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
412
+ */
413
+ user_key: B64;
197
414
  }
198
- export class ClientCrypto {
199
- free(): void;
415
+
416
+ /**
417
+ * Result of TDE registration process.
418
+ */
419
+ export interface TdeRegistrationResponse {
200
420
  /**
201
- * Initialization method for the user crypto. Needs to be called before any other crypto
202
- * operations.
203
- * @param {InitUserCryptoRequest} req
204
- * @returns {Promise<void>}
421
+ * The account cryptographic state of the user
205
422
  */
206
- initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
423
+ account_cryptographic_state: WrappedAccountCryptographicState;
207
424
  /**
208
- * Initialization method for the organization crypto. Needs to be called after
209
- * `initialize_user_crypto` but before any other crypto operations.
210
- * @param {InitOrgCryptoRequest} req
211
- * @returns {Promise<void>}
425
+ * The device key
212
426
  */
213
- initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
427
+ device_key: B64;
428
+ /**
429
+ * The decrypted user key. This can be used to get the consuming client to an unlocked state.
430
+ */
431
+ user_key: B64;
214
432
  }
215
- export class ClientFolders {
216
- free(): void;
433
+
434
+ /**
435
+ * Result of JIT master password registration process.
436
+ */
437
+ export interface JitMasterPasswordRegistrationResponse {
217
438
  /**
218
- * Decrypt folder
219
- * @param {Folder} folder
220
- * @returns {FolderView}
439
+ * The account cryptographic state of the user
221
440
  */
222
- decrypt(folder: Folder): FolderView;
441
+ account_cryptographic_state: WrappedAccountCryptographicState;
442
+ /**
443
+ * The master password unlock data
444
+ */
445
+ master_password_unlock: MasterPasswordUnlockData;
446
+ /**
447
+ * The decrypted user key.
448
+ */
449
+ user_key: B64;
223
450
  }
224
- export class ClientVault {
225
- free(): void;
451
+
452
+ export interface RegistrationError extends Error {
453
+ name: "RegistrationError";
454
+ variant: "KeyConnectorApi" | "Api" | "Crypto";
455
+ }
456
+
457
+ export function isRegistrationError(error: any): error is RegistrationError;
458
+
459
+ export interface PasswordPreloginError extends Error {
460
+ name: "PasswordPreloginError";
461
+ variant: "Api" | "Unknown";
462
+ }
463
+
464
+ export function isPasswordPreloginError(error: any): error is PasswordPreloginError;
465
+
466
+ export interface PasswordLoginError extends Error {
467
+ name: "PasswordLoginError";
468
+ variant: "InvalidUsernameOrPassword" | "PasswordAuthenticationDataDerivation" | "Unknown";
469
+ }
470
+
471
+ export function isPasswordLoginError(error: any): error is PasswordLoginError;
472
+
473
+ /**
474
+ * Public SDK request model for logging in via password
475
+ */
476
+ export interface PasswordLoginRequest {
477
+ /**
478
+ * Common login request fields
479
+ */
480
+ loginRequest: LoginRequest;
481
+ /**
482
+ * User\'s email address
483
+ */
484
+ email: string;
485
+ /**
486
+ * User\'s master password
487
+ */
488
+ password: string;
489
+ /**
490
+ * Prelogin data required for password authentication
491
+ * (e.g., KDF configuration for deriving the master key)
492
+ */
493
+ preloginResponse: PasswordPreloginResponse;
494
+ }
495
+
496
+ /**
497
+ * Response containing the data required before password-based authentication
498
+ */
499
+ export interface PasswordPreloginResponse {
500
+ /**
501
+ * The Key Derivation Function (KDF) configuration for the user
502
+ */
503
+ kdf: Kdf;
504
+ /**
505
+ * The salt used in the KDF process
506
+ */
507
+ salt: string;
508
+ }
509
+
510
+ /**
511
+ * The common bucket of login fields to be re-used across all login mechanisms
512
+ * (e.g., password, SSO, etc.). This will include handling client_id and 2FA.
513
+ */
514
+ export interface LoginRequest {
515
+ /**
516
+ * OAuth client identifier
517
+ */
518
+ clientId: string;
519
+ /**
520
+ * Device information for this login request
521
+ */
522
+ device: LoginDeviceRequest;
523
+ }
524
+
525
+ /**
526
+ * Common login response model used across different login methods.
527
+ */
528
+ export type LoginResponse = { Authenticated: LoginSuccessResponse };
529
+
530
+ /**
531
+ * Device information for login requests.
532
+ * This is common across all login mechanisms and describes the device
533
+ * making the authentication request.
534
+ */
535
+ export interface LoginDeviceRequest {
536
+ /**
537
+ * The type of device making the login request
538
+ * Note: today, we already have the DeviceType on the ApiConfigurations
539
+ * but we do not have the other device fields so we will accept the device data at login time
540
+ * for now. In the future, we might refactor the unauthN client to instantiate with full
541
+ * device info which would deprecate this struct. However, using the device_type here
542
+ * allows us to avoid any timing issues in scenarios where the device type could change
543
+ * between client instantiation and login (unlikely but possible).
544
+ */
545
+ deviceType: DeviceType;
546
+ /**
547
+ * Unique identifier for the device
548
+ */
549
+ deviceIdentifier: string;
550
+ /**
551
+ * Human-readable name of the device
552
+ */
553
+ deviceName: string;
554
+ /**
555
+ * Push notification token for the device (only for mobile devices)
556
+ */
557
+ devicePushToken: string | undefined;
558
+ }
559
+
560
+ /**
561
+ * SDK response model for a successful login.
562
+ * This is the model that will be exposed to consuming applications.
563
+ */
564
+ export interface LoginSuccessResponse {
565
+ /**
566
+ * The access token string.
567
+ */
568
+ accessToken: string;
569
+ /**
570
+ * The duration in seconds until the token expires.
571
+ */
572
+ expiresIn: number;
573
+ /**
574
+ * The timestamp in milliseconds when the token expires.
575
+ * We calculate this for more convenient token expiration handling.
576
+ */
577
+ expiresAt: number;
578
+ /**
579
+ * The scope of the access token.
580
+ * OAuth 2.0 RFC reference: <https://datatracker.ietf.org/doc/html/rfc6749#section-3.3>
581
+ */
582
+ scope: string;
583
+ /**
584
+ * The type of the token.
585
+ * This will be \"Bearer\" for send access tokens.
586
+ * OAuth 2.0 RFC reference: <https://datatracker.ietf.org/doc/html/rfc6749#section-7.1>
587
+ */
588
+ tokenType: string;
589
+ /**
590
+ * The optional refresh token string.
591
+ * This token can be used to obtain new access tokens when the current one expires.
592
+ */
593
+ refreshToken: string | undefined;
594
+ /**
595
+ * The user key wrapped user private key.
596
+ * Note: previously known as \"private_key\".
597
+ */
598
+ userKeyWrappedUserPrivateKey: string | undefined;
599
+ /**
600
+ * Two-factor authentication token for future requests.
601
+ */
602
+ twoFactorToken: string | undefined;
603
+ /**
604
+ * Indicates whether an admin has reset the user\'s master password,
605
+ * requiring them to set a new password upon next login.
606
+ */
607
+ forcePasswordReset: boolean | undefined;
608
+ /**
609
+ * Indicates whether the user uses Key Connector and if the client should have a locally
610
+ * configured Key Connector URL in their environment.
611
+ * Note: This is currently only applicable for client_credential grant type logins and
612
+ * is only expected to be relevant for the CLI
613
+ */
614
+ apiUseKeyConnector: boolean | undefined;
615
+ /**
616
+ * The user\'s decryption options for unlocking their vault.
617
+ */
618
+ userDecryptionOptions: UserDecryptionOptionsResponse;
619
+ /**
620
+ * If the user is subject to an organization master password policy,
621
+ * this field contains the requirements of that policy.
622
+ */
623
+ masterPasswordPolicy: MasterPasswordPolicyResponse | undefined;
624
+ }
625
+
626
+ /**
627
+ * SDK domain model for user decryption options.
628
+ * Provides the various methods available to unlock a user\'s vault.
629
+ */
630
+ export interface UserDecryptionOptionsResponse {
631
+ /**
632
+ * Master password unlock option. None if user doesn\'t have a master password.
633
+ */
634
+ masterPasswordUnlock?: MasterPasswordUnlockData;
635
+ /**
636
+ * Trusted Device decryption option.
637
+ */
638
+ trustedDeviceOption?: TrustedDeviceUserDecryptionOption;
639
+ /**
640
+ * Key Connector decryption option.
641
+ * Mutually exclusive with Trusted Device option.
642
+ */
643
+ keyConnectorOption?: KeyConnectorUserDecryptionOption;
644
+ /**
645
+ * WebAuthn PRF decryption option.
646
+ */
647
+ webauthnPrfOption?: WebAuthnPrfUserDecryptionOption;
648
+ }
649
+
650
+ /**
651
+ * SDK domain model for WebAuthn PRF user decryption option.
652
+ */
653
+ export interface WebAuthnPrfUserDecryptionOption {
654
+ /**
655
+ * PRF key encrypted private key
656
+ */
657
+ encryptedPrivateKey: EncString;
658
+ /**
659
+ * Public Key encrypted user key
660
+ */
661
+ encryptedUserKey: UnsignedSharedKey;
662
+ /**
663
+ * Credential ID for this WebAuthn PRF credential.
664
+ * TODO: PM-32163 - can remove `Option<T>` after 3 releases from server v2026.1.1
665
+ */
666
+ credentialId: string | undefined;
667
+ /**
668
+ * Transport methods available for this credential (e.g., \"usb\", \"nfc\", \"ble\", \"internal\",
669
+ * \"hybrid\").
670
+ * TODO: PM-32163 - can remove `Option<T>` after 3 releases from server v2026.1.1
671
+ */
672
+ transports: string[] | undefined;
673
+ }
674
+
675
+ /**
676
+ * SDK domain model for Key Connector user decryption option.
677
+ */
678
+ export interface KeyConnectorUserDecryptionOption {
679
+ /**
680
+ * URL of the Key Connector server to use for decryption.
681
+ */
682
+ keyConnectorUrl: string;
683
+ }
684
+
685
+ /**
686
+ * SDK domain model for Trusted Device user decryption option.
687
+ */
688
+ export interface TrustedDeviceUserDecryptionOption {
689
+ /**
690
+ * Whether the user has admin approval for device login.
691
+ */
692
+ hasAdminApproval: boolean;
693
+ /**
694
+ * Whether the user has a device that can approve logins.
695
+ */
696
+ hasLoginApprovingDevice: boolean;
697
+ /**
698
+ * Whether the user has permission to manage password reset for other users.
699
+ */
700
+ hasManageResetPasswordPermission: boolean;
701
+ /**
702
+ * Whether the user is in TDE offboarding.
703
+ */
704
+ isTdeOffboarding: boolean;
705
+ /**
706
+ * The device key encrypted device private key. Only present if the device is trusted.
707
+ */
708
+ encryptedPrivateKey?: EncString;
709
+ /**
710
+ * The device private key encrypted user key. Only present if the device is trusted.
711
+ */
712
+ encryptedUserKey?: UnsignedSharedKey;
713
+ }
714
+
715
+ export interface Collection {
716
+ id: CollectionId | undefined;
717
+ organizationId: OrganizationId;
718
+ name: EncString;
719
+ externalId: string | undefined;
720
+ hidePasswords: boolean;
721
+ readOnly: boolean;
722
+ manage: boolean;
723
+ defaultUserCollectionEmail: string | undefined;
724
+ type: CollectionType;
725
+ }
726
+
727
+ /**
728
+ * Type of collection
729
+ */
730
+ export type CollectionType = "SharedCollection" | "DefaultUserCollection";
731
+
732
+ export interface CollectionView {
733
+ id: CollectionId | undefined;
734
+ organizationId: OrganizationId;
735
+ name: string;
736
+ externalId: string | undefined;
737
+ hidePasswords: boolean;
738
+ readOnly: boolean;
739
+ manage: boolean;
740
+ type: CollectionType;
741
+ }
742
+
743
+ /**
744
+ * NewType wrapper for `CollectionId`
745
+ */
746
+ export type CollectionId = Tagged<Uuid, "CollectionId">;
747
+
748
+ export interface CollectionDecryptError extends Error {
749
+ name: "CollectionDecryptError";
750
+ variant: "Crypto";
751
+ }
752
+
753
+ export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
754
+
755
+ export type SignedSecurityState = string;
756
+
757
+ /**
758
+ * Represents the data required to unlock with the master password.
759
+ */
760
+ export interface MasterPasswordUnlockData {
761
+ /**
762
+ * The key derivation function used to derive the master key
763
+ */
764
+ kdf: Kdf;
765
+ /**
766
+ * The master key wrapped user key
767
+ */
768
+ masterKeyWrappedUserKey: EncString;
769
+ /**
770
+ * The salt used in the KDF, typically the user\'s email
771
+ */
772
+ salt: string;
773
+ }
774
+
775
+ export interface MasterPasswordError extends Error {
776
+ name: "MasterPasswordError";
777
+ variant:
778
+ | "EncryptionKeyMalformed"
779
+ | "KdfMalformed"
780
+ | "InvalidKdfConfiguration"
781
+ | "MissingField"
782
+ | "Crypto"
783
+ | "WrongPassword";
784
+ }
785
+
786
+ export function isMasterPasswordError(error: any): error is MasterPasswordError;
787
+
788
+ /**
789
+ * Represents the data required to authenticate with the master password.
790
+ */
791
+ export interface MasterPasswordAuthenticationData {
792
+ kdf: Kdf;
793
+ salt: string;
794
+ masterPasswordAuthenticationHash: B64;
795
+ }
796
+
797
+ /**
798
+ * Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
799
+ * Private keys are protected by the user key.
800
+ */
801
+ export type WrappedAccountCryptographicState =
802
+ | { V1: { private_key: EncString } }
803
+ | {
804
+ V2: {
805
+ private_key: EncString;
806
+ signed_public_key: SignedPublicKey | undefined;
807
+ signing_key: EncString;
808
+ security_state: SignedSecurityState;
809
+ };
810
+ };
811
+
812
+ export interface AccountCryptographyInitializationError extends Error {
813
+ name: "AccountCryptographyInitializationError";
814
+ variant:
815
+ | "WrongUserKeyType"
816
+ | "WrongUserKey"
817
+ | "CorruptData"
818
+ | "TamperedData"
819
+ | "KeyStoreAlreadyInitialized"
820
+ | "GenericCrypto";
821
+ }
822
+
823
+ export function isAccountCryptographyInitializationError(
824
+ error: any,
825
+ ): error is AccountCryptographyInitializationError;
826
+
827
+ export interface RotateCryptographyStateError extends Error {
828
+ name: "RotateCryptographyStateError";
829
+ variant: "KeyMissing" | "InvalidData";
830
+ }
831
+
832
+ export function isRotateCryptographyStateError(error: any): error is RotateCryptographyStateError;
833
+
834
+ /**
835
+ * Response for `verify_asymmetric_keys`.
836
+ */
837
+ export interface VerifyAsymmetricKeysResponse {
838
+ /**
839
+ * Whether the user\'s private key was decryptable by the user key.
840
+ */
841
+ privateKeyDecryptable: boolean;
842
+ /**
843
+ * Whether the user\'s private key was a valid RSA key and matched the public key provided.
844
+ */
845
+ validPrivateKey: boolean;
846
+ }
847
+
848
+ /**
849
+ * Represents the request to initialize the user\'s organizational cryptographic state.
850
+ */
851
+ export interface InitOrgCryptoRequest {
852
+ /**
853
+ * The encryption keys for all the organizations the user is a part of
854
+ */
855
+ organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
856
+ }
857
+
858
+ /**
859
+ * Response from the `make_key_pair` function
860
+ */
861
+ export interface MakeKeyPairResponse {
862
+ /**
863
+ * The user\'s public key
864
+ */
865
+ userPublicKey: B64;
866
+ /**
867
+ * User\'s private key, encrypted with the user key
868
+ */
869
+ userKeyEncryptedPrivateKey: EncString;
870
+ }
871
+
872
+ /**
873
+ * Response from the `make_update_password` function
874
+ */
875
+ export interface UpdatePasswordResponse {
876
+ /**
877
+ * Hash of the new password
878
+ */
879
+ passwordHash: B64;
880
+ /**
881
+ * User key, encrypted with the new password
882
+ */
883
+ newKey: EncString;
884
+ }
885
+
886
+ /**
887
+ * Request for deriving a pin protected user key
888
+ */
889
+ export interface DerivePinKeyResponse {
890
+ /**
891
+ * [UserKey] protected by PIN
892
+ */
893
+ pinProtectedUserKey: EncString;
894
+ /**
895
+ * PIN protected by [UserKey]
896
+ */
897
+ encryptedPin: EncString;
898
+ }
899
+
900
+ /**
901
+ * Auth requests supports multiple initialization methods.
902
+ */
903
+ export type AuthRequestMethod =
904
+ | { userKey: { protected_user_key: UnsignedSharedKey } }
905
+ | { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
906
+
907
+ /**
908
+ * State used for initializing the user cryptographic state.
909
+ */
910
+ export interface InitUserCryptoRequest {
911
+ /**
912
+ * The user\'s ID.
913
+ */
914
+ userId: UserId | undefined;
915
+ /**
916
+ * The user\'s KDF parameters, as received from the prelogin request
917
+ */
918
+ kdfParams: Kdf;
919
+ /**
920
+ * The user\'s email address
921
+ */
922
+ email: string;
923
+ /**
924
+ * The user\'s account cryptographic state, containing their signature and
925
+ * public-key-encryption keys, along with the signed security state, protected by the user key
926
+ */
927
+ accountCryptographicState: WrappedAccountCryptographicState;
928
+ /**
929
+ * The method to decrypt the user\'s account symmetric key (user key)
930
+ */
931
+ method: InitUserCryptoMethod;
932
+ }
933
+
934
+ /**
935
+ * The crypto method used to initialize the user cryptographic state.
936
+ */
937
+ export type InitUserCryptoMethod =
938
+ | { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
939
+ | { decryptedKey: { decrypted_user_key: string } }
940
+ | { pin: { pin: string; pin_protected_user_key: EncString } }
941
+ | { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
942
+ | { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
943
+ | {
944
+ deviceKey: {
945
+ device_key: string;
946
+ protected_device_private_key: EncString;
947
+ device_protected_user_key: UnsignedSharedKey;
948
+ };
949
+ }
950
+ | { keyConnector: { master_key: B64; user_key: EncString } };
951
+
952
+ /**
953
+ * Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
954
+ */
955
+ export interface UserCryptoV2KeysResponse {
956
+ /**
957
+ * User key
958
+ */
959
+ userKey: B64;
960
+ /**
961
+ * Wrapped private key
962
+ */
963
+ privateKey: EncString;
964
+ /**
965
+ * Public key
966
+ */
967
+ publicKey: B64;
968
+ /**
969
+ * The user\'s public key, signed by the signing key
970
+ */
971
+ signedPublicKey: SignedPublicKey;
972
+ /**
973
+ * Signing key, encrypted with the user\'s symmetric key
974
+ */
975
+ signingKey: EncString;
976
+ /**
977
+ * Base64 encoded verifying key
978
+ */
979
+ verifyingKey: B64;
980
+ /**
981
+ * The user\'s signed security state
982
+ */
983
+ securityState: SignedSecurityState;
984
+ /**
985
+ * The security state\'s version
986
+ */
987
+ securityVersion: number;
988
+ }
989
+
990
+ /**
991
+ * Request for deriving a pin protected user key
992
+ */
993
+ export interface EnrollPinResponse {
994
+ /**
995
+ * [UserKey] protected by PIN
996
+ */
997
+ pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
998
+ /**
999
+ * PIN protected by [UserKey]
1000
+ */
1001
+ userKeyEncryptedPin: EncString;
1002
+ }
1003
+
1004
+ export interface EnrollAdminPasswordResetError extends Error {
1005
+ name: "EnrollAdminPasswordResetError";
1006
+ variant: "Crypto";
1007
+ }
1008
+
1009
+ export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
1010
+
1011
+ export interface MakeKeysError extends Error {
1012
+ name: "MakeKeysError";
1013
+ variant:
1014
+ | "AccountCryptographyInitialization"
1015
+ | "MasterPasswordDerivation"
1016
+ | "RequestModelCreation"
1017
+ | "Crypto";
1018
+ }
1019
+
1020
+ export function isMakeKeysError(error: any): error is MakeKeysError;
1021
+
1022
+ /**
1023
+ * Request for migrating an account from password to key connector.
1024
+ */
1025
+ export interface DeriveKeyConnectorRequest {
1026
+ /**
1027
+ * Encrypted user key, used to validate the master key
1028
+ */
1029
+ userKeyEncrypted: EncString;
1030
+ /**
1031
+ * The user\'s master password
1032
+ */
1033
+ password: string;
1034
+ /**
1035
+ * The KDF parameters used to derive the master key
1036
+ */
1037
+ kdf: Kdf;
1038
+ /**
1039
+ * The user\'s email address
1040
+ */
1041
+ email: string;
1042
+ }
1043
+
1044
+ export interface DeriveKeyConnectorError extends Error {
1045
+ name: "DeriveKeyConnectorError";
1046
+ variant: "WrongPassword" | "Crypto";
1047
+ }
1048
+
1049
+ export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
1050
+
1051
+ /**
1052
+ * Request for `verify_asymmetric_keys`.
1053
+ */
1054
+ export interface VerifyAsymmetricKeysRequest {
1055
+ /**
1056
+ * The user\'s user key
1057
+ */
1058
+ userKey: B64;
1059
+ /**
1060
+ * The user\'s public key
1061
+ */
1062
+ userPublicKey: B64;
1063
+ /**
1064
+ * User\'s private key, encrypted with the user key
1065
+ */
1066
+ userKeyEncryptedPrivateKey: EncString;
1067
+ }
1068
+
1069
+ export interface CryptoClientError extends Error {
1070
+ name: "CryptoClientError";
1071
+ variant:
1072
+ | "NotAuthenticated"
1073
+ | "Crypto"
1074
+ | "InvalidKdfSettings"
1075
+ | "PasswordProtectedKeyEnvelope"
1076
+ | "InvalidPrfInput";
1077
+ }
1078
+
1079
+ export function isCryptoClientError(error: any): error is CryptoClientError;
1080
+
1081
+ /**
1082
+ * Response from the `update_kdf` function
1083
+ */
1084
+ export interface UpdateKdfResponse {
1085
+ /**
1086
+ * The authentication data for the new KDF setting
1087
+ */
1088
+ masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
1089
+ /**
1090
+ * The unlock data for the new KDF setting
1091
+ */
1092
+ masterPasswordUnlockData: MasterPasswordUnlockData;
1093
+ /**
1094
+ * The authentication data for the KDF setting prior to the change
1095
+ */
1096
+ oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
1097
+ }
1098
+
1099
+ /**
1100
+ * NewType wrapper for `UserId`
1101
+ */
1102
+ export type UserId = Tagged<Uuid, "UserId">;
1103
+
1104
+ /**
1105
+ * NewType wrapper for `OrganizationId`
1106
+ */
1107
+ export type OrganizationId = Tagged<Uuid, "OrganizationId">;
1108
+
1109
+ export interface StatefulCryptoError extends Error {
1110
+ name: "StatefulCryptoError";
1111
+ variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
1112
+ }
1113
+
1114
+ export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
1115
+
1116
+ /**
1117
+ * Basic client behavior settings. These settings specify the various targets and behavior of the
1118
+ * Bitwarden Client. They are optional and uneditable once the client is initialized.
1119
+ *
1120
+ * Defaults to
1121
+ *
1122
+ * ```
1123
+ * # use bitwarden_core::{ClientSettings, DeviceType};
1124
+ * let settings = ClientSettings {
1125
+ * identity_url: \"https://identity.bitwarden.com\".to_string(),
1126
+ * api_url: \"https://api.bitwarden.com\".to_string(),
1127
+ * user_agent: \"Bitwarden Rust-SDK\".to_string(),
1128
+ * device_type: DeviceType::SDK,
1129
+ * bitwarden_client_version: None,
1130
+ * bitwarden_package_type: None,
1131
+ * device_identifier: None,
1132
+ * };
1133
+ * let default = ClientSettings::default();
1134
+ * ```
1135
+ */
1136
+ export interface ClientSettings {
1137
+ /**
1138
+ * The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
1139
+ */
1140
+ identityUrl?: string;
1141
+ /**
1142
+ * The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
1143
+ */
1144
+ apiUrl?: string;
1145
+ /**
1146
+ * The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
1147
+ */
1148
+ userAgent?: string;
1149
+ /**
1150
+ * Device type to send to Bitwarden. Defaults to SDK
1151
+ */
1152
+ deviceType?: DeviceType;
1153
+ /**
1154
+ * Device identifier to send to Bitwarden. Optional for now in transition period.
1155
+ */
1156
+ deviceIdentifier?: string | undefined;
1157
+ /**
1158
+ * Bitwarden Client Version to send to Bitwarden. Optional for now in transition period.
1159
+ */
1160
+ bitwardenClientVersion?: string | undefined;
1161
+ /**
1162
+ * Bitwarden Package Type to send to Bitwarden. We should evaluate this field to see if it
1163
+ * should be optional later.
1164
+ */
1165
+ bitwardenPackageType?: string | undefined;
1166
+ }
1167
+
1168
+ export type DeviceType =
1169
+ | "Android"
1170
+ | "iOS"
1171
+ | "ChromeExtension"
1172
+ | "FirefoxExtension"
1173
+ | "OperaExtension"
1174
+ | "EdgeExtension"
1175
+ | "WindowsDesktop"
1176
+ | "MacOsDesktop"
1177
+ | "LinuxDesktop"
1178
+ | "ChromeBrowser"
1179
+ | "FirefoxBrowser"
1180
+ | "OperaBrowser"
1181
+ | "EdgeBrowser"
1182
+ | "IEBrowser"
1183
+ | "UnknownBrowser"
1184
+ | "AndroidAmazon"
1185
+ | "UWP"
1186
+ | "SafariBrowser"
1187
+ | "VivaldiBrowser"
1188
+ | "VivaldiExtension"
1189
+ | "SafariExtension"
1190
+ | "SDK"
1191
+ | "Server"
1192
+ | "WindowsCLI"
1193
+ | "MacOsCLI"
1194
+ | "LinuxCLI"
1195
+ | "DuckDuckGoBrowser";
1196
+
1197
+ export interface EncryptionSettingsError extends Error {
1198
+ name: "EncryptionSettingsError";
1199
+ variant:
1200
+ | "Crypto"
1201
+ | "CryptoInitialization"
1202
+ | "MissingPrivateKey"
1203
+ | "UserIdAlreadySet"
1204
+ | "WrongPin";
1205
+ }
1206
+
1207
+ export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
1208
+
1209
+ export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
1210
+
1211
+ export type EncString = Tagged<string, "EncString">;
1212
+
1213
+ export interface TrustDeviceResponse {
1214
+ /**
1215
+ * Base64 encoded device key
1216
+ */
1217
+ device_key: B64;
1218
+ /**
1219
+ * UserKey encrypted with DevicePublicKey
1220
+ */
1221
+ protected_user_key: UnsignedSharedKey;
1222
+ /**
1223
+ * DevicePrivateKey encrypted with [DeviceKey]
1224
+ */
1225
+ protected_device_private_key: EncString;
1226
+ /**
1227
+ * DevicePublicKey encrypted with [UserKey](super::UserKey)
1228
+ */
1229
+ protected_device_public_key: EncString;
1230
+ }
1231
+
1232
+ export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
1233
+
1234
+ /**
1235
+ * A set of keys where a given `DownstreamKey` is protected by an encrypted public/private
1236
+ * key-pair. The `DownstreamKey` is used to encrypt/decrypt data, while the public/private key-pair
1237
+ * is used to rotate the `DownstreamKey`.
1238
+ *
1239
+ * The `PrivateKey` is protected by an `UpstreamKey`, such as a `DeviceKey`, or `PrfKey`,
1240
+ * and the `PublicKey` is protected by the `DownstreamKey`. This setup allows:
1241
+ *
1242
+ * - Access to `DownstreamKey` by knowing the `UpstreamKey`
1243
+ * - Rotation to a `NewDownstreamKey` by knowing the current `DownstreamKey`, without needing
1244
+ * access to the `UpstreamKey`
1245
+ */
1246
+ export interface RotateableKeySet {
1247
+ /**
1248
+ * `DownstreamKey` protected by encapsulation key
1249
+ */
1250
+ encapsulatedDownstreamKey: UnsignedSharedKey;
1251
+ /**
1252
+ * Encapsulation key protected by `DownstreamKey`
1253
+ */
1254
+ encryptedEncapsulationKey: EncString;
1255
+ /**
1256
+ * Decapsulation key protected by `UpstreamKey`
1257
+ */
1258
+ encryptedDecapsulationKey: EncString;
1259
+ }
1260
+
1261
+ export type PublicKey = Tagged<string, "PublicKey">;
1262
+
1263
+ /**
1264
+ * Key Derivation Function for Bitwarden Account
1265
+ *
1266
+ * In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
1267
+ * Enum represents all the possible KDFs.
1268
+ */
1269
+ export type Kdf =
1270
+ | { pBKDF2: { iterations: NonZeroU32 } }
1271
+ | { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
1272
+
1273
+ export type DataEnvelope = Tagged<string, "DataEnvelope">;
1274
+
1275
+ export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
1276
+
1277
+ export interface CryptoError extends Error {
1278
+ name: "CryptoError";
1279
+ variant:
1280
+ | "Decrypt"
1281
+ | "InvalidKey"
1282
+ | "KeyDecrypt"
1283
+ | "InvalidKeyLen"
1284
+ | "InvalidUtf8String"
1285
+ | "MissingKey"
1286
+ | "MissingField"
1287
+ | "MissingKeyId"
1288
+ | "KeyOperationNotSupported"
1289
+ | "ReadOnlyKeyStore"
1290
+ | "InvalidKeyStoreOperation"
1291
+ | "InsufficientKdfParameters"
1292
+ | "EncString"
1293
+ | "Rsa"
1294
+ | "Fingerprint"
1295
+ | "Argon"
1296
+ | "ZeroNumber"
1297
+ | "OperationNotSupported"
1298
+ | "WrongKeyType"
1299
+ | "WrongCoseKeyId"
1300
+ | "InvalidNonceLength"
1301
+ | "InvalidPadding"
1302
+ | "Signature"
1303
+ | "Encoding";
1304
+ }
1305
+
1306
+ export function isCryptoError(error: any): error is CryptoError;
1307
+
1308
+ /**
1309
+ * The type of key / signature scheme used for signing and verifying.
1310
+ */
1311
+ export type SignatureAlgorithm = "ed25519";
1312
+
1313
+ /**
1314
+ * Base64 encoded data
1315
+ *
1316
+ * Is indifferent about padding when decoding, but always produces padding when encoding.
1317
+ */
1318
+ export type B64 = string;
1319
+
1320
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
1321
+
1322
+ /**
1323
+ * Temporary struct to hold metadata related to current account
1324
+ *
1325
+ * Eventually the SDK itself should have this state and we get rid of this struct.
1326
+ */
1327
+ export interface Account {
1328
+ id: Uuid;
1329
+ email: string;
1330
+ name: string | undefined;
1331
+ }
1332
+
1333
+ export interface ExportError extends Error {
1334
+ name: "ExportError";
1335
+ variant:
1336
+ | "MissingField"
1337
+ | "NotAuthenticated"
1338
+ | "Csv"
1339
+ | "Cxf"
1340
+ | "Json"
1341
+ | "EncryptedJson"
1342
+ | "BitwardenCrypto"
1343
+ | "Cipher";
1344
+ }
1345
+
1346
+ export function isExportError(error: any): error is ExportError;
1347
+
1348
+ export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
1349
+
1350
+ /**
1351
+ * Passphrase generator request options.
1352
+ */
1353
+ export interface PassphraseGeneratorRequest {
1354
+ /**
1355
+ * Number of words in the generated passphrase.
1356
+ * This value must be between 3 and 20.
1357
+ */
1358
+ numWords: number;
1359
+ /**
1360
+ * Character separator between words in the generated passphrase. The value cannot be empty.
1361
+ */
1362
+ wordSeparator: string;
1363
+ /**
1364
+ * When set to true, capitalize the first letter of each word in the generated passphrase.
1365
+ */
1366
+ capitalize: boolean;
1367
+ /**
1368
+ * When set to true, include a number at the end of one of the words in the generated
1369
+ * passphrase.
1370
+ */
1371
+ includeNumber: boolean;
1372
+ }
1373
+
1374
+ export interface PasswordError extends Error {
1375
+ name: "PasswordError";
1376
+ variant: "NoCharacterSetEnabled" | "InvalidLength";
1377
+ }
1378
+
1379
+ export function isPasswordError(error: any): error is PasswordError;
1380
+
1381
+ /**
1382
+ * Password generator request options.
1383
+ */
1384
+ export interface PasswordGeneratorRequest {
1385
+ /**
1386
+ * Include lowercase characters (a-z).
1387
+ */
1388
+ lowercase: boolean;
1389
+ /**
1390
+ * Include uppercase characters (A-Z).
1391
+ */
1392
+ uppercase: boolean;
1393
+ /**
1394
+ * Include numbers (0-9).
1395
+ */
1396
+ numbers: boolean;
1397
+ /**
1398
+ * Include special characters: ! @ # $ % ^ & *
1399
+ */
1400
+ special: boolean;
1401
+ /**
1402
+ * The length of the generated password.
1403
+ * Note that the password length must be greater than the sum of all the minimums.
1404
+ */
1405
+ length: number;
1406
+ /**
1407
+ * When set to true, the generated password will not contain ambiguous characters.
1408
+ * The ambiguous characters are: I, O, l, 0, 1
1409
+ */
1410
+ avoidAmbiguous: boolean;
1411
+ /**
1412
+ * The minimum number of lowercase characters in the generated password.
1413
+ * When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
1414
+ */
1415
+ minLowercase: number | undefined;
1416
+ /**
1417
+ * The minimum number of uppercase characters in the generated password.
1418
+ * When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
1419
+ */
1420
+ minUppercase: number | undefined;
1421
+ /**
1422
+ * The minimum number of numbers in the generated password.
1423
+ * When set, the value must be between 1 and 9. This value is ignored if numbers is false.
1424
+ */
1425
+ minNumber: number | undefined;
1426
+ /**
1427
+ * The minimum number of special characters in the generated password.
1428
+ * When set, the value must be between 1 and 9. This value is ignored if special is false.
1429
+ */
1430
+ minSpecial: number | undefined;
1431
+ }
1432
+
1433
+ export interface UsernameError extends Error {
1434
+ name: "UsernameError";
1435
+ variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
1436
+ }
1437
+
1438
+ export function isUsernameError(error: any): error is UsernameError;
1439
+
1440
+ export type AppendType = "random" | { websiteName: { website: string } };
1441
+
1442
+ /**
1443
+ * Configures the email forwarding service to use.
1444
+ * For instructions on how to configure each service, see the documentation:
1445
+ * <https://bitwarden.com/help/generator/#username-types>
1446
+ */
1447
+ export type ForwarderServiceType =
1448
+ | { addyIo: { api_token: string; domain: string; base_url: string } }
1449
+ | { duckDuckGo: { token: string } }
1450
+ | { firefox: { api_token: string } }
1451
+ | { fastmail: { api_token: string } }
1452
+ | { forwardEmail: { api_token: string; domain: string } }
1453
+ | { simpleLogin: { api_key: string; base_url: string } };
1454
+
1455
+ export type UsernameGeneratorRequest =
1456
+ | { word: { capitalize: boolean; include_number: boolean } }
1457
+ | { subaddress: { type: AppendType; email: string } }
1458
+ | { catchall: { type: AppendType; domain: string } }
1459
+ | { forwarded: { service: ForwarderServiceType; website: string | undefined } };
1460
+
1461
+ export interface TypedReceiveError extends Error {
1462
+ name: "TypedReceiveError";
1463
+ variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
1464
+ }
1465
+
1466
+ export function isTypedReceiveError(error: any): error is TypedReceiveError;
1467
+
1468
+ export interface ReceiveError extends Error {
1469
+ name: "ReceiveError";
1470
+ variant: "Channel" | "Timeout" | "Cancelled";
1471
+ }
1472
+
1473
+ export function isReceiveError(error: any): error is ReceiveError;
1474
+
1475
+ export interface RequestError extends Error {
1476
+ name: "RequestError";
1477
+ variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
1478
+ }
1479
+
1480
+ export function isRequestError(error: any): error is RequestError;
1481
+
1482
+ export interface SubscribeError extends Error {
1483
+ name: "SubscribeError";
1484
+ variant: "NotStarted";
1485
+ }
1486
+
1487
+ export function isSubscribeError(error: any): error is SubscribeError;
1488
+
1489
+ export interface IpcCommunicationBackendSender {
1490
+ send(message: OutgoingMessage): Promise<void>;
1491
+ }
1492
+
1493
+ export interface ChannelError extends Error {
1494
+ name: "ChannelError";
1495
+ }
1496
+
1497
+ export function isChannelError(error: any): error is ChannelError;
1498
+
1499
+ export interface DeserializeError extends Error {
1500
+ name: "DeserializeError";
1501
+ }
1502
+
1503
+ export function isDeserializeError(error: any): error is DeserializeError;
1504
+
1505
+ export interface IpcSessionRepository {
1506
+ get(endpoint: Endpoint): Promise<any | undefined>;
1507
+ save(endpoint: Endpoint, session: any): Promise<void>;
1508
+ remove(endpoint: Endpoint): Promise<void>;
1509
+ }
1510
+
1511
+ export interface DiscoverResponse {
1512
+ version: string;
1513
+ }
1514
+
1515
+ export type Endpoint =
1516
+ | { Web: { id: number } }
1517
+ | "BrowserForeground"
1518
+ | "BrowserBackground"
1519
+ | "DesktopRenderer"
1520
+ | "DesktopMain";
1521
+
1522
+ /**
1523
+ * SDK domain model for master password policy requirements.
1524
+ * Defines the complexity requirements for a user\'s master password
1525
+ * when enforced by an organization policy.
1526
+ */
1527
+ export interface MasterPasswordPolicyResponse {
1528
+ /**
1529
+ * The minimum complexity score required for the master password.
1530
+ * Complexity is calculated based on password strength metrics.
1531
+ */
1532
+ minComplexity?: number;
1533
+ /**
1534
+ * The minimum length required for the master password.
1535
+ */
1536
+ minLength?: number;
1537
+ /**
1538
+ * Whether the master password must contain at least one lowercase letter.
1539
+ */
1540
+ requireLower?: boolean;
1541
+ /**
1542
+ * Whether the master password must contain at least one uppercase letter.
1543
+ */
1544
+ requireUpper?: boolean;
1545
+ /**
1546
+ * Whether the master password must contain at least one numeric digit.
1547
+ */
1548
+ requireNumbers?: boolean;
1549
+ /**
1550
+ * Whether the master password must contain at least one special character.
1551
+ */
1552
+ requireSpecial?: boolean;
1553
+ /**
1554
+ * Whether this policy should be enforced when the user logs in.
1555
+ * If true, the user will be required to update their master password
1556
+ * if it doesn\'t meet the policy requirements.
1557
+ */
1558
+ enforceOnLogin?: boolean;
1559
+ }
1560
+
1561
+ export interface ServerCommunicationConfigRepositoryError extends Error {
1562
+ name: "ServerCommunicationConfigRepositoryError";
1563
+ variant: "GetError" | "SaveError";
1564
+ }
1565
+
1566
+ export function isServerCommunicationConfigRepositoryError(
1567
+ error: any,
1568
+ ): error is ServerCommunicationConfigRepositoryError;
1569
+
1570
+ /**
1571
+ * A cookie acquired from the platform
1572
+ *
1573
+ * Represents a single cookie name/value pair as received from the browser or HTTP client.
1574
+ * For sharded cookies (AWS ALB pattern), each shard is a separate `AcquiredCookie` with
1575
+ * its own name including the `-{N}` suffix (e.g., `AWSELBAuthSessionCookie-0`).
1576
+ */
1577
+ export interface AcquiredCookie {
1578
+ /**
1579
+ * Cookie name
1580
+ *
1581
+ * For sharded cookies, this includes the shard suffix (e.g., `AWSELBAuthSessionCookie-0`)
1582
+ * For unsharded cookies, this is the cookie name without any suffix.
1583
+ */
1584
+ name: string;
1585
+ /**
1586
+ * Cookie value
1587
+ */
1588
+ value: string;
1589
+ }
1590
+
1591
+ export interface AcquireCookieError extends Error {
1592
+ name: "AcquireCookieError";
1593
+ variant:
1594
+ | "Cancelled"
1595
+ | "UnsupportedConfiguration"
1596
+ | "CookieNameMismatch"
1597
+ | "RepositoryGetError"
1598
+ | "RepositorySaveError";
1599
+ }
1600
+
1601
+ export function isAcquireCookieError(error: any): error is AcquireCookieError;
1602
+
1603
+ /**
1604
+ * Repository interface for storing server communication configuration.
1605
+ *
1606
+ * Implementations use StateProvider (or equivalent storage mechanism) to
1607
+ * persist configuration across sessions. The hostname is typically the vault
1608
+ * server's hostname (e.g., "vault.acme.com").
1609
+ */
1610
+ export interface ServerCommunicationConfigRepository {
1611
+ /**
1612
+ * Retrieves the server communication configuration for a given hostname.
1613
+ *
1614
+ * @param hostname The server hostname (e.g., "vault.acme.com")
1615
+ * @returns The configuration if it exists, undefined otherwise
1616
+ */
1617
+ get(hostname: string): Promise<ServerCommunicationConfig | undefined>;
1618
+
1619
+ /**
1620
+ * Saves the server communication configuration for a given hostname.
1621
+ *
1622
+ * @param hostname The server hostname (e.g., "vault.acme.com")
1623
+ * @param config The configuration to store
1624
+ */
1625
+ save(hostname: string, config: ServerCommunicationConfig): Promise<void>;
1626
+ }
1627
+
1628
+ /**
1629
+ * Platform API interface for acquiring SSO cookies.
1630
+ *
1631
+ * Platform clients implement this interface to handle cookie acquisition
1632
+ * through browser redirects or other platform-specific mechanisms.
1633
+ */
1634
+ export interface ServerCommunicationConfigPlatformApi {
1635
+ /**
1636
+ * Acquires cookies for the given hostname.
1637
+ *
1638
+ * This typically involves redirecting to an IdP login page and extracting
1639
+ * cookies from the load balancer response. For sharded cookies, returns
1640
+ * multiple entries with names like "CookieName-0", "CookieName-1", etc.
1641
+ *
1642
+ * @param hostname The server hostname (e.g., "vault.acme.com")
1643
+ * @returns An array of AcquiredCookie objects, or undefined if acquisition failed or was cancelled
1644
+ */
1645
+ acquireCookies(hostname: string): Promise<AcquiredCookie[] | undefined>;
1646
+ }
1647
+
1648
+ /**
1649
+ * SSO cookie vendor configuration
1650
+ *
1651
+ * This configuration is provided by the server.
1652
+ */
1653
+ export interface SsoCookieVendorConfig {
1654
+ /**
1655
+ * Identity provider login URL for browser redirect during bootstrap
1656
+ */
1657
+ idpLoginUrl: string | undefined;
1658
+ /**
1659
+ * Cookie name (base name, without shard suffix)
1660
+ */
1661
+ cookieName: string | undefined;
1662
+ /**
1663
+ * Cookie domain for validation
1664
+ */
1665
+ cookieDomain: string | undefined;
1666
+ /**
1667
+ * Acquired cookies
1668
+ *
1669
+ * For sharded cookies, this contains multiple entries with names like
1670
+ * `AWSELBAuthSessionCookie-0`, `AWSELBAuthSessionCookie-1`, etc.
1671
+ * For unsharded cookies, this contains a single entry with the base name.
1672
+ */
1673
+ cookieValue: AcquiredCookie[] | undefined;
1674
+ }
1675
+
1676
+ /**
1677
+ * Server communication configuration
1678
+ */
1679
+ export interface ServerCommunicationConfig {
1680
+ /**
1681
+ * Bootstrap configuration determining how to establish server communication
1682
+ */
1683
+ bootstrap: BootstrapConfig;
1684
+ }
1685
+
1686
+ /**
1687
+ * Bootstrap configuration for server communication
1688
+ */
1689
+ export type BootstrapConfig =
1690
+ | { type: "direct" }
1691
+ | ({ type: "ssoCookieVendor" } & SsoCookieVendorConfig);
1692
+
1693
+ export interface KeyGenerationError extends Error {
1694
+ name: "KeyGenerationError";
1695
+ variant: "KeyGeneration" | "KeyConversion";
1696
+ }
1697
+
1698
+ export function isKeyGenerationError(error: any): error is KeyGenerationError;
1699
+
1700
+ export interface SshKeyImportError extends Error {
1701
+ name: "SshKeyImportError";
1702
+ variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
1703
+ }
1704
+
1705
+ export function isSshKeyImportError(error: any): error is SshKeyImportError;
1706
+
1707
+ export interface SshKeyExportError extends Error {
1708
+ name: "SshKeyExportError";
1709
+ variant: "KeyConversion";
1710
+ }
1711
+
1712
+ export function isSshKeyExportError(error: any): error is SshKeyExportError;
1713
+
1714
+ export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
1715
+
1716
+ export interface DatabaseError extends Error {
1717
+ name: "DatabaseError";
1718
+ variant: "UnsupportedConfiguration" | "ThreadBoundRunner" | "Serialization" | "JS" | "Internal";
1719
+ }
1720
+
1721
+ export function isDatabaseError(error: any): error is DatabaseError;
1722
+
1723
+ export interface StateRegistryError extends Error {
1724
+ name: "StateRegistryError";
1725
+ variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
1726
+ }
1727
+
1728
+ export function isStateRegistryError(error: any): error is StateRegistryError;
1729
+
1730
+ export interface CallError extends Error {
1731
+ name: "CallError";
1732
+ }
1733
+
1734
+ export function isCallError(error: any): error is CallError;
1735
+
1736
+ export interface RotateUserKeysRequest {
1737
+ master_key_unlock_method: MasterkeyUnlockMethod;
1738
+ trusted_emergency_access_public_keys: PublicKey[];
1739
+ trusted_organization_public_keys: PublicKey[];
1740
+ }
1741
+
1742
+ export type MasterkeyUnlockMethod =
1743
+ | { Password: { old_password: string; password: string; hint: string | undefined } }
1744
+ | "KeyConnector"
1745
+ | "None";
1746
+
1747
+ export interface RotateUserKeysError extends Error {
1748
+ name: "RotateUserKeysError";
1749
+ variant: "ApiError" | "CryptoError" | "InvalidPublicKey" | "UntrustedKeyError";
1750
+ }
1751
+
1752
+ export function isRotateUserKeysError(error: any): error is RotateUserKeysError;
1753
+
1754
+ export interface SyncError extends Error {
1755
+ name: "SyncError";
1756
+ variant: "NetworkError" | "DataError";
1757
+ }
1758
+
1759
+ export function isSyncError(error: any): error is SyncError;
1760
+
1761
+ export interface PrivateKeysParsingError extends Error {
1762
+ name: "PrivateKeysParsingError";
1763
+ variant: "MissingField" | "InvalidFormat";
1764
+ }
1765
+
1766
+ export function isPrivateKeysParsingError(error: any): error is PrivateKeysParsingError;
1767
+
1768
+ /**
1769
+ * The data necessary to re-share the user-key to a V1 emergency access membership. Note: The
1770
+ * Public-key must be verified/trusted. Further, there is no sender authentication possible here.
1771
+ */
1772
+ export interface V1EmergencyAccessMembership {
1773
+ id: Uuid;
1774
+ name: string;
1775
+ public_key: PublicKey;
1776
+ }
1777
+
1778
+ /**
1779
+ * The data necessary to re-share the user-key to a V1 organization membership. Note: The
1780
+ * Public-key must be verified/trusted. Further, there is no sender authentication possible here.
1781
+ */
1782
+ export interface V1OrganizationMembership {
1783
+ organization_id: Uuid;
1784
+ name: string;
1785
+ public_key: PublicKey;
1786
+ }
1787
+
1788
+ export interface CipherRiskError extends Error {
1789
+ name: "CipherRiskError";
1790
+ variant: "Reqwest";
1791
+ }
1792
+
1793
+ export function isCipherRiskError(error: any): error is CipherRiskError;
1794
+
1795
+ /**
1796
+ * Password reuse map wrapper for WASM compatibility.
1797
+ */
1798
+ export type PasswordReuseMap = Record<string, number>;
1799
+
1800
+ /**
1801
+ * Options for configuring risk computation.
1802
+ */
1803
+ export interface CipherRiskOptions {
1804
+ /**
1805
+ * Pre-computed password reuse map (password → count).
1806
+ * If provided, enables reuse detection across ciphers.
1807
+ */
1808
+ passwordMap?: PasswordReuseMap | undefined;
1809
+ /**
1810
+ * Whether to check passwords against Have I Been Pwned API.
1811
+ * When true, makes network requests to check for exposed passwords.
1812
+ */
1813
+ checkExposed?: boolean;
1814
+ /**
1815
+ * Optional HIBP API base URL override. When None, uses the production HIBP URL.
1816
+ * Can be used for testing or alternative password breach checking services.
1817
+ */
1818
+ hibpBaseUrl?: string | undefined;
1819
+ }
1820
+
1821
+ /**
1822
+ * Risk evaluation result for a single cipher.
1823
+ */
1824
+ export interface CipherRiskResult {
1825
+ /**
1826
+ * Cipher ID matching the input CipherLoginDetails.
1827
+ */
1828
+ id: CipherId;
1829
+ /**
1830
+ * Password strength score from 0 (weakest) to 4 (strongest).
1831
+ * Calculated using zxcvbn with cipher-specific context.
1832
+ */
1833
+ password_strength: number;
1834
+ /**
1835
+ * Result of checking password exposure via HIBP API.
1836
+ * - `NotChecked`: check_exposed was false, or password was empty
1837
+ * - `Found(n)`: Successfully checked, found in n breaches
1838
+ * - `Error(msg)`: HIBP API request failed for this cipher with the given error message
1839
+ */
1840
+ exposed_result: ExposedPasswordResult;
1841
+ /**
1842
+ * Number of times this password appears in the provided password_map.
1843
+ * None if not found or if no password_map was provided.
1844
+ */
1845
+ reuse_count: number | undefined;
1846
+ }
1847
+
1848
+ /**
1849
+ * Result of checking password exposure via HIBP API.
1850
+ */
1851
+ export type ExposedPasswordResult =
1852
+ | { type: "NotChecked" }
1853
+ | { type: "Found"; value: number }
1854
+ | { type: "Error"; value: string };
1855
+
1856
+ /**
1857
+ * Login cipher data needed for risk evaluation.
1858
+ */
1859
+ export interface CipherLoginDetails {
1860
+ /**
1861
+ * Cipher ID to identify which cipher in results.
1862
+ */
1863
+ id: CipherId;
1864
+ /**
1865
+ * The decrypted password to evaluate.
1866
+ */
1867
+ password: string;
1868
+ /**
1869
+ * Username or email (login ciphers only have one field).
1870
+ */
1871
+ username: string | undefined;
1872
+ }
1873
+
1874
+ export interface PasswordHistoryView {
1875
+ password: string;
1876
+ lastUsedDate: DateTime<Utc>;
1877
+ }
1878
+
1879
+ export interface PasswordHistory {
1880
+ password: EncString;
1881
+ lastUsedDate: DateTime<Utc>;
1882
+ }
1883
+
1884
+ export interface AncestorMap {
1885
+ ancestors: Map<CollectionId, string>;
1886
+ }
1887
+
1888
+ export interface TotpError extends Error {
1889
+ name: "TotpError";
1890
+ variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
1891
+ }
1892
+
1893
+ export function isTotpError(error: any): error is TotpError;
1894
+
1895
+ export interface TotpResponse {
1896
+ /**
1897
+ * Generated TOTP code
1898
+ */
1899
+ code: string;
1900
+ /**
1901
+ * Time period
1902
+ */
1903
+ period: number;
1904
+ }
1905
+
1906
+ export interface DecryptError extends Error {
1907
+ name: "DecryptError";
1908
+ variant: "Crypto";
1909
+ }
1910
+
1911
+ export function isDecryptError(error: any): error is DecryptError;
1912
+
1913
+ export interface EncryptError extends Error {
1914
+ name: "EncryptError";
1915
+ variant: "Crypto" | "MissingUserId";
1916
+ }
1917
+
1918
+ export function isEncryptError(error: any): error is EncryptError;
1919
+
1920
+ export interface Attachment {
1921
+ id: string | undefined;
1922
+ url: string | undefined;
1923
+ size: string | undefined;
1924
+ /**
1925
+ * Readable size, ex: \"4.2 KB\" or \"1.43 GB\
1926
+ */
1927
+ sizeName: string | undefined;
1928
+ fileName: EncString | undefined;
1929
+ key: EncString | undefined;
1930
+ }
1931
+
1932
+ export interface AttachmentView {
1933
+ id: string | undefined;
1934
+ url: string | undefined;
1935
+ size: string | undefined;
1936
+ sizeName: string | undefined;
1937
+ fileName: string | undefined;
1938
+ key: EncString | undefined;
1939
+ /**
1940
+ * The decrypted attachmentkey in base64 format.
1941
+ *
1942
+ * **TEMPORARY FIELD**: This field is a temporary workaround to provide
1943
+ * decrypted attachment keys to the TypeScript client during the migration
1944
+ * process. It will be removed once the encryption/decryption logic is
1945
+ * fully migrated to the SDK.
1946
+ *
1947
+ * **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
1948
+ *
1949
+ * Do not rely on this field for long-term use.
1950
+ */
1951
+ decryptedKey: string | undefined;
1952
+ }
1953
+
1954
+ export interface LocalDataView {
1955
+ lastUsedDate: DateTime<Utc> | undefined;
1956
+ lastLaunched: DateTime<Utc> | undefined;
1957
+ }
1958
+
1959
+ export interface LocalData {
1960
+ lastUsedDate: DateTime<Utc> | undefined;
1961
+ lastLaunched: DateTime<Utc> | undefined;
1962
+ }
1963
+
1964
+ export interface SecureNoteView {
1965
+ type: SecureNoteType;
1966
+ }
1967
+
1968
+ export interface SecureNote {
1969
+ type: SecureNoteType;
1970
+ }
1971
+
1972
+ export interface GetCipherError extends Error {
1973
+ name: "GetCipherError";
1974
+ variant: "ItemNotFound" | "Crypto" | "Repository";
1975
+ }
1976
+
1977
+ export function isGetCipherError(error: any): error is GetCipherError;
1978
+
1979
+ export interface EditCipherError extends Error {
1980
+ name: "EditCipherError";
1981
+ variant:
1982
+ | "ItemNotFound"
1983
+ | "Crypto"
1984
+ | "Api"
1985
+ | "VaultParse"
1986
+ | "MissingField"
1987
+ | "NotAuthenticated"
1988
+ | "Repository"
1989
+ | "Uuid";
1990
+ }
1991
+
1992
+ export function isEditCipherError(error: any): error is EditCipherError;
1993
+
1994
+ /**
1995
+ * Request to edit a cipher.
1996
+ */
1997
+ export interface CipherEditRequest {
1998
+ id: CipherId;
1999
+ organizationId: OrganizationId | undefined;
2000
+ folderId: FolderId | undefined;
2001
+ favorite: boolean;
2002
+ reprompt: CipherRepromptType;
2003
+ name: string;
2004
+ notes: string | undefined;
2005
+ fields: FieldView[];
2006
+ type: CipherViewType;
2007
+ revisionDate: DateTime<Utc>;
2008
+ archivedDate: DateTime<Utc> | undefined;
2009
+ attachments: AttachmentView[];
2010
+ key: EncString | undefined;
2011
+ }
2012
+
2013
+ export interface GetOrganizationCiphersAdminError extends Error {
2014
+ name: "GetOrganizationCiphersAdminError";
2015
+ variant: "Crypto" | "VaultParse" | "Api";
2016
+ }
2017
+
2018
+ export function isGetOrganizationCiphersAdminError(
2019
+ error: any,
2020
+ ): error is GetOrganizationCiphersAdminError;
2021
+
2022
+ export interface EditCipherAdminError extends Error {
2023
+ name: "EditCipherAdminError";
2024
+ variant:
2025
+ | "ItemNotFound"
2026
+ | "Crypto"
2027
+ | "Api"
2028
+ | "VaultParse"
2029
+ | "MissingField"
2030
+ | "NotAuthenticated"
2031
+ | "Repository"
2032
+ | "Uuid"
2033
+ | "Decrypt";
2034
+ }
2035
+
2036
+ export function isEditCipherAdminError(error: any): error is EditCipherAdminError;
2037
+
2038
+ export interface CreateCipherAdminError extends Error {
2039
+ name: "CreateCipherAdminError";
2040
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated";
2041
+ }
2042
+
2043
+ export function isCreateCipherAdminError(error: any): error is CreateCipherAdminError;
2044
+
2045
+ export interface DeleteCipherAdminError extends Error {
2046
+ name: "DeleteCipherAdminError";
2047
+ variant: "Api";
2048
+ }
2049
+
2050
+ export function isDeleteCipherAdminError(error: any): error is DeleteCipherAdminError;
2051
+
2052
+ export interface RestoreCipherAdminError extends Error {
2053
+ name: "RestoreCipherAdminError";
2054
+ variant: "Api" | "VaultParse" | "Crypto";
2055
+ }
2056
+
2057
+ export function isRestoreCipherAdminError(error: any): error is RestoreCipherAdminError;
2058
+
2059
+ /**
2060
+ * Request to add a cipher.
2061
+ */
2062
+ export interface CipherCreateRequest {
2063
+ organizationId: OrganizationId | undefined;
2064
+ collectionIds: CollectionId[];
2065
+ folderId: FolderId | undefined;
2066
+ name: string;
2067
+ notes: string | undefined;
2068
+ favorite: boolean;
2069
+ reprompt: CipherRepromptType;
2070
+ type: CipherViewType;
2071
+ fields: FieldView[];
2072
+ }
2073
+
2074
+ export interface CreateCipherError extends Error {
2075
+ name: "CreateCipherError";
2076
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
2077
+ }
2078
+
2079
+ export function isCreateCipherError(error: any): error is CreateCipherError;
2080
+
2081
+ export interface DeleteCipherError extends Error {
2082
+ name: "DeleteCipherError";
2083
+ variant: "Api" | "Repository";
2084
+ }
2085
+
2086
+ export function isDeleteCipherError(error: any): error is DeleteCipherError;
2087
+
2088
+ export interface RestoreCipherError extends Error {
2089
+ name: "RestoreCipherError";
2090
+ variant: "Api" | "VaultParse" | "Repository" | "Crypto";
2091
+ }
2092
+
2093
+ export function isRestoreCipherError(error: any): error is RestoreCipherError;
2094
+
2095
+ /**
2096
+ * Represents the inner data of a cipher view.
2097
+ */
2098
+ export type CipherViewType =
2099
+ | { login: LoginView }
2100
+ | { card: CardView }
2101
+ | { identity: IdentityView }
2102
+ | { secureNote: SecureNoteView }
2103
+ | { sshKey: SshKeyView };
2104
+
2105
+ export interface EncryptFileError extends Error {
2106
+ name: "EncryptFileError";
2107
+ variant: "Encrypt" | "Io";
2108
+ }
2109
+
2110
+ export function isEncryptFileError(error: any): error is EncryptFileError;
2111
+
2112
+ export interface DecryptFileError extends Error {
2113
+ name: "DecryptFileError";
2114
+ variant: "Decrypt" | "Io";
2115
+ }
2116
+
2117
+ export function isDecryptFileError(error: any): error is DecryptFileError;
2118
+
2119
+ export interface CipherPermissions {
2120
+ delete: boolean;
2121
+ restore: boolean;
2122
+ }
2123
+
2124
+ export interface Card {
2125
+ cardholderName: EncString | undefined;
2126
+ expMonth: EncString | undefined;
2127
+ expYear: EncString | undefined;
2128
+ code: EncString | undefined;
2129
+ brand: EncString | undefined;
2130
+ number: EncString | undefined;
2131
+ }
2132
+
2133
+ /**
2134
+ * Minimal CardView only including the needed details for list views
2135
+ */
2136
+ export interface CardListView {
2137
+ /**
2138
+ * The brand of the card, e.g. Visa, Mastercard, etc.
2139
+ */
2140
+ brand: string | undefined;
2141
+ }
2142
+
2143
+ export interface CardView {
2144
+ cardholderName: string | undefined;
2145
+ expMonth: string | undefined;
2146
+ expYear: string | undefined;
2147
+ code: string | undefined;
2148
+ brand: string | undefined;
2149
+ number: string | undefined;
2150
+ }
2151
+
2152
+ export interface Field {
2153
+ name: EncString | undefined;
2154
+ value: EncString | undefined;
2155
+ type: FieldType;
2156
+ linkedId: LinkedIdType | undefined;
2157
+ }
2158
+
2159
+ export interface FieldView {
2160
+ name: string | undefined;
2161
+ value: string | undefined;
2162
+ type: FieldType;
2163
+ linkedId: LinkedIdType | undefined;
2164
+ }
2165
+
2166
+ /**
2167
+ * Minimal field view for list/search operations.
2168
+ * Contains only the fields needed for search indexing.
2169
+ */
2170
+ export interface FieldListView {
2171
+ /**
2172
+ * Only populated if the field has a name.
2173
+ */
2174
+ name: string | undefined;
2175
+ /**
2176
+ * Only populated for [FieldType::Text] fields.
2177
+ */
2178
+ value: string | undefined;
2179
+ /**
2180
+ * The field type.
2181
+ */
2182
+ type: FieldType;
2183
+ }
2184
+
2185
+ export interface Fido2CredentialNewView {
2186
+ credentialId: string;
2187
+ keyType: string;
2188
+ keyAlgorithm: string;
2189
+ keyCurve: string;
2190
+ rpId: string;
2191
+ userHandle: string | undefined;
2192
+ userName: string | undefined;
2193
+ counter: string;
2194
+ rpName: string | undefined;
2195
+ userDisplayName: string | undefined;
2196
+ creationDate: DateTime<Utc>;
2197
+ }
2198
+
2199
+ export interface Fido2CredentialFullView {
2200
+ credentialId: string;
2201
+ keyType: string;
2202
+ keyAlgorithm: string;
2203
+ keyCurve: string;
2204
+ keyValue: string;
2205
+ rpId: string;
2206
+ userHandle: string | undefined;
2207
+ userName: string | undefined;
2208
+ counter: string;
2209
+ rpName: string | undefined;
2210
+ userDisplayName: string | undefined;
2211
+ discoverable: string;
2212
+ creationDate: DateTime<Utc>;
2213
+ }
2214
+
2215
+ export interface LoginUri {
2216
+ uri: EncString | undefined;
2217
+ match: UriMatchType | undefined;
2218
+ uriChecksum: EncString | undefined;
2219
+ }
2220
+
2221
+ export interface Fido2CredentialView {
2222
+ credentialId: string;
2223
+ keyType: string;
2224
+ keyAlgorithm: string;
2225
+ keyCurve: string;
2226
+ keyValue: EncString;
2227
+ rpId: string;
2228
+ userHandle: string | undefined;
2229
+ userName: string | undefined;
2230
+ counter: string;
2231
+ rpName: string | undefined;
2232
+ userDisplayName: string | undefined;
2233
+ discoverable: string;
2234
+ creationDate: DateTime<Utc>;
2235
+ }
2236
+
2237
+ export interface LoginListView {
2238
+ fido2Credentials: Fido2CredentialListView[] | undefined;
2239
+ hasFido2: boolean;
2240
+ username: string | undefined;
2241
+ /**
2242
+ * The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
2243
+ */
2244
+ totp: EncString | undefined;
2245
+ uris: LoginUriView[] | undefined;
2246
+ }
2247
+
2248
+ export interface LoginUriView {
2249
+ uri: string | undefined;
2250
+ match: UriMatchType | undefined;
2251
+ uriChecksum: string | undefined;
2252
+ }
2253
+
2254
+ export interface Fido2Credential {
2255
+ credentialId: EncString;
2256
+ keyType: EncString;
2257
+ keyAlgorithm: EncString;
2258
+ keyCurve: EncString;
2259
+ keyValue: EncString;
2260
+ rpId: EncString;
2261
+ userHandle: EncString | undefined;
2262
+ userName: EncString | undefined;
2263
+ counter: EncString;
2264
+ rpName: EncString | undefined;
2265
+ userDisplayName: EncString | undefined;
2266
+ discoverable: EncString;
2267
+ creationDate: DateTime<Utc>;
2268
+ }
2269
+
2270
+ export interface Login {
2271
+ username: EncString | undefined;
2272
+ password: EncString | undefined;
2273
+ passwordRevisionDate: DateTime<Utc> | undefined;
2274
+ uris: LoginUri[] | undefined;
2275
+ totp: EncString | undefined;
2276
+ autofillOnPageLoad: boolean | undefined;
2277
+ fido2Credentials: Fido2Credential[] | undefined;
2278
+ }
2279
+
2280
+ export interface Fido2CredentialListView {
2281
+ credentialId: string;
2282
+ rpId: string;
2283
+ userHandle: string | undefined;
2284
+ userName: string | undefined;
2285
+ userDisplayName: string | undefined;
2286
+ counter: string;
2287
+ }
2288
+
2289
+ export interface LoginView {
2290
+ username: string | undefined;
2291
+ password: string | undefined;
2292
+ passwordRevisionDate: DateTime<Utc> | undefined;
2293
+ uris: LoginUriView[] | undefined;
2294
+ totp: string | undefined;
2295
+ autofillOnPageLoad: boolean | undefined;
2296
+ fido2Credentials: Fido2Credential[] | undefined;
2297
+ }
2298
+
2299
+ export interface CipherView {
2300
+ id: CipherId | undefined;
2301
+ organizationId: OrganizationId | undefined;
2302
+ folderId: FolderId | undefined;
2303
+ collectionIds: CollectionId[];
2304
+ /**
2305
+ * Temporary, required to support re-encrypting existing items.
2306
+ */
2307
+ key: EncString | undefined;
2308
+ name: string;
2309
+ notes: string | undefined;
2310
+ type: CipherType;
2311
+ login: LoginView | undefined;
2312
+ identity: IdentityView | undefined;
2313
+ card: CardView | undefined;
2314
+ secureNote: SecureNoteView | undefined;
2315
+ sshKey: SshKeyView | undefined;
2316
+ favorite: boolean;
2317
+ reprompt: CipherRepromptType;
2318
+ organizationUseTotp: boolean;
2319
+ edit: boolean;
2320
+ permissions: CipherPermissions | undefined;
2321
+ viewPassword: boolean;
2322
+ localData: LocalDataView | undefined;
2323
+ attachments: AttachmentView[] | undefined;
2324
+ /**
2325
+ * Attachments that failed to decrypt. Only present when there are decryption failures.
2326
+ */
2327
+ attachmentDecryptionFailures?: AttachmentView[];
2328
+ fields: FieldView[] | undefined;
2329
+ passwordHistory: PasswordHistoryView[] | undefined;
2330
+ creationDate: DateTime<Utc>;
2331
+ deletedDate: DateTime<Utc> | undefined;
2332
+ revisionDate: DateTime<Utc>;
2333
+ archivedDate: DateTime<Utc> | undefined;
2334
+ }
2335
+
2336
+ /**
2337
+ * Represents the result of decrypting a list of ciphers.
2338
+ *
2339
+ * This struct contains two vectors: `successes` and `failures`.
2340
+ * `successes` contains the decrypted `CipherView` objects,
2341
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
2342
+ */
2343
+ export interface DecryptCipherResult {
2344
+ /**
2345
+ * The decrypted `CipherView` objects.
2346
+ */
2347
+ successes: CipherView[];
2348
+ /**
2349
+ * The original `Cipher` objects that failed to decrypt.
2350
+ */
2351
+ failures: Cipher[];
2352
+ }
2353
+
2354
+ /**
2355
+ * Represents the result of decrypting a list of ciphers.
2356
+ *
2357
+ * This struct contains two vectors: `successes` and `failures`.
2358
+ * `successes` contains the decrypted `CipherListView` objects,
2359
+ * while `failures` contains the original `Cipher` objects that failed to decrypt.
2360
+ */
2361
+ export interface DecryptCipherListResult {
2362
+ /**
2363
+ * The decrypted `CipherListView` objects.
2364
+ */
2365
+ successes: CipherListView[];
2366
+ /**
2367
+ * The original `Cipher` objects that failed to decrypt.
2368
+ */
2369
+ failures: Cipher[];
2370
+ }
2371
+
2372
+ export type CipherListViewType =
2373
+ | { login: LoginListView }
2374
+ | "secureNote"
2375
+ | { card: CardListView }
2376
+ | "identity"
2377
+ | "sshKey";
2378
+
2379
+ export interface Cipher {
2380
+ id: CipherId | undefined;
2381
+ organizationId: OrganizationId | undefined;
2382
+ folderId: FolderId | undefined;
2383
+ collectionIds: CollectionId[];
2384
+ /**
2385
+ * More recent ciphers uses individual encryption keys to encrypt the other fields of the
2386
+ * Cipher.
2387
+ */
2388
+ key: EncString | undefined;
2389
+ name: EncString;
2390
+ notes: EncString | undefined;
2391
+ type: CipherType;
2392
+ login: Login | undefined;
2393
+ identity: Identity | undefined;
2394
+ card: Card | undefined;
2395
+ secureNote: SecureNote | undefined;
2396
+ sshKey: SshKey | undefined;
2397
+ favorite: boolean;
2398
+ reprompt: CipherRepromptType;
2399
+ organizationUseTotp: boolean;
2400
+ edit: boolean;
2401
+ permissions: CipherPermissions | undefined;
2402
+ viewPassword: boolean;
2403
+ localData: LocalData | undefined;
2404
+ attachments: Attachment[] | undefined;
2405
+ fields: Field[] | undefined;
2406
+ passwordHistory: PasswordHistory[] | undefined;
2407
+ creationDate: DateTime<Utc>;
2408
+ deletedDate: DateTime<Utc> | undefined;
2409
+ revisionDate: DateTime<Utc>;
2410
+ archivedDate: DateTime<Utc> | undefined;
2411
+ data: string | undefined;
2412
+ }
2413
+
2414
+ export interface EncryptionContext {
2415
+ /**
2416
+ * The Id of the user that encrypted the cipher. It should always represent a UserId, even for
2417
+ * Organization-owned ciphers
2418
+ */
2419
+ encryptedFor: UserId;
2420
+ cipher: Cipher;
2421
+ }
2422
+
2423
+ export interface CipherError extends Error {
2424
+ name: "CipherError";
2425
+ variant:
2426
+ | "MissingField"
2427
+ | "Crypto"
2428
+ | "Decrypt"
2429
+ | "Encrypt"
2430
+ | "AttachmentsWithoutKeys"
2431
+ | "OrganizationAlreadySet"
2432
+ | "Repository"
2433
+ | "Chrono"
2434
+ | "SerdeJson"
2435
+ | "Api";
2436
+ }
2437
+
2438
+ export function isCipherError(error: any): error is CipherError;
2439
+
2440
+ /**
2441
+ * NewType wrapper for `CipherId`
2442
+ */
2443
+ export type CipherId = Tagged<Uuid, "CipherId">;
2444
+
2445
+ /**
2446
+ * Available fields on a cipher and can be copied from a the list view in the UI.
2447
+ */
2448
+ export type CopyableCipherFields =
2449
+ | "LoginUsername"
2450
+ | "LoginPassword"
2451
+ | "LoginTotp"
2452
+ | "CardNumber"
2453
+ | "CardSecurityCode"
2454
+ | "IdentityUsername"
2455
+ | "IdentityEmail"
2456
+ | "IdentityPhone"
2457
+ | "IdentityAddress"
2458
+ | "SshKey"
2459
+ | "SecureNotes";
2460
+
2461
+ export interface CipherListView {
2462
+ id: CipherId | undefined;
2463
+ organizationId: OrganizationId | undefined;
2464
+ folderId: FolderId | undefined;
2465
+ collectionIds: CollectionId[];
2466
+ /**
2467
+ * Temporary, required to support calculating TOTP from CipherListView.
2468
+ */
2469
+ key: EncString | undefined;
2470
+ name: string;
2471
+ subtitle: string;
2472
+ type: CipherListViewType;
2473
+ favorite: boolean;
2474
+ reprompt: CipherRepromptType;
2475
+ organizationUseTotp: boolean;
2476
+ edit: boolean;
2477
+ permissions: CipherPermissions | undefined;
2478
+ viewPassword: boolean;
2479
+ /**
2480
+ * The number of attachments
2481
+ */
2482
+ attachments: number;
2483
+ /**
2484
+ * Indicates if the cipher has old attachments that need to be re-uploaded
2485
+ */
2486
+ hasOldAttachments: boolean;
2487
+ creationDate: DateTime<Utc>;
2488
+ deletedDate: DateTime<Utc> | undefined;
2489
+ revisionDate: DateTime<Utc>;
2490
+ archivedDate: DateTime<Utc> | undefined;
2491
+ /**
2492
+ * Hints for the presentation layer for which fields can be copied.
2493
+ */
2494
+ copyableFields: CopyableCipherFields[];
2495
+ localData: LocalDataView | undefined;
2496
+ /**
2497
+ * Decrypted cipher notes for search indexing.
2498
+ */
2499
+ notes: string | undefined;
2500
+ /**
2501
+ * Decrypted cipher fields for search indexing.
2502
+ * Only includes name and value (for text fields only).
2503
+ */
2504
+ fields: FieldListView[] | undefined;
2505
+ /**
2506
+ * Decrypted attachment filenames for search indexing.
2507
+ */
2508
+ attachmentNames: string[] | undefined;
2509
+ }
2510
+
2511
+ export interface SshKey {
2512
+ /**
2513
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
2514
+ */
2515
+ privateKey: EncString;
2516
+ /**
2517
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
2518
+ */
2519
+ publicKey: EncString;
2520
+ /**
2521
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
2522
+ */
2523
+ fingerprint: EncString;
2524
+ }
2525
+
2526
+ export interface SshKeyView {
2527
+ /**
2528
+ * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
2529
+ */
2530
+ privateKey: string;
2531
+ /**
2532
+ * SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
2533
+ */
2534
+ publicKey: string;
2535
+ /**
2536
+ * SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
2537
+ */
2538
+ fingerprint: string;
2539
+ }
2540
+
2541
+ export interface IdentityView {
2542
+ title: string | undefined;
2543
+ firstName: string | undefined;
2544
+ middleName: string | undefined;
2545
+ lastName: string | undefined;
2546
+ address1: string | undefined;
2547
+ address2: string | undefined;
2548
+ address3: string | undefined;
2549
+ city: string | undefined;
2550
+ state: string | undefined;
2551
+ postalCode: string | undefined;
2552
+ country: string | undefined;
2553
+ company: string | undefined;
2554
+ email: string | undefined;
2555
+ phone: string | undefined;
2556
+ ssn: string | undefined;
2557
+ username: string | undefined;
2558
+ passportNumber: string | undefined;
2559
+ licenseNumber: string | undefined;
2560
+ }
2561
+
2562
+ export interface Identity {
2563
+ title: EncString | undefined;
2564
+ firstName: EncString | undefined;
2565
+ middleName: EncString | undefined;
2566
+ lastName: EncString | undefined;
2567
+ address1: EncString | undefined;
2568
+ address2: EncString | undefined;
2569
+ address3: EncString | undefined;
2570
+ city: EncString | undefined;
2571
+ state: EncString | undefined;
2572
+ postalCode: EncString | undefined;
2573
+ country: EncString | undefined;
2574
+ company: EncString | undefined;
2575
+ email: EncString | undefined;
2576
+ phone: EncString | undefined;
2577
+ ssn: EncString | undefined;
2578
+ username: EncString | undefined;
2579
+ passportNumber: EncString | undefined;
2580
+ licenseNumber: EncString | undefined;
2581
+ }
2582
+
2583
+ export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
2584
+
2585
+ /**
2586
+ * NewType wrapper for `FolderId`
2587
+ */
2588
+ export type FolderId = Tagged<Uuid, "FolderId">;
2589
+
2590
+ export interface Folder {
2591
+ id: FolderId | undefined;
2592
+ name: EncString;
2593
+ revisionDate: DateTime<Utc>;
2594
+ }
2595
+
2596
+ export interface FolderView {
2597
+ id: FolderId | undefined;
2598
+ name: string;
2599
+ revisionDate: DateTime<Utc>;
2600
+ }
2601
+
2602
+ export interface EditFolderError extends Error {
2603
+ name: "EditFolderError";
2604
+ variant:
2605
+ | "ItemNotFound"
2606
+ | "Crypto"
2607
+ | "Api"
2608
+ | "VaultParse"
2609
+ | "MissingField"
2610
+ | "Repository"
2611
+ | "Uuid";
2612
+ }
2613
+
2614
+ export function isEditFolderError(error: any): error is EditFolderError;
2615
+
2616
+ /**
2617
+ * Request to add or edit a folder.
2618
+ */
2619
+ export interface FolderAddEditRequest {
2620
+ /**
2621
+ * The new name of the folder.
2622
+ */
2623
+ name: string;
2624
+ }
2625
+
2626
+ export interface CreateFolderError extends Error {
2627
+ name: "CreateFolderError";
2628
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
2629
+ }
2630
+
2631
+ export function isCreateFolderError(error: any): error is CreateFolderError;
2632
+
2633
+ export interface GetFolderError extends Error {
2634
+ name: "GetFolderError";
2635
+ variant: "ItemNotFound" | "Crypto" | "Repository";
2636
+ }
2637
+
2638
+ export function isGetFolderError(error: any): error is GetFolderError;
2639
+
2640
+ export class AttachmentsClient {
2641
+ private constructor();
2642
+ free(): void;
2643
+ [Symbol.dispose](): void;
2644
+ decrypt_buffer(
2645
+ cipher: Cipher,
2646
+ attachment: AttachmentView,
2647
+ encrypted_buffer: Uint8Array,
2648
+ ): Uint8Array;
2649
+ }
2650
+ /**
2651
+ * Subclient containing auth functionality.
2652
+ */
2653
+ export class AuthClient {
2654
+ private constructor();
2655
+ free(): void;
2656
+ [Symbol.dispose](): void;
2657
+ /**
2658
+ * Client for send access functionality
2659
+ */
2660
+ send_access(): SendAccessClient;
2661
+ /**
2662
+ * Client for initializing user account cryptography and unlock methods after JIT provisioning
2663
+ */
2664
+ registration(): RegistrationClient;
2665
+ /**
2666
+ * Client for login functionality
2667
+ */
2668
+ login(client_settings: ClientSettings): LoginClient;
2669
+ }
2670
+ /**
2671
+ * Client for performing admin operations on ciphers. Unlike the regular CiphersClient,
2672
+ * this client uses the admin server API endpoints, and does not modify local state.
2673
+ */
2674
+ export class CipherAdminClient {
2675
+ private constructor();
2676
+ free(): void;
2677
+ [Symbol.dispose](): void;
2678
+ list_org_ciphers(
2679
+ org_id: OrganizationId,
2680
+ include_member_items: boolean,
2681
+ ): Promise<DecryptCipherListResult>;
2682
+ /**
2683
+ * Adds the cipher matched by [CipherId] to any number of collections on the server.
2684
+ */
2685
+ update_collection(cipher_id: CipherId, collection_ids: CollectionId[]): Promise<CipherView>;
2686
+ /**
2687
+ * Edit an existing [Cipher] and save it to the server.
2688
+ */
2689
+ edit(request: CipherEditRequest, original_cipher_view: CipherView): Promise<CipherView>;
2690
+ /**
2691
+ * Creates a new [Cipher] for an organization, using the admin server endpoints.
2692
+ * Creates the Cipher on the server only, does not store it to local state.
2693
+ */
2694
+ create(request: CipherCreateRequest): Promise<CipherView>;
2695
+ /**
2696
+ * Deletes all Cipher objects with a matching CipherId from the server, using the admin
2697
+ * endpoint. Affects server data only, does not modify local state.
2698
+ */
2699
+ delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
2700
+ /**
2701
+ * Soft-deletes the Cipher with the matching CipherId from the server, using the admin
2702
+ * endpoint. Affects server data only, does not modify local state.
2703
+ */
2704
+ soft_delete(cipher_id: CipherId): Promise<void>;
2705
+ /**
2706
+ * Soft-deletes all Cipher objects for the given CipherIds from the server, using the admin
2707
+ * endpoint. Affects server data only, does not modify local state.
2708
+ */
2709
+ soft_delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
2710
+ /**
2711
+ * Deletes the Cipher with the matching CipherId from the server, using the admin endpoint.
2712
+ * Affects server data only, does not modify local state.
2713
+ */
2714
+ delete(cipher_id: CipherId): Promise<void>;
2715
+ /**
2716
+ * Restores multiple soft-deleted ciphers on the server.
2717
+ */
2718
+ restore_many(cipher_ids: CipherId[], org_id: OrganizationId): Promise<DecryptCipherListResult>;
2719
+ /**
2720
+ * Restores a soft-deleted cipher on the server, using the admin endpoint.
2721
+ */
2722
+ restore(cipher_id: CipherId): Promise<CipherView>;
2723
+ }
2724
+ /**
2725
+ * Client for evaluating credential risk for login ciphers.
2726
+ */
2727
+ export class CipherRiskClient {
2728
+ private constructor();
2729
+ free(): void;
2730
+ [Symbol.dispose](): void;
2731
+ /**
2732
+ * Evaluate security risks for multiple login ciphers concurrently.
2733
+ *
2734
+ * For each cipher:
2735
+ * 1. Calculates password strength (0-4) using zxcvbn with cipher-specific context
2736
+ * 2. Optionally checks if the password has been exposed via Have I Been Pwned API
2737
+ * 3. Counts how many times the password is reused in the provided `password_map`
2738
+ *
2739
+ * Returns a vector of `CipherRisk` results, one for each input cipher.
2740
+ *
2741
+ * ## HIBP Check Results (`exposed_result` field)
2742
+ *
2743
+ * The `exposed_result` field uses the `ExposedPasswordResult` enum with three possible states:
2744
+ * - `NotChecked`: Password exposure check was not performed because:
2745
+ * - `check_exposed` option was `false`, or
2746
+ * - Password was empty
2747
+ * - `Found(n)`: Successfully checked via HIBP API, password appears in `n` data breaches
2748
+ * - `Error(msg)`: HIBP API request failed with error message `msg`
2749
+ *
2750
+ * # Errors
2751
+ *
2752
+ * This method only returns `Err` for internal logic failures. HIBP API errors are
2753
+ * captured per-cipher in the `exposed_result` field as `ExposedPasswordResult::Error(msg)`.
2754
+ */
2755
+ compute_risk(
2756
+ login_details: CipherLoginDetails[],
2757
+ options: CipherRiskOptions,
2758
+ ): Promise<CipherRiskResult[]>;
2759
+ /**
2760
+ * Build password reuse map for a list of login ciphers.
2761
+ *
2762
+ * Returns a map where keys are passwords and values are the number of times
2763
+ * each password appears in the provided list. This map can be passed to `compute_risk()`
2764
+ * to enable password reuse detection.
2765
+ */
2766
+ password_reuse_map(login_details: CipherLoginDetails[]): PasswordReuseMap;
2767
+ }
2768
+ export class CiphersClient {
2769
+ private constructor();
2770
+ free(): void;
2771
+ [Symbol.dispose](): void;
2772
+ /**
2773
+ * Moves a cipher into an organization, adds it to collections, and calls the share_cipher API.
2774
+ */
2775
+ share_cipher(
2776
+ cipher_view: CipherView,
2777
+ organization_id: OrganizationId,
2778
+ collection_ids: CollectionId[],
2779
+ original_cipher?: Cipher | null,
2780
+ ): Promise<Cipher>;
2781
+ /**
2782
+ * Moves a group of ciphers into an organization, adds them to collections, and calls the
2783
+ * share_ciphers API.
2784
+ */
2785
+ share_ciphers_bulk(
2786
+ cipher_views: CipherView[],
2787
+ organization_id: OrganizationId,
2788
+ collection_ids: CollectionId[],
2789
+ ): Promise<Cipher[]>;
2790
+ decrypt_list(ciphers: Cipher[]): CipherListView[];
2791
+ /**
2792
+ * Encrypt a list of cipher views.
2793
+ *
2794
+ * This method attempts to encrypt all ciphers in the list. If any cipher
2795
+ * fails to encrypt, the entire operation fails and an error is returned.
2796
+ */
2797
+ encrypt_list(cipher_views: CipherView[]): EncryptionContext[];
2798
+ move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
2799
+ /**
2800
+ * Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
2801
+ * Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
2802
+ * TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
2803
+ * encrypting the rest of the CipherView.
2804
+ * TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
2805
+ */
2806
+ set_fido2_credentials(
2807
+ cipher_view: CipherView,
2808
+ fido2_credentials: Fido2CredentialFullView[],
2809
+ ): CipherView;
2810
+ decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
2811
+ decrypt_fido2_private_key(cipher_view: CipherView): string;
2812
+ /**
2813
+ * Decrypt cipher list with failures
2814
+ * Returns both successfully decrypted ciphers and any that failed to decrypt
2815
+ */
2816
+ decrypt_list_with_failures(ciphers: Cipher[]): DecryptCipherListResult;
2817
+ /**
2818
+ * Encrypt a cipher with the provided key. This should only be used when rotating encryption
2819
+ * keys in the Web client.
2820
+ *
2821
+ * Until key rotation is fully implemented in the SDK, this method must be provided the new
2822
+ * symmetric key in base64 format. See PM-23084
2823
+ *
2824
+ * If the cipher has a CipherKey, it will be re-encrypted with the new key.
2825
+ * If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
2826
+ * generated using the new key. Otherwise, the cipher's data will be encrypted with the new
2827
+ * key directly.
2828
+ */
2829
+ encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): EncryptionContext;
2830
+ /**
2831
+ * Decrypt full cipher list
2832
+ * Returns both successfully fully decrypted ciphers and any that failed to decrypt
2833
+ */
2834
+ decrypt_list_full_with_failures(ciphers: Cipher[]): DecryptCipherResult;
2835
+ /**
2836
+ * Returns a new client for performing admin operations.
2837
+ * Uses the admin server API endpoints and does not modify local state.
2838
+ */
2839
+ admin(): CipherAdminClient;
2840
+ decrypt(cipher: Cipher): CipherView;
2841
+ encrypt(cipher_view: CipherView): EncryptionContext;
2842
+ /**
2843
+ * Get [Cipher] by ID from state and decrypt it to a [CipherView].
2844
+ */
2845
+ get(cipher_id: string): Promise<CipherView>;
2846
+ /**
2847
+ * Get all ciphers from state and decrypt them, returning both successes and failures.
2848
+ * This method will not fail when some ciphers fail to decrypt, allowing for graceful
2849
+ * handling of corrupted or problematic cipher data.
2850
+ */
2851
+ list(): Promise<DecryptCipherListResult>;
2852
+ /**
2853
+ * Adds the cipher matched by [CipherId] to any number of collections on the server.
2854
+ */
2855
+ update_collection(
2856
+ cipher_id: CipherId,
2857
+ collection_ids: CollectionId[],
2858
+ is_admin: boolean,
2859
+ ): Promise<CipherView>;
2860
+ /**
2861
+ * Edit an existing [Cipher] and save it to the server.
2862
+ */
2863
+ edit(request: CipherEditRequest): Promise<CipherView>;
2864
+ /**
2865
+ * Creates a new [Cipher] and saves it to the server.
2866
+ */
2867
+ create(request: CipherCreateRequest): Promise<CipherView>;
2868
+ /**
2869
+ * Deletes all [Cipher] objects with a matching [CipherId] from the server.
2870
+ */
2871
+ delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
2872
+ /**
2873
+ * Soft-deletes the [Cipher] with the matching [CipherId] from the server.
2874
+ */
2875
+ soft_delete(cipher_id: CipherId): Promise<void>;
2876
+ /**
2877
+ * Soft-deletes all [Cipher] objects for the given [CipherId]s from the server.
2878
+ */
2879
+ soft_delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
2880
+ /**
2881
+ * Deletes the [Cipher] with the matching [CipherId] from the server.
2882
+ */
2883
+ delete(cipher_id: CipherId): Promise<void>;
2884
+ /**
2885
+ * Restores multiple soft-deleted ciphers on the server.
2886
+ */
2887
+ restore_many(cipher_ids: CipherId[]): Promise<DecryptCipherListResult>;
2888
+ /**
2889
+ * Restores a soft-deleted cipher on the server.
2890
+ */
2891
+ restore(cipher_id: CipherId): Promise<CipherView>;
2892
+ }
2893
+ export class CollectionViewNodeItem {
2894
+ private constructor();
2895
+ free(): void;
2896
+ [Symbol.dispose](): void;
2897
+ get_parent(): CollectionView | undefined;
2898
+ get_children(): CollectionView[];
2899
+ get_ancestors(): AncestorMap;
2900
+ get_item(): CollectionView;
2901
+ }
2902
+ export class CollectionViewTree {
2903
+ private constructor();
2904
+ free(): void;
2905
+ [Symbol.dispose](): void;
2906
+ get_flat_items(): CollectionViewNodeItem[];
2907
+ get_root_items(): CollectionViewNodeItem[];
2908
+ get_item_for_view(collection_view: CollectionView): CollectionViewNodeItem | undefined;
2909
+ }
2910
+ export class CollectionsClient {
2911
+ private constructor();
2912
+ free(): void;
2913
+ [Symbol.dispose](): void;
2914
+ decrypt_list(collections: Collection[]): CollectionView[];
2915
+ /**
2916
+ *
2917
+ * Returns the vector of CollectionView objects in a tree structure based on its implemented
2918
+ * path().
2919
+ */
2920
+ get_collection_tree(collections: CollectionView[]): CollectionViewTree;
2921
+ decrypt(collection: Collection): CollectionView;
2922
+ }
2923
+ /**
2924
+ * A client for the crypto operations.
2925
+ */
2926
+ export class CryptoClient {
2927
+ private constructor();
2928
+ free(): void;
2929
+ [Symbol.dispose](): void;
2930
+ /**
2931
+ * Protects the current user key with the provided PIN. The result can be stored and later
2932
+ * used to initialize another client instance by using the PIN and the PIN key with
2933
+ * `initialize_user_crypto`.
2934
+ */
2935
+ enroll_pin(pin: string): EnrollPinResponse;
2936
+ /**
2937
+ * Generates a new key pair and encrypts the private key with the provided user key.
2938
+ * Crypto initialization not required.
2939
+ */
2940
+ make_key_pair(user_key: B64): MakeKeyPairResponse;
2941
+ /**
2942
+ * Create the data necessary to update the user's kdf settings. The user's encryption key is
2943
+ * re-encrypted for the password under the new kdf settings. This returns the re-encrypted
2944
+ * user key and the new password hash but does not update sdk state.
2945
+ */
2946
+ make_update_kdf(password: string, kdf: Kdf): UpdateKdfResponse;
2947
+ /**
2948
+ * Initialization method for the organization crypto. Needs to be called after
2949
+ * `initialize_user_crypto` but before any other crypto operations.
2950
+ */
2951
+ initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
2952
+ /**
2953
+ * Initialization method for the user crypto. Needs to be called before any other crypto
2954
+ * operations.
2955
+ */
2956
+ initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
2957
+ /**
2958
+ * Verifies a user's asymmetric keys by decrypting the private key with the provided user
2959
+ * key. Returns if the private key is decryptable and if it is a valid matching key.
2960
+ * Crypto initialization not required.
2961
+ */
2962
+ verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
2963
+ /**
2964
+ * Creates a rotated set of account keys for the current state
2965
+ */
2966
+ get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
2967
+ /**
2968
+ * Makes a new signing key pair and signs the public key for the user
2969
+ */
2970
+ make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
2971
+ /**
2972
+ * Protects the current user key with the provided PIN. The result can be stored and later
2973
+ * used to initialize another client instance by using the PIN and the PIN key with
2974
+ * `initialize_user_crypto`. The provided pin is encrypted with the user key.
2975
+ */
2976
+ enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
2977
+ /**
2978
+ * Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
2979
+ * This is a stop-gap solution, until initialization of the SDK is used.
2980
+ */
2981
+ unseal_password_protected_key_envelope(pin: string, envelope: string): Uint8Array;
2982
+ }
2983
+ export class ExporterClient {
2984
+ private constructor();
2985
+ free(): void;
2986
+ [Symbol.dispose](): void;
2987
+ /**
2988
+ * Credential Exchange Format (CXF)
2989
+ *
2990
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
2991
+ *
2992
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
2993
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
2994
+ */
2995
+ export_cxf(account: Account, ciphers: Cipher[]): string;
2996
+ /**
2997
+ * Credential Exchange Format (CXF)
2998
+ *
2999
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
3000
+ *
3001
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
3002
+ * Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
3003
+ */
3004
+ import_cxf(payload: string): Cipher[];
3005
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
3006
+ export_organization_vault(
3007
+ collections: Collection[],
3008
+ ciphers: Cipher[],
3009
+ format: ExportFormat,
3010
+ ): string;
3011
+ }
3012
+ /**
3013
+ * Wrapper for folder specific functionality.
3014
+ */
3015
+ export class FoldersClient {
3016
+ private constructor();
3017
+ free(): void;
3018
+ [Symbol.dispose](): void;
3019
+ /**
3020
+ * Decrypt a list of [Folder]s to a list of [FolderView]s.
3021
+ */
3022
+ decrypt_list(folders: Folder[]): FolderView[];
3023
+ /**
3024
+ * Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
3025
+ */
3026
+ get(folder_id: FolderId): Promise<FolderView>;
3027
+ /**
3028
+ * Edit the [Folder] and save it to the server.
3029
+ */
3030
+ edit(folder_id: FolderId, request: FolderAddEditRequest): Promise<FolderView>;
3031
+ /**
3032
+ * Get all folders from state and decrypt them to a list of [FolderView].
3033
+ */
3034
+ list(): Promise<FolderView[]>;
3035
+ /**
3036
+ * Create a new [Folder] and save it to the server.
3037
+ */
3038
+ create(request: FolderAddEditRequest): Promise<FolderView>;
3039
+ /**
3040
+ * Encrypt a [Folder] to [FolderView].
3041
+ */
3042
+ decrypt(folder: Folder): FolderView;
3043
+ /**
3044
+ * Encrypt a [FolderView] to a [Folder].
3045
+ */
3046
+ encrypt(folder_view: FolderView): Folder;
3047
+ }
3048
+ export class GeneratorClient {
3049
+ private constructor();
3050
+ free(): void;
3051
+ [Symbol.dispose](): void;
3052
+ /**
3053
+ * Generates a random passphrase.
3054
+ * A passphrase is a combination of random words separated by a character.
3055
+ * An example of passphrase is `correct horse battery staple`.
3056
+ *
3057
+ * The number of words and their case, the word separator, and the inclusion of
3058
+ * a number in the passphrase can be customized using the `input` parameter.
3059
+ *
3060
+ * # Examples
3061
+ *
3062
+ * ```
3063
+ * use bitwarden_core::Client;
3064
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
3065
+ *
3066
+ * async fn test() -> Result<(), PassphraseError> {
3067
+ * let input = PassphraseGeneratorRequest {
3068
+ * num_words: 4,
3069
+ * ..Default::default()
3070
+ * };
3071
+ * let passphrase = Client::new(None).generator().passphrase(input).unwrap();
3072
+ * println!("{}", passphrase);
3073
+ * Ok(())
3074
+ * }
3075
+ * ```
3076
+ */
3077
+ passphrase(input: PassphraseGeneratorRequest): string;
3078
+ /**
3079
+ * Generates a random password.
3080
+ *
3081
+ * The character sets and password length can be customized using the `input` parameter.
3082
+ *
3083
+ * # Examples
3084
+ *
3085
+ * ```
3086
+ * use bitwarden_core::Client;
3087
+ * use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
3088
+ *
3089
+ * async fn test() -> Result<(), PassphraseError> {
3090
+ * let input = PasswordGeneratorRequest {
3091
+ * lowercase: true,
3092
+ * uppercase: true,
3093
+ * numbers: true,
3094
+ * length: 20,
3095
+ * ..Default::default()
3096
+ * };
3097
+ * let password = Client::new(None).generator().password(input).unwrap();
3098
+ * println!("{}", password);
3099
+ * Ok(())
3100
+ * }
3101
+ * ```
3102
+ */
3103
+ password(input: PasswordGeneratorRequest): string;
3104
+ }
3105
+ export class IncomingMessage {
3106
+ free(): void;
3107
+ [Symbol.dispose](): void;
3108
+ /**
3109
+ * Try to parse the payload as JSON.
3110
+ * @returns The parsed JSON value, or undefined if the payload is not valid JSON.
3111
+ */
3112
+ parse_payload_as_json(): any;
3113
+ constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
3114
+ payload: Uint8Array;
3115
+ destination: Endpoint;
3116
+ source: Endpoint;
3117
+ get topic(): string | undefined;
3118
+ set topic(value: string | null | undefined);
3119
+ }
3120
+ /**
3121
+ * JavaScript wrapper around the IPC client. For more information, see the
3122
+ * [IpcClient] documentation.
3123
+ */
3124
+ export class IpcClient {
3125
+ private constructor();
3126
+ free(): void;
3127
+ [Symbol.dispose](): void;
3128
+ isRunning(): Promise<boolean>;
3129
+ /**
3130
+ * Create a new `IpcClient` instance with an in-memory session repository for saving
3131
+ * sessions within the SDK.
3132
+ */
3133
+ static newWithSdkInMemorySessions(communication_provider: IpcCommunicationBackend): IpcClient;
3134
+ /**
3135
+ * Create a new `IpcClient` instance with a client-managed session repository for saving
3136
+ * sessions using State Provider.
3137
+ */
3138
+ static newWithClientManagedSessions(
3139
+ communication_provider: IpcCommunicationBackend,
3140
+ session_repository: IpcSessionRepository,
3141
+ ): IpcClient;
3142
+ send(message: OutgoingMessage): Promise<void>;
3143
+ start(): Promise<void>;
3144
+ subscribe(): Promise<IpcClientSubscription>;
3145
+ }
3146
+ /**
3147
+ * JavaScript wrapper around the IPC client subscription. For more information, see the
3148
+ * [IpcClientSubscription](crate::IpcClientSubscription) documentation.
3149
+ */
3150
+ export class IpcClientSubscription {
3151
+ private constructor();
3152
+ free(): void;
3153
+ [Symbol.dispose](): void;
3154
+ receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
3155
+ }
3156
+ /**
3157
+ * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
3158
+ */
3159
+ export class IpcCommunicationBackend {
3160
+ free(): void;
3161
+ [Symbol.dispose](): void;
3162
+ /**
3163
+ * Creates a new instance of the JavaScript communication backend.
3164
+ */
3165
+ constructor(sender: IpcCommunicationBackendSender);
3166
+ /**
3167
+ * Used by JavaScript to provide an incoming message to the IPC framework.
3168
+ */
3169
+ receive(message: IncomingMessage): void;
3170
+ }
3171
+ /**
3172
+ * Client for authenticating Bitwarden users.
3173
+ *
3174
+ * Handles unauthenticated operations to obtain access tokens from the Identity API.
3175
+ * After successful authentication, use the returned tokens to create an authenticated core client.
3176
+ *
3177
+ * # Lifecycle
3178
+ *
3179
+ * 1. Create `LoginClient` via `AuthClient`
3180
+ * 2. Call login method
3181
+ * 3. Use returned tokens with authenticated core client
3182
+ *
3183
+ * # Password Login Example
3184
+ *
3185
+ * ```rust,no_run
3186
+ * # use bitwarden_auth::{AuthClient, login::login_via_password::PasswordLoginRequest};
3187
+ * # use bitwarden_auth::login::models::{LoginRequest, LoginDeviceRequest, LoginResponse};
3188
+ * # use bitwarden_core::{Client, ClientSettings, DeviceType};
3189
+ * # async fn example(email: String, password: String) -> Result<(), Box<dyn std::error::Error>> {
3190
+ * // Create auth client
3191
+ * let client = Client::new(None);
3192
+ * let auth_client = AuthClient::new(client);
3193
+ *
3194
+ * // Configure client settings and create login client
3195
+ * let settings = ClientSettings {
3196
+ * identity_url: "https://identity.bitwarden.com".to_string(),
3197
+ * api_url: "https://api.bitwarden.com".to_string(),
3198
+ * user_agent: "MyApp/1.0".to_string(),
3199
+ * device_type: DeviceType::SDK,
3200
+ * device_identifier: None,
3201
+ * bitwarden_client_version: None,
3202
+ * bitwarden_package_type: None,
3203
+ * };
3204
+ * let login_client = auth_client.login(settings);
3205
+ *
3206
+ * // Get user's KDF config
3207
+ * let prelogin = login_client.get_password_prelogin(email.clone()).await?;
3208
+ *
3209
+ * // Login with credentials
3210
+ * let response = login_client.login_via_password(PasswordLoginRequest {
3211
+ * login_request: LoginRequest {
3212
+ * client_id: "connector".to_string(),
3213
+ * device: LoginDeviceRequest {
3214
+ * device_type: DeviceType::SDK,
3215
+ * device_identifier: "device-id".to_string(),
3216
+ * device_name: "My Device".to_string(),
3217
+ * device_push_token: None,
3218
+ * },
3219
+ * },
3220
+ * email,
3221
+ * password,
3222
+ * prelogin_response: prelogin,
3223
+ * }).await?;
3224
+ *
3225
+ * // Use tokens from response for authenticated requests
3226
+ * match response {
3227
+ * LoginResponse::Authenticated(success) => {
3228
+ * let access_token = success.access_token;
3229
+ * // Use access_token for authenticated requests
3230
+ * }
3231
+ * }
3232
+ * # Ok(())
3233
+ * # }
3234
+ * ```
3235
+ */
3236
+ export class LoginClient {
3237
+ private constructor();
3238
+ free(): void;
3239
+ [Symbol.dispose](): void;
3240
+ /**
3241
+ * Retrieves the data required before authenticating with a password.
3242
+ * This includes the user's KDF configuration needed to properly derive the master key.
3243
+ */
3244
+ get_password_prelogin(email: string): Promise<PasswordPreloginResponse>;
3245
+ /**
3246
+ * Authenticates a user via email and master password.
3247
+ *
3248
+ * Derives the master password hash using KDF settings from prelogin, then sends
3249
+ * the authentication request to obtain access tokens and vault keys.
3250
+ */
3251
+ login_via_password(request: PasswordLoginRequest): Promise<LoginResponse>;
3252
+ }
3253
+ export class OutgoingMessage {
3254
+ free(): void;
3255
+ [Symbol.dispose](): void;
3256
+ /**
3257
+ * Create a new message and encode the payload as JSON.
3258
+ */
3259
+ static new_json_payload(
3260
+ payload: any,
3261
+ destination: Endpoint,
3262
+ topic?: string | null,
3263
+ ): OutgoingMessage;
3264
+ constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
3265
+ payload: Uint8Array;
3266
+ destination: Endpoint;
3267
+ get topic(): string | undefined;
3268
+ set topic(value: string | null | undefined);
3269
+ }
3270
+ /**
3271
+ * The main entry point for the Bitwarden SDK in WebAssembly environments
3272
+ */
3273
+ export class PasswordManagerClient {
3274
+ free(): void;
3275
+ [Symbol.dispose](): void;
3276
+ /**
3277
+ * User crypto management related operations.
3278
+ */
3279
+ user_crypto_management(): UserCryptoManagementClient;
3280
+ /**
3281
+ * Initialize a new instance of the SDK client
3282
+ */
3283
+ constructor(token_provider: any, settings?: ClientSettings | null);
3284
+ /**
3285
+ * Auth related operations.
3286
+ */
3287
+ auth(): AuthClient;
3288
+ /**
3289
+ * Test method, echoes back the input
3290
+ */
3291
+ echo(msg: string): string;
3292
+ /**
3293
+ * Test method, always throws an error
3294
+ */
3295
+ throw(msg: string): void;
3296
+ /**
3297
+ * Vault item related operations.
3298
+ */
3299
+ vault(): VaultClient;
3300
+ /**
3301
+ * Crypto related operations.
3302
+ */
3303
+ crypto(): CryptoClient;
3304
+ /**
3305
+ * Returns the current SDK version
3306
+ */
3307
+ version(): string;
3308
+ /**
3309
+ * Test method, calls http endpoint
3310
+ */
3311
+ http_get(url: string): Promise<string>;
3312
+ /**
3313
+ * Constructs a specific client for platform-specific functionality
3314
+ */
3315
+ platform(): PlatformClient;
3316
+ /**
3317
+ * Exporter related operations.
3318
+ */
3319
+ exporters(): ExporterClient;
3320
+ /**
3321
+ * Constructs a specific client for generating passwords and passphrases
3322
+ */
3323
+ generator(): GeneratorClient;
3324
+ }
3325
+ export class PlatformClient {
3326
+ private constructor();
3327
+ free(): void;
3328
+ [Symbol.dispose](): void;
3329
+ /**
3330
+ * Load feature flags into the client
3331
+ */
3332
+ load_flags(flags: FeatureFlags): void;
3333
+ state(): StateClient;
3334
+ }
3335
+ /**
3336
+ * This module represents a stopgap solution to provide access to primitive crypto functions for JS
3337
+ * clients. It is not intended to be used outside of the JS clients and this pattern should not be
3338
+ * proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
3339
+ * responsible for state and keys.
3340
+ */
3341
+ export class PureCrypto {
3342
+ private constructor();
3343
+ free(): void;
3344
+ [Symbol.dispose](): void;
3345
+ /**
3346
+ * Generates a cryptographically secure random number between the given min and max
3347
+ * (inclusive).
3348
+ */
3349
+ static random_number(min: number, max: number): number;
3350
+ /**
3351
+ * Decrypts data using RSAES-OAEP with SHA-1
3352
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
3353
+ */
3354
+ static rsa_decrypt_data(encrypted_data: Uint8Array, private_key: Uint8Array): Uint8Array;
3355
+ /**
3356
+ * Encrypts data using RSAES-OAEP with SHA-1
3357
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
3358
+ */
3359
+ static rsa_encrypt_data(plain_data: Uint8Array, public_key: Uint8Array): Uint8Array;
3360
+ /**
3361
+ * DEPRECATED: Use `symmetric_decrypt_string` instead.
3362
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
3363
+ */
3364
+ static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
3365
+ /**
3366
+ * Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
3367
+ * as an EncString.
3368
+ */
3369
+ static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
3370
+ /**
3371
+ * Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
3372
+ */
3373
+ static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
3374
+ /**
3375
+ * Generates a new RSA key pair and returns the private key
3376
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
3377
+ */
3378
+ static rsa_generate_keypair(): Uint8Array;
3379
+ /**
3380
+ * Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
3381
+ * unwrapped key as a serialized byte array.
3382
+ */
3383
+ static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
3384
+ /**
3385
+ * Given a decrypted private RSA key PKCS8 DER this
3386
+ * returns the corresponding public RSA key in DER format.
3387
+ * HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
3388
+ */
3389
+ static rsa_extract_public_key(private_key: Uint8Array): Uint8Array;
3390
+ /**
3391
+ * Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
3392
+ * key,
3393
+ */
3394
+ static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
3395
+ /**
3396
+ * Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
3397
+ * key. Note: Usually, a public key is - by definition - public, so this should not be
3398
+ * used. The specific use-case for this function is to enable rotateable key sets, where
3399
+ * the "public key" is not public, with the intent of preventing the server from being able
3400
+ * to overwrite the user key unlocked by the rotateable keyset.
3401
+ */
3402
+ static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
3403
+ static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
3404
+ /**
3405
+ * DEPRECATED: Only used by send keys
3406
+ */
3407
+ static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
3408
+ /**
3409
+ * Decapsulates (decrypts) a symmetric key using an decapsulation-key/private-key in PKCS8
3410
+ * DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
3411
+ * recipient.
3412
+ */
3413
+ static decapsulate_key_unsigned(
3414
+ encapsulated_key: string,
3415
+ decapsulation_key: Uint8Array,
3416
+ ): Uint8Array;
3417
+ /**
3418
+ * Encapsulates (encrypts) a symmetric key using an public-key/encapsulation-key
3419
+ * in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
3420
+ * the sender's authenticity cannot be verified by the recipient.
3421
+ */
3422
+ static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
3423
+ static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
3424
+ static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
3425
+ /**
3426
+ * Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
3427
+ * wrapping key.
3428
+ */
3429
+ static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
3430
+ /**
3431
+ * Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
3432
+ * wrapping key.
3433
+ */
3434
+ static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
3435
+ static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
3436
+ static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
3437
+ static make_user_key_aes256_cbc_hmac(): Uint8Array;
3438
+ /**
3439
+ * Given a wrapped signing key and the symmetric key it is wrapped with, this returns
3440
+ * the corresponding verifying key.
3441
+ */
3442
+ static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
3443
+ /**
3444
+ * DEPRECATED: Use `symmetric_decrypt_filedata` instead.
3445
+ * Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
3446
+ */
3447
+ static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
3448
+ /**
3449
+ * Returns the algorithm used for the given verifying key.
3450
+ */
3451
+ static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
3452
+ static decrypt_user_key_with_master_key(
3453
+ encrypted_user_key: string,
3454
+ master_key: Uint8Array,
3455
+ ): Uint8Array;
3456
+ static make_user_key_xchacha20_poly1305(): Uint8Array;
3457
+ /**
3458
+ * For a given signing identity (verifying key), this function verifies that the signing
3459
+ * identity claimed ownership of the public key. This is a one-sided claim and merely shows
3460
+ * that the signing identity has the intent to receive messages encrypted to the public
3461
+ * key.
3462
+ */
3463
+ static verify_and_unwrap_signed_public_key(
3464
+ signed_public_key: Uint8Array,
3465
+ verifying_key: Uint8Array,
3466
+ ): Uint8Array;
3467
+ static decrypt_user_key_with_master_password(
3468
+ encrypted_user_key: string,
3469
+ master_password: string,
3470
+ email: string,
3471
+ kdf: Kdf,
3472
+ ): Uint8Array;
3473
+ static encrypt_user_key_with_master_password(
3474
+ user_key: Uint8Array,
3475
+ master_password: string,
3476
+ email: string,
3477
+ kdf: Kdf,
3478
+ ): string;
3479
+ }
3480
+ /**
3481
+ * Client for initializing a user account.
3482
+ */
3483
+ export class RegistrationClient {
3484
+ private constructor();
3485
+ free(): void;
3486
+ [Symbol.dispose](): void;
3487
+ /**
3488
+ * Initializes a new cryptographic state for a user and posts it to the server; enrolls in
3489
+ * admin password reset and finally enrolls the user to TDE unlock.
3490
+ */
3491
+ post_keys_for_tde_registration(request: TdeRegistrationRequest): Promise<TdeRegistrationResponse>;
3492
+ /**
3493
+ * Initializes a new cryptographic state for a user and posts it to the server;
3494
+ * enrolls the user to master password unlock.
3495
+ */
3496
+ post_keys_for_jit_password_registration(
3497
+ request: JitMasterPasswordRegistrationRequest,
3498
+ ): Promise<JitMasterPasswordRegistrationResponse>;
3499
+ /**
3500
+ * Initializes a new cryptographic state for a user and posts it to the server; enrolls the
3501
+ * user to key connector unlock.
3502
+ */
3503
+ post_keys_for_key_connector_registration(
3504
+ key_connector_url: string,
3505
+ sso_org_identifier: string,
3506
+ user_id: UserId,
3507
+ ): Promise<KeyConnectorRegistrationResult>;
3508
+ }
3509
+ /**
3510
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
3511
+ */
3512
+ export class SendAccessClient {
3513
+ private constructor();
3514
+ free(): void;
3515
+ [Symbol.dispose](): void;
3516
+ /**
3517
+ * Requests a new send access token.
3518
+ */
3519
+ request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
3520
+ }
3521
+ /**
3522
+ * JavaScript wrapper for ServerCommunicationConfigClient
3523
+ *
3524
+ * This provides TypeScript access to the server communication configuration client,
3525
+ * allowing clients to check bootstrap requirements and retrieve cookies for HTTP requests.
3526
+ */
3527
+ export class ServerCommunicationConfigClient {
3528
+ free(): void;
3529
+ [Symbol.dispose](): void;
3530
+ /**
3531
+ * Retrieves the server communication configuration for a hostname
3532
+ *
3533
+ * If no configuration exists, returns a default Direct bootstrap configuration.
3534
+ *
3535
+ * # Arguments
3536
+ *
3537
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
3538
+ *
3539
+ * # Errors
3540
+ *
3541
+ * Returns an error if the repository fails to retrieve the configuration.
3542
+ */
3543
+ getConfig(hostname: string): Promise<ServerCommunicationConfig>;
3544
+ /**
3545
+ * Acquires a cookie from the platform and saves it to the repository
3546
+ *
3547
+ * This method calls the platform API to trigger cookie acquisition (e.g., browser
3548
+ * redirect to IdP), then validates and stores the acquired cookie in the repository.
3549
+ *
3550
+ * # Arguments
3551
+ *
3552
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
3553
+ *
3554
+ * # Errors
3555
+ *
3556
+ * Returns an error if:
3557
+ * - Cookie acquisition was cancelled by the user
3558
+ * - Server configuration doesn't support SSO cookies (Direct bootstrap)
3559
+ * - Acquired cookie name doesn't match expected name
3560
+ * - Repository operations fail
3561
+ */
3562
+ acquireCookie(hostname: string): Promise<void>;
3563
+ /**
3564
+ * Determines if cookie bootstrapping is needed for this hostname
3565
+ *
3566
+ * # Arguments
3567
+ *
3568
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
3569
+ */
3570
+ needsBootstrap(hostname: string): Promise<boolean>;
3571
+ /**
3572
+ * Sets the server communication configuration for a hostname
3573
+ *
3574
+ * This method saves the provided communication configuration to the repository.
3575
+ * Typically called when receiving the `/api/config` response from the server.
3576
+ *
3577
+ * # Arguments
3578
+ *
3579
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
3580
+ * * `config` - The server communication configuration to store
3581
+ *
3582
+ * # Errors
3583
+ *
3584
+ * Returns an error if the repository save operation fails
3585
+ */
3586
+ setCommunicationType(hostname: string, config: ServerCommunicationConfig): Promise<void>;
3587
+ /**
3588
+ * Creates a new ServerCommunicationConfigClient with a JavaScript repository and platform API
3589
+ *
3590
+ * The repository should be backed by StateProvider (or equivalent
3591
+ * storage mechanism) for persistence.
3592
+ *
3593
+ * # Arguments
3594
+ *
3595
+ * * `repository` - JavaScript implementation of the repository interface
3596
+ * * `platform_api` - JavaScript implementation of the platform API interface
3597
+ */
3598
+ constructor(
3599
+ repository: ServerCommunicationConfigRepository,
3600
+ platform_api: ServerCommunicationConfigPlatformApi,
3601
+ );
3602
+ /**
3603
+ * Returns all cookies that should be included in requests to this server
3604
+ *
3605
+ * Returns an array of [cookie_name, cookie_value] pairs.
3606
+ *
3607
+ * # Arguments
3608
+ *
3609
+ * * `hostname` - The server hostname (e.g., "vault.acme.com")
3610
+ */
3611
+ cookies(hostname: string): Promise<any>;
3612
+ }
3613
+ export class StateClient {
3614
+ private constructor();
3615
+ free(): void;
3616
+ [Symbol.dispose](): void;
3617
+ /**
3618
+ * Initialize the database for SDK managed repositories.
3619
+ */
3620
+ initialize_state(configuration: IndexedDbConfiguration): Promise<void>;
3621
+ register_cipher_repository(cipher_repository: any): void;
3622
+ register_folder_repository(store: any): void;
3623
+ register_client_managed_repositories(repositories: Repositories): void;
3624
+ }
3625
+ export class TotpClient {
3626
+ private constructor();
3627
+ free(): void;
3628
+ [Symbol.dispose](): void;
3629
+ /**
3630
+ * Generates a TOTP code from a provided key
3631
+ *
3632
+ * # Arguments
3633
+ * - `key` - Can be:
3634
+ * - A base32 encoded string
3635
+ * - OTP Auth URI
3636
+ * - Steam URI
3637
+ * - `time_ms` - Optional timestamp in milliseconds
3638
+ */
3639
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
3640
+ }
3641
+ /**
3642
+ * Client for managing the cryptographic machinery of a user account, including key-rotation.
3643
+ */
3644
+ export class UserCryptoManagementClient {
3645
+ private constructor();
3646
+ free(): void;
3647
+ [Symbol.dispose](): void;
3648
+ /**
3649
+ * Rotates the user's encryption keys. The user must have a master-password.
3650
+ */
3651
+ rotate_user_keys(request: RotateUserKeysRequest): Promise<void>;
3652
+ /**
3653
+ * Fetches the organization public keys for V1 organization memberships for the user.
3654
+ * These have to be trusted manually be the user before rotating.
3655
+ */
3656
+ get_untrusted_organization_public_keys(): Promise<V1OrganizationMembership[]>;
3657
+ /**
3658
+ * Fetches the emergency access public keys for V1 emergency access memberships for the user.
3659
+ * These have to be trusted manually be the user before rotating.
3660
+ */
3661
+ get_untrusted_emergency_access_public_keys(): Promise<V1EmergencyAccessMembership[]>;
3662
+ }
3663
+ export class VaultClient {
3664
+ private constructor();
3665
+ free(): void;
3666
+ [Symbol.dispose](): void;
3667
+ /**
3668
+ * Attachment related operations.
3669
+ */
3670
+ attachments(): AttachmentsClient;
3671
+ /**
3672
+ * Cipher risk evaluation operations.
3673
+ */
3674
+ cipher_risk(): CipherRiskClient;
3675
+ /**
3676
+ * Collection related operations.
3677
+ */
3678
+ collections(): CollectionsClient;
3679
+ /**
3680
+ * TOTP related operations.
3681
+ */
3682
+ totp(): TotpClient;
3683
+ /**
3684
+ * Cipher related operations.
3685
+ */
3686
+ ciphers(): CiphersClient;
226
3687
  /**
227
- * @returns {ClientFolders}
3688
+ * Folder related operations.
228
3689
  */
229
- folders(): ClientFolders;
3690
+ folders(): FoldersClient;
230
3691
  }