@bitwarden/sdk-internal 0.2.0-main.29 → 0.2.0-main.290
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.
- package/VERSION +1 -0
- package/bitwarden_wasm_internal.d.ts +1789 -103
- package/bitwarden_wasm_internal_bg.js +4393 -676
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +418 -37
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +1789 -103
- package/node/bitwarden_wasm_internal.js +4428 -693
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +418 -37
- package/package.json +16 -5
@@ -1,10 +1,110 @@
|
|
1
1
|
/* tslint:disable */
|
2
2
|
/* eslint-disable */
|
3
|
+
export function set_log_level(level: LogLevel): void;
|
4
|
+
export function init_sdk(log_level?: LogLevel | null): void;
|
3
5
|
/**
|
4
|
-
*
|
5
|
-
*
|
6
|
+
* Generate a new SSH key pair
|
7
|
+
*
|
8
|
+
* # Arguments
|
9
|
+
* - `key_algorithm` - The algorithm to use for the key pair
|
10
|
+
*
|
11
|
+
* # Returns
|
12
|
+
* - `Ok(SshKey)` if the key was successfully generated
|
13
|
+
* - `Err(KeyGenerationError)` if the key could not be generated
|
14
|
+
*/
|
15
|
+
export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
|
16
|
+
/**
|
17
|
+
* Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
|
18
|
+
* to an OpenSSH private key with public key and fingerprint
|
19
|
+
*
|
20
|
+
* # Arguments
|
21
|
+
* - `imported_key` - The private key to convert
|
22
|
+
* - `password` - The password to use for decrypting the key
|
23
|
+
*
|
24
|
+
* # Returns
|
25
|
+
* - `Ok(SshKey)` if the key was successfully coneverted
|
26
|
+
* - `Err(PasswordRequired)` if the key is encrypted and no password was provided
|
27
|
+
* - `Err(WrongPassword)` if the password provided is incorrect
|
28
|
+
* - `Err(ParsingError)` if the key could not be parsed
|
29
|
+
* - `Err(UnsupportedKeyType)` if the key type is not supported
|
30
|
+
*/
|
31
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
|
32
|
+
/**
|
33
|
+
* Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
|
6
34
|
*/
|
7
|
-
export function
|
35
|
+
export function ipcRegisterDiscoverHandler(
|
36
|
+
ipc_client: IpcClient,
|
37
|
+
response: DiscoverResponse,
|
38
|
+
): Promise<void>;
|
39
|
+
/**
|
40
|
+
* Sends a DiscoverRequest to the specified destination and returns the response.
|
41
|
+
*/
|
42
|
+
export function ipcRequestDiscover(
|
43
|
+
ipc_client: IpcClient,
|
44
|
+
destination: Endpoint,
|
45
|
+
abort_signal?: AbortSignal | null,
|
46
|
+
): Promise<DiscoverResponse>;
|
47
|
+
export enum CardLinkedIdType {
|
48
|
+
CardholderName = 300,
|
49
|
+
ExpMonth = 301,
|
50
|
+
ExpYear = 302,
|
51
|
+
Code = 303,
|
52
|
+
Brand = 304,
|
53
|
+
Number = 305,
|
54
|
+
}
|
55
|
+
export enum CipherRepromptType {
|
56
|
+
None = 0,
|
57
|
+
Password = 1,
|
58
|
+
}
|
59
|
+
export enum CipherType {
|
60
|
+
Login = 1,
|
61
|
+
SecureNote = 2,
|
62
|
+
Card = 3,
|
63
|
+
Identity = 4,
|
64
|
+
SshKey = 5,
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Represents the type of a [FieldView].
|
68
|
+
*/
|
69
|
+
export enum FieldType {
|
70
|
+
/**
|
71
|
+
* Text field
|
72
|
+
*/
|
73
|
+
Text = 0,
|
74
|
+
/**
|
75
|
+
* Hidden text field
|
76
|
+
*/
|
77
|
+
Hidden = 1,
|
78
|
+
/**
|
79
|
+
* Boolean field
|
80
|
+
*/
|
81
|
+
Boolean = 2,
|
82
|
+
/**
|
83
|
+
* Linked field
|
84
|
+
*/
|
85
|
+
Linked = 3,
|
86
|
+
}
|
87
|
+
export enum IdentityLinkedIdType {
|
88
|
+
Title = 400,
|
89
|
+
MiddleName = 401,
|
90
|
+
Address1 = 402,
|
91
|
+
Address2 = 403,
|
92
|
+
Address3 = 404,
|
93
|
+
City = 405,
|
94
|
+
State = 406,
|
95
|
+
PostalCode = 407,
|
96
|
+
Country = 408,
|
97
|
+
Company = 409,
|
98
|
+
Email = 410,
|
99
|
+
Phone = 411,
|
100
|
+
Ssn = 412,
|
101
|
+
Username = 413,
|
102
|
+
PassportNumber = 414,
|
103
|
+
LicenseNumber = 415,
|
104
|
+
FirstName = 416,
|
105
|
+
LastName = 417,
|
106
|
+
FullName = 418,
|
107
|
+
}
|
8
108
|
export enum LogLevel {
|
9
109
|
Trace = 0,
|
10
110
|
Debug = 1,
|
@@ -12,7 +112,121 @@ export enum LogLevel {
|
|
12
112
|
Warn = 3,
|
13
113
|
Error = 4,
|
14
114
|
}
|
115
|
+
export enum LoginLinkedIdType {
|
116
|
+
Username = 100,
|
117
|
+
Password = 101,
|
118
|
+
}
|
119
|
+
export enum SecureNoteType {
|
120
|
+
Generic = 0,
|
121
|
+
}
|
122
|
+
export enum UriMatchType {
|
123
|
+
Domain = 0,
|
124
|
+
Host = 1,
|
125
|
+
StartsWith = 2,
|
126
|
+
Exact = 3,
|
127
|
+
RegularExpression = 4,
|
128
|
+
Never = 5,
|
129
|
+
}
|
130
|
+
|
131
|
+
import { Tagged } from "type-fest";
|
132
|
+
|
133
|
+
/**
|
134
|
+
* A string that **MUST** be a valid UUID.
|
135
|
+
*
|
136
|
+
* Never create or cast to this type directly, use the `uuid<T>()` function instead.
|
137
|
+
*/
|
138
|
+
export type Uuid = unknown;
|
139
|
+
|
140
|
+
/**
|
141
|
+
* RFC3339 compliant date-time string.
|
142
|
+
* @typeParam T - Not used in JavaScript.
|
143
|
+
*/
|
144
|
+
export type DateTime<T = unknown> = string;
|
145
|
+
|
146
|
+
/**
|
147
|
+
* UTC date-time string. Not used in JavaScript.
|
148
|
+
*/
|
149
|
+
export type Utc = unknown;
|
150
|
+
|
151
|
+
/**
|
152
|
+
* An integer that is known not to equal zero.
|
153
|
+
*/
|
154
|
+
export type NonZeroU32 = number;
|
155
|
+
|
156
|
+
export interface Repository<T> {
|
157
|
+
get(id: string): Promise<T | null>;
|
158
|
+
list(): Promise<T[]>;
|
159
|
+
set(id: string, value: T): Promise<void>;
|
160
|
+
remove(id: string): Promise<void>;
|
161
|
+
}
|
162
|
+
|
163
|
+
export interface TokenProvider {
|
164
|
+
get_access_token(): Promise<string | undefined>;
|
165
|
+
}
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Active feature flags for the SDK.
|
169
|
+
*/
|
170
|
+
export interface FeatureFlags extends Map<string, boolean> {}
|
171
|
+
|
172
|
+
export interface IndexedDbConfiguration {
|
173
|
+
db_name: string;
|
174
|
+
}
|
175
|
+
|
176
|
+
export interface TestError extends Error {
|
177
|
+
name: "TestError";
|
178
|
+
}
|
179
|
+
|
180
|
+
export function isTestError(error: any): error is TestError;
|
181
|
+
|
182
|
+
/**
|
183
|
+
* NewType wrapper for `CollectionId`
|
184
|
+
*/
|
185
|
+
export type CollectionId = Tagged<Uuid, "CollectionId">;
|
186
|
+
|
187
|
+
export interface Collection {
|
188
|
+
id: CollectionId | undefined;
|
189
|
+
organizationId: OrganizationId;
|
190
|
+
name: EncString;
|
191
|
+
externalId: string | undefined;
|
192
|
+
hidePasswords: boolean;
|
193
|
+
readOnly: boolean;
|
194
|
+
manage: boolean;
|
195
|
+
defaultUserCollectionEmail: string | undefined;
|
196
|
+
type: CollectionType;
|
197
|
+
}
|
198
|
+
|
199
|
+
export interface CollectionView {
|
200
|
+
id: CollectionId | undefined;
|
201
|
+
organizationId: OrganizationId;
|
202
|
+
name: string;
|
203
|
+
externalId: string | undefined;
|
204
|
+
hidePasswords: boolean;
|
205
|
+
readOnly: boolean;
|
206
|
+
manage: boolean;
|
207
|
+
type: CollectionType;
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* Type of collection
|
212
|
+
*/
|
213
|
+
export type CollectionType = "SharedCollection" | "DefaultUserCollection";
|
214
|
+
|
215
|
+
export interface CollectionDecryptError extends Error {
|
216
|
+
name: "CollectionDecryptError";
|
217
|
+
variant: "Crypto";
|
218
|
+
}
|
219
|
+
|
220
|
+
export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
|
221
|
+
|
222
|
+
/**
|
223
|
+
* State used for initializing the user cryptographic state.
|
224
|
+
*/
|
15
225
|
export interface InitUserCryptoRequest {
|
226
|
+
/**
|
227
|
+
* The user\'s ID.
|
228
|
+
*/
|
229
|
+
userId: UserId | undefined;
|
16
230
|
/**
|
17
231
|
* The user\'s KDF parameters, as received from the prelogin request
|
18
232
|
*/
|
@@ -24,66 +238,267 @@ export interface InitUserCryptoRequest {
|
|
24
238
|
/**
|
25
239
|
* The user\'s encrypted private key
|
26
240
|
*/
|
27
|
-
privateKey:
|
241
|
+
privateKey: EncString;
|
242
|
+
/**
|
243
|
+
* The user\'s signing key
|
244
|
+
*/
|
245
|
+
signingKey: EncString | undefined;
|
246
|
+
/**
|
247
|
+
* The user\'s security state
|
248
|
+
*/
|
249
|
+
securityState: SignedSecurityState | undefined;
|
28
250
|
/**
|
29
251
|
* The initialization method to use
|
30
252
|
*/
|
31
253
|
method: InitUserCryptoMethod;
|
32
254
|
}
|
33
255
|
|
256
|
+
/**
|
257
|
+
* The crypto method used to initialize the user cryptographic state.
|
258
|
+
*/
|
34
259
|
export type InitUserCryptoMethod =
|
35
|
-
| { password: { password: string; user_key:
|
260
|
+
| { password: { password: string; user_key: EncString } }
|
36
261
|
| { decryptedKey: { decrypted_user_key: string } }
|
37
262
|
| { pin: { pin: string; pin_protected_user_key: EncString } }
|
38
|
-
| {
|
263
|
+
| { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
|
264
|
+
| { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
|
39
265
|
| {
|
40
266
|
deviceKey: {
|
41
267
|
device_key: string;
|
42
268
|
protected_device_private_key: EncString;
|
43
|
-
device_protected_user_key:
|
269
|
+
device_protected_user_key: UnsignedSharedKey;
|
44
270
|
};
|
45
271
|
}
|
46
|
-
| { keyConnector: { master_key:
|
272
|
+
| { keyConnector: { master_key: B64; user_key: EncString } };
|
47
273
|
|
274
|
+
/**
|
275
|
+
* Auth requests supports multiple initialization methods.
|
276
|
+
*/
|
48
277
|
export type AuthRequestMethod =
|
49
|
-
| { userKey: { protected_user_key:
|
50
|
-
| { masterKey: { protected_master_key:
|
278
|
+
| { userKey: { protected_user_key: UnsignedSharedKey } }
|
279
|
+
| { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
|
51
280
|
|
281
|
+
/**
|
282
|
+
* Represents the request to initialize the user\'s organizational cryptographic state.
|
283
|
+
*/
|
52
284
|
export interface InitOrgCryptoRequest {
|
53
285
|
/**
|
54
286
|
* The encryption keys for all the organizations the user is a part of
|
55
287
|
*/
|
56
|
-
organizationKeys: Map<
|
288
|
+
organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
|
57
289
|
}
|
58
290
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
291
|
+
/**
|
292
|
+
* Response from the `update_password` function
|
293
|
+
*/
|
294
|
+
export interface UpdatePasswordResponse {
|
295
|
+
/**
|
296
|
+
* Hash of the new password
|
297
|
+
*/
|
298
|
+
passwordHash: B64;
|
299
|
+
/**
|
300
|
+
* User key, encrypted with the new password
|
301
|
+
*/
|
302
|
+
newKey: EncString;
|
303
|
+
}
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Request for deriving a pin protected user key
|
307
|
+
*/
|
308
|
+
export interface EnrollPinResponse {
|
309
|
+
/**
|
310
|
+
* [UserKey] protected by PIN
|
311
|
+
*/
|
312
|
+
pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
|
313
|
+
/**
|
314
|
+
* PIN protected by [UserKey]
|
315
|
+
*/
|
316
|
+
userKeyEncryptedPin: EncString;
|
317
|
+
}
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Request for deriving a pin protected user key
|
321
|
+
*/
|
322
|
+
export interface DerivePinKeyResponse {
|
323
|
+
/**
|
324
|
+
* [UserKey] protected by PIN
|
325
|
+
*/
|
326
|
+
pinProtectedUserKey: EncString;
|
327
|
+
/**
|
328
|
+
* PIN protected by [UserKey]
|
329
|
+
*/
|
330
|
+
encryptedPin: EncString;
|
331
|
+
}
|
332
|
+
|
333
|
+
/**
|
334
|
+
* Request for migrating an account from password to key connector.
|
335
|
+
*/
|
336
|
+
export interface DeriveKeyConnectorRequest {
|
337
|
+
/**
|
338
|
+
* Encrypted user key, used to validate the master key
|
339
|
+
*/
|
340
|
+
userKeyEncrypted: EncString;
|
341
|
+
/**
|
342
|
+
* The user\'s master password
|
343
|
+
*/
|
344
|
+
password: string;
|
345
|
+
/**
|
346
|
+
* The KDF parameters used to derive the master key
|
347
|
+
*/
|
348
|
+
kdf: Kdf;
|
349
|
+
/**
|
350
|
+
* The user\'s email address
|
351
|
+
*/
|
352
|
+
email: string;
|
353
|
+
}
|
354
|
+
|
355
|
+
/**
|
356
|
+
* Response from the `make_key_pair` function
|
357
|
+
*/
|
358
|
+
export interface MakeKeyPairResponse {
|
359
|
+
/**
|
360
|
+
* The user\'s public key
|
361
|
+
*/
|
362
|
+
userPublicKey: B64;
|
363
|
+
/**
|
364
|
+
* User\'s private key, encrypted with the user key
|
365
|
+
*/
|
366
|
+
userKeyEncryptedPrivateKey: EncString;
|
367
|
+
}
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Request for `verify_asymmetric_keys`.
|
371
|
+
*/
|
372
|
+
export interface VerifyAsymmetricKeysRequest {
|
373
|
+
/**
|
374
|
+
* The user\'s user key
|
375
|
+
*/
|
376
|
+
userKey: B64;
|
377
|
+
/**
|
378
|
+
* The user\'s public key
|
379
|
+
*/
|
380
|
+
userPublicKey: B64;
|
381
|
+
/**
|
382
|
+
* User\'s private key, encrypted with the user key
|
383
|
+
*/
|
384
|
+
userKeyEncryptedPrivateKey: EncString;
|
385
|
+
}
|
386
|
+
|
387
|
+
/**
|
388
|
+
* Response for `verify_asymmetric_keys`.
|
389
|
+
*/
|
390
|
+
export interface VerifyAsymmetricKeysResponse {
|
391
|
+
/**
|
392
|
+
* Whether the user\'s private key was decryptable by the user key.
|
393
|
+
*/
|
394
|
+
privateKeyDecryptable: boolean;
|
395
|
+
/**
|
396
|
+
* Whether the user\'s private key was a valid RSA key and matched the public key provided.
|
397
|
+
*/
|
398
|
+
validPrivateKey: boolean;
|
399
|
+
}
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
|
403
|
+
*/
|
404
|
+
export interface UserCryptoV2KeysResponse {
|
405
|
+
/**
|
406
|
+
* User key
|
407
|
+
*/
|
408
|
+
userKey: B64;
|
409
|
+
/**
|
410
|
+
* Wrapped private key
|
411
|
+
*/
|
412
|
+
privateKey: EncString;
|
413
|
+
/**
|
414
|
+
* Public key
|
415
|
+
*/
|
416
|
+
publicKey: B64;
|
417
|
+
/**
|
418
|
+
* The user\'s public key, signed by the signing key
|
419
|
+
*/
|
420
|
+
signedPublicKey: SignedPublicKey;
|
421
|
+
/**
|
422
|
+
* Signing key, encrypted with the user\'s symmetric key
|
423
|
+
*/
|
424
|
+
signingKey: EncString;
|
425
|
+
/**
|
426
|
+
* Base64 encoded verifying key
|
427
|
+
*/
|
428
|
+
verifyingKey: B64;
|
429
|
+
/**
|
430
|
+
* The user\'s signed security state
|
431
|
+
*/
|
432
|
+
securityState: SignedSecurityState;
|
433
|
+
/**
|
434
|
+
* The security state\'s version
|
435
|
+
*/
|
436
|
+
securityVersion: number;
|
437
|
+
}
|
438
|
+
|
439
|
+
export type SignedSecurityState = string;
|
440
|
+
|
441
|
+
/**
|
442
|
+
* NewType wrapper for `UserId`
|
443
|
+
*/
|
444
|
+
export type UserId = Tagged<Uuid, "UserId">;
|
445
|
+
|
446
|
+
/**
|
447
|
+
* NewType wrapper for `OrganizationId`
|
448
|
+
*/
|
449
|
+
export type OrganizationId = Tagged<Uuid, "OrganizationId">;
|
450
|
+
|
451
|
+
/**
|
452
|
+
* A non-generic wrapper around `bitwarden-crypto`\'s `PasswordProtectedKeyEnvelope`.
|
453
|
+
*/
|
454
|
+
export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
|
455
|
+
|
456
|
+
export interface MasterPasswordError extends Error {
|
457
|
+
name: "MasterPasswordError";
|
458
|
+
variant: "EncryptionKeyMalformed" | "KdfMalformed" | "MissingField";
|
459
|
+
}
|
460
|
+
|
461
|
+
export function isMasterPasswordError(error: any): error is MasterPasswordError;
|
462
|
+
|
463
|
+
export interface DeriveKeyConnectorError extends Error {
|
464
|
+
name: "DeriveKeyConnectorError";
|
465
|
+
variant: "WrongPassword" | "Crypto";
|
466
|
+
}
|
467
|
+
|
468
|
+
export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
|
469
|
+
|
470
|
+
export interface EnrollAdminPasswordResetError extends Error {
|
471
|
+
name: "EnrollAdminPasswordResetError";
|
472
|
+
variant: "VaultLocked" | "Crypto";
|
473
|
+
}
|
474
|
+
|
475
|
+
export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
|
476
|
+
|
477
|
+
export interface CryptoClientError extends Error {
|
478
|
+
name: "CryptoClientError";
|
479
|
+
variant: "NotAuthenticated" | "VaultLocked" | "Crypto" | "PasswordProtectedKeyEnvelope";
|
480
|
+
}
|
481
|
+
|
482
|
+
export function isCryptoClientError(error: any): error is CryptoClientError;
|
483
|
+
|
484
|
+
export interface StatefulCryptoError extends Error {
|
485
|
+
name: "StatefulCryptoError";
|
486
|
+
variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "CryptoError";
|
487
|
+
}
|
488
|
+
|
489
|
+
export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
|
83
490
|
|
84
491
|
export interface EncryptionSettingsError extends Error {
|
85
492
|
name: "EncryptionSettingsError";
|
86
|
-
variant:
|
493
|
+
variant:
|
494
|
+
| "Crypto"
|
495
|
+
| "VaultLocked"
|
496
|
+
| "InvalidPrivateKey"
|
497
|
+
| "InvalidSigningKey"
|
498
|
+
| "InvalidSecurityState"
|
499
|
+
| "MissingPrivateKey"
|
500
|
+
| "UserIdAlreadySetError"
|
501
|
+
| "WrongPin";
|
87
502
|
}
|
88
503
|
|
89
504
|
export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
|
@@ -152,9 +567,16 @@ export interface ClientSettings {
|
|
152
567
|
deviceType?: DeviceType;
|
153
568
|
}
|
154
569
|
|
155
|
-
export type
|
570
|
+
export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
|
571
|
+
|
572
|
+
export type EncString = Tagged<string, "EncString">;
|
156
573
|
|
157
|
-
export type
|
574
|
+
export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
|
575
|
+
|
576
|
+
/**
|
577
|
+
* The type of key / signature scheme used for signing and verifying.
|
578
|
+
*/
|
579
|
+
export type SignatureAlgorithm = "ed25519";
|
158
580
|
|
159
581
|
/**
|
160
582
|
* Key Derivation Function for Bitwarden Account
|
@@ -166,124 +588,1388 @@ export type Kdf =
|
|
166
588
|
| { pBKDF2: { iterations: NonZeroU32 } }
|
167
589
|
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
168
590
|
|
169
|
-
export interface
|
170
|
-
|
171
|
-
|
172
|
-
|
591
|
+
export interface CryptoError extends Error {
|
592
|
+
name: "CryptoError";
|
593
|
+
variant:
|
594
|
+
| "InvalidKey"
|
595
|
+
| "InvalidMac"
|
596
|
+
| "MacNotProvided"
|
597
|
+
| "KeyDecrypt"
|
598
|
+
| "InvalidKeyLen"
|
599
|
+
| "InvalidUtf8String"
|
600
|
+
| "MissingKey"
|
601
|
+
| "MissingField"
|
602
|
+
| "MissingKeyId"
|
603
|
+
| "ReadOnlyKeyStore"
|
604
|
+
| "InsufficientKdfParameters"
|
605
|
+
| "EncString"
|
606
|
+
| "RsaError"
|
607
|
+
| "FingerprintError"
|
608
|
+
| "ArgonError"
|
609
|
+
| "ZeroNumber"
|
610
|
+
| "OperationNotSupported"
|
611
|
+
| "WrongKeyType"
|
612
|
+
| "WrongCoseKeyId"
|
613
|
+
| "InvalidNonceLength"
|
614
|
+
| "InvalidPadding"
|
615
|
+
| "SignatureError"
|
616
|
+
| "EncodingError";
|
173
617
|
}
|
174
618
|
|
175
|
-
export
|
176
|
-
|
177
|
-
export interface KeyGenerationError extends Error {
|
178
|
-
name: "KeyGenerationError";
|
179
|
-
variant: "KeyGenerationError" | "KeyConversionError";
|
180
|
-
}
|
619
|
+
export function isCryptoError(error: any): error is CryptoError;
|
181
620
|
|
182
|
-
|
621
|
+
/**
|
622
|
+
* Base64 encoded data
|
623
|
+
*
|
624
|
+
* Is indifferent about padding when decoding, but always produces padding when encoding.
|
625
|
+
*/
|
626
|
+
export type B64 = string;
|
183
627
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
628
|
+
/**
|
629
|
+
* Temporary struct to hold metadata related to current account
|
630
|
+
*
|
631
|
+
* Eventually the SDK itself should have this state and we get rid of this struct.
|
632
|
+
*/
|
633
|
+
export interface Account {
|
634
|
+
id: Uuid;
|
635
|
+
email: string;
|
636
|
+
name: string | undefined;
|
188
637
|
}
|
189
638
|
|
190
|
-
export
|
191
|
-
id: Uuid | undefined;
|
192
|
-
name: string;
|
193
|
-
revisionDate: DateTime<Utc>;
|
194
|
-
}
|
639
|
+
export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
|
195
640
|
|
196
|
-
export interface
|
197
|
-
name: "
|
641
|
+
export interface ExportError extends Error {
|
642
|
+
name: "ExportError";
|
643
|
+
variant:
|
644
|
+
| "MissingField"
|
645
|
+
| "NotAuthenticated"
|
646
|
+
| "VaultLocked"
|
647
|
+
| "Csv"
|
648
|
+
| "CxfError"
|
649
|
+
| "Json"
|
650
|
+
| "EncryptedJsonError"
|
651
|
+
| "BitwardenCryptoError"
|
652
|
+
| "CipherError";
|
198
653
|
}
|
199
654
|
|
200
|
-
export function
|
655
|
+
export function isExportError(error: any): error is ExportError;
|
201
656
|
|
202
|
-
export type
|
657
|
+
export type UsernameGeneratorRequest =
|
658
|
+
| { word: { capitalize: boolean; include_number: boolean } }
|
659
|
+
| { subaddress: { type: AppendType; email: string } }
|
660
|
+
| { catchall: { type: AppendType; domain: string } }
|
661
|
+
| { forwarded: { service: ForwarderServiceType; website: string | undefined } };
|
203
662
|
|
204
663
|
/**
|
205
|
-
*
|
206
|
-
*
|
664
|
+
* Configures the email forwarding service to use.
|
665
|
+
* For instructions on how to configure each service, see the documentation:
|
666
|
+
* <https://bitwarden.com/help/generator/#username-types>
|
207
667
|
*/
|
208
|
-
export type
|
668
|
+
export type ForwarderServiceType =
|
669
|
+
| { addyIo: { api_token: string; domain: string; base_url: string } }
|
670
|
+
| { duckDuckGo: { token: string } }
|
671
|
+
| { firefox: { api_token: string } }
|
672
|
+
| { fastmail: { api_token: string } }
|
673
|
+
| { forwardEmail: { api_token: string; domain: string } }
|
674
|
+
| { simpleLogin: { api_key: string; base_url: string } };
|
209
675
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
676
|
+
export type AppendType = "random" | { websiteName: { website: string } };
|
677
|
+
|
678
|
+
export interface UsernameError extends Error {
|
679
|
+
name: "UsernameError";
|
680
|
+
variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
|
681
|
+
}
|
682
|
+
|
683
|
+
export function isUsernameError(error: any): error is UsernameError;
|
214
684
|
|
215
685
|
/**
|
216
|
-
*
|
686
|
+
* Password generator request options.
|
217
687
|
*/
|
218
|
-
export
|
219
|
-
|
220
|
-
|
688
|
+
export interface PasswordGeneratorRequest {
|
689
|
+
/**
|
690
|
+
* Include lowercase characters (a-z).
|
691
|
+
*/
|
692
|
+
lowercase: boolean;
|
693
|
+
/**
|
694
|
+
* Include uppercase characters (A-Z).
|
695
|
+
*/
|
696
|
+
uppercase: boolean;
|
697
|
+
/**
|
698
|
+
* Include numbers (0-9).
|
699
|
+
*/
|
700
|
+
numbers: boolean;
|
701
|
+
/**
|
702
|
+
* Include special characters: ! @ # $ % ^ & *
|
703
|
+
*/
|
704
|
+
special: boolean;
|
705
|
+
/**
|
706
|
+
* The length of the generated password.
|
707
|
+
* Note that the password length must be greater than the sum of all the minimums.
|
708
|
+
*/
|
709
|
+
length: number;
|
710
|
+
/**
|
711
|
+
* When set to true, the generated password will not contain ambiguous characters.
|
712
|
+
* The ambiguous characters are: I, O, l, 0, 1
|
713
|
+
*/
|
714
|
+
avoidAmbiguous: boolean;
|
715
|
+
/**
|
716
|
+
* The minimum number of lowercase characters in the generated password.
|
717
|
+
* When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
|
718
|
+
*/
|
719
|
+
minLowercase: number | undefined;
|
720
|
+
/**
|
721
|
+
* The minimum number of uppercase characters in the generated password.
|
722
|
+
* When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
|
723
|
+
*/
|
724
|
+
minUppercase: number | undefined;
|
725
|
+
/**
|
726
|
+
* The minimum number of numbers in the generated password.
|
727
|
+
* When set, the value must be between 1 and 9. This value is ignored if numbers is false.
|
728
|
+
*/
|
729
|
+
minNumber: number | undefined;
|
730
|
+
/**
|
731
|
+
* The minimum number of special characters in the generated password.
|
732
|
+
* When set, the value must be between 1 and 9. This value is ignored if special is false.
|
733
|
+
*/
|
734
|
+
minSpecial: number | undefined;
|
735
|
+
}
|
736
|
+
|
737
|
+
export interface PasswordError extends Error {
|
738
|
+
name: "PasswordError";
|
739
|
+
variant: "NoCharacterSetEnabled" | "InvalidLength";
|
740
|
+
}
|
741
|
+
|
742
|
+
export function isPasswordError(error: any): error is PasswordError;
|
743
|
+
|
744
|
+
/**
|
745
|
+
* Passphrase generator request options.
|
746
|
+
*/
|
747
|
+
export interface PassphraseGeneratorRequest {
|
748
|
+
/**
|
749
|
+
* Number of words in the generated passphrase.
|
750
|
+
* This value must be between 3 and 20.
|
751
|
+
*/
|
752
|
+
numWords: number;
|
753
|
+
/**
|
754
|
+
* Character separator between words in the generated passphrase. The value cannot be empty.
|
755
|
+
*/
|
756
|
+
wordSeparator: string;
|
757
|
+
/**
|
758
|
+
* When set to true, capitalize the first letter of each word in the generated passphrase.
|
759
|
+
*/
|
760
|
+
capitalize: boolean;
|
761
|
+
/**
|
762
|
+
* When set to true, include a number at the end of one of the words in the generated
|
763
|
+
* passphrase.
|
764
|
+
*/
|
765
|
+
includeNumber: boolean;
|
766
|
+
}
|
767
|
+
|
768
|
+
export interface PassphraseError extends Error {
|
769
|
+
name: "PassphraseError";
|
770
|
+
variant: "InvalidNumWords";
|
771
|
+
}
|
772
|
+
|
773
|
+
export function isPassphraseError(error: any): error is PassphraseError;
|
774
|
+
|
775
|
+
export interface DiscoverResponse {
|
776
|
+
version: string;
|
777
|
+
}
|
778
|
+
|
779
|
+
export type Endpoint =
|
780
|
+
| { Web: { id: number } }
|
781
|
+
| "BrowserForeground"
|
782
|
+
| "BrowserBackground"
|
783
|
+
| "DesktopRenderer"
|
784
|
+
| "DesktopMain";
|
785
|
+
|
786
|
+
export interface IpcCommunicationBackendSender {
|
787
|
+
send(message: OutgoingMessage): Promise<void>;
|
788
|
+
}
|
789
|
+
|
790
|
+
export interface ChannelError extends Error {
|
791
|
+
name: "ChannelError";
|
792
|
+
}
|
793
|
+
|
794
|
+
export function isChannelError(error: any): error is ChannelError;
|
795
|
+
|
796
|
+
export interface DeserializeError extends Error {
|
797
|
+
name: "DeserializeError";
|
798
|
+
}
|
799
|
+
|
800
|
+
export function isDeserializeError(error: any): error is DeserializeError;
|
801
|
+
|
802
|
+
export interface RequestError extends Error {
|
803
|
+
name: "RequestError";
|
804
|
+
variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "RpcError";
|
805
|
+
}
|
806
|
+
|
807
|
+
export function isRequestError(error: any): error is RequestError;
|
808
|
+
|
809
|
+
export interface TypedReceiveError extends Error {
|
810
|
+
name: "TypedReceiveError";
|
811
|
+
variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
|
812
|
+
}
|
813
|
+
|
814
|
+
export function isTypedReceiveError(error: any): error is TypedReceiveError;
|
815
|
+
|
816
|
+
export interface ReceiveError extends Error {
|
817
|
+
name: "ReceiveError";
|
818
|
+
variant: "Channel" | "Timeout" | "Cancelled";
|
819
|
+
}
|
820
|
+
|
821
|
+
export function isReceiveError(error: any): error is ReceiveError;
|
822
|
+
|
823
|
+
export interface SubscribeError extends Error {
|
824
|
+
name: "SubscribeError";
|
825
|
+
variant: "NotStarted";
|
826
|
+
}
|
827
|
+
|
828
|
+
export function isSubscribeError(error: any): error is SubscribeError;
|
829
|
+
|
830
|
+
export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
831
|
+
|
832
|
+
export interface SshKeyExportError extends Error {
|
833
|
+
name: "SshKeyExportError";
|
834
|
+
variant: "KeyConversionError";
|
835
|
+
}
|
836
|
+
|
837
|
+
export function isSshKeyExportError(error: any): error is SshKeyExportError;
|
838
|
+
|
839
|
+
export interface SshKeyImportError extends Error {
|
840
|
+
name: "SshKeyImportError";
|
841
|
+
variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
|
842
|
+
}
|
843
|
+
|
844
|
+
export function isSshKeyImportError(error: any): error is SshKeyImportError;
|
845
|
+
|
846
|
+
export interface KeyGenerationError extends Error {
|
847
|
+
name: "KeyGenerationError";
|
848
|
+
variant: "KeyGenerationError" | "KeyConversionError";
|
849
|
+
}
|
850
|
+
|
851
|
+
export function isKeyGenerationError(error: any): error is KeyGenerationError;
|
852
|
+
|
853
|
+
export interface DatabaseError extends Error {
|
854
|
+
name: "DatabaseError";
|
855
|
+
variant:
|
856
|
+
| "UnsupportedConfiguration"
|
857
|
+
| "ThreadBoundRunner"
|
858
|
+
| "Serialization"
|
859
|
+
| "JSError"
|
860
|
+
| "Internal";
|
861
|
+
}
|
862
|
+
|
863
|
+
export function isDatabaseError(error: any): error is DatabaseError;
|
864
|
+
|
865
|
+
export interface StateRegistryError extends Error {
|
866
|
+
name: "StateRegistryError";
|
867
|
+
variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
|
868
|
+
}
|
869
|
+
|
870
|
+
export function isStateRegistryError(error: any): error is StateRegistryError;
|
871
|
+
|
872
|
+
export interface CallError extends Error {
|
873
|
+
name: "CallError";
|
874
|
+
}
|
875
|
+
|
876
|
+
export function isCallError(error: any): error is CallError;
|
877
|
+
|
878
|
+
/**
|
879
|
+
* NewType wrapper for `CipherId`
|
880
|
+
*/
|
881
|
+
export type CipherId = Tagged<Uuid, "CipherId">;
|
882
|
+
|
883
|
+
export interface EncryptionContext {
|
884
|
+
/**
|
885
|
+
* The Id of the user that encrypted the cipher. It should always represent a UserId, even for
|
886
|
+
* Organization-owned ciphers
|
887
|
+
*/
|
888
|
+
encryptedFor: UserId;
|
889
|
+
cipher: Cipher;
|
890
|
+
}
|
891
|
+
|
892
|
+
export interface Cipher {
|
893
|
+
id: CipherId | undefined;
|
894
|
+
organizationId: OrganizationId | undefined;
|
895
|
+
folderId: FolderId | undefined;
|
896
|
+
collectionIds: CollectionId[];
|
897
|
+
/**
|
898
|
+
* More recent ciphers uses individual encryption keys to encrypt the other fields of the
|
899
|
+
* Cipher.
|
900
|
+
*/
|
901
|
+
key: EncString | undefined;
|
902
|
+
name: EncString;
|
903
|
+
notes: EncString | undefined;
|
904
|
+
type: CipherType;
|
905
|
+
login: Login | undefined;
|
906
|
+
identity: Identity | undefined;
|
907
|
+
card: Card | undefined;
|
908
|
+
secureNote: SecureNote | undefined;
|
909
|
+
sshKey: SshKey | undefined;
|
910
|
+
favorite: boolean;
|
911
|
+
reprompt: CipherRepromptType;
|
912
|
+
organizationUseTotp: boolean;
|
913
|
+
edit: boolean;
|
914
|
+
permissions: CipherPermissions | undefined;
|
915
|
+
viewPassword: boolean;
|
916
|
+
localData: LocalData | undefined;
|
917
|
+
attachments: Attachment[] | undefined;
|
918
|
+
fields: Field[] | undefined;
|
919
|
+
passwordHistory: PasswordHistory[] | undefined;
|
920
|
+
creationDate: DateTime<Utc>;
|
921
|
+
deletedDate: DateTime<Utc> | undefined;
|
922
|
+
revisionDate: DateTime<Utc>;
|
923
|
+
}
|
924
|
+
|
925
|
+
export interface CipherView {
|
926
|
+
id: CipherId | undefined;
|
927
|
+
organizationId: OrganizationId | undefined;
|
928
|
+
folderId: FolderId | undefined;
|
929
|
+
collectionIds: CollectionId[];
|
930
|
+
/**
|
931
|
+
* Temporary, required to support re-encrypting existing items.
|
932
|
+
*/
|
933
|
+
key: EncString | undefined;
|
934
|
+
name: string;
|
935
|
+
notes: string | undefined;
|
936
|
+
type: CipherType;
|
937
|
+
login: LoginView | undefined;
|
938
|
+
identity: IdentityView | undefined;
|
939
|
+
card: CardView | undefined;
|
940
|
+
secureNote: SecureNoteView | undefined;
|
941
|
+
sshKey: SshKeyView | undefined;
|
942
|
+
favorite: boolean;
|
943
|
+
reprompt: CipherRepromptType;
|
944
|
+
organizationUseTotp: boolean;
|
945
|
+
edit: boolean;
|
946
|
+
permissions: CipherPermissions | undefined;
|
947
|
+
viewPassword: boolean;
|
948
|
+
localData: LocalDataView | undefined;
|
949
|
+
attachments: AttachmentView[] | undefined;
|
950
|
+
fields: FieldView[] | undefined;
|
951
|
+
passwordHistory: PasswordHistoryView[] | undefined;
|
952
|
+
creationDate: DateTime<Utc>;
|
953
|
+
deletedDate: DateTime<Utc> | undefined;
|
954
|
+
revisionDate: DateTime<Utc>;
|
955
|
+
}
|
956
|
+
|
957
|
+
export type CipherListViewType =
|
958
|
+
| { login: LoginListView }
|
959
|
+
| "secureNote"
|
960
|
+
| { card: CardListView }
|
961
|
+
| "identity"
|
962
|
+
| "sshKey";
|
963
|
+
|
964
|
+
/**
|
965
|
+
* Available fields on a cipher and can be copied from a the list view in the UI.
|
966
|
+
*/
|
967
|
+
export type CopyableCipherFields =
|
968
|
+
| "LoginUsername"
|
969
|
+
| "LoginPassword"
|
970
|
+
| "LoginTotp"
|
971
|
+
| "CardNumber"
|
972
|
+
| "CardSecurityCode"
|
973
|
+
| "IdentityUsername"
|
974
|
+
| "IdentityEmail"
|
975
|
+
| "IdentityPhone"
|
976
|
+
| "IdentityAddress"
|
977
|
+
| "SshKey"
|
978
|
+
| "SecureNotes";
|
979
|
+
|
980
|
+
export interface CipherListView {
|
981
|
+
id: CipherId | undefined;
|
982
|
+
organizationId: OrganizationId | undefined;
|
983
|
+
folderId: FolderId | undefined;
|
984
|
+
collectionIds: CollectionId[];
|
985
|
+
/**
|
986
|
+
* Temporary, required to support calculating TOTP from CipherListView.
|
987
|
+
*/
|
988
|
+
key: EncString | undefined;
|
989
|
+
name: string;
|
990
|
+
subtitle: string;
|
991
|
+
type: CipherListViewType;
|
992
|
+
favorite: boolean;
|
993
|
+
reprompt: CipherRepromptType;
|
994
|
+
organizationUseTotp: boolean;
|
995
|
+
edit: boolean;
|
996
|
+
permissions: CipherPermissions | undefined;
|
997
|
+
viewPassword: boolean;
|
998
|
+
/**
|
999
|
+
* The number of attachments
|
1000
|
+
*/
|
1001
|
+
attachments: number;
|
1002
|
+
/**
|
1003
|
+
* Indicates if the cipher has old attachments that need to be re-uploaded
|
1004
|
+
*/
|
1005
|
+
hasOldAttachments: boolean;
|
1006
|
+
creationDate: DateTime<Utc>;
|
1007
|
+
deletedDate: DateTime<Utc> | undefined;
|
1008
|
+
revisionDate: DateTime<Utc>;
|
1009
|
+
/**
|
1010
|
+
* Hints for the presentation layer for which fields can be copied.
|
1011
|
+
*/
|
1012
|
+
copyableFields: CopyableCipherFields[];
|
1013
|
+
localData: LocalDataView | undefined;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
/**
|
1017
|
+
* Represents the result of decrypting a list of ciphers.
|
1018
|
+
*
|
1019
|
+
* This struct contains two vectors: `successes` and `failures`.
|
1020
|
+
* `successes` contains the decrypted `CipherListView` objects,
|
1021
|
+
* while `failures` contains the original `Cipher` objects that failed to decrypt.
|
1022
|
+
*/
|
1023
|
+
export interface DecryptCipherListResult {
|
1024
|
+
/**
|
1025
|
+
* The decrypted `CipherListView` objects.
|
1026
|
+
*/
|
1027
|
+
successes: CipherListView[];
|
1028
|
+
/**
|
1029
|
+
* The original `Cipher` objects that failed to decrypt.
|
1030
|
+
*/
|
1031
|
+
failures: Cipher[];
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
export interface Field {
|
1035
|
+
name: EncString | undefined;
|
1036
|
+
value: EncString | undefined;
|
1037
|
+
type: FieldType;
|
1038
|
+
linkedId: LinkedIdType | undefined;
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
export interface FieldView {
|
1042
|
+
name: string | undefined;
|
1043
|
+
value: string | undefined;
|
1044
|
+
type: FieldType;
|
1045
|
+
linkedId: LinkedIdType | undefined;
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
|
1049
|
+
|
1050
|
+
export interface LoginUri {
|
1051
|
+
uri: EncString | undefined;
|
1052
|
+
match: UriMatchType | undefined;
|
1053
|
+
uriChecksum: EncString | undefined;
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
export interface LoginUriView {
|
1057
|
+
uri: string | undefined;
|
1058
|
+
match: UriMatchType | undefined;
|
1059
|
+
uriChecksum: string | undefined;
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
export interface Fido2Credential {
|
1063
|
+
credentialId: EncString;
|
1064
|
+
keyType: EncString;
|
1065
|
+
keyAlgorithm: EncString;
|
1066
|
+
keyCurve: EncString;
|
1067
|
+
keyValue: EncString;
|
1068
|
+
rpId: EncString;
|
1069
|
+
userHandle: EncString | undefined;
|
1070
|
+
userName: EncString | undefined;
|
1071
|
+
counter: EncString;
|
1072
|
+
rpName: EncString | undefined;
|
1073
|
+
userDisplayName: EncString | undefined;
|
1074
|
+
discoverable: EncString;
|
1075
|
+
creationDate: DateTime<Utc>;
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
export interface Fido2CredentialListView {
|
1079
|
+
credentialId: string;
|
1080
|
+
rpId: string;
|
1081
|
+
userHandle: string | undefined;
|
1082
|
+
userName: string | undefined;
|
1083
|
+
userDisplayName: string | undefined;
|
1084
|
+
counter: string;
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
export interface Fido2CredentialView {
|
1088
|
+
credentialId: string;
|
1089
|
+
keyType: string;
|
1090
|
+
keyAlgorithm: string;
|
1091
|
+
keyCurve: string;
|
1092
|
+
keyValue: EncString;
|
1093
|
+
rpId: string;
|
1094
|
+
userHandle: string | undefined;
|
1095
|
+
userName: string | undefined;
|
1096
|
+
counter: string;
|
1097
|
+
rpName: string | undefined;
|
1098
|
+
userDisplayName: string | undefined;
|
1099
|
+
discoverable: string;
|
1100
|
+
creationDate: DateTime<Utc>;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
export interface Fido2CredentialFullView {
|
1104
|
+
credentialId: string;
|
1105
|
+
keyType: string;
|
1106
|
+
keyAlgorithm: string;
|
1107
|
+
keyCurve: string;
|
1108
|
+
keyValue: string;
|
1109
|
+
rpId: string;
|
1110
|
+
userHandle: string | undefined;
|
1111
|
+
userName: string | undefined;
|
1112
|
+
counter: string;
|
1113
|
+
rpName: string | undefined;
|
1114
|
+
userDisplayName: string | undefined;
|
1115
|
+
discoverable: string;
|
1116
|
+
creationDate: DateTime<Utc>;
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
export interface Fido2CredentialNewView {
|
1120
|
+
credentialId: string;
|
1121
|
+
keyType: string;
|
1122
|
+
keyAlgorithm: string;
|
1123
|
+
keyCurve: string;
|
1124
|
+
rpId: string;
|
1125
|
+
userHandle: string | undefined;
|
1126
|
+
userName: string | undefined;
|
1127
|
+
counter: string;
|
1128
|
+
rpName: string | undefined;
|
1129
|
+
userDisplayName: string | undefined;
|
1130
|
+
creationDate: DateTime<Utc>;
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
export interface Login {
|
1134
|
+
username: EncString | undefined;
|
1135
|
+
password: EncString | undefined;
|
1136
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
1137
|
+
uris: LoginUri[] | undefined;
|
1138
|
+
totp: EncString | undefined;
|
1139
|
+
autofillOnPageLoad: boolean | undefined;
|
1140
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
export interface LoginView {
|
1144
|
+
username: string | undefined;
|
1145
|
+
password: string | undefined;
|
1146
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
1147
|
+
uris: LoginUriView[] | undefined;
|
1148
|
+
totp: string | undefined;
|
1149
|
+
autofillOnPageLoad: boolean | undefined;
|
1150
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
export interface LoginListView {
|
1154
|
+
fido2Credentials: Fido2CredentialListView[] | undefined;
|
1155
|
+
hasFido2: boolean;
|
1156
|
+
username: string | undefined;
|
1157
|
+
/**
|
1158
|
+
* The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
|
1159
|
+
*/
|
1160
|
+
totp: EncString | undefined;
|
1161
|
+
uris: LoginUriView[] | undefined;
|
1162
|
+
}
|
1163
|
+
|
1164
|
+
export interface SecureNote {
|
1165
|
+
type: SecureNoteType;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
export interface SecureNoteView {
|
1169
|
+
type: SecureNoteType;
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
/**
|
1173
|
+
* Request to add or edit a folder.
|
1174
|
+
*/
|
1175
|
+
export interface FolderAddEditRequest {
|
1176
|
+
/**
|
1177
|
+
* The new name of the folder.
|
1178
|
+
*/
|
1179
|
+
name: string;
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
/**
|
1183
|
+
* NewType wrapper for `FolderId`
|
1184
|
+
*/
|
1185
|
+
export type FolderId = Tagged<Uuid, "FolderId">;
|
1186
|
+
|
1187
|
+
export interface Folder {
|
1188
|
+
id: FolderId | undefined;
|
1189
|
+
name: EncString;
|
1190
|
+
revisionDate: DateTime<Utc>;
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
export interface FolderView {
|
1194
|
+
id: FolderId | undefined;
|
1195
|
+
name: string;
|
1196
|
+
revisionDate: DateTime<Utc>;
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
export interface DecryptError extends Error {
|
1200
|
+
name: "DecryptError";
|
1201
|
+
variant: "Crypto" | "VaultLocked";
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
export function isDecryptError(error: any): error is DecryptError;
|
1205
|
+
|
1206
|
+
export interface EncryptError extends Error {
|
1207
|
+
name: "EncryptError";
|
1208
|
+
variant: "Crypto" | "VaultLocked" | "MissingUserId";
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
export function isEncryptError(error: any): error is EncryptError;
|
1212
|
+
|
1213
|
+
export interface TotpResponse {
|
1214
|
+
/**
|
1215
|
+
* Generated TOTP code
|
1216
|
+
*/
|
1217
|
+
code: string;
|
1218
|
+
/**
|
1219
|
+
* Time period
|
1220
|
+
*/
|
1221
|
+
period: number;
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
export interface TotpError extends Error {
|
1225
|
+
name: "TotpError";
|
1226
|
+
variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
export function isTotpError(error: any): error is TotpError;
|
1230
|
+
|
1231
|
+
export interface PasswordHistoryView {
|
1232
|
+
password: string;
|
1233
|
+
lastUsedDate: DateTime<Utc>;
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
export interface PasswordHistory {
|
1237
|
+
password: EncString;
|
1238
|
+
lastUsedDate: DateTime<Utc>;
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
export interface GetFolderError extends Error {
|
1242
|
+
name: "GetFolderError";
|
1243
|
+
variant: "ItemNotFound" | "Crypto" | "RepositoryError";
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
export function isGetFolderError(error: any): error is GetFolderError;
|
1247
|
+
|
1248
|
+
export interface EditFolderError extends Error {
|
1249
|
+
name: "EditFolderError";
|
1250
|
+
variant:
|
1251
|
+
| "ItemNotFound"
|
1252
|
+
| "Crypto"
|
1253
|
+
| "Api"
|
1254
|
+
| "VaultParse"
|
1255
|
+
| "MissingField"
|
1256
|
+
| "RepositoryError"
|
1257
|
+
| "Uuid";
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
export function isEditFolderError(error: any): error is EditFolderError;
|
1261
|
+
|
1262
|
+
export interface CreateFolderError extends Error {
|
1263
|
+
name: "CreateFolderError";
|
1264
|
+
variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "RepositoryError";
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
export function isCreateFolderError(error: any): error is CreateFolderError;
|
1268
|
+
|
1269
|
+
export interface SshKeyView {
|
1270
|
+
/**
|
1271
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
1272
|
+
*/
|
1273
|
+
privateKey: string;
|
1274
|
+
/**
|
1275
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
1276
|
+
*/
|
1277
|
+
publicKey: string;
|
1278
|
+
/**
|
1279
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
1280
|
+
*/
|
1281
|
+
fingerprint: string;
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
export interface SshKey {
|
1285
|
+
/**
|
1286
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
1287
|
+
*/
|
1288
|
+
privateKey: EncString;
|
1289
|
+
/**
|
1290
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
1291
|
+
*/
|
1292
|
+
publicKey: EncString;
|
1293
|
+
/**
|
1294
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
1295
|
+
*/
|
1296
|
+
fingerprint: EncString;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
export interface LocalDataView {
|
1300
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
1301
|
+
lastLaunched: DateTime<Utc> | undefined;
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
export interface LocalData {
|
1305
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
1306
|
+
lastLaunched: DateTime<Utc> | undefined;
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
export interface IdentityView {
|
1310
|
+
title: string | undefined;
|
1311
|
+
firstName: string | undefined;
|
1312
|
+
middleName: string | undefined;
|
1313
|
+
lastName: string | undefined;
|
1314
|
+
address1: string | undefined;
|
1315
|
+
address2: string | undefined;
|
1316
|
+
address3: string | undefined;
|
1317
|
+
city: string | undefined;
|
1318
|
+
state: string | undefined;
|
1319
|
+
postalCode: string | undefined;
|
1320
|
+
country: string | undefined;
|
1321
|
+
company: string | undefined;
|
1322
|
+
email: string | undefined;
|
1323
|
+
phone: string | undefined;
|
1324
|
+
ssn: string | undefined;
|
1325
|
+
username: string | undefined;
|
1326
|
+
passportNumber: string | undefined;
|
1327
|
+
licenseNumber: string | undefined;
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
export interface Identity {
|
1331
|
+
title: EncString | undefined;
|
1332
|
+
firstName: EncString | undefined;
|
1333
|
+
middleName: EncString | undefined;
|
1334
|
+
lastName: EncString | undefined;
|
1335
|
+
address1: EncString | undefined;
|
1336
|
+
address2: EncString | undefined;
|
1337
|
+
address3: EncString | undefined;
|
1338
|
+
city: EncString | undefined;
|
1339
|
+
state: EncString | undefined;
|
1340
|
+
postalCode: EncString | undefined;
|
1341
|
+
country: EncString | undefined;
|
1342
|
+
company: EncString | undefined;
|
1343
|
+
email: EncString | undefined;
|
1344
|
+
phone: EncString | undefined;
|
1345
|
+
ssn: EncString | undefined;
|
1346
|
+
username: EncString | undefined;
|
1347
|
+
passportNumber: EncString | undefined;
|
1348
|
+
licenseNumber: EncString | undefined;
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
export interface CipherPermissions {
|
1352
|
+
delete: boolean;
|
1353
|
+
restore: boolean;
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
export interface CipherError extends Error {
|
1357
|
+
name: "CipherError";
|
1358
|
+
variant:
|
1359
|
+
| "MissingFieldError"
|
1360
|
+
| "VaultLocked"
|
1361
|
+
| "CryptoError"
|
1362
|
+
| "EncryptError"
|
1363
|
+
| "AttachmentsWithoutKeys";
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
export function isCipherError(error: any): error is CipherError;
|
1367
|
+
|
1368
|
+
/**
|
1369
|
+
* Minimal CardView only including the needed details for list views
|
1370
|
+
*/
|
1371
|
+
export interface CardListView {
|
1372
|
+
/**
|
1373
|
+
* The brand of the card, e.g. Visa, Mastercard, etc.
|
1374
|
+
*/
|
1375
|
+
brand: string | undefined;
|
1376
|
+
}
|
1377
|
+
|
1378
|
+
export interface CardView {
|
1379
|
+
cardholderName: string | undefined;
|
1380
|
+
expMonth: string | undefined;
|
1381
|
+
expYear: string | undefined;
|
1382
|
+
code: string | undefined;
|
1383
|
+
brand: string | undefined;
|
1384
|
+
number: string | undefined;
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
export interface Card {
|
1388
|
+
cardholderName: EncString | undefined;
|
1389
|
+
expMonth: EncString | undefined;
|
1390
|
+
expYear: EncString | undefined;
|
1391
|
+
code: EncString | undefined;
|
1392
|
+
brand: EncString | undefined;
|
1393
|
+
number: EncString | undefined;
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
export interface DecryptFileError extends Error {
|
1397
|
+
name: "DecryptFileError";
|
1398
|
+
variant: "Decrypt" | "Io";
|
1399
|
+
}
|
1400
|
+
|
1401
|
+
export function isDecryptFileError(error: any): error is DecryptFileError;
|
1402
|
+
|
1403
|
+
export interface EncryptFileError extends Error {
|
1404
|
+
name: "EncryptFileError";
|
1405
|
+
variant: "Encrypt" | "Io";
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
export function isEncryptFileError(error: any): error is EncryptFileError;
|
1409
|
+
|
1410
|
+
export interface AttachmentView {
|
1411
|
+
id: string | undefined;
|
1412
|
+
url: string | undefined;
|
1413
|
+
size: string | undefined;
|
1414
|
+
sizeName: string | undefined;
|
1415
|
+
fileName: string | undefined;
|
1416
|
+
key: EncString | undefined;
|
1417
|
+
/**
|
1418
|
+
* The decrypted attachmentkey in base64 format.
|
1419
|
+
*
|
1420
|
+
* **TEMPORARY FIELD**: This field is a temporary workaround to provide
|
1421
|
+
* decrypted attachment keys to the TypeScript client during the migration
|
1422
|
+
* process. It will be removed once the encryption/decryption logic is
|
1423
|
+
* fully migrated to the SDK.
|
1424
|
+
*
|
1425
|
+
* **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
|
1426
|
+
*
|
1427
|
+
* Do not rely on this field for long-term use.
|
1428
|
+
*/
|
1429
|
+
decryptedKey: string | undefined;
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
export interface Attachment {
|
1433
|
+
id: string | undefined;
|
1434
|
+
url: string | undefined;
|
1435
|
+
size: string | undefined;
|
1436
|
+
/**
|
1437
|
+
* Readable size, ex: \"4.2 KB\" or \"1.43 GB\
|
1438
|
+
*/
|
1439
|
+
sizeName: string | undefined;
|
1440
|
+
fileName: EncString | undefined;
|
1441
|
+
key: EncString | undefined;
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
export class AttachmentsClient {
|
1445
|
+
private constructor();
|
1446
|
+
free(): void;
|
1447
|
+
decrypt_buffer(
|
1448
|
+
cipher: Cipher,
|
1449
|
+
attachment: AttachmentView,
|
1450
|
+
encrypted_buffer: Uint8Array,
|
1451
|
+
): Uint8Array;
|
1452
|
+
}
|
1453
|
+
/**
|
1454
|
+
* Subclient containing auth functionality.
|
1455
|
+
*/
|
1456
|
+
export class AuthClient {
|
1457
|
+
private constructor();
|
221
1458
|
free(): void;
|
222
1459
|
/**
|
223
|
-
*
|
224
|
-
* @param {LogLevel | undefined} [log_level]
|
1460
|
+
* Client for send access functionality
|
225
1461
|
*/
|
226
|
-
|
1462
|
+
send_access(): SendAccessClient;
|
1463
|
+
}
|
1464
|
+
export class BitwardenClient {
|
1465
|
+
free(): void;
|
1466
|
+
constructor(token_provider: any, settings?: ClientSettings | null);
|
227
1467
|
/**
|
228
1468
|
* Test method, echoes back the input
|
229
|
-
* @param {string} msg
|
230
|
-
* @returns {string}
|
231
1469
|
*/
|
232
1470
|
echo(msg: string): string;
|
1471
|
+
version(): string;
|
1472
|
+
throw(msg: string): void;
|
233
1473
|
/**
|
234
|
-
*
|
1474
|
+
* Test method, calls http endpoint
|
235
1475
|
*/
|
236
|
-
|
1476
|
+
http_get(url: string): Promise<string>;
|
237
1477
|
/**
|
238
|
-
*
|
239
|
-
* @returns {Promise<void>}
|
1478
|
+
* Auth related operations.
|
240
1479
|
*/
|
241
|
-
|
1480
|
+
auth(): AuthClient;
|
1481
|
+
crypto(): CryptoClient;
|
1482
|
+
vault(): VaultClient;
|
242
1483
|
/**
|
243
|
-
*
|
244
|
-
* @param {string} url
|
245
|
-
* @returns {Promise<string>}
|
1484
|
+
* Constructs a specific client for platform-specific functionality
|
246
1485
|
*/
|
247
|
-
|
1486
|
+
platform(): PlatformClient;
|
1487
|
+
/**
|
1488
|
+
* Constructs a specific client for generating passwords and passphrases
|
1489
|
+
*/
|
1490
|
+
generator(): GeneratorClient;
|
1491
|
+
exporters(): ExporterClient;
|
1492
|
+
}
|
1493
|
+
export class CiphersClient {
|
1494
|
+
private constructor();
|
1495
|
+
free(): void;
|
1496
|
+
encrypt(cipher_view: CipherView): EncryptionContext;
|
1497
|
+
/**
|
1498
|
+
* Encrypt a cipher with the provided key. This should only be used when rotating encryption
|
1499
|
+
* keys in the Web client.
|
1500
|
+
*
|
1501
|
+
* Until key rotation is fully implemented in the SDK, this method must be provided the new
|
1502
|
+
* symmetric key in base64 format. See PM-23084
|
1503
|
+
*
|
1504
|
+
* If the cipher has a CipherKey, it will be re-encrypted with the new key.
|
1505
|
+
* If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
|
1506
|
+
* generated using the new key. Otherwise, the cipher's data will be encrypted with the new
|
1507
|
+
* key directly.
|
1508
|
+
*/
|
1509
|
+
encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): EncryptionContext;
|
1510
|
+
decrypt(cipher: Cipher): CipherView;
|
1511
|
+
decrypt_list(ciphers: Cipher[]): CipherListView[];
|
248
1512
|
/**
|
249
|
-
*
|
1513
|
+
* Decrypt cipher list with failures
|
1514
|
+
* Returns both successfully decrypted ciphers and any that failed to decrypt
|
250
1515
|
*/
|
251
|
-
|
1516
|
+
decrypt_list_with_failures(ciphers: Cipher[]): DecryptCipherListResult;
|
1517
|
+
decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
|
252
1518
|
/**
|
253
|
-
*
|
1519
|
+
* Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
|
1520
|
+
* Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
|
1521
|
+
* TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
|
1522
|
+
* encrypting the rest of the CipherView.
|
1523
|
+
* TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
|
254
1524
|
*/
|
255
|
-
|
1525
|
+
set_fido2_credentials(
|
1526
|
+
cipher_view: CipherView,
|
1527
|
+
fido2_credentials: Fido2CredentialFullView[],
|
1528
|
+
): CipherView;
|
1529
|
+
move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
|
1530
|
+
decrypt_fido2_private_key(cipher_view: CipherView): string;
|
1531
|
+
}
|
1532
|
+
export class CollectionViewNodeItem {
|
1533
|
+
private constructor();
|
1534
|
+
free(): void;
|
1535
|
+
get_item(): CollectionView;
|
1536
|
+
get_parent(): CollectionView | undefined;
|
1537
|
+
get_children(): CollectionView[];
|
1538
|
+
get_ancestors(): Map<any, any>;
|
256
1539
|
}
|
257
|
-
export class
|
1540
|
+
export class CollectionViewTree {
|
1541
|
+
private constructor();
|
1542
|
+
free(): void;
|
1543
|
+
get_item_by_id(collection_view: CollectionView): CollectionViewNodeItem | undefined;
|
1544
|
+
get_root_items(): CollectionViewNodeItem[];
|
1545
|
+
get_flat_items(): CollectionViewNodeItem[];
|
1546
|
+
}
|
1547
|
+
export class CollectionsClient {
|
1548
|
+
private constructor();
|
1549
|
+
free(): void;
|
1550
|
+
decrypt(collection: Collection): CollectionView;
|
1551
|
+
decrypt_list(collections: Collection[]): CollectionView[];
|
1552
|
+
/**
|
1553
|
+
*
|
1554
|
+
* Returns the vector of CollectionView objects in a tree structure based on its implemented
|
1555
|
+
* path().
|
1556
|
+
*/
|
1557
|
+
get_collection_tree(collections: CollectionView[]): CollectionViewTree;
|
1558
|
+
}
|
1559
|
+
/**
|
1560
|
+
* A client for the crypto operations.
|
1561
|
+
*/
|
1562
|
+
export class CryptoClient {
|
1563
|
+
private constructor();
|
258
1564
|
free(): void;
|
259
1565
|
/**
|
260
1566
|
* Initialization method for the user crypto. Needs to be called before any other crypto
|
261
1567
|
* operations.
|
262
|
-
* @param {InitUserCryptoRequest} req
|
263
|
-
* @returns {Promise<void>}
|
264
1568
|
*/
|
265
1569
|
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
266
1570
|
/**
|
267
1571
|
* Initialization method for the organization crypto. Needs to be called after
|
268
1572
|
* `initialize_user_crypto` but before any other crypto operations.
|
269
|
-
* @param {InitOrgCryptoRequest} req
|
270
|
-
* @returns {Promise<void>}
|
271
1573
|
*/
|
272
1574
|
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
1575
|
+
/**
|
1576
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
1577
|
+
* Crypto initialization not required.
|
1578
|
+
*/
|
1579
|
+
make_key_pair(user_key: B64): MakeKeyPairResponse;
|
1580
|
+
/**
|
1581
|
+
* Verifies a user's asymmetric keys by decrypting the private key with the provided user
|
1582
|
+
* key. Returns if the private key is decryptable and if it is a valid matching key.
|
1583
|
+
* Crypto initialization not required.
|
1584
|
+
*/
|
1585
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
1586
|
+
/**
|
1587
|
+
* Makes a new signing key pair and signs the public key for the user
|
1588
|
+
*/
|
1589
|
+
make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
|
1590
|
+
/**
|
1591
|
+
* Creates a rotated set of account keys for the current state
|
1592
|
+
*/
|
1593
|
+
get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
|
1594
|
+
/**
|
1595
|
+
* Protects the current user key with the provided PIN. The result can be stored and later
|
1596
|
+
* used to initialize another client instance by using the PIN and the PIN key with
|
1597
|
+
* `initialize_user_crypto`.
|
1598
|
+
*/
|
1599
|
+
enroll_pin(pin: string): EnrollPinResponse;
|
1600
|
+
/**
|
1601
|
+
* Protects the current user key with the provided PIN. The result can be stored and later
|
1602
|
+
* used to initialize another client instance by using the PIN and the PIN key with
|
1603
|
+
* `initialize_user_crypto`. The provided pin is encrypted with the user key.
|
1604
|
+
*/
|
1605
|
+
enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
|
1606
|
+
/**
|
1607
|
+
* Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
|
1608
|
+
* This is a stop-gap solution, until initialization of the SDK is used.
|
1609
|
+
*/
|
1610
|
+
unseal_password_protected_key_envelope(
|
1611
|
+
pin: string,
|
1612
|
+
envelope: PasswordProtectedKeyEnvelope,
|
1613
|
+
): Uint8Array;
|
1614
|
+
}
|
1615
|
+
export class ExporterClient {
|
1616
|
+
private constructor();
|
1617
|
+
free(): void;
|
1618
|
+
export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
|
1619
|
+
export_organization_vault(
|
1620
|
+
collections: Collection[],
|
1621
|
+
ciphers: Cipher[],
|
1622
|
+
format: ExportFormat,
|
1623
|
+
): string;
|
1624
|
+
/**
|
1625
|
+
* Credential Exchange Format (CXF)
|
1626
|
+
*
|
1627
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
1628
|
+
*
|
1629
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
1630
|
+
* Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
1631
|
+
*/
|
1632
|
+
export_cxf(account: Account, ciphers: Cipher[]): string;
|
1633
|
+
/**
|
1634
|
+
* Credential Exchange Format (CXF)
|
1635
|
+
*
|
1636
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
1637
|
+
*
|
1638
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
1639
|
+
* Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
1640
|
+
*/
|
1641
|
+
import_cxf(payload: string): Cipher[];
|
273
1642
|
}
|
274
|
-
|
1643
|
+
/**
|
1644
|
+
* Wrapper for folder specific functionality.
|
1645
|
+
*/
|
1646
|
+
export class FoldersClient {
|
1647
|
+
private constructor();
|
275
1648
|
free(): void;
|
276
1649
|
/**
|
277
|
-
*
|
278
|
-
|
279
|
-
|
1650
|
+
* Encrypt a [FolderView] to a [Folder].
|
1651
|
+
*/
|
1652
|
+
encrypt(folder_view: FolderView): Folder;
|
1653
|
+
/**
|
1654
|
+
* Encrypt a [Folder] to [FolderView].
|
280
1655
|
*/
|
281
1656
|
decrypt(folder: Folder): FolderView;
|
1657
|
+
/**
|
1658
|
+
* Decrypt a list of [Folder]s to a list of [FolderView]s.
|
1659
|
+
*/
|
1660
|
+
decrypt_list(folders: Folder[]): FolderView[];
|
1661
|
+
/**
|
1662
|
+
* Get all folders from state and decrypt them to a list of [FolderView].
|
1663
|
+
*/
|
1664
|
+
list(): Promise<FolderView[]>;
|
1665
|
+
/**
|
1666
|
+
* Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
|
1667
|
+
*/
|
1668
|
+
get(folder_id: string): Promise<FolderView>;
|
1669
|
+
/**
|
1670
|
+
* Create a new [Folder] and save it to the server.
|
1671
|
+
*/
|
1672
|
+
create(request: FolderAddEditRequest): Promise<FolderView>;
|
1673
|
+
/**
|
1674
|
+
* Edit the [Folder] and save it to the server.
|
1675
|
+
*/
|
1676
|
+
edit(folder_id: string, request: FolderAddEditRequest): Promise<FolderView>;
|
282
1677
|
}
|
283
|
-
export class
|
1678
|
+
export class GeneratorClient {
|
1679
|
+
private constructor();
|
284
1680
|
free(): void;
|
285
1681
|
/**
|
286
|
-
*
|
1682
|
+
* Generates a random password.
|
1683
|
+
*
|
1684
|
+
* The character sets and password length can be customized using the `input` parameter.
|
1685
|
+
*
|
1686
|
+
* # Examples
|
1687
|
+
*
|
1688
|
+
* ```
|
1689
|
+
* use bitwarden_core::Client;
|
1690
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
|
1691
|
+
*
|
1692
|
+
* async fn test() -> Result<(), PassphraseError> {
|
1693
|
+
* let input = PasswordGeneratorRequest {
|
1694
|
+
* lowercase: true,
|
1695
|
+
* uppercase: true,
|
1696
|
+
* numbers: true,
|
1697
|
+
* length: 20,
|
1698
|
+
* ..Default::default()
|
1699
|
+
* };
|
1700
|
+
* let password = Client::new(None).generator().password(input).unwrap();
|
1701
|
+
* println!("{}", password);
|
1702
|
+
* Ok(())
|
1703
|
+
* }
|
1704
|
+
* ```
|
1705
|
+
*/
|
1706
|
+
password(input: PasswordGeneratorRequest): string;
|
1707
|
+
/**
|
1708
|
+
* Generates a random passphrase.
|
1709
|
+
* A passphrase is a combination of random words separated by a character.
|
1710
|
+
* An example of passphrase is `correct horse battery staple`.
|
1711
|
+
*
|
1712
|
+
* The number of words and their case, the word separator, and the inclusion of
|
1713
|
+
* a number in the passphrase can be customized using the `input` parameter.
|
1714
|
+
*
|
1715
|
+
* # Examples
|
1716
|
+
*
|
1717
|
+
* ```
|
1718
|
+
* use bitwarden_core::Client;
|
1719
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
|
1720
|
+
*
|
1721
|
+
* async fn test() -> Result<(), PassphraseError> {
|
1722
|
+
* let input = PassphraseGeneratorRequest {
|
1723
|
+
* num_words: 4,
|
1724
|
+
* ..Default::default()
|
1725
|
+
* };
|
1726
|
+
* let passphrase = Client::new(None).generator().passphrase(input).unwrap();
|
1727
|
+
* println!("{}", passphrase);
|
1728
|
+
* Ok(())
|
1729
|
+
* }
|
1730
|
+
* ```
|
1731
|
+
*/
|
1732
|
+
passphrase(input: PassphraseGeneratorRequest): string;
|
1733
|
+
}
|
1734
|
+
export class IncomingMessage {
|
1735
|
+
free(): void;
|
1736
|
+
constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
|
1737
|
+
/**
|
1738
|
+
* Try to parse the payload as JSON.
|
1739
|
+
* @returns The parsed JSON value, or undefined if the payload is not valid JSON.
|
1740
|
+
*/
|
1741
|
+
parse_payload_as_json(): any;
|
1742
|
+
payload: Uint8Array;
|
1743
|
+
destination: Endpoint;
|
1744
|
+
source: Endpoint;
|
1745
|
+
get topic(): string | undefined;
|
1746
|
+
set topic(value: string | null | undefined);
|
1747
|
+
}
|
1748
|
+
/**
|
1749
|
+
* JavaScript wrapper around the IPC client. For more information, see the
|
1750
|
+
* [IpcClient] documentation.
|
1751
|
+
*/
|
1752
|
+
export class IpcClient {
|
1753
|
+
free(): void;
|
1754
|
+
constructor(communication_provider: IpcCommunicationBackend);
|
1755
|
+
start(): Promise<void>;
|
1756
|
+
isRunning(): Promise<boolean>;
|
1757
|
+
send(message: OutgoingMessage): Promise<void>;
|
1758
|
+
subscribe(): Promise<IpcClientSubscription>;
|
1759
|
+
}
|
1760
|
+
/**
|
1761
|
+
* JavaScript wrapper around the IPC client subscription. For more information, see the
|
1762
|
+
* [IpcClientSubscription](crate::IpcClientSubscription) documentation.
|
1763
|
+
*/
|
1764
|
+
export class IpcClientSubscription {
|
1765
|
+
private constructor();
|
1766
|
+
free(): void;
|
1767
|
+
receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
|
1768
|
+
}
|
1769
|
+
/**
|
1770
|
+
* JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
|
1771
|
+
*/
|
1772
|
+
export class IpcCommunicationBackend {
|
1773
|
+
free(): void;
|
1774
|
+
/**
|
1775
|
+
* Creates a new instance of the JavaScript communication backend.
|
1776
|
+
*/
|
1777
|
+
constructor(sender: IpcCommunicationBackendSender);
|
1778
|
+
/**
|
1779
|
+
* Used by JavaScript to provide an incoming message to the IPC framework.
|
1780
|
+
*/
|
1781
|
+
receive(message: IncomingMessage): void;
|
1782
|
+
}
|
1783
|
+
export class OutgoingMessage {
|
1784
|
+
free(): void;
|
1785
|
+
constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
|
1786
|
+
/**
|
1787
|
+
* Create a new message and encode the payload as JSON.
|
1788
|
+
*/
|
1789
|
+
static new_json_payload(
|
1790
|
+
payload: any,
|
1791
|
+
destination: Endpoint,
|
1792
|
+
topic?: string | null,
|
1793
|
+
): OutgoingMessage;
|
1794
|
+
payload: Uint8Array;
|
1795
|
+
destination: Endpoint;
|
1796
|
+
get topic(): string | undefined;
|
1797
|
+
set topic(value: string | null | undefined);
|
1798
|
+
}
|
1799
|
+
export class PlatformClient {
|
1800
|
+
private constructor();
|
1801
|
+
free(): void;
|
1802
|
+
state(): StateClient;
|
1803
|
+
/**
|
1804
|
+
* Load feature flags into the client
|
1805
|
+
*/
|
1806
|
+
load_flags(flags: FeatureFlags): void;
|
1807
|
+
}
|
1808
|
+
/**
|
1809
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
1810
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
1811
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
1812
|
+
* responsible for state and keys.
|
1813
|
+
*/
|
1814
|
+
export class PureCrypto {
|
1815
|
+
private constructor();
|
1816
|
+
free(): void;
|
1817
|
+
/**
|
1818
|
+
* DEPRECATED: Use `symmetric_decrypt_string` instead.
|
1819
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
1820
|
+
*/
|
1821
|
+
static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
|
1822
|
+
static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
|
1823
|
+
static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
|
1824
|
+
/**
|
1825
|
+
* DEPRECATED: Use `symmetric_decrypt_filedata` instead.
|
1826
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
1827
|
+
*/
|
1828
|
+
static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
1829
|
+
static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
1830
|
+
static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
|
1831
|
+
/**
|
1832
|
+
* DEPRECATED: Only used by send keys
|
1833
|
+
*/
|
1834
|
+
static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
|
1835
|
+
static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
|
1836
|
+
static decrypt_user_key_with_master_password(
|
1837
|
+
encrypted_user_key: string,
|
1838
|
+
master_password: string,
|
1839
|
+
email: string,
|
1840
|
+
kdf: Kdf,
|
1841
|
+
): Uint8Array;
|
1842
|
+
static encrypt_user_key_with_master_password(
|
1843
|
+
user_key: Uint8Array,
|
1844
|
+
master_password: string,
|
1845
|
+
email: string,
|
1846
|
+
kdf: Kdf,
|
1847
|
+
): string;
|
1848
|
+
static make_user_key_aes256_cbc_hmac(): Uint8Array;
|
1849
|
+
static make_user_key_xchacha20_poly1305(): Uint8Array;
|
1850
|
+
/**
|
1851
|
+
* Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
|
1852
|
+
* as an EncString.
|
1853
|
+
*/
|
1854
|
+
static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
|
1855
|
+
/**
|
1856
|
+
* Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
|
1857
|
+
* unwrapped key as a serialized byte array.
|
1858
|
+
*/
|
1859
|
+
static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
1860
|
+
/**
|
1861
|
+
* Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
|
1862
|
+
* key. Note: Usually, a public key is - by definition - public, so this should not be
|
1863
|
+
* used. The specific use-case for this function is to enable rotateable key sets, where
|
1864
|
+
* the "public key" is not public, with the intent of preventing the server from being able
|
1865
|
+
* to overwrite the user key unlocked by the rotateable keyset.
|
1866
|
+
*/
|
1867
|
+
static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
1868
|
+
/**
|
1869
|
+
* Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
|
1870
|
+
* wrapping key.
|
1871
|
+
*/
|
1872
|
+
static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
1873
|
+
/**
|
1874
|
+
* Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
|
1875
|
+
* key,
|
1876
|
+
*/
|
1877
|
+
static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
1878
|
+
/**
|
1879
|
+
* Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
|
1880
|
+
* wrapping key.
|
1881
|
+
*/
|
1882
|
+
static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
1883
|
+
/**
|
1884
|
+
* Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key)
|
1885
|
+
* in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
|
1886
|
+
* the sender's authenticity cannot be verified by the recipient.
|
1887
|
+
*/
|
1888
|
+
static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
|
1889
|
+
/**
|
1890
|
+
* Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8
|
1891
|
+
* DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
|
1892
|
+
* recipient.
|
1893
|
+
*/
|
1894
|
+
static decapsulate_key_unsigned(
|
1895
|
+
encapsulated_key: string,
|
1896
|
+
decapsulation_key: Uint8Array,
|
1897
|
+
): Uint8Array;
|
1898
|
+
/**
|
1899
|
+
* Given a wrapped signing key and the symmetric key it is wrapped with, this returns
|
1900
|
+
* the corresponding verifying key.
|
1901
|
+
*/
|
1902
|
+
static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
|
1903
|
+
/**
|
1904
|
+
* Returns the algorithm used for the given verifying key.
|
1905
|
+
*/
|
1906
|
+
static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
|
1907
|
+
/**
|
1908
|
+
* For a given signing identity (verifying key), this function verifies that the signing
|
1909
|
+
* identity claimed ownership of the public key. This is a one-sided claim and merely shows
|
1910
|
+
* that the signing identity has the intent to receive messages encrypted to the public
|
1911
|
+
* key.
|
1912
|
+
*/
|
1913
|
+
static verify_and_unwrap_signed_public_key(
|
1914
|
+
signed_public_key: Uint8Array,
|
1915
|
+
verifying_key: Uint8Array,
|
1916
|
+
): Uint8Array;
|
1917
|
+
/**
|
1918
|
+
* Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
|
1919
|
+
*/
|
1920
|
+
static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
|
1921
|
+
}
|
1922
|
+
export class SendAccessClient {
|
1923
|
+
private constructor();
|
1924
|
+
free(): void;
|
1925
|
+
/**
|
1926
|
+
* Request an access token for the provided send
|
1927
|
+
*/
|
1928
|
+
request_send_access_token(request: string): Promise<string>;
|
1929
|
+
}
|
1930
|
+
export class StateClient {
|
1931
|
+
private constructor();
|
1932
|
+
free(): void;
|
1933
|
+
register_cipher_repository(cipher_repository: Repository<Cipher>): void;
|
1934
|
+
initialize_state(configuration: IndexedDbConfiguration): Promise<void>;
|
1935
|
+
register_folder_repository(store: Repository<Folder>): void;
|
1936
|
+
}
|
1937
|
+
export class TotpClient {
|
1938
|
+
private constructor();
|
1939
|
+
free(): void;
|
1940
|
+
/**
|
1941
|
+
* Generates a TOTP code from a provided key
|
1942
|
+
*
|
1943
|
+
* # Arguments
|
1944
|
+
* - `key` - Can be:
|
1945
|
+
* - A base32 encoded string
|
1946
|
+
* - OTP Auth URI
|
1947
|
+
* - Steam URI
|
1948
|
+
* - `time_ms` - Optional timestamp in milliseconds
|
1949
|
+
*/
|
1950
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
1951
|
+
}
|
1952
|
+
export class VaultClient {
|
1953
|
+
private constructor();
|
1954
|
+
free(): void;
|
1955
|
+
/**
|
1956
|
+
* Attachment related operations.
|
1957
|
+
*/
|
1958
|
+
attachments(): AttachmentsClient;
|
1959
|
+
/**
|
1960
|
+
* Cipher related operations.
|
1961
|
+
*/
|
1962
|
+
ciphers(): CiphersClient;
|
1963
|
+
/**
|
1964
|
+
* Folder related operations.
|
1965
|
+
*/
|
1966
|
+
folders(): FoldersClient;
|
1967
|
+
/**
|
1968
|
+
* TOTP related operations.
|
1969
|
+
*/
|
1970
|
+
totp(): TotpClient;
|
1971
|
+
/**
|
1972
|
+
* Collection related operations.
|
287
1973
|
*/
|
288
|
-
|
1974
|
+
collections(): CollectionsClient;
|
289
1975
|
}
|