@bitwarden/sdk-internal 0.2.0-main.60 → 0.2.0-main.600

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