@bitwarden/sdk-internal 0.2.0-main.53 → 0.2.0-main.530

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