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