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