@bitwarden/sdk-internal 0.2.0-main.17 → 0.2.0-main.170
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 +1129 -69
- package/bitwarden_wasm_internal_bg.js +3043 -591
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +308 -37
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +1129 -69
- package/node/bitwarden_wasm_internal.js +3063 -598
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +308 -37
- package/package.json +5 -4
|
@@ -1,10 +1,80 @@
|
|
|
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
|
|
6
30
|
*/
|
|
7
|
-
export function
|
|
31
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
|
|
32
|
+
export enum CardLinkedIdType {
|
|
33
|
+
CardholderName = 300,
|
|
34
|
+
ExpMonth = 301,
|
|
35
|
+
ExpYear = 302,
|
|
36
|
+
Code = 303,
|
|
37
|
+
Brand = 304,
|
|
38
|
+
Number = 305,
|
|
39
|
+
}
|
|
40
|
+
export enum CipherRepromptType {
|
|
41
|
+
None = 0,
|
|
42
|
+
Password = 1,
|
|
43
|
+
}
|
|
44
|
+
export enum CipherType {
|
|
45
|
+
Login = 1,
|
|
46
|
+
SecureNote = 2,
|
|
47
|
+
Card = 3,
|
|
48
|
+
Identity = 4,
|
|
49
|
+
SshKey = 5,
|
|
50
|
+
}
|
|
51
|
+
export enum FieldType {
|
|
52
|
+
Text = 0,
|
|
53
|
+
Hidden = 1,
|
|
54
|
+
Boolean = 2,
|
|
55
|
+
Linked = 3,
|
|
56
|
+
}
|
|
57
|
+
export enum IdentityLinkedIdType {
|
|
58
|
+
Title = 400,
|
|
59
|
+
MiddleName = 401,
|
|
60
|
+
Address1 = 402,
|
|
61
|
+
Address2 = 403,
|
|
62
|
+
Address3 = 404,
|
|
63
|
+
City = 405,
|
|
64
|
+
State = 406,
|
|
65
|
+
PostalCode = 407,
|
|
66
|
+
Country = 408,
|
|
67
|
+
Company = 409,
|
|
68
|
+
Email = 410,
|
|
69
|
+
Phone = 411,
|
|
70
|
+
Ssn = 412,
|
|
71
|
+
Username = 413,
|
|
72
|
+
PassportNumber = 414,
|
|
73
|
+
LicenseNumber = 415,
|
|
74
|
+
FirstName = 416,
|
|
75
|
+
LastName = 417,
|
|
76
|
+
FullName = 418,
|
|
77
|
+
}
|
|
8
78
|
export enum LogLevel {
|
|
9
79
|
Trace = 0,
|
|
10
80
|
Debug = 1,
|
|
@@ -12,6 +82,24 @@ export enum LogLevel {
|
|
|
12
82
|
Warn = 3,
|
|
13
83
|
Error = 4,
|
|
14
84
|
}
|
|
85
|
+
export enum LoginLinkedIdType {
|
|
86
|
+
Username = 100,
|
|
87
|
+
Password = 101,
|
|
88
|
+
}
|
|
89
|
+
export enum SecureNoteType {
|
|
90
|
+
Generic = 0,
|
|
91
|
+
}
|
|
92
|
+
export enum UriMatchType {
|
|
93
|
+
Domain = 0,
|
|
94
|
+
Host = 1,
|
|
95
|
+
StartsWith = 2,
|
|
96
|
+
Exact = 3,
|
|
97
|
+
RegularExpression = 4,
|
|
98
|
+
Never = 5,
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* State used for initializing the user cryptographic state.
|
|
102
|
+
*/
|
|
15
103
|
export interface InitUserCryptoRequest {
|
|
16
104
|
/**
|
|
17
105
|
* The user\'s KDF parameters, as received from the prelogin request
|
|
@@ -31,6 +119,9 @@ export interface InitUserCryptoRequest {
|
|
|
31
119
|
method: InitUserCryptoMethod;
|
|
32
120
|
}
|
|
33
121
|
|
|
122
|
+
/**
|
|
123
|
+
* The crypto method used to initialize the user cryptographic state.
|
|
124
|
+
*/
|
|
34
125
|
export type InitUserCryptoMethod =
|
|
35
126
|
| { password: { password: string; user_key: string } }
|
|
36
127
|
| { decryptedKey: { decrypted_user_key: string } }
|
|
@@ -40,46 +131,73 @@ export type InitUserCryptoMethod =
|
|
|
40
131
|
deviceKey: {
|
|
41
132
|
device_key: string;
|
|
42
133
|
protected_device_private_key: EncString;
|
|
43
|
-
device_protected_user_key:
|
|
134
|
+
device_protected_user_key: UnsignedSharedKey;
|
|
44
135
|
};
|
|
45
136
|
}
|
|
46
137
|
| { keyConnector: { master_key: string; user_key: string } };
|
|
47
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Auth requests supports multiple initialization methods.
|
|
141
|
+
*/
|
|
48
142
|
export type AuthRequestMethod =
|
|
49
|
-
| { userKey: { protected_user_key:
|
|
50
|
-
| { masterKey: { protected_master_key:
|
|
143
|
+
| { userKey: { protected_user_key: UnsignedSharedKey } }
|
|
144
|
+
| { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
|
|
51
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Represents the request to initialize the user\'s organizational cryptographic state.
|
|
148
|
+
*/
|
|
52
149
|
export interface InitOrgCryptoRequest {
|
|
53
150
|
/**
|
|
54
151
|
* The encryption keys for all the organizations the user is a part of
|
|
55
152
|
*/
|
|
56
|
-
organizationKeys: Map<Uuid,
|
|
153
|
+
organizationKeys: Map<Uuid, UnsignedSharedKey>;
|
|
57
154
|
}
|
|
58
155
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Response from the `make_key_pair` function
|
|
158
|
+
*/
|
|
159
|
+
export interface MakeKeyPairResponse {
|
|
160
|
+
/**
|
|
161
|
+
* The user\'s public key
|
|
162
|
+
*/
|
|
163
|
+
userPublicKey: string;
|
|
164
|
+
/**
|
|
165
|
+
* User\'s private key, encrypted with the user key
|
|
166
|
+
*/
|
|
167
|
+
userKeyEncryptedPrivateKey: EncString;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Request for `verify_asymmetric_keys`.
|
|
172
|
+
*/
|
|
173
|
+
export interface VerifyAsymmetricKeysRequest {
|
|
174
|
+
/**
|
|
175
|
+
* The user\'s user key
|
|
176
|
+
*/
|
|
177
|
+
userKey: string;
|
|
178
|
+
/**
|
|
179
|
+
* The user\'s public key
|
|
180
|
+
*/
|
|
181
|
+
userPublicKey: string;
|
|
182
|
+
/**
|
|
183
|
+
* User\'s private key, encrypted with the user key
|
|
184
|
+
*/
|
|
185
|
+
userKeyEncryptedPrivateKey: EncString;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Response for `verify_asymmetric_keys`.
|
|
190
|
+
*/
|
|
191
|
+
export interface VerifyAsymmetricKeysResponse {
|
|
192
|
+
/**
|
|
193
|
+
* Whether the user\'s private key was decryptable by the user key.
|
|
194
|
+
*/
|
|
195
|
+
privateKeyDecryptable: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Whether the user\'s private key was a valid RSA key and matched the public key provided.
|
|
198
|
+
*/
|
|
199
|
+
validPrivateKey: boolean;
|
|
200
|
+
}
|
|
83
201
|
|
|
84
202
|
export interface EncryptionSettingsError extends Error {
|
|
85
203
|
name: "EncryptionSettingsError";
|
|
@@ -152,7 +270,7 @@ export interface ClientSettings {
|
|
|
152
270
|
deviceType?: DeviceType;
|
|
153
271
|
}
|
|
154
272
|
|
|
155
|
-
export type
|
|
273
|
+
export type UnsignedSharedKey = string;
|
|
156
274
|
|
|
157
275
|
export type EncString = string;
|
|
158
276
|
|
|
@@ -166,14 +284,218 @@ export type Kdf =
|
|
|
166
284
|
| { pBKDF2: { iterations: NonZeroU32 } }
|
|
167
285
|
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
|
168
286
|
|
|
169
|
-
export interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
287
|
+
export interface CryptoError extends Error {
|
|
288
|
+
name: "CryptoError";
|
|
289
|
+
variant:
|
|
290
|
+
| "InvalidKey"
|
|
291
|
+
| "InvalidMac"
|
|
292
|
+
| "MacNotProvided"
|
|
293
|
+
| "KeyDecrypt"
|
|
294
|
+
| "InvalidKeyLen"
|
|
295
|
+
| "InvalidUtf8String"
|
|
296
|
+
| "MissingKey"
|
|
297
|
+
| "MissingField"
|
|
298
|
+
| "MissingKeyId"
|
|
299
|
+
| "ReadOnlyKeyStore"
|
|
300
|
+
| "InsufficientKdfParameters"
|
|
301
|
+
| "EncString"
|
|
302
|
+
| "RsaError"
|
|
303
|
+
| "FingerprintError"
|
|
304
|
+
| "ArgonError"
|
|
305
|
+
| "ZeroNumber"
|
|
306
|
+
| "OperationNotSupported"
|
|
307
|
+
| "WrongKeyType"
|
|
308
|
+
| "InvalidNonceLength";
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function isCryptoError(error: any): error is CryptoError;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Temporary struct to hold metadata related to current account
|
|
315
|
+
*
|
|
316
|
+
* Eventually the SDK itself should have this state and we get rid of this struct.
|
|
317
|
+
*/
|
|
318
|
+
export interface Account {
|
|
319
|
+
id: Uuid;
|
|
320
|
+
email: string;
|
|
321
|
+
name: string | undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
|
|
325
|
+
|
|
326
|
+
export interface ExportError extends Error {
|
|
327
|
+
name: "ExportError";
|
|
328
|
+
variant:
|
|
329
|
+
| "MissingField"
|
|
330
|
+
| "NotAuthenticated"
|
|
331
|
+
| "VaultLocked"
|
|
332
|
+
| "Csv"
|
|
333
|
+
| "CxfError"
|
|
334
|
+
| "Json"
|
|
335
|
+
| "EncryptedJsonError"
|
|
336
|
+
| "BitwardenCryptoError"
|
|
337
|
+
| "CipherError";
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function isExportError(error: any): error is ExportError;
|
|
341
|
+
|
|
342
|
+
export type UsernameGeneratorRequest =
|
|
343
|
+
| { word: { capitalize: boolean; include_number: boolean } }
|
|
344
|
+
| { subaddress: { type: AppendType; email: string } }
|
|
345
|
+
| { catchall: { type: AppendType; domain: string } }
|
|
346
|
+
| { forwarded: { service: ForwarderServiceType; website: string | undefined } };
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Configures the email forwarding service to use.
|
|
350
|
+
* For instructions on how to configure each service, see the documentation:
|
|
351
|
+
* <https://bitwarden.com/help/generator/#username-types>
|
|
352
|
+
*/
|
|
353
|
+
export type ForwarderServiceType =
|
|
354
|
+
| { addyIo: { api_token: string; domain: string; base_url: string } }
|
|
355
|
+
| { duckDuckGo: { token: string } }
|
|
356
|
+
| { firefox: { api_token: string } }
|
|
357
|
+
| { fastmail: { api_token: string } }
|
|
358
|
+
| { forwardEmail: { api_token: string; domain: string } }
|
|
359
|
+
| { simpleLogin: { api_key: string; base_url: string } };
|
|
360
|
+
|
|
361
|
+
export type AppendType = "random" | { websiteName: { website: string } };
|
|
362
|
+
|
|
363
|
+
export interface UsernameError extends Error {
|
|
364
|
+
name: "UsernameError";
|
|
365
|
+
variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function isUsernameError(error: any): error is UsernameError;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Password generator request options.
|
|
372
|
+
*/
|
|
373
|
+
export interface PasswordGeneratorRequest {
|
|
374
|
+
/**
|
|
375
|
+
* Include lowercase characters (a-z).
|
|
376
|
+
*/
|
|
377
|
+
lowercase: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Include uppercase characters (A-Z).
|
|
380
|
+
*/
|
|
381
|
+
uppercase: boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Include numbers (0-9).
|
|
384
|
+
*/
|
|
385
|
+
numbers: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Include special characters: ! @ # $ % ^ & *
|
|
388
|
+
*/
|
|
389
|
+
special: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* The length of the generated password.
|
|
392
|
+
* Note that the password length must be greater than the sum of all the minimums.
|
|
393
|
+
*/
|
|
394
|
+
length: number;
|
|
395
|
+
/**
|
|
396
|
+
* When set to true, the generated password will not contain ambiguous characters.
|
|
397
|
+
* The ambiguous characters are: I, O, l, 0, 1
|
|
398
|
+
*/
|
|
399
|
+
avoidAmbiguous: boolean;
|
|
400
|
+
/**
|
|
401
|
+
* The minimum number of lowercase characters in the generated password.
|
|
402
|
+
* When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
|
|
403
|
+
*/
|
|
404
|
+
minLowercase: number | undefined;
|
|
405
|
+
/**
|
|
406
|
+
* The minimum number of uppercase characters in the generated password.
|
|
407
|
+
* When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
|
|
408
|
+
*/
|
|
409
|
+
minUppercase: number | undefined;
|
|
410
|
+
/**
|
|
411
|
+
* The minimum number of numbers in the generated password.
|
|
412
|
+
* When set, the value must be between 1 and 9. This value is ignored if numbers is false.
|
|
413
|
+
*/
|
|
414
|
+
minNumber: number | undefined;
|
|
415
|
+
/**
|
|
416
|
+
* The minimum number of special characters in the generated password.
|
|
417
|
+
* When set, the value must be between 1 and 9. This value is ignored if special is false.
|
|
418
|
+
*/
|
|
419
|
+
minSpecial: number | undefined;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export interface PasswordError extends Error {
|
|
423
|
+
name: "PasswordError";
|
|
424
|
+
variant: "NoCharacterSetEnabled" | "InvalidLength";
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function isPasswordError(error: any): error is PasswordError;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Passphrase generator request options.
|
|
431
|
+
*/
|
|
432
|
+
export interface PassphraseGeneratorRequest {
|
|
433
|
+
/**
|
|
434
|
+
* Number of words in the generated passphrase.
|
|
435
|
+
* This value must be between 3 and 20.
|
|
436
|
+
*/
|
|
437
|
+
numWords: number;
|
|
438
|
+
/**
|
|
439
|
+
* Character separator between words in the generated passphrase. The value cannot be empty.
|
|
440
|
+
*/
|
|
441
|
+
wordSeparator: string;
|
|
442
|
+
/**
|
|
443
|
+
* When set to true, capitalize the first letter of each word in the generated passphrase.
|
|
444
|
+
*/
|
|
445
|
+
capitalize: boolean;
|
|
446
|
+
/**
|
|
447
|
+
* When set to true, include a number at the end of one of the words in the generated
|
|
448
|
+
* passphrase.
|
|
449
|
+
*/
|
|
450
|
+
includeNumber: boolean;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface PassphraseError extends Error {
|
|
454
|
+
name: "PassphraseError";
|
|
455
|
+
variant: "InvalidNumWords";
|
|
173
456
|
}
|
|
174
457
|
|
|
458
|
+
export function isPassphraseError(error: any): error is PassphraseError;
|
|
459
|
+
|
|
460
|
+
export type Endpoint =
|
|
461
|
+
| { Web: { id: number } }
|
|
462
|
+
| "BrowserForeground"
|
|
463
|
+
| "BrowserBackground"
|
|
464
|
+
| "DesktopRenderer"
|
|
465
|
+
| "DesktopMain";
|
|
466
|
+
|
|
467
|
+
export interface IpcCommunicationBackendSender {
|
|
468
|
+
send(message: OutgoingMessage): Promise<void>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface ChannelError extends Error {
|
|
472
|
+
name: "ChannelError";
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export function isChannelError(error: any): error is ChannelError;
|
|
476
|
+
|
|
477
|
+
export interface DeserializeError extends Error {
|
|
478
|
+
name: "DeserializeError";
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export function isDeserializeError(error: any): error is DeserializeError;
|
|
482
|
+
|
|
175
483
|
export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
|
176
484
|
|
|
485
|
+
export interface SshKeyExportError extends Error {
|
|
486
|
+
name: "SshKeyExportError";
|
|
487
|
+
variant: "KeyConversionError";
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export function isSshKeyExportError(error: any): error is SshKeyExportError;
|
|
491
|
+
|
|
492
|
+
export interface SshKeyImportError extends Error {
|
|
493
|
+
name: "SshKeyImportError";
|
|
494
|
+
variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export function isSshKeyImportError(error: any): error is SshKeyImportError;
|
|
498
|
+
|
|
177
499
|
export interface KeyGenerationError extends Error {
|
|
178
500
|
name: "KeyGenerationError";
|
|
179
501
|
variant: "KeyGenerationError" | "KeyConversionError";
|
|
@@ -181,6 +503,226 @@ export interface KeyGenerationError extends Error {
|
|
|
181
503
|
|
|
182
504
|
export function isKeyGenerationError(error: any): error is KeyGenerationError;
|
|
183
505
|
|
|
506
|
+
export interface Cipher {
|
|
507
|
+
id: Uuid | undefined;
|
|
508
|
+
organizationId: Uuid | undefined;
|
|
509
|
+
folderId: Uuid | undefined;
|
|
510
|
+
collectionIds: Uuid[];
|
|
511
|
+
/**
|
|
512
|
+
* More recent ciphers uses individual encryption keys to encrypt the other fields of the
|
|
513
|
+
* Cipher.
|
|
514
|
+
*/
|
|
515
|
+
key: EncString | undefined;
|
|
516
|
+
name: EncString;
|
|
517
|
+
notes: EncString | undefined;
|
|
518
|
+
type: CipherType;
|
|
519
|
+
login: Login | undefined;
|
|
520
|
+
identity: Identity | undefined;
|
|
521
|
+
card: Card | undefined;
|
|
522
|
+
secureNote: SecureNote | undefined;
|
|
523
|
+
sshKey: SshKey | undefined;
|
|
524
|
+
favorite: boolean;
|
|
525
|
+
reprompt: CipherRepromptType;
|
|
526
|
+
organizationUseTotp: boolean;
|
|
527
|
+
edit: boolean;
|
|
528
|
+
permissions: CipherPermissions | undefined;
|
|
529
|
+
viewPassword: boolean;
|
|
530
|
+
localData: LocalData | undefined;
|
|
531
|
+
attachments: Attachment[] | undefined;
|
|
532
|
+
fields: Field[] | undefined;
|
|
533
|
+
passwordHistory: PasswordHistory[] | undefined;
|
|
534
|
+
creationDate: DateTime<Utc>;
|
|
535
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
536
|
+
revisionDate: DateTime<Utc>;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export interface CipherView {
|
|
540
|
+
id: Uuid | undefined;
|
|
541
|
+
organizationId: Uuid | undefined;
|
|
542
|
+
folderId: Uuid | undefined;
|
|
543
|
+
collectionIds: Uuid[];
|
|
544
|
+
/**
|
|
545
|
+
* Temporary, required to support re-encrypting existing items.
|
|
546
|
+
*/
|
|
547
|
+
key: EncString | undefined;
|
|
548
|
+
name: string;
|
|
549
|
+
notes: string | undefined;
|
|
550
|
+
type: CipherType;
|
|
551
|
+
login: LoginView | undefined;
|
|
552
|
+
identity: IdentityView | undefined;
|
|
553
|
+
card: CardView | undefined;
|
|
554
|
+
secureNote: SecureNoteView | undefined;
|
|
555
|
+
sshKey: SshKeyView | undefined;
|
|
556
|
+
favorite: boolean;
|
|
557
|
+
reprompt: CipherRepromptType;
|
|
558
|
+
organizationUseTotp: boolean;
|
|
559
|
+
edit: boolean;
|
|
560
|
+
permissions: CipherPermissions | undefined;
|
|
561
|
+
viewPassword: boolean;
|
|
562
|
+
localData: LocalDataView | undefined;
|
|
563
|
+
attachments: AttachmentView[] | undefined;
|
|
564
|
+
fields: FieldView[] | undefined;
|
|
565
|
+
passwordHistory: PasswordHistoryView[] | undefined;
|
|
566
|
+
creationDate: DateTime<Utc>;
|
|
567
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
568
|
+
revisionDate: DateTime<Utc>;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export type CipherListViewType =
|
|
572
|
+
| { login: LoginListView }
|
|
573
|
+
| "secureNote"
|
|
574
|
+
| "card"
|
|
575
|
+
| "identity"
|
|
576
|
+
| "sshKey";
|
|
577
|
+
|
|
578
|
+
export interface CipherListView {
|
|
579
|
+
id: Uuid | undefined;
|
|
580
|
+
organizationId: Uuid | undefined;
|
|
581
|
+
folderId: Uuid | undefined;
|
|
582
|
+
collectionIds: Uuid[];
|
|
583
|
+
/**
|
|
584
|
+
* Temporary, required to support calculating TOTP from CipherListView.
|
|
585
|
+
*/
|
|
586
|
+
key: EncString | undefined;
|
|
587
|
+
name: string;
|
|
588
|
+
subtitle: string;
|
|
589
|
+
type: CipherListViewType;
|
|
590
|
+
favorite: boolean;
|
|
591
|
+
reprompt: CipherRepromptType;
|
|
592
|
+
organizationUseTotp: boolean;
|
|
593
|
+
edit: boolean;
|
|
594
|
+
permissions: CipherPermissions | undefined;
|
|
595
|
+
viewPassword: boolean;
|
|
596
|
+
/**
|
|
597
|
+
* The number of attachments
|
|
598
|
+
*/
|
|
599
|
+
attachments: number;
|
|
600
|
+
creationDate: DateTime<Utc>;
|
|
601
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
602
|
+
revisionDate: DateTime<Utc>;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export interface Field {
|
|
606
|
+
name: EncString | undefined;
|
|
607
|
+
value: EncString | undefined;
|
|
608
|
+
type: FieldType;
|
|
609
|
+
linkedId: LinkedIdType | undefined;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export interface FieldView {
|
|
613
|
+
name: string | undefined;
|
|
614
|
+
value: string | undefined;
|
|
615
|
+
type: FieldType;
|
|
616
|
+
linkedId: LinkedIdType | undefined;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
|
|
620
|
+
|
|
621
|
+
export interface LoginUri {
|
|
622
|
+
uri: EncString | undefined;
|
|
623
|
+
match: UriMatchType | undefined;
|
|
624
|
+
uriChecksum: EncString | undefined;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export interface LoginUriView {
|
|
628
|
+
uri: string | undefined;
|
|
629
|
+
match: UriMatchType | undefined;
|
|
630
|
+
uriChecksum: string | undefined;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export interface Fido2Credential {
|
|
634
|
+
credentialId: EncString;
|
|
635
|
+
keyType: EncString;
|
|
636
|
+
keyAlgorithm: EncString;
|
|
637
|
+
keyCurve: EncString;
|
|
638
|
+
keyValue: EncString;
|
|
639
|
+
rpId: EncString;
|
|
640
|
+
userHandle: EncString | undefined;
|
|
641
|
+
userName: EncString | undefined;
|
|
642
|
+
counter: EncString;
|
|
643
|
+
rpName: EncString | undefined;
|
|
644
|
+
userDisplayName: EncString | undefined;
|
|
645
|
+
discoverable: EncString;
|
|
646
|
+
creationDate: DateTime<Utc>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export interface Fido2CredentialListView {
|
|
650
|
+
credentialId: string;
|
|
651
|
+
rpId: string;
|
|
652
|
+
userHandle: string | undefined;
|
|
653
|
+
userName: string | undefined;
|
|
654
|
+
userDisplayName: string | undefined;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export interface Fido2CredentialView {
|
|
658
|
+
credentialId: string;
|
|
659
|
+
keyType: string;
|
|
660
|
+
keyAlgorithm: string;
|
|
661
|
+
keyCurve: string;
|
|
662
|
+
keyValue: EncString;
|
|
663
|
+
rpId: string;
|
|
664
|
+
userHandle: string | undefined;
|
|
665
|
+
userName: string | undefined;
|
|
666
|
+
counter: string;
|
|
667
|
+
rpName: string | undefined;
|
|
668
|
+
userDisplayName: string | undefined;
|
|
669
|
+
discoverable: string;
|
|
670
|
+
creationDate: DateTime<Utc>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface Fido2CredentialNewView {
|
|
674
|
+
credentialId: string;
|
|
675
|
+
keyType: string;
|
|
676
|
+
keyAlgorithm: string;
|
|
677
|
+
keyCurve: string;
|
|
678
|
+
rpId: string;
|
|
679
|
+
userHandle: string | undefined;
|
|
680
|
+
userName: string | undefined;
|
|
681
|
+
counter: string;
|
|
682
|
+
rpName: string | undefined;
|
|
683
|
+
userDisplayName: string | undefined;
|
|
684
|
+
creationDate: DateTime<Utc>;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export interface Login {
|
|
688
|
+
username: EncString | undefined;
|
|
689
|
+
password: EncString | undefined;
|
|
690
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
|
691
|
+
uris: LoginUri[] | undefined;
|
|
692
|
+
totp: EncString | undefined;
|
|
693
|
+
autofillOnPageLoad: boolean | undefined;
|
|
694
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface LoginView {
|
|
698
|
+
username: string | undefined;
|
|
699
|
+
password: string | undefined;
|
|
700
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
|
701
|
+
uris: LoginUriView[] | undefined;
|
|
702
|
+
totp: string | undefined;
|
|
703
|
+
autofillOnPageLoad: boolean | undefined;
|
|
704
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export interface LoginListView {
|
|
708
|
+
fido2Credentials: Fido2CredentialListView[] | undefined;
|
|
709
|
+
hasFido2: boolean;
|
|
710
|
+
username: string | undefined;
|
|
711
|
+
/**
|
|
712
|
+
* The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
|
|
713
|
+
*/
|
|
714
|
+
totp: EncString | undefined;
|
|
715
|
+
uris: LoginUriView[] | undefined;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export interface SecureNote {
|
|
719
|
+
type: SecureNoteType;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
export interface SecureNoteView {
|
|
723
|
+
type: SecureNoteType;
|
|
724
|
+
}
|
|
725
|
+
|
|
184
726
|
export interface Folder {
|
|
185
727
|
id: Uuid | undefined;
|
|
186
728
|
name: EncString;
|
|
@@ -193,11 +735,204 @@ export interface FolderView {
|
|
|
193
735
|
revisionDate: DateTime<Utc>;
|
|
194
736
|
}
|
|
195
737
|
|
|
196
|
-
export interface
|
|
197
|
-
name: "
|
|
738
|
+
export interface DecryptError extends Error {
|
|
739
|
+
name: "DecryptError";
|
|
740
|
+
variant: "Crypto" | "VaultLocked";
|
|
198
741
|
}
|
|
199
742
|
|
|
200
|
-
export function
|
|
743
|
+
export function isDecryptError(error: any): error is DecryptError;
|
|
744
|
+
|
|
745
|
+
export interface EncryptError extends Error {
|
|
746
|
+
name: "EncryptError";
|
|
747
|
+
variant: "Crypto" | "VaultLocked";
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
export function isEncryptError(error: any): error is EncryptError;
|
|
751
|
+
|
|
752
|
+
export interface TotpResponse {
|
|
753
|
+
/**
|
|
754
|
+
* Generated TOTP code
|
|
755
|
+
*/
|
|
756
|
+
code: string;
|
|
757
|
+
/**
|
|
758
|
+
* Time period
|
|
759
|
+
*/
|
|
760
|
+
period: number;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
export interface TotpError extends Error {
|
|
764
|
+
name: "TotpError";
|
|
765
|
+
variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
export function isTotpError(error: any): error is TotpError;
|
|
769
|
+
|
|
770
|
+
export interface PasswordHistoryView {
|
|
771
|
+
password: string;
|
|
772
|
+
lastUsedDate: DateTime<Utc>;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
export interface PasswordHistory {
|
|
776
|
+
password: EncString;
|
|
777
|
+
lastUsedDate: DateTime<Utc>;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export interface Collection {
|
|
781
|
+
id: Uuid | undefined;
|
|
782
|
+
organizationId: Uuid;
|
|
783
|
+
name: EncString;
|
|
784
|
+
externalId: string | undefined;
|
|
785
|
+
hidePasswords: boolean;
|
|
786
|
+
readOnly: boolean;
|
|
787
|
+
manage: boolean;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
export interface SshKeyView {
|
|
791
|
+
/**
|
|
792
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
|
793
|
+
*/
|
|
794
|
+
privateKey: string;
|
|
795
|
+
/**
|
|
796
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
|
797
|
+
*/
|
|
798
|
+
publicKey: string;
|
|
799
|
+
/**
|
|
800
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
|
801
|
+
*/
|
|
802
|
+
fingerprint: string;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
export interface SshKey {
|
|
806
|
+
/**
|
|
807
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
|
808
|
+
*/
|
|
809
|
+
privateKey: EncString;
|
|
810
|
+
/**
|
|
811
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
|
812
|
+
*/
|
|
813
|
+
publicKey: EncString;
|
|
814
|
+
/**
|
|
815
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
|
816
|
+
*/
|
|
817
|
+
fingerprint: EncString;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
export interface LocalDataView {
|
|
821
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
|
822
|
+
lastLaunched: DateTime<Utc> | undefined;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export interface LocalData {
|
|
826
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
|
827
|
+
lastLaunched: DateTime<Utc> | undefined;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
export interface IdentityView {
|
|
831
|
+
title: string | undefined;
|
|
832
|
+
firstName: string | undefined;
|
|
833
|
+
middleName: string | undefined;
|
|
834
|
+
lastName: string | undefined;
|
|
835
|
+
address1: string | undefined;
|
|
836
|
+
address2: string | undefined;
|
|
837
|
+
address3: string | undefined;
|
|
838
|
+
city: string | undefined;
|
|
839
|
+
state: string | undefined;
|
|
840
|
+
postalCode: string | undefined;
|
|
841
|
+
country: string | undefined;
|
|
842
|
+
company: string | undefined;
|
|
843
|
+
email: string | undefined;
|
|
844
|
+
phone: string | undefined;
|
|
845
|
+
ssn: string | undefined;
|
|
846
|
+
username: string | undefined;
|
|
847
|
+
passportNumber: string | undefined;
|
|
848
|
+
licenseNumber: string | undefined;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export interface Identity {
|
|
852
|
+
title: EncString | undefined;
|
|
853
|
+
firstName: EncString | undefined;
|
|
854
|
+
middleName: EncString | undefined;
|
|
855
|
+
lastName: EncString | undefined;
|
|
856
|
+
address1: EncString | undefined;
|
|
857
|
+
address2: EncString | undefined;
|
|
858
|
+
address3: EncString | undefined;
|
|
859
|
+
city: EncString | undefined;
|
|
860
|
+
state: EncString | undefined;
|
|
861
|
+
postalCode: EncString | undefined;
|
|
862
|
+
country: EncString | undefined;
|
|
863
|
+
company: EncString | undefined;
|
|
864
|
+
email: EncString | undefined;
|
|
865
|
+
phone: EncString | undefined;
|
|
866
|
+
ssn: EncString | undefined;
|
|
867
|
+
username: EncString | undefined;
|
|
868
|
+
passportNumber: EncString | undefined;
|
|
869
|
+
licenseNumber: EncString | undefined;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export interface CipherPermissions {
|
|
873
|
+
delete: boolean;
|
|
874
|
+
restore: boolean;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export interface CipherError extends Error {
|
|
878
|
+
name: "CipherError";
|
|
879
|
+
variant: "MissingFieldError" | "VaultLocked" | "CryptoError" | "AttachmentsWithoutKeys";
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export function isCipherError(error: any): error is CipherError;
|
|
883
|
+
|
|
884
|
+
export interface CardView {
|
|
885
|
+
cardholderName: string | undefined;
|
|
886
|
+
expMonth: string | undefined;
|
|
887
|
+
expYear: string | undefined;
|
|
888
|
+
code: string | undefined;
|
|
889
|
+
brand: string | undefined;
|
|
890
|
+
number: string | undefined;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
export interface Card {
|
|
894
|
+
cardholderName: EncString | undefined;
|
|
895
|
+
expMonth: EncString | undefined;
|
|
896
|
+
expYear: EncString | undefined;
|
|
897
|
+
code: EncString | undefined;
|
|
898
|
+
brand: EncString | undefined;
|
|
899
|
+
number: EncString | undefined;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
export interface DecryptFileError extends Error {
|
|
903
|
+
name: "DecryptFileError";
|
|
904
|
+
variant: "Decrypt" | "Io";
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
export function isDecryptFileError(error: any): error is DecryptFileError;
|
|
908
|
+
|
|
909
|
+
export interface EncryptFileError extends Error {
|
|
910
|
+
name: "EncryptFileError";
|
|
911
|
+
variant: "Encrypt" | "Io";
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
export function isEncryptFileError(error: any): error is EncryptFileError;
|
|
915
|
+
|
|
916
|
+
export interface AttachmentView {
|
|
917
|
+
id: string | undefined;
|
|
918
|
+
url: string | undefined;
|
|
919
|
+
size: string | undefined;
|
|
920
|
+
sizeName: string | undefined;
|
|
921
|
+
fileName: string | undefined;
|
|
922
|
+
key: EncString | undefined;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
export interface Attachment {
|
|
926
|
+
id: string | undefined;
|
|
927
|
+
url: string | undefined;
|
|
928
|
+
size: string | undefined;
|
|
929
|
+
/**
|
|
930
|
+
* Readable size, ex: \"4.2 KB\" or \"1.43 GB\
|
|
931
|
+
*/
|
|
932
|
+
sizeName: string | undefined;
|
|
933
|
+
fileName: EncString | undefined;
|
|
934
|
+
key: EncString | undefined;
|
|
935
|
+
}
|
|
201
936
|
|
|
202
937
|
export type Uuid = string;
|
|
203
938
|
|
|
@@ -217,73 +952,398 @@ export type Utc = unknown;
|
|
|
217
952
|
*/
|
|
218
953
|
export type NonZeroU32 = number;
|
|
219
954
|
|
|
220
|
-
export
|
|
955
|
+
export interface TestError extends Error {
|
|
956
|
+
name: "TestError";
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
export function isTestError(error: any): error is TestError;
|
|
960
|
+
|
|
961
|
+
export class AttachmentsClient {
|
|
962
|
+
private constructor();
|
|
221
963
|
free(): void;
|
|
222
964
|
/**
|
|
223
|
-
*
|
|
224
|
-
* @param {LogLevel | undefined} [log_level]
|
|
965
|
+
* Decrypts an attachment's encrypted content
|
|
225
966
|
*/
|
|
226
|
-
|
|
967
|
+
decrypt_buffer(
|
|
968
|
+
cipher: Cipher,
|
|
969
|
+
attachment: AttachmentView,
|
|
970
|
+
encrypted_buffer: Uint8Array,
|
|
971
|
+
): Uint8Array;
|
|
972
|
+
}
|
|
973
|
+
export class BitwardenClient {
|
|
974
|
+
free(): void;
|
|
975
|
+
constructor(settings?: ClientSettings | null);
|
|
227
976
|
/**
|
|
228
977
|
* Test method, echoes back the input
|
|
229
|
-
* @param {string} msg
|
|
230
|
-
* @returns {string}
|
|
231
978
|
*/
|
|
232
979
|
echo(msg: string): string;
|
|
980
|
+
version(): string;
|
|
981
|
+
throw(msg: string): void;
|
|
233
982
|
/**
|
|
234
|
-
*
|
|
983
|
+
* Test method, calls http endpoint
|
|
235
984
|
*/
|
|
236
|
-
|
|
985
|
+
http_get(url: string): Promise<string>;
|
|
986
|
+
crypto(): CryptoClient;
|
|
987
|
+
vault(): VaultClient;
|
|
988
|
+
/**
|
|
989
|
+
* Constructs a specific client for generating passwords and passphrases
|
|
990
|
+
*/
|
|
991
|
+
generator(): GeneratorClient;
|
|
992
|
+
exporters(): ExporterClient;
|
|
993
|
+
}
|
|
994
|
+
export class CiphersClient {
|
|
995
|
+
private constructor();
|
|
996
|
+
free(): void;
|
|
237
997
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
998
|
+
* Encrypt cipher
|
|
999
|
+
*
|
|
1000
|
+
* # Arguments
|
|
1001
|
+
* - `cipher_view` - The decrypted cipher to encrypt
|
|
1002
|
+
*
|
|
1003
|
+
* # Returns
|
|
1004
|
+
* - `Ok(Cipher)` containing the encrypted cipher
|
|
1005
|
+
* - `Err(EncryptError)` if encryption fails
|
|
240
1006
|
*/
|
|
241
|
-
|
|
1007
|
+
encrypt(cipher_view: CipherView): Cipher;
|
|
242
1008
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
1009
|
+
* Decrypt cipher
|
|
1010
|
+
*
|
|
1011
|
+
* # Arguments
|
|
1012
|
+
* - `cipher` - The encrypted cipher to decrypt
|
|
1013
|
+
*
|
|
1014
|
+
* # Returns
|
|
1015
|
+
* - `Ok(CipherView)` containing the decrypted cipher
|
|
1016
|
+
* - `Err(DecryptError)` if decryption fails
|
|
246
1017
|
*/
|
|
247
|
-
|
|
1018
|
+
decrypt(cipher: Cipher): CipherView;
|
|
1019
|
+
/**
|
|
1020
|
+
* Decrypt list of ciphers
|
|
1021
|
+
*
|
|
1022
|
+
* # Arguments
|
|
1023
|
+
* - `ciphers` - The list of encrypted ciphers to decrypt
|
|
1024
|
+
*
|
|
1025
|
+
* # Returns
|
|
1026
|
+
* - `Ok(Vec<CipherListView>)` containing the decrypted ciphers
|
|
1027
|
+
* - `Err(DecryptError)` if decryption fails
|
|
1028
|
+
*/
|
|
1029
|
+
decrypt_list(ciphers: Cipher[]): CipherListView[];
|
|
248
1030
|
/**
|
|
249
|
-
*
|
|
1031
|
+
* Decrypt FIDO2 credentials
|
|
1032
|
+
*
|
|
1033
|
+
* # Arguments
|
|
1034
|
+
* - `cipher_view` - Cipher to encrypt containing the FIDO2 credential
|
|
1035
|
+
*
|
|
1036
|
+
* # Returns
|
|
1037
|
+
* - `Ok(Vec<Fido2CredentialView>)` containing the decrypted FIDO2 credentials
|
|
1038
|
+
* - `Err(DecryptError)` if decryption fails
|
|
250
1039
|
*/
|
|
251
|
-
|
|
1040
|
+
decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
|
|
252
1041
|
/**
|
|
253
|
-
*
|
|
1042
|
+
* Decrypt key
|
|
1043
|
+
*
|
|
1044
|
+
* This method is a temporary solution to allow typescript client access to decrypted key
|
|
1045
|
+
* values, particularly for FIDO2 credentials.
|
|
1046
|
+
*
|
|
1047
|
+
* # Arguments
|
|
1048
|
+
* - `cipher_view` - Decrypted cipher containing the key
|
|
1049
|
+
*
|
|
1050
|
+
* # Returns
|
|
1051
|
+
* - `Ok(String)` containing the decrypted key
|
|
1052
|
+
* - `Err(CipherError)`
|
|
254
1053
|
*/
|
|
255
|
-
|
|
1054
|
+
decrypt_fido2_private_key(cipher_view: CipherView): string;
|
|
256
1055
|
}
|
|
257
|
-
export class
|
|
1056
|
+
export class CryptoClient {
|
|
1057
|
+
private constructor();
|
|
258
1058
|
free(): void;
|
|
259
1059
|
/**
|
|
260
1060
|
* Initialization method for the user crypto. Needs to be called before any other crypto
|
|
261
1061
|
* operations.
|
|
262
|
-
* @param {InitUserCryptoRequest} req
|
|
263
|
-
* @returns {Promise<void>}
|
|
264
1062
|
*/
|
|
265
1063
|
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
|
266
1064
|
/**
|
|
267
1065
|
* Initialization method for the organization crypto. Needs to be called after
|
|
268
1066
|
* `initialize_user_crypto` but before any other crypto operations.
|
|
269
|
-
* @param {InitOrgCryptoRequest} req
|
|
270
|
-
* @returns {Promise<void>}
|
|
271
1067
|
*/
|
|
272
1068
|
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
|
1071
|
+
* Crypto initialization not required.
|
|
1072
|
+
*/
|
|
1073
|
+
make_key_pair(user_key: string): MakeKeyPairResponse;
|
|
1074
|
+
/**
|
|
1075
|
+
* Verifies a user's asymmetric keys by decrypting the private key with the provided user
|
|
1076
|
+
* key. Returns if the private key is decryptable and if it is a valid matching key.
|
|
1077
|
+
* Crypto initialization not required.
|
|
1078
|
+
*/
|
|
1079
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
|
1080
|
+
}
|
|
1081
|
+
export class ExporterClient {
|
|
1082
|
+
private constructor();
|
|
1083
|
+
free(): void;
|
|
1084
|
+
export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
|
|
1085
|
+
export_organization_vault(
|
|
1086
|
+
collections: Collection[],
|
|
1087
|
+
ciphers: Cipher[],
|
|
1088
|
+
format: ExportFormat,
|
|
1089
|
+
): string;
|
|
1090
|
+
/**
|
|
1091
|
+
* Credential Exchange Format (CXF)
|
|
1092
|
+
*
|
|
1093
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
|
1094
|
+
*
|
|
1095
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
|
1096
|
+
* Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
|
1097
|
+
*/
|
|
1098
|
+
export_cxf(account: Account, ciphers: Cipher[]): string;
|
|
1099
|
+
/**
|
|
1100
|
+
* Credential Exchange Format (CXF)
|
|
1101
|
+
*
|
|
1102
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
|
1103
|
+
*
|
|
1104
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
|
1105
|
+
* Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
|
1106
|
+
*/
|
|
1107
|
+
import_cxf(payload: string): Cipher[];
|
|
273
1108
|
}
|
|
274
|
-
export class
|
|
1109
|
+
export class FoldersClient {
|
|
1110
|
+
private constructor();
|
|
275
1111
|
free(): void;
|
|
276
1112
|
/**
|
|
277
1113
|
* Decrypt folder
|
|
278
|
-
* @param {Folder} folder
|
|
279
|
-
* @returns {FolderView}
|
|
280
1114
|
*/
|
|
281
1115
|
decrypt(folder: Folder): FolderView;
|
|
282
1116
|
}
|
|
283
|
-
export class
|
|
1117
|
+
export class GeneratorClient {
|
|
1118
|
+
private constructor();
|
|
1119
|
+
free(): void;
|
|
1120
|
+
/**
|
|
1121
|
+
* Generates a random password.
|
|
1122
|
+
*
|
|
1123
|
+
* The character sets and password length can be customized using the `input` parameter.
|
|
1124
|
+
*
|
|
1125
|
+
* # Examples
|
|
1126
|
+
*
|
|
1127
|
+
* ```
|
|
1128
|
+
* use bitwarden_core::Client;
|
|
1129
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
|
|
1130
|
+
*
|
|
1131
|
+
* async fn test() -> Result<(), PassphraseError> {
|
|
1132
|
+
* let input = PasswordGeneratorRequest {
|
|
1133
|
+
* lowercase: true,
|
|
1134
|
+
* uppercase: true,
|
|
1135
|
+
* numbers: true,
|
|
1136
|
+
* length: 20,
|
|
1137
|
+
* ..Default::default()
|
|
1138
|
+
* };
|
|
1139
|
+
* let password = Client::new(None).generator().password(input).unwrap();
|
|
1140
|
+
* println!("{}", password);
|
|
1141
|
+
* Ok(())
|
|
1142
|
+
* }
|
|
1143
|
+
* ```
|
|
1144
|
+
*/
|
|
1145
|
+
password(input: PasswordGeneratorRequest): string;
|
|
1146
|
+
/**
|
|
1147
|
+
* Generates a random passphrase.
|
|
1148
|
+
* A passphrase is a combination of random words separated by a character.
|
|
1149
|
+
* An example of passphrase is `correct horse battery staple`.
|
|
1150
|
+
*
|
|
1151
|
+
* The number of words and their case, the word separator, and the inclusion of
|
|
1152
|
+
* a number in the passphrase can be customized using the `input` parameter.
|
|
1153
|
+
*
|
|
1154
|
+
* # Examples
|
|
1155
|
+
*
|
|
1156
|
+
* ```
|
|
1157
|
+
* use bitwarden_core::Client;
|
|
1158
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
|
|
1159
|
+
*
|
|
1160
|
+
* async fn test() -> Result<(), PassphraseError> {
|
|
1161
|
+
* let input = PassphraseGeneratorRequest {
|
|
1162
|
+
* num_words: 4,
|
|
1163
|
+
* ..Default::default()
|
|
1164
|
+
* };
|
|
1165
|
+
* let passphrase = Client::new(None).generator().passphrase(input).unwrap();
|
|
1166
|
+
* println!("{}", passphrase);
|
|
1167
|
+
* Ok(())
|
|
1168
|
+
* }
|
|
1169
|
+
* ```
|
|
1170
|
+
*/
|
|
1171
|
+
passphrase(input: PassphraseGeneratorRequest): string;
|
|
1172
|
+
}
|
|
1173
|
+
export class IncomingMessage {
|
|
1174
|
+
free(): void;
|
|
1175
|
+
constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
|
|
1176
|
+
/**
|
|
1177
|
+
* Try to parse the payload as JSON.
|
|
1178
|
+
* @returns The parsed JSON value, or undefined if the payload is not valid JSON.
|
|
1179
|
+
*/
|
|
1180
|
+
parse_payload_as_json(): any;
|
|
1181
|
+
payload: Uint8Array;
|
|
1182
|
+
destination: Endpoint;
|
|
1183
|
+
source: Endpoint;
|
|
1184
|
+
get topic(): string | undefined;
|
|
1185
|
+
set topic(value: string | null | undefined);
|
|
1186
|
+
}
|
|
1187
|
+
export class IpcClient {
|
|
284
1188
|
free(): void;
|
|
1189
|
+
constructor(communication_provider: IpcCommunicationBackend);
|
|
1190
|
+
send(message: OutgoingMessage): Promise<void>;
|
|
1191
|
+
subscribe(): Promise<IpcClientSubscription>;
|
|
1192
|
+
}
|
|
1193
|
+
export class IpcClientSubscription {
|
|
1194
|
+
private constructor();
|
|
1195
|
+
free(): void;
|
|
1196
|
+
receive(): Promise<IncomingMessage>;
|
|
1197
|
+
}
|
|
1198
|
+
export class IpcCommunicationBackend {
|
|
1199
|
+
free(): void;
|
|
1200
|
+
constructor(sender: IpcCommunicationBackendSender);
|
|
1201
|
+
/**
|
|
1202
|
+
* JavaScript function to provide a received message to the backend/IPC framework.
|
|
1203
|
+
*/
|
|
1204
|
+
deliver_message(message: IncomingMessage): void;
|
|
1205
|
+
}
|
|
1206
|
+
export class OutgoingMessage {
|
|
1207
|
+
free(): void;
|
|
1208
|
+
constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
|
|
1209
|
+
/**
|
|
1210
|
+
* Create a new message and encode the payload as JSON.
|
|
1211
|
+
*/
|
|
1212
|
+
static new_json_payload(
|
|
1213
|
+
payload: any,
|
|
1214
|
+
destination: Endpoint,
|
|
1215
|
+
topic?: string | null,
|
|
1216
|
+
): OutgoingMessage;
|
|
1217
|
+
payload: Uint8Array;
|
|
1218
|
+
destination: Endpoint;
|
|
1219
|
+
get topic(): string | undefined;
|
|
1220
|
+
set topic(value: string | null | undefined);
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
|
1224
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
|
1225
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
|
1226
|
+
* responsible for state and keys.
|
|
1227
|
+
*/
|
|
1228
|
+
export class PureCrypto {
|
|
1229
|
+
private constructor();
|
|
1230
|
+
free(): void;
|
|
1231
|
+
/**
|
|
1232
|
+
* DEPRECATED: Use `symmetric_decrypt_string` instead.
|
|
1233
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
|
1234
|
+
*/
|
|
1235
|
+
static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
|
|
1236
|
+
static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
|
|
1237
|
+
static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
|
|
1238
|
+
/**
|
|
1239
|
+
* DEPRECATED: Use `symmetric_decrypt_filedata` instead.
|
|
1240
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
|
1241
|
+
*/
|
|
1242
|
+
static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
|
1243
|
+
static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
|
1244
|
+
static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
|
|
1245
|
+
static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
|
|
1246
|
+
static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
|
|
1247
|
+
static decrypt_user_key_with_master_password(
|
|
1248
|
+
encrypted_user_key: string,
|
|
1249
|
+
master_password: string,
|
|
1250
|
+
email: string,
|
|
1251
|
+
kdf: Kdf,
|
|
1252
|
+
): Uint8Array;
|
|
1253
|
+
static encrypt_user_key_with_master_password(
|
|
1254
|
+
user_key: Uint8Array,
|
|
1255
|
+
master_password: string,
|
|
1256
|
+
email: string,
|
|
1257
|
+
kdf: Kdf,
|
|
1258
|
+
): string;
|
|
1259
|
+
static make_user_key_aes256_cbc_hmac(): Uint8Array;
|
|
1260
|
+
static make_user_key_xchacha20_poly1305(): Uint8Array;
|
|
1261
|
+
/**
|
|
1262
|
+
* Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
|
|
1263
|
+
* as an EncString.
|
|
1264
|
+
*/
|
|
1265
|
+
static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
|
|
1266
|
+
/**
|
|
1267
|
+
* Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
|
|
1268
|
+
* unwrapped key as a serialized byte array.
|
|
1269
|
+
*/
|
|
1270
|
+
static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
1271
|
+
/**
|
|
1272
|
+
* Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
|
|
1273
|
+
* key. Note: Usually, a public key is - by definition - public, so this should not be
|
|
1274
|
+
* used. The specific use-case for this function is to enable rotateable key sets, where
|
|
1275
|
+
* the "public key" is not public, with the intent of preventing the server from being able
|
|
1276
|
+
* to overwrite the user key unlocked by the rotateable keyset.
|
|
1277
|
+
*/
|
|
1278
|
+
static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
|
1279
|
+
/**
|
|
1280
|
+
* Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
|
|
1281
|
+
* wrapping key.
|
|
1282
|
+
*/
|
|
1283
|
+
static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
1284
|
+
/**
|
|
1285
|
+
* Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
|
|
1286
|
+
* key,
|
|
1287
|
+
*/
|
|
1288
|
+
static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
|
|
1291
|
+
* wrapping key.
|
|
1292
|
+
*/
|
|
1293
|
+
static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
1294
|
+
/**
|
|
1295
|
+
* Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key)
|
|
1296
|
+
* in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
|
|
1297
|
+
* the sender's authenticity cannot be verified by the recipient.
|
|
1298
|
+
*/
|
|
1299
|
+
static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
|
|
285
1300
|
/**
|
|
286
|
-
*
|
|
1301
|
+
* Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8
|
|
1302
|
+
* DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
|
|
1303
|
+
* recipient.
|
|
287
1304
|
*/
|
|
288
|
-
|
|
1305
|
+
static decapsulate_key_unsigned(
|
|
1306
|
+
encapsulated_key: string,
|
|
1307
|
+
decapsulation_key: Uint8Array,
|
|
1308
|
+
): Uint8Array;
|
|
1309
|
+
}
|
|
1310
|
+
export class ReceiveError {
|
|
1311
|
+
private constructor();
|
|
1312
|
+
free(): void;
|
|
1313
|
+
timeout: boolean;
|
|
1314
|
+
crypto: any;
|
|
1315
|
+
communication: any;
|
|
1316
|
+
}
|
|
1317
|
+
export class SendError {
|
|
1318
|
+
private constructor();
|
|
1319
|
+
free(): void;
|
|
1320
|
+
crypto: any;
|
|
1321
|
+
communication: any;
|
|
1322
|
+
}
|
|
1323
|
+
export class TotpClient {
|
|
1324
|
+
private constructor();
|
|
1325
|
+
free(): void;
|
|
1326
|
+
/**
|
|
1327
|
+
* Generates a TOTP code from a provided key
|
|
1328
|
+
*
|
|
1329
|
+
* # Arguments
|
|
1330
|
+
* - `key` - Can be:
|
|
1331
|
+
* - A base32 encoded string
|
|
1332
|
+
* - OTP Auth URI
|
|
1333
|
+
* - Steam URI
|
|
1334
|
+
* - `time_ms` - Optional timestamp in milliseconds
|
|
1335
|
+
*
|
|
1336
|
+
* # Returns
|
|
1337
|
+
* - `Ok(TotpResponse)` containing the generated code and period
|
|
1338
|
+
* - `Err(TotpError)` if code generation fails
|
|
1339
|
+
*/
|
|
1340
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
|
1341
|
+
}
|
|
1342
|
+
export class VaultClient {
|
|
1343
|
+
private constructor();
|
|
1344
|
+
free(): void;
|
|
1345
|
+
attachments(): AttachmentsClient;
|
|
1346
|
+
ciphers(): CiphersClient;
|
|
1347
|
+
folders(): FoldersClient;
|
|
1348
|
+
totp(): TotpClient;
|
|
289
1349
|
}
|