@bitwarden/sdk-internal 0.2.0-main.42 → 0.2.0-main.421

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