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