@bitwarden/sdk-internal 0.2.0-main.52 → 0.2.0-main.521

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