@bitwarden/sdk-internal 0.2.0-main.44 → 0.2.0-main.441

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