@bitwarden/sdk-internal 0.2.0-main.51 → 0.2.0-main.510
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 -1
- package/bitwarden_wasm_internal.d.ts +2816 -212
- package/bitwarden_wasm_internal.js +1 -1
- package/bitwarden_wasm_internal_bg.js +5406 -1085
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +526 -29
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +2816 -212
- package/node/bitwarden_wasm_internal.js +5373 -1011
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +526 -29
- package/package.json +12 -2
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - `Ok(SshKey)` if the key was successfully generated
|
|
11
11
|
* - `Err(KeyGenerationError)` if the key could not be generated
|
|
12
12
|
*/
|
|
13
|
-
export function generate_ssh_key(key_algorithm: KeyAlgorithm):
|
|
13
|
+
export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKeyView;
|
|
14
14
|
/**
|
|
15
15
|
* Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
|
|
16
16
|
* to an OpenSSH private key with public key and fingerprint
|
|
@@ -26,324 +26,2928 @@ export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKey;
|
|
|
26
26
|
* - `Err(ParsingError)` if the key could not be parsed
|
|
27
27
|
* - `Err(UnsupportedKeyType)` if the key type is not supported
|
|
28
28
|
*/
|
|
29
|
-
export function import_ssh_key(imported_key: string, password?: string):
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
|
|
30
|
+
export function init_sdk(log_level?: LogLevel | null): void;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
|
|
33
|
+
*/
|
|
34
|
+
export function ipcRegisterDiscoverHandler(
|
|
35
|
+
ipc_client: IpcClient,
|
|
36
|
+
response: DiscoverResponse,
|
|
37
|
+
): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Sends a DiscoverRequest to the specified destination and returns the response.
|
|
40
|
+
*/
|
|
41
|
+
export function ipcRequestDiscover(
|
|
42
|
+
ipc_client: IpcClient,
|
|
43
|
+
destination: Endpoint,
|
|
44
|
+
abort_signal?: AbortSignal | null,
|
|
45
|
+
): Promise<DiscoverResponse>;
|
|
46
|
+
export enum CardLinkedIdType {
|
|
47
|
+
CardholderName = 300,
|
|
48
|
+
ExpMonth = 301,
|
|
49
|
+
ExpYear = 302,
|
|
50
|
+
Code = 303,
|
|
51
|
+
Brand = 304,
|
|
52
|
+
Number = 305,
|
|
36
53
|
}
|
|
37
|
-
export
|
|
54
|
+
export enum CipherRepromptType {
|
|
55
|
+
None = 0,
|
|
56
|
+
Password = 1,
|
|
57
|
+
}
|
|
58
|
+
export enum CipherType {
|
|
59
|
+
Login = 1,
|
|
60
|
+
SecureNote = 2,
|
|
61
|
+
Card = 3,
|
|
62
|
+
Identity = 4,
|
|
63
|
+
SshKey = 5,
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Represents the type of a [FieldView].
|
|
67
|
+
*/
|
|
68
|
+
export enum FieldType {
|
|
38
69
|
/**
|
|
39
|
-
*
|
|
70
|
+
* Text field
|
|
40
71
|
*/
|
|
41
|
-
|
|
72
|
+
Text = 0,
|
|
42
73
|
/**
|
|
43
|
-
*
|
|
74
|
+
* Hidden text field
|
|
44
75
|
*/
|
|
45
|
-
|
|
76
|
+
Hidden = 1,
|
|
46
77
|
/**
|
|
47
|
-
*
|
|
78
|
+
* Boolean field
|
|
48
79
|
*/
|
|
49
|
-
|
|
80
|
+
Boolean = 2,
|
|
50
81
|
/**
|
|
51
|
-
*
|
|
82
|
+
* Linked field
|
|
52
83
|
*/
|
|
53
|
-
|
|
84
|
+
Linked = 3,
|
|
85
|
+
}
|
|
86
|
+
export enum IdentityLinkedIdType {
|
|
87
|
+
Title = 400,
|
|
88
|
+
MiddleName = 401,
|
|
89
|
+
Address1 = 402,
|
|
90
|
+
Address2 = 403,
|
|
91
|
+
Address3 = 404,
|
|
92
|
+
City = 405,
|
|
93
|
+
State = 406,
|
|
94
|
+
PostalCode = 407,
|
|
95
|
+
Country = 408,
|
|
96
|
+
Company = 409,
|
|
97
|
+
Email = 410,
|
|
98
|
+
Phone = 411,
|
|
99
|
+
Ssn = 412,
|
|
100
|
+
Username = 413,
|
|
101
|
+
PassportNumber = 414,
|
|
102
|
+
LicenseNumber = 415,
|
|
103
|
+
FirstName = 416,
|
|
104
|
+
LastName = 417,
|
|
105
|
+
FullName = 418,
|
|
106
|
+
}
|
|
107
|
+
export enum LogLevel {
|
|
108
|
+
Trace = 0,
|
|
109
|
+
Debug = 1,
|
|
110
|
+
Info = 2,
|
|
111
|
+
Warn = 3,
|
|
112
|
+
Error = 4,
|
|
113
|
+
}
|
|
114
|
+
export enum LoginLinkedIdType {
|
|
115
|
+
Username = 100,
|
|
116
|
+
Password = 101,
|
|
117
|
+
}
|
|
118
|
+
export enum RsaError {
|
|
119
|
+
Decryption = 0,
|
|
120
|
+
Encryption = 1,
|
|
121
|
+
KeyParse = 2,
|
|
122
|
+
KeySerialize = 3,
|
|
123
|
+
}
|
|
124
|
+
export enum SecureNoteType {
|
|
125
|
+
Generic = 0,
|
|
126
|
+
}
|
|
127
|
+
export enum UriMatchType {
|
|
128
|
+
Domain = 0,
|
|
129
|
+
Host = 1,
|
|
130
|
+
StartsWith = 2,
|
|
131
|
+
Exact = 3,
|
|
132
|
+
RegularExpression = 4,
|
|
133
|
+
Never = 5,
|
|
54
134
|
}
|
|
55
135
|
|
|
56
|
-
|
|
57
|
-
| { password: { password: string; user_key: string } }
|
|
58
|
-
| { decryptedKey: { decrypted_user_key: string } }
|
|
59
|
-
| { pin: { pin: string; pin_protected_user_key: EncString } }
|
|
60
|
-
| { authRequest: { request_private_key: string; method: AuthRequestMethod } }
|
|
61
|
-
| {
|
|
62
|
-
deviceKey: {
|
|
63
|
-
device_key: string;
|
|
64
|
-
protected_device_private_key: EncString;
|
|
65
|
-
device_protected_user_key: AsymmetricEncString;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
| { keyConnector: { master_key: string; user_key: string } };
|
|
136
|
+
import { Tagged } from "type-fest";
|
|
69
137
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
138
|
+
/**
|
|
139
|
+
* A string that **MUST** be a valid UUID.
|
|
140
|
+
*
|
|
141
|
+
* Never create or cast to this type directly, use the `uuid<T>()` function instead.
|
|
142
|
+
*/
|
|
143
|
+
export type Uuid = unknown;
|
|
73
144
|
|
|
74
|
-
|
|
145
|
+
/**
|
|
146
|
+
* RFC3339 compliant date-time string.
|
|
147
|
+
* @typeParam T - Not used in JavaScript.
|
|
148
|
+
*/
|
|
149
|
+
export type DateTime<T = unknown> = string;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* UTC date-time string. Not used in JavaScript.
|
|
153
|
+
*/
|
|
154
|
+
export type Utc = unknown;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* An integer that is known not to equal zero.
|
|
158
|
+
*/
|
|
159
|
+
export type NonZeroU32 = number;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated Use PasswordManagerClient instead
|
|
163
|
+
*/
|
|
164
|
+
export type BitwardenClient = PasswordManagerClient;
|
|
165
|
+
|
|
166
|
+
export interface TestError extends Error {
|
|
167
|
+
name: "TestError";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function isTestError(error: any): error is TestError;
|
|
171
|
+
|
|
172
|
+
export interface Repository<T> {
|
|
173
|
+
get(id: string): Promise<T | null>;
|
|
174
|
+
list(): Promise<T[]>;
|
|
175
|
+
set(id: string, value: T): Promise<void>;
|
|
176
|
+
remove(id: string): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface TokenProvider {
|
|
180
|
+
get_access_token(): Promise<string | undefined>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface IndexedDbConfiguration {
|
|
184
|
+
db_name: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface Repositories {
|
|
188
|
+
cipher: Repository<Cipher> | null;
|
|
189
|
+
folder: Repository<Folder> | null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Active feature flags for the SDK.
|
|
194
|
+
*/
|
|
195
|
+
export interface FeatureFlags extends Map<string, boolean> {}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Credentials for sending password secured access requests.
|
|
199
|
+
* Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
|
|
200
|
+
* struct.
|
|
201
|
+
*/
|
|
202
|
+
export interface SendPasswordCredentials {
|
|
75
203
|
/**
|
|
76
|
-
*
|
|
204
|
+
* A Base64-encoded hash of the password protecting the send.
|
|
77
205
|
*/
|
|
78
|
-
|
|
206
|
+
passwordHashB64: string;
|
|
79
207
|
}
|
|
80
208
|
|
|
81
|
-
|
|
209
|
+
/**
|
|
210
|
+
* A request structure for requesting a send access token from the API.
|
|
211
|
+
*/
|
|
212
|
+
export interface SendAccessTokenRequest {
|
|
82
213
|
/**
|
|
83
|
-
* The
|
|
214
|
+
* The id of the send for which the access token is requested.
|
|
84
215
|
*/
|
|
85
|
-
|
|
216
|
+
sendId: string;
|
|
86
217
|
/**
|
|
87
|
-
*
|
|
218
|
+
* The optional send access credentials.
|
|
88
219
|
*/
|
|
89
|
-
|
|
220
|
+
sendAccessCredentials?: SendAccessCredentials;
|
|
90
221
|
}
|
|
91
222
|
|
|
92
|
-
|
|
223
|
+
/**
|
|
224
|
+
* The credentials used for send access requests.
|
|
225
|
+
*/
|
|
226
|
+
export type SendAccessCredentials =
|
|
227
|
+
| SendPasswordCredentials
|
|
228
|
+
| SendEmailOtpCredentials
|
|
229
|
+
| SendEmailCredentials;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Credentials for sending an OTP to the user\'s email address.
|
|
233
|
+
* This is used when the send requires email verification with an OTP.
|
|
234
|
+
*/
|
|
235
|
+
export interface SendEmailCredentials {
|
|
93
236
|
/**
|
|
94
|
-
* The
|
|
237
|
+
* The email address to which the OTP will be sent.
|
|
95
238
|
*/
|
|
96
|
-
|
|
239
|
+
email: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Credentials for getting a send access token using an email and OTP.
|
|
244
|
+
*/
|
|
245
|
+
export interface SendEmailOtpCredentials {
|
|
97
246
|
/**
|
|
98
|
-
* The
|
|
247
|
+
* The email address to which the OTP will be sent.
|
|
99
248
|
*/
|
|
100
|
-
|
|
249
|
+
email: string;
|
|
101
250
|
/**
|
|
102
|
-
*
|
|
251
|
+
* The one-time password (OTP) that the user has received via email.
|
|
103
252
|
*/
|
|
104
|
-
|
|
253
|
+
otp: string;
|
|
105
254
|
}
|
|
106
255
|
|
|
107
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Any unexpected error that occurs when making requests to identity. This could be
|
|
258
|
+
* local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
|
|
259
|
+
* connection reset, or JSON decode failure on a success response) or non-2xx response with an
|
|
260
|
+
* unexpected body or status. Used when decoding the server\'s error payload into
|
|
261
|
+
* `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
|
|
262
|
+
* available.
|
|
263
|
+
*/
|
|
264
|
+
export type UnexpectedIdentityError = string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* A send access token which can be used to access a send.
|
|
268
|
+
*/
|
|
269
|
+
export interface SendAccessTokenResponse {
|
|
108
270
|
/**
|
|
109
|
-
*
|
|
271
|
+
* The actual token string.
|
|
110
272
|
*/
|
|
111
|
-
|
|
273
|
+
token: string;
|
|
112
274
|
/**
|
|
113
|
-
*
|
|
275
|
+
* The timestamp in milliseconds when the token expires.
|
|
114
276
|
*/
|
|
115
|
-
|
|
277
|
+
expiresAt: number;
|
|
116
278
|
}
|
|
117
279
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
280
|
+
/**
|
|
281
|
+
* Represents errors that can occur when requesting a send access token.
|
|
282
|
+
* It includes expected and unexpected API errors.
|
|
283
|
+
*/
|
|
284
|
+
export type SendAccessTokenError =
|
|
285
|
+
| { kind: "unexpected"; data: UnexpectedIdentityError }
|
|
286
|
+
| { kind: "expected"; data: SendAccessTokenApiErrorResponse };
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Represents the possible, expected errors that can occur when requesting a send access token.
|
|
290
|
+
*/
|
|
291
|
+
export type SendAccessTokenApiErrorResponse =
|
|
292
|
+
| {
|
|
293
|
+
error: "invalid_request";
|
|
294
|
+
error_description?: string;
|
|
295
|
+
send_access_error_type?: SendAccessTokenInvalidRequestError;
|
|
296
|
+
}
|
|
297
|
+
| {
|
|
298
|
+
error: "invalid_grant";
|
|
299
|
+
error_description?: string;
|
|
300
|
+
send_access_error_type?: SendAccessTokenInvalidGrantError;
|
|
301
|
+
}
|
|
302
|
+
| { error: "invalid_client"; error_description?: string }
|
|
303
|
+
| { error: "unauthorized_client"; error_description?: string }
|
|
304
|
+
| { error: "unsupported_grant_type"; error_description?: string }
|
|
305
|
+
| { error: "invalid_scope"; error_description?: string }
|
|
306
|
+
| { error: "invalid_target"; error_description?: string };
|
|
140
307
|
|
|
141
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Invalid grant errors - typically due to invalid credentials.
|
|
310
|
+
*/
|
|
311
|
+
export type SendAccessTokenInvalidGrantError =
|
|
312
|
+
| "send_id_invalid"
|
|
313
|
+
| "password_hash_b64_invalid"
|
|
314
|
+
| "otp_invalid"
|
|
315
|
+
| "otp_generation_failed"
|
|
316
|
+
| "unknown";
|
|
142
317
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Invalid request errors - typically due to missing parameters.
|
|
320
|
+
*/
|
|
321
|
+
export type SendAccessTokenInvalidRequestError =
|
|
322
|
+
| "send_id_required"
|
|
323
|
+
| "password_hash_b64_required"
|
|
324
|
+
| "email_required"
|
|
325
|
+
| "email_and_otp_required"
|
|
326
|
+
| "unknown";
|
|
147
327
|
|
|
148
|
-
export
|
|
328
|
+
export interface RegistrationError extends Error {
|
|
329
|
+
name: "RegistrationError";
|
|
330
|
+
variant: "KeyConnectorApi" | "Api" | "Crypto";
|
|
331
|
+
}
|
|
149
332
|
|
|
150
|
-
export
|
|
151
|
-
| "Android"
|
|
152
|
-
| "iOS"
|
|
153
|
-
| "ChromeExtension"
|
|
154
|
-
| "FirefoxExtension"
|
|
155
|
-
| "OperaExtension"
|
|
156
|
-
| "EdgeExtension"
|
|
157
|
-
| "WindowsDesktop"
|
|
158
|
-
| "MacOsDesktop"
|
|
159
|
-
| "LinuxDesktop"
|
|
160
|
-
| "ChromeBrowser"
|
|
161
|
-
| "FirefoxBrowser"
|
|
162
|
-
| "OperaBrowser"
|
|
163
|
-
| "EdgeBrowser"
|
|
164
|
-
| "IEBrowser"
|
|
165
|
-
| "UnknownBrowser"
|
|
166
|
-
| "AndroidAmazon"
|
|
167
|
-
| "UWP"
|
|
168
|
-
| "SafariBrowser"
|
|
169
|
-
| "VivaldiBrowser"
|
|
170
|
-
| "VivaldiExtension"
|
|
171
|
-
| "SafariExtension"
|
|
172
|
-
| "SDK"
|
|
173
|
-
| "Server"
|
|
174
|
-
| "WindowsCLI"
|
|
175
|
-
| "MacOsCLI"
|
|
176
|
-
| "LinuxCLI";
|
|
333
|
+
export function isRegistrationError(error: any): error is RegistrationError;
|
|
177
334
|
|
|
178
335
|
/**
|
|
179
|
-
*
|
|
180
|
-
* Bitwarden Client. They are optional and uneditable once the client is initialized.
|
|
181
|
-
*
|
|
182
|
-
* Defaults to
|
|
183
|
-
*
|
|
184
|
-
* ```
|
|
185
|
-
* # use bitwarden_core::{ClientSettings, DeviceType};
|
|
186
|
-
* let settings = ClientSettings {
|
|
187
|
-
* identity_url: \"https://identity.bitwarden.com\".to_string(),
|
|
188
|
-
* api_url: \"https://api.bitwarden.com\".to_string(),
|
|
189
|
-
* user_agent: \"Bitwarden Rust-SDK\".to_string(),
|
|
190
|
-
* device_type: DeviceType::SDK,
|
|
191
|
-
* };
|
|
192
|
-
* let default = ClientSettings::default();
|
|
193
|
-
* ```
|
|
336
|
+
* Request parameters for SSO JIT master password registration.
|
|
194
337
|
*/
|
|
195
|
-
export interface
|
|
338
|
+
export interface JitMasterPasswordRegistrationRequest {
|
|
196
339
|
/**
|
|
197
|
-
*
|
|
340
|
+
* Organization ID to enroll in
|
|
198
341
|
*/
|
|
199
|
-
|
|
342
|
+
org_id: OrganizationId;
|
|
200
343
|
/**
|
|
201
|
-
*
|
|
344
|
+
* Organization\'s public key for encrypting the reset password key. This should be verified by
|
|
345
|
+
* the client and not verifying may compromise the security of the user\'s account.
|
|
202
346
|
*/
|
|
203
|
-
|
|
347
|
+
org_public_key: B64;
|
|
204
348
|
/**
|
|
205
|
-
*
|
|
349
|
+
* Organization SSO identifier
|
|
206
350
|
*/
|
|
207
|
-
|
|
351
|
+
organization_sso_identifier: string;
|
|
208
352
|
/**
|
|
209
|
-
*
|
|
353
|
+
* User ID for the account being initialized
|
|
210
354
|
*/
|
|
211
|
-
|
|
355
|
+
user_id: UserId;
|
|
356
|
+
/**
|
|
357
|
+
* Salt for master password hashing, usually email
|
|
358
|
+
*/
|
|
359
|
+
salt: string;
|
|
360
|
+
/**
|
|
361
|
+
* Master password for the account
|
|
362
|
+
*/
|
|
363
|
+
master_password: string;
|
|
364
|
+
/**
|
|
365
|
+
* Optional hint for the master password
|
|
366
|
+
*/
|
|
367
|
+
master_password_hint: string | undefined;
|
|
368
|
+
/**
|
|
369
|
+
* Should enroll user into admin password reset
|
|
370
|
+
*/
|
|
371
|
+
reset_password_enroll: boolean;
|
|
212
372
|
}
|
|
213
373
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Request parameters for TDE (Trusted Device Encryption) registration.
|
|
376
|
+
*/
|
|
377
|
+
export interface TdeRegistrationRequest {
|
|
378
|
+
/**
|
|
379
|
+
* Organization ID to enroll in
|
|
380
|
+
*/
|
|
381
|
+
org_id: OrganizationId;
|
|
382
|
+
/**
|
|
383
|
+
* Organization\'s public key for encrypting the reset password key. This should be verified by
|
|
384
|
+
* the client and not verifying may compromise the security of the user\'s account.
|
|
385
|
+
*/
|
|
386
|
+
org_public_key: B64;
|
|
387
|
+
/**
|
|
388
|
+
* User ID for the account being initialized
|
|
389
|
+
*/
|
|
390
|
+
user_id: UserId;
|
|
391
|
+
/**
|
|
392
|
+
* Device identifier for TDE enrollment
|
|
393
|
+
*/
|
|
394
|
+
device_identifier: string;
|
|
395
|
+
/**
|
|
396
|
+
* Whether to trust this device for TDE
|
|
397
|
+
*/
|
|
398
|
+
trust_device: boolean;
|
|
399
|
+
}
|
|
217
400
|
|
|
218
401
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
|
|
222
|
-
* Enum represents all the possible KDFs.
|
|
402
|
+
* Result of TDE registration process.
|
|
223
403
|
*/
|
|
224
|
-
export
|
|
225
|
-
|
|
226
|
-
|
|
404
|
+
export interface TdeRegistrationResponse {
|
|
405
|
+
/**
|
|
406
|
+
* The account cryptographic state of the user
|
|
407
|
+
*/
|
|
408
|
+
account_cryptographic_state: WrappedAccountCryptographicState;
|
|
409
|
+
/**
|
|
410
|
+
* The device key
|
|
411
|
+
*/
|
|
412
|
+
device_key: B64;
|
|
413
|
+
/**
|
|
414
|
+
* The decrypted user key. This can be used to get the consuming client to an unlocked state.
|
|
415
|
+
*/
|
|
416
|
+
user_key: B64;
|
|
417
|
+
}
|
|
227
418
|
|
|
228
|
-
|
|
419
|
+
/**
|
|
420
|
+
* Result of Key Connector registration process.
|
|
421
|
+
*/
|
|
422
|
+
export interface KeyConnectorRegistrationResult {
|
|
423
|
+
/**
|
|
424
|
+
* The account cryptographic state of the user.
|
|
425
|
+
*/
|
|
426
|
+
account_cryptographic_state: WrappedAccountCryptographicState;
|
|
229
427
|
/**
|
|
230
|
-
* The
|
|
428
|
+
* The key connector key used for unlocking.
|
|
231
429
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
430
|
+
key_connector_key: B64;
|
|
431
|
+
/**
|
|
432
|
+
* The encrypted user key, wrapped with the key connector key.
|
|
433
|
+
*/
|
|
434
|
+
key_connector_key_wrapped_user_key: EncString;
|
|
435
|
+
/**
|
|
436
|
+
* The decrypted user key. This can be used to get the consuming client to an unlocked state.
|
|
437
|
+
*/
|
|
438
|
+
user_key: B64;
|
|
235
439
|
}
|
|
236
440
|
|
|
237
|
-
|
|
441
|
+
/**
|
|
442
|
+
* Result of JIT master password registration process.
|
|
443
|
+
*/
|
|
444
|
+
export interface JitMasterPasswordRegistrationResponse {
|
|
445
|
+
/**
|
|
446
|
+
* The account cryptographic state of the user
|
|
447
|
+
*/
|
|
448
|
+
account_cryptographic_state: WrappedAccountCryptographicState;
|
|
449
|
+
/**
|
|
450
|
+
* The master password unlock data
|
|
451
|
+
*/
|
|
452
|
+
master_password_unlock: MasterPasswordUnlockData;
|
|
453
|
+
/**
|
|
454
|
+
* The decrypted user key.
|
|
455
|
+
*/
|
|
456
|
+
user_key: B64;
|
|
457
|
+
}
|
|
238
458
|
|
|
239
|
-
export interface
|
|
240
|
-
|
|
241
|
-
|
|
459
|
+
export interface CollectionView {
|
|
460
|
+
id: CollectionId | undefined;
|
|
461
|
+
organizationId: OrganizationId;
|
|
462
|
+
name: string;
|
|
463
|
+
externalId: string | undefined;
|
|
464
|
+
hidePasswords: boolean;
|
|
465
|
+
readOnly: boolean;
|
|
466
|
+
manage: boolean;
|
|
467
|
+
type: CollectionType;
|
|
242
468
|
}
|
|
243
469
|
|
|
244
|
-
|
|
470
|
+
/**
|
|
471
|
+
* Type of collection
|
|
472
|
+
*/
|
|
473
|
+
export type CollectionType = "SharedCollection" | "DefaultUserCollection";
|
|
245
474
|
|
|
246
|
-
export interface
|
|
247
|
-
|
|
248
|
-
|
|
475
|
+
export interface Collection {
|
|
476
|
+
id: CollectionId | undefined;
|
|
477
|
+
organizationId: OrganizationId;
|
|
478
|
+
name: EncString;
|
|
479
|
+
externalId: string | undefined;
|
|
480
|
+
hidePasswords: boolean;
|
|
481
|
+
readOnly: boolean;
|
|
482
|
+
manage: boolean;
|
|
483
|
+
defaultUserCollectionEmail: string | undefined;
|
|
484
|
+
type: CollectionType;
|
|
249
485
|
}
|
|
250
486
|
|
|
251
|
-
|
|
487
|
+
/**
|
|
488
|
+
* NewType wrapper for `CollectionId`
|
|
489
|
+
*/
|
|
490
|
+
export type CollectionId = Tagged<Uuid, "CollectionId">;
|
|
491
|
+
|
|
492
|
+
export interface CollectionDecryptError extends Error {
|
|
493
|
+
name: "CollectionDecryptError";
|
|
494
|
+
variant: "Crypto";
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export function isCollectionDecryptError(error: any): error is CollectionDecryptError;
|
|
498
|
+
|
|
499
|
+
export type SignedSecurityState = string;
|
|
500
|
+
|
|
501
|
+
export interface MasterPasswordError extends Error {
|
|
502
|
+
name: "MasterPasswordError";
|
|
503
|
+
variant:
|
|
504
|
+
| "EncryptionKeyMalformed"
|
|
505
|
+
| "KdfMalformed"
|
|
506
|
+
| "InvalidKdfConfiguration"
|
|
507
|
+
| "MissingField"
|
|
508
|
+
| "Crypto"
|
|
509
|
+
| "WrongPassword";
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export function isMasterPasswordError(error: any): error is MasterPasswordError;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Represents the data required to unlock with the master password.
|
|
516
|
+
*/
|
|
517
|
+
export interface MasterPasswordUnlockData {
|
|
518
|
+
/**
|
|
519
|
+
* The key derivation function used to derive the master key
|
|
520
|
+
*/
|
|
521
|
+
kdf: Kdf;
|
|
522
|
+
/**
|
|
523
|
+
* The master key wrapped user key
|
|
524
|
+
*/
|
|
525
|
+
masterKeyWrappedUserKey: EncString;
|
|
526
|
+
/**
|
|
527
|
+
* The salt used in the KDF, typically the user\'s email
|
|
528
|
+
*/
|
|
529
|
+
salt: string;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Represents the data required to authenticate with the master password.
|
|
534
|
+
*/
|
|
535
|
+
export interface MasterPasswordAuthenticationData {
|
|
536
|
+
kdf: Kdf;
|
|
537
|
+
salt: string;
|
|
538
|
+
masterPasswordAuthenticationHash: B64;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
export interface AccountCryptographyInitializationError extends Error {
|
|
542
|
+
name: "AccountCryptographyInitializationError";
|
|
543
|
+
variant:
|
|
544
|
+
| "WrongUserKeyType"
|
|
545
|
+
| "WrongUserKey"
|
|
546
|
+
| "CorruptData"
|
|
547
|
+
| "TamperedData"
|
|
548
|
+
| "KeyStoreAlreadyInitialized"
|
|
549
|
+
| "GenericCrypto";
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export function isAccountCryptographyInitializationError(
|
|
553
|
+
error: any,
|
|
554
|
+
): error is AccountCryptographyInitializationError;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Any keys / cryptographic protection \"downstream\" from the account symmetric key (user key).
|
|
558
|
+
* Private keys are protected by the user key.
|
|
559
|
+
*/
|
|
560
|
+
export type WrappedAccountCryptographicState =
|
|
561
|
+
| { V1: { private_key: EncString } }
|
|
562
|
+
| {
|
|
563
|
+
V2: {
|
|
564
|
+
private_key: EncString;
|
|
565
|
+
signed_public_key: SignedPublicKey | undefined;
|
|
566
|
+
signing_key: EncString;
|
|
567
|
+
security_state: SignedSecurityState;
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
export interface RotateCryptographyStateError extends Error {
|
|
572
|
+
name: "RotateCryptographyStateError";
|
|
573
|
+
variant: "KeyMissing" | "InvalidData";
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export function isRotateCryptographyStateError(error: any): error is RotateCryptographyStateError;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Represents the request to initialize the user\'s organizational cryptographic state.
|
|
580
|
+
*/
|
|
581
|
+
export interface InitOrgCryptoRequest {
|
|
582
|
+
/**
|
|
583
|
+
* The encryption keys for all the organizations the user is a part of
|
|
584
|
+
*/
|
|
585
|
+
organizationKeys: Map<OrganizationId, UnsignedSharedKey>;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export interface MakeKeysError extends Error {
|
|
589
|
+
name: "MakeKeysError";
|
|
590
|
+
variant:
|
|
591
|
+
| "AccountCryptographyInitialization"
|
|
592
|
+
| "MasterPasswordDerivation"
|
|
593
|
+
| "RequestModelCreation"
|
|
594
|
+
| "Crypto";
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export function isMakeKeysError(error: any): error is MakeKeysError;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* The crypto method used to initialize the user cryptographic state.
|
|
601
|
+
*/
|
|
602
|
+
export type InitUserCryptoMethod =
|
|
603
|
+
| { masterPasswordUnlock: { password: string; master_password_unlock: MasterPasswordUnlockData } }
|
|
604
|
+
| { decryptedKey: { decrypted_user_key: string } }
|
|
605
|
+
| { pin: { pin: string; pin_protected_user_key: EncString } }
|
|
606
|
+
| { pinEnvelope: { pin: string; pin_protected_user_key_envelope: PasswordProtectedKeyEnvelope } }
|
|
607
|
+
| { authRequest: { request_private_key: B64; method: AuthRequestMethod } }
|
|
608
|
+
| {
|
|
609
|
+
deviceKey: {
|
|
610
|
+
device_key: string;
|
|
611
|
+
protected_device_private_key: EncString;
|
|
612
|
+
device_protected_user_key: UnsignedSharedKey;
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
| { keyConnector: { master_key: B64; user_key: EncString } };
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Request for deriving a pin protected user key
|
|
619
|
+
*/
|
|
620
|
+
export interface EnrollPinResponse {
|
|
621
|
+
/**
|
|
622
|
+
* [UserKey] protected by PIN
|
|
623
|
+
*/
|
|
624
|
+
pinProtectedUserKeyEnvelope: PasswordProtectedKeyEnvelope;
|
|
625
|
+
/**
|
|
626
|
+
* PIN protected by [UserKey]
|
|
627
|
+
*/
|
|
628
|
+
userKeyEncryptedPin: EncString;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Request for deriving a pin protected user key
|
|
633
|
+
*/
|
|
634
|
+
export interface DerivePinKeyResponse {
|
|
635
|
+
/**
|
|
636
|
+
* [UserKey] protected by PIN
|
|
637
|
+
*/
|
|
638
|
+
pinProtectedUserKey: EncString;
|
|
639
|
+
/**
|
|
640
|
+
* PIN protected by [UserKey]
|
|
641
|
+
*/
|
|
642
|
+
encryptedPin: EncString;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Request for `verify_asymmetric_keys`.
|
|
647
|
+
*/
|
|
648
|
+
export interface VerifyAsymmetricKeysRequest {
|
|
649
|
+
/**
|
|
650
|
+
* The user\'s user key
|
|
651
|
+
*/
|
|
652
|
+
userKey: B64;
|
|
653
|
+
/**
|
|
654
|
+
* The user\'s public key
|
|
655
|
+
*/
|
|
656
|
+
userPublicKey: B64;
|
|
657
|
+
/**
|
|
658
|
+
* User\'s private key, encrypted with the user key
|
|
659
|
+
*/
|
|
660
|
+
userKeyEncryptedPrivateKey: EncString;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Response for `verify_asymmetric_keys`.
|
|
665
|
+
*/
|
|
666
|
+
export interface VerifyAsymmetricKeysResponse {
|
|
667
|
+
/**
|
|
668
|
+
* Whether the user\'s private key was decryptable by the user key.
|
|
669
|
+
*/
|
|
670
|
+
privateKeyDecryptable: boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Whether the user\'s private key was a valid RSA key and matched the public key provided.
|
|
673
|
+
*/
|
|
674
|
+
validPrivateKey: boolean;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Response for the `make_keys_for_user_crypto_v2`, containing a set of keys for a user
|
|
679
|
+
*/
|
|
680
|
+
export interface UserCryptoV2KeysResponse {
|
|
681
|
+
/**
|
|
682
|
+
* User key
|
|
683
|
+
*/
|
|
684
|
+
userKey: B64;
|
|
685
|
+
/**
|
|
686
|
+
* Wrapped private key
|
|
687
|
+
*/
|
|
688
|
+
privateKey: EncString;
|
|
689
|
+
/**
|
|
690
|
+
* Public key
|
|
691
|
+
*/
|
|
692
|
+
publicKey: B64;
|
|
693
|
+
/**
|
|
694
|
+
* The user\'s public key, signed by the signing key
|
|
695
|
+
*/
|
|
696
|
+
signedPublicKey: SignedPublicKey;
|
|
697
|
+
/**
|
|
698
|
+
* Signing key, encrypted with the user\'s symmetric key
|
|
699
|
+
*/
|
|
700
|
+
signingKey: EncString;
|
|
701
|
+
/**
|
|
702
|
+
* Base64 encoded verifying key
|
|
703
|
+
*/
|
|
704
|
+
verifyingKey: B64;
|
|
705
|
+
/**
|
|
706
|
+
* The user\'s signed security state
|
|
707
|
+
*/
|
|
708
|
+
securityState: SignedSecurityState;
|
|
709
|
+
/**
|
|
710
|
+
* The security state\'s version
|
|
711
|
+
*/
|
|
712
|
+
securityVersion: number;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export interface EnrollAdminPasswordResetError extends Error {
|
|
716
|
+
name: "EnrollAdminPasswordResetError";
|
|
717
|
+
variant: "Crypto";
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export function isEnrollAdminPasswordResetError(error: any): error is EnrollAdminPasswordResetError;
|
|
721
|
+
|
|
722
|
+
export interface CryptoClientError extends Error {
|
|
723
|
+
name: "CryptoClientError";
|
|
724
|
+
variant:
|
|
725
|
+
| "NotAuthenticated"
|
|
726
|
+
| "Crypto"
|
|
727
|
+
| "InvalidKdfSettings"
|
|
728
|
+
| "PasswordProtectedKeyEnvelope"
|
|
729
|
+
| "InvalidPrfInput";
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
export function isCryptoClientError(error: any): error is CryptoClientError;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Request for migrating an account from password to key connector.
|
|
736
|
+
*/
|
|
737
|
+
export interface DeriveKeyConnectorRequest {
|
|
738
|
+
/**
|
|
739
|
+
* Encrypted user key, used to validate the master key
|
|
740
|
+
*/
|
|
741
|
+
userKeyEncrypted: EncString;
|
|
742
|
+
/**
|
|
743
|
+
* The user\'s master password
|
|
744
|
+
*/
|
|
745
|
+
password: string;
|
|
746
|
+
/**
|
|
747
|
+
* The KDF parameters used to derive the master key
|
|
748
|
+
*/
|
|
749
|
+
kdf: Kdf;
|
|
750
|
+
/**
|
|
751
|
+
* The user\'s email address
|
|
752
|
+
*/
|
|
753
|
+
email: string;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
export interface DeriveKeyConnectorError extends Error {
|
|
757
|
+
name: "DeriveKeyConnectorError";
|
|
758
|
+
variant: "WrongPassword" | "Crypto";
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export function isDeriveKeyConnectorError(error: any): error is DeriveKeyConnectorError;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Response from the `make_update_password` function
|
|
765
|
+
*/
|
|
766
|
+
export interface UpdatePasswordResponse {
|
|
767
|
+
/**
|
|
768
|
+
* Hash of the new password
|
|
769
|
+
*/
|
|
770
|
+
passwordHash: B64;
|
|
771
|
+
/**
|
|
772
|
+
* User key, encrypted with the new password
|
|
773
|
+
*/
|
|
774
|
+
newKey: EncString;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Response from the `make_key_pair` function
|
|
779
|
+
*/
|
|
780
|
+
export interface MakeKeyPairResponse {
|
|
781
|
+
/**
|
|
782
|
+
* The user\'s public key
|
|
783
|
+
*/
|
|
784
|
+
userPublicKey: B64;
|
|
785
|
+
/**
|
|
786
|
+
* User\'s private key, encrypted with the user key
|
|
787
|
+
*/
|
|
788
|
+
userKeyEncryptedPrivateKey: EncString;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* State used for initializing the user cryptographic state.
|
|
793
|
+
*/
|
|
794
|
+
export interface InitUserCryptoRequest {
|
|
795
|
+
/**
|
|
796
|
+
* The user\'s ID.
|
|
797
|
+
*/
|
|
798
|
+
userId: UserId | undefined;
|
|
799
|
+
/**
|
|
800
|
+
* The user\'s KDF parameters, as received from the prelogin request
|
|
801
|
+
*/
|
|
802
|
+
kdfParams: Kdf;
|
|
803
|
+
/**
|
|
804
|
+
* The user\'s email address
|
|
805
|
+
*/
|
|
806
|
+
email: string;
|
|
807
|
+
/**
|
|
808
|
+
* The user\'s account cryptographic state, containing their signature and
|
|
809
|
+
* public-key-encryption keys, along with the signed security state, protected by the user key
|
|
810
|
+
*/
|
|
811
|
+
accountCryptographicState: WrappedAccountCryptographicState;
|
|
812
|
+
/**
|
|
813
|
+
* The method to decrypt the user\'s account symmetric key (user key)
|
|
814
|
+
*/
|
|
815
|
+
method: InitUserCryptoMethod;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Response from the `update_kdf` function
|
|
820
|
+
*/
|
|
821
|
+
export interface UpdateKdfResponse {
|
|
822
|
+
/**
|
|
823
|
+
* The authentication data for the new KDF setting
|
|
824
|
+
*/
|
|
825
|
+
masterPasswordAuthenticationData: MasterPasswordAuthenticationData;
|
|
826
|
+
/**
|
|
827
|
+
* The unlock data for the new KDF setting
|
|
828
|
+
*/
|
|
829
|
+
masterPasswordUnlockData: MasterPasswordUnlockData;
|
|
830
|
+
/**
|
|
831
|
+
* The authentication data for the KDF setting prior to the change
|
|
832
|
+
*/
|
|
833
|
+
oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Auth requests supports multiple initialization methods.
|
|
838
|
+
*/
|
|
839
|
+
export type AuthRequestMethod =
|
|
840
|
+
| { userKey: { protected_user_key: UnsignedSharedKey } }
|
|
841
|
+
| { masterKey: { protected_master_key: UnsignedSharedKey; auth_request_key: EncString } };
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* NewType wrapper for `OrganizationId`
|
|
845
|
+
*/
|
|
846
|
+
export type OrganizationId = Tagged<Uuid, "OrganizationId">;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* NewType wrapper for `UserId`
|
|
850
|
+
*/
|
|
851
|
+
export type UserId = Tagged<Uuid, "UserId">;
|
|
852
|
+
|
|
853
|
+
export interface StatefulCryptoError extends Error {
|
|
854
|
+
name: "StatefulCryptoError";
|
|
855
|
+
variant: "MissingSecurityState" | "WrongAccountCryptoVersion" | "Crypto";
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
export function isStatefulCryptoError(error: any): error is StatefulCryptoError;
|
|
859
|
+
|
|
860
|
+
export type DeviceType =
|
|
861
|
+
| "Android"
|
|
862
|
+
| "iOS"
|
|
863
|
+
| "ChromeExtension"
|
|
864
|
+
| "FirefoxExtension"
|
|
865
|
+
| "OperaExtension"
|
|
866
|
+
| "EdgeExtension"
|
|
867
|
+
| "WindowsDesktop"
|
|
868
|
+
| "MacOsDesktop"
|
|
869
|
+
| "LinuxDesktop"
|
|
870
|
+
| "ChromeBrowser"
|
|
871
|
+
| "FirefoxBrowser"
|
|
872
|
+
| "OperaBrowser"
|
|
873
|
+
| "EdgeBrowser"
|
|
874
|
+
| "IEBrowser"
|
|
875
|
+
| "UnknownBrowser"
|
|
876
|
+
| "AndroidAmazon"
|
|
877
|
+
| "UWP"
|
|
878
|
+
| "SafariBrowser"
|
|
879
|
+
| "VivaldiBrowser"
|
|
880
|
+
| "VivaldiExtension"
|
|
881
|
+
| "SafariExtension"
|
|
882
|
+
| "SDK"
|
|
883
|
+
| "Server"
|
|
884
|
+
| "WindowsCLI"
|
|
885
|
+
| "MacOsCLI"
|
|
886
|
+
| "LinuxCLI"
|
|
887
|
+
| "DuckDuckGoBrowser";
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Basic client behavior settings. These settings specify the various targets and behavior of the
|
|
891
|
+
* Bitwarden Client. They are optional and uneditable once the client is initialized.
|
|
892
|
+
*
|
|
893
|
+
* Defaults to
|
|
894
|
+
*
|
|
895
|
+
* ```
|
|
896
|
+
* # use bitwarden_core::{ClientSettings, DeviceType};
|
|
897
|
+
* let settings = ClientSettings {
|
|
898
|
+
* identity_url: \"https://identity.bitwarden.com\".to_string(),
|
|
899
|
+
* api_url: \"https://api.bitwarden.com\".to_string(),
|
|
900
|
+
* user_agent: \"Bitwarden Rust-SDK\".to_string(),
|
|
901
|
+
* device_type: DeviceType::SDK,
|
|
902
|
+
* bitwarden_client_version: None,
|
|
903
|
+
* bitwarden_package_type: None,
|
|
904
|
+
* device_identifier: None,
|
|
905
|
+
* };
|
|
906
|
+
* let default = ClientSettings::default();
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
909
|
+
export interface ClientSettings {
|
|
910
|
+
/**
|
|
911
|
+
* The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
|
|
912
|
+
*/
|
|
913
|
+
identityUrl?: string;
|
|
914
|
+
/**
|
|
915
|
+
* The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`
|
|
916
|
+
*/
|
|
917
|
+
apiUrl?: string;
|
|
918
|
+
/**
|
|
919
|
+
* The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`
|
|
920
|
+
*/
|
|
921
|
+
userAgent?: string;
|
|
922
|
+
/**
|
|
923
|
+
* Device type to send to Bitwarden. Defaults to SDK
|
|
924
|
+
*/
|
|
925
|
+
deviceType?: DeviceType;
|
|
926
|
+
/**
|
|
927
|
+
* Device identifier to send to Bitwarden. Optional for now in transition period.
|
|
928
|
+
*/
|
|
929
|
+
deviceIdentifier?: string | undefined;
|
|
930
|
+
/**
|
|
931
|
+
* Bitwarden Client Version to send to Bitwarden. Optional for now in transition period.
|
|
932
|
+
*/
|
|
933
|
+
bitwardenClientVersion?: string | undefined;
|
|
934
|
+
/**
|
|
935
|
+
* Bitwarden Package Type to send to Bitwarden. We should evaluate this field to see if it
|
|
936
|
+
* should be optional later.
|
|
937
|
+
*/
|
|
938
|
+
bitwardenPackageType?: string | undefined;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
export interface EncryptionSettingsError extends Error {
|
|
942
|
+
name: "EncryptionSettingsError";
|
|
943
|
+
variant:
|
|
944
|
+
| "Crypto"
|
|
945
|
+
| "CryptoInitialization"
|
|
946
|
+
| "MissingPrivateKey"
|
|
947
|
+
| "UserIdAlreadySet"
|
|
948
|
+
| "WrongPin";
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
|
|
952
|
+
|
|
953
|
+
export type UnsignedSharedKey = Tagged<string, "UnsignedSharedKey">;
|
|
954
|
+
|
|
955
|
+
export type EncString = Tagged<string, "EncString">;
|
|
956
|
+
|
|
957
|
+
export interface TrustDeviceResponse {
|
|
958
|
+
/**
|
|
959
|
+
* Base64 encoded device key
|
|
960
|
+
*/
|
|
961
|
+
device_key: B64;
|
|
962
|
+
/**
|
|
963
|
+
* UserKey encrypted with DevicePublicKey
|
|
964
|
+
*/
|
|
965
|
+
protected_user_key: UnsignedSharedKey;
|
|
966
|
+
/**
|
|
967
|
+
* DevicePrivateKey encrypted with [DeviceKey]
|
|
968
|
+
*/
|
|
969
|
+
protected_device_private_key: EncString;
|
|
970
|
+
/**
|
|
971
|
+
* DevicePublicKey encrypted with [UserKey](super::UserKey)
|
|
972
|
+
*/
|
|
973
|
+
protected_device_public_key: EncString;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
export type SignedPublicKey = Tagged<string, "SignedPublicKey">;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* A set of keys where a given `DownstreamKey` is protected by an encrypted public/private
|
|
980
|
+
* key-pair. The `DownstreamKey` is used to encrypt/decrypt data, while the public/private key-pair
|
|
981
|
+
* is used to rotate the `DownstreamKey`.
|
|
982
|
+
*
|
|
983
|
+
* The `PrivateKey` is protected by an `UpstreamKey`, such as a `DeviceKey`, or `PrfKey`,
|
|
984
|
+
* and the `PublicKey` is protected by the `DownstreamKey`. This setup allows:
|
|
985
|
+
*
|
|
986
|
+
* - Access to `DownstreamKey` by knowing the `UpstreamKey`
|
|
987
|
+
* - Rotation to a `NewDownstreamKey` by knowing the current `DownstreamKey`, without needing
|
|
988
|
+
* access to the `UpstreamKey`
|
|
989
|
+
*/
|
|
990
|
+
export interface RotateableKeySet {
|
|
991
|
+
/**
|
|
992
|
+
* `DownstreamKey` protected by encapsulation key
|
|
993
|
+
*/
|
|
994
|
+
encapsulatedDownstreamKey: UnsignedSharedKey;
|
|
995
|
+
/**
|
|
996
|
+
* Encapsulation key protected by `DownstreamKey`
|
|
997
|
+
*/
|
|
998
|
+
encryptedEncapsulationKey: EncString;
|
|
999
|
+
/**
|
|
1000
|
+
* Decapsulation key protected by `UpstreamKey`
|
|
1001
|
+
*/
|
|
1002
|
+
encryptedDecapsulationKey: EncString;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
export type PublicKey = Tagged<string, "PublicKey">;
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Key Derivation Function for Bitwarden Account
|
|
1009
|
+
*
|
|
1010
|
+
* In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This
|
|
1011
|
+
* Enum represents all the possible KDFs.
|
|
1012
|
+
*/
|
|
1013
|
+
export type Kdf =
|
|
1014
|
+
| { pBKDF2: { iterations: NonZeroU32 } }
|
|
1015
|
+
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
|
1016
|
+
|
|
1017
|
+
export type DataEnvelope = Tagged<string, "DataEnvelope">;
|
|
1018
|
+
|
|
1019
|
+
export type PasswordProtectedKeyEnvelope = Tagged<string, "PasswordProtectedKeyEnvelope">;
|
|
1020
|
+
|
|
1021
|
+
export interface CryptoError extends Error {
|
|
1022
|
+
name: "CryptoError";
|
|
1023
|
+
variant:
|
|
1024
|
+
| "Decrypt"
|
|
1025
|
+
| "InvalidKey"
|
|
1026
|
+
| "KeyDecrypt"
|
|
1027
|
+
| "InvalidKeyLen"
|
|
1028
|
+
| "InvalidUtf8String"
|
|
1029
|
+
| "MissingKey"
|
|
1030
|
+
| "MissingField"
|
|
1031
|
+
| "MissingKeyId"
|
|
1032
|
+
| "KeyOperationNotSupported"
|
|
1033
|
+
| "ReadOnlyKeyStore"
|
|
1034
|
+
| "InvalidKeyStoreOperation"
|
|
1035
|
+
| "InsufficientKdfParameters"
|
|
1036
|
+
| "EncString"
|
|
1037
|
+
| "Rsa"
|
|
1038
|
+
| "Fingerprint"
|
|
1039
|
+
| "Argon"
|
|
1040
|
+
| "ZeroNumber"
|
|
1041
|
+
| "OperationNotSupported"
|
|
1042
|
+
| "WrongKeyType"
|
|
1043
|
+
| "WrongCoseKeyId"
|
|
1044
|
+
| "InvalidNonceLength"
|
|
1045
|
+
| "InvalidPadding"
|
|
1046
|
+
| "Signature"
|
|
1047
|
+
| "Encoding";
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export function isCryptoError(error: any): error is CryptoError;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* The type of key / signature scheme used for signing and verifying.
|
|
1054
|
+
*/
|
|
1055
|
+
export type SignatureAlgorithm = "ed25519";
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Base64 encoded data
|
|
1059
|
+
*
|
|
1060
|
+
* Is indifferent about padding when decoding, but always produces padding when encoding.
|
|
1061
|
+
*/
|
|
1062
|
+
export type B64 = string;
|
|
1063
|
+
|
|
1064
|
+
export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Temporary struct to hold metadata related to current account
|
|
1068
|
+
*
|
|
1069
|
+
* Eventually the SDK itself should have this state and we get rid of this struct.
|
|
1070
|
+
*/
|
|
1071
|
+
export interface Account {
|
|
1072
|
+
id: Uuid;
|
|
1073
|
+
email: string;
|
|
1074
|
+
name: string | undefined;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
export interface ExportError extends Error {
|
|
1078
|
+
name: "ExportError";
|
|
1079
|
+
variant:
|
|
1080
|
+
| "MissingField"
|
|
1081
|
+
| "NotAuthenticated"
|
|
1082
|
+
| "Csv"
|
|
1083
|
+
| "Cxf"
|
|
1084
|
+
| "Json"
|
|
1085
|
+
| "EncryptedJson"
|
|
1086
|
+
| "BitwardenCrypto"
|
|
1087
|
+
| "Cipher";
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export function isExportError(error: any): error is ExportError;
|
|
1091
|
+
|
|
1092
|
+
export type PassphraseError = { InvalidNumWords: { minimum: number; maximum: number } };
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Passphrase generator request options.
|
|
1096
|
+
*/
|
|
1097
|
+
export interface PassphraseGeneratorRequest {
|
|
1098
|
+
/**
|
|
1099
|
+
* Number of words in the generated passphrase.
|
|
1100
|
+
* This value must be between 3 and 20.
|
|
1101
|
+
*/
|
|
1102
|
+
numWords: number;
|
|
1103
|
+
/**
|
|
1104
|
+
* Character separator between words in the generated passphrase. The value cannot be empty.
|
|
1105
|
+
*/
|
|
1106
|
+
wordSeparator: string;
|
|
1107
|
+
/**
|
|
1108
|
+
* When set to true, capitalize the first letter of each word in the generated passphrase.
|
|
1109
|
+
*/
|
|
1110
|
+
capitalize: boolean;
|
|
1111
|
+
/**
|
|
1112
|
+
* When set to true, include a number at the end of one of the words in the generated
|
|
1113
|
+
* passphrase.
|
|
1114
|
+
*/
|
|
1115
|
+
includeNumber: boolean;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Password generator request options.
|
|
1120
|
+
*/
|
|
1121
|
+
export interface PasswordGeneratorRequest {
|
|
1122
|
+
/**
|
|
1123
|
+
* Include lowercase characters (a-z).
|
|
1124
|
+
*/
|
|
1125
|
+
lowercase: boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* Include uppercase characters (A-Z).
|
|
1128
|
+
*/
|
|
1129
|
+
uppercase: boolean;
|
|
1130
|
+
/**
|
|
1131
|
+
* Include numbers (0-9).
|
|
1132
|
+
*/
|
|
1133
|
+
numbers: boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* Include special characters: ! @ # $ % ^ & *
|
|
1136
|
+
*/
|
|
1137
|
+
special: boolean;
|
|
1138
|
+
/**
|
|
1139
|
+
* The length of the generated password.
|
|
1140
|
+
* Note that the password length must be greater than the sum of all the minimums.
|
|
1141
|
+
*/
|
|
1142
|
+
length: number;
|
|
1143
|
+
/**
|
|
1144
|
+
* When set to true, the generated password will not contain ambiguous characters.
|
|
1145
|
+
* The ambiguous characters are: I, O, l, 0, 1
|
|
1146
|
+
*/
|
|
1147
|
+
avoidAmbiguous: boolean;
|
|
1148
|
+
/**
|
|
1149
|
+
* The minimum number of lowercase characters in the generated password.
|
|
1150
|
+
* When set, the value must be between 1 and 9. This value is ignored if lowercase is false.
|
|
1151
|
+
*/
|
|
1152
|
+
minLowercase: number | undefined;
|
|
1153
|
+
/**
|
|
1154
|
+
* The minimum number of uppercase characters in the generated password.
|
|
1155
|
+
* When set, the value must be between 1 and 9. This value is ignored if uppercase is false.
|
|
1156
|
+
*/
|
|
1157
|
+
minUppercase: number | undefined;
|
|
1158
|
+
/**
|
|
1159
|
+
* The minimum number of numbers in the generated password.
|
|
1160
|
+
* When set, the value must be between 1 and 9. This value is ignored if numbers is false.
|
|
1161
|
+
*/
|
|
1162
|
+
minNumber: number | undefined;
|
|
1163
|
+
/**
|
|
1164
|
+
* The minimum number of special characters in the generated password.
|
|
1165
|
+
* When set, the value must be between 1 and 9. This value is ignored if special is false.
|
|
1166
|
+
*/
|
|
1167
|
+
minSpecial: number | undefined;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
export interface PasswordError extends Error {
|
|
1171
|
+
name: "PasswordError";
|
|
1172
|
+
variant: "NoCharacterSetEnabled" | "InvalidLength";
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
export function isPasswordError(error: any): error is PasswordError;
|
|
1176
|
+
|
|
1177
|
+
export type UsernameGeneratorRequest =
|
|
1178
|
+
| { word: { capitalize: boolean; include_number: boolean } }
|
|
1179
|
+
| { subaddress: { type: AppendType; email: string } }
|
|
1180
|
+
| { catchall: { type: AppendType; domain: string } }
|
|
1181
|
+
| { forwarded: { service: ForwarderServiceType; website: string | undefined } };
|
|
1182
|
+
|
|
1183
|
+
export type AppendType = "random" | { websiteName: { website: string } };
|
|
1184
|
+
|
|
1185
|
+
export interface UsernameError extends Error {
|
|
1186
|
+
name: "UsernameError";
|
|
1187
|
+
variant: "InvalidApiKey" | "Unknown" | "ResponseContent" | "Reqwest";
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
export function isUsernameError(error: any): error is UsernameError;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Configures the email forwarding service to use.
|
|
1194
|
+
* For instructions on how to configure each service, see the documentation:
|
|
1195
|
+
* <https://bitwarden.com/help/generator/#username-types>
|
|
1196
|
+
*/
|
|
1197
|
+
export type ForwarderServiceType =
|
|
1198
|
+
| { addyIo: { api_token: string; domain: string; base_url: string } }
|
|
1199
|
+
| { duckDuckGo: { token: string } }
|
|
1200
|
+
| { firefox: { api_token: string } }
|
|
1201
|
+
| { fastmail: { api_token: string } }
|
|
1202
|
+
| { forwardEmail: { api_token: string; domain: string } }
|
|
1203
|
+
| { simpleLogin: { api_key: string; base_url: string } };
|
|
1204
|
+
|
|
1205
|
+
export interface ReceiveError extends Error {
|
|
1206
|
+
name: "ReceiveError";
|
|
1207
|
+
variant: "Channel" | "Timeout" | "Cancelled";
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
export function isReceiveError(error: any): error is ReceiveError;
|
|
1211
|
+
|
|
1212
|
+
export interface TypedReceiveError extends Error {
|
|
1213
|
+
name: "TypedReceiveError";
|
|
1214
|
+
variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
export function isTypedReceiveError(error: any): error is TypedReceiveError;
|
|
1218
|
+
|
|
1219
|
+
export interface SubscribeError extends Error {
|
|
1220
|
+
name: "SubscribeError";
|
|
1221
|
+
variant: "NotStarted";
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
export function isSubscribeError(error: any): error is SubscribeError;
|
|
1225
|
+
|
|
1226
|
+
export interface RequestError extends Error {
|
|
1227
|
+
name: "RequestError";
|
|
1228
|
+
variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "Rpc";
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
export function isRequestError(error: any): error is RequestError;
|
|
1232
|
+
|
|
1233
|
+
export interface IpcCommunicationBackendSender {
|
|
1234
|
+
send(message: OutgoingMessage): Promise<void>;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
export interface DeserializeError extends Error {
|
|
1238
|
+
name: "DeserializeError";
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export function isDeserializeError(error: any): error is DeserializeError;
|
|
1242
|
+
|
|
1243
|
+
export interface ChannelError extends Error {
|
|
1244
|
+
name: "ChannelError";
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
export function isChannelError(error: any): error is ChannelError;
|
|
1248
|
+
|
|
1249
|
+
export interface IpcSessionRepository {
|
|
1250
|
+
get(endpoint: Endpoint): Promise<any | undefined>;
|
|
1251
|
+
save(endpoint: Endpoint, session: any): Promise<void>;
|
|
1252
|
+
remove(endpoint: Endpoint): Promise<void>;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
export interface DiscoverResponse {
|
|
1256
|
+
version: string;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
export type Endpoint =
|
|
1260
|
+
| { Web: { id: number } }
|
|
1261
|
+
| "BrowserForeground"
|
|
1262
|
+
| "BrowserBackground"
|
|
1263
|
+
| "DesktopRenderer"
|
|
1264
|
+
| "DesktopMain";
|
|
1265
|
+
|
|
1266
|
+
export interface SshKeyImportError extends Error {
|
|
1267
|
+
name: "SshKeyImportError";
|
|
1268
|
+
variant: "Parsing" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
export function isSshKeyImportError(error: any): error is SshKeyImportError;
|
|
1272
|
+
|
|
1273
|
+
export interface SshKeyExportError extends Error {
|
|
1274
|
+
name: "SshKeyExportError";
|
|
1275
|
+
variant: "KeyConversion";
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
export function isSshKeyExportError(error: any): error is SshKeyExportError;
|
|
1279
|
+
|
|
1280
|
+
export interface KeyGenerationError extends Error {
|
|
1281
|
+
name: "KeyGenerationError";
|
|
1282
|
+
variant: "KeyGeneration" | "KeyConversion";
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
export function isKeyGenerationError(error: any): error is KeyGenerationError;
|
|
1286
|
+
|
|
1287
|
+
export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
|
1288
|
+
|
|
1289
|
+
export interface DatabaseError extends Error {
|
|
1290
|
+
name: "DatabaseError";
|
|
1291
|
+
variant: "UnsupportedConfiguration" | "ThreadBoundRunner" | "Serialization" | "JS" | "Internal";
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
export function isDatabaseError(error: any): error is DatabaseError;
|
|
1295
|
+
|
|
1296
|
+
export interface StateRegistryError extends Error {
|
|
1297
|
+
name: "StateRegistryError";
|
|
1298
|
+
variant: "DatabaseAlreadyInitialized" | "DatabaseNotInitialized" | "Database";
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
export function isStateRegistryError(error: any): error is StateRegistryError;
|
|
1302
|
+
|
|
1303
|
+
export interface CallError extends Error {
|
|
1304
|
+
name: "CallError";
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
export function isCallError(error: any): error is CallError;
|
|
1308
|
+
|
|
1309
|
+
export interface CipherRiskError extends Error {
|
|
1310
|
+
name: "CipherRiskError";
|
|
1311
|
+
variant: "Reqwest";
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
export function isCipherRiskError(error: any): error is CipherRiskError;
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Result of checking password exposure via HIBP API.
|
|
1318
|
+
*/
|
|
1319
|
+
export type ExposedPasswordResult =
|
|
1320
|
+
| { type: "NotChecked" }
|
|
1321
|
+
| { type: "Found"; value: number }
|
|
1322
|
+
| { type: "Error"; value: string };
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Password reuse map wrapper for WASM compatibility.
|
|
1326
|
+
*/
|
|
1327
|
+
export type PasswordReuseMap = Record<string, number>;
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Login cipher data needed for risk evaluation.
|
|
1331
|
+
*/
|
|
1332
|
+
export interface CipherLoginDetails {
|
|
1333
|
+
/**
|
|
1334
|
+
* Cipher ID to identify which cipher in results.
|
|
1335
|
+
*/
|
|
1336
|
+
id: CipherId;
|
|
1337
|
+
/**
|
|
1338
|
+
* The decrypted password to evaluate.
|
|
1339
|
+
*/
|
|
1340
|
+
password: string;
|
|
1341
|
+
/**
|
|
1342
|
+
* Username or email (login ciphers only have one field).
|
|
1343
|
+
*/
|
|
1344
|
+
username: string | undefined;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* Risk evaluation result for a single cipher.
|
|
1349
|
+
*/
|
|
1350
|
+
export interface CipherRiskResult {
|
|
1351
|
+
/**
|
|
1352
|
+
* Cipher ID matching the input CipherLoginDetails.
|
|
1353
|
+
*/
|
|
1354
|
+
id: CipherId;
|
|
1355
|
+
/**
|
|
1356
|
+
* Password strength score from 0 (weakest) to 4 (strongest).
|
|
1357
|
+
* Calculated using zxcvbn with cipher-specific context.
|
|
1358
|
+
*/
|
|
1359
|
+
password_strength: number;
|
|
1360
|
+
/**
|
|
1361
|
+
* Result of checking password exposure via HIBP API.
|
|
1362
|
+
* - `NotChecked`: check_exposed was false, or password was empty
|
|
1363
|
+
* - `Found(n)`: Successfully checked, found in n breaches
|
|
1364
|
+
* - `Error(msg)`: HIBP API request failed for this cipher with the given error message
|
|
1365
|
+
*/
|
|
1366
|
+
exposed_result: ExposedPasswordResult;
|
|
1367
|
+
/**
|
|
1368
|
+
* Number of times this password appears in the provided password_map.
|
|
1369
|
+
* None if not found or if no password_map was provided.
|
|
1370
|
+
*/
|
|
1371
|
+
reuse_count: number | undefined;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Options for configuring risk computation.
|
|
1376
|
+
*/
|
|
1377
|
+
export interface CipherRiskOptions {
|
|
1378
|
+
/**
|
|
1379
|
+
* Pre-computed password reuse map (password → count).
|
|
1380
|
+
* If provided, enables reuse detection across ciphers.
|
|
1381
|
+
*/
|
|
1382
|
+
passwordMap?: PasswordReuseMap | undefined;
|
|
1383
|
+
/**
|
|
1384
|
+
* Whether to check passwords against Have I Been Pwned API.
|
|
1385
|
+
* When true, makes network requests to check for exposed passwords.
|
|
1386
|
+
*/
|
|
1387
|
+
checkExposed?: boolean;
|
|
1388
|
+
/**
|
|
1389
|
+
* Optional HIBP API base URL override. When None, uses the production HIBP URL.
|
|
1390
|
+
* Can be used for testing or alternative password breach checking services.
|
|
1391
|
+
*/
|
|
1392
|
+
hibpBaseUrl?: string | undefined;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
export interface PasswordHistory {
|
|
1396
|
+
password: EncString;
|
|
1397
|
+
lastUsedDate: DateTime<Utc>;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
export interface PasswordHistoryView {
|
|
1401
|
+
password: string;
|
|
1402
|
+
lastUsedDate: DateTime<Utc>;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
export interface AncestorMap {
|
|
1406
|
+
ancestors: Map<CollectionId, string>;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
export interface TotpError extends Error {
|
|
1410
|
+
name: "TotpError";
|
|
1411
|
+
variant: "InvalidOtpauth" | "MissingSecret" | "Crypto";
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
export function isTotpError(error: any): error is TotpError;
|
|
1415
|
+
|
|
1416
|
+
export interface TotpResponse {
|
|
1417
|
+
/**
|
|
1418
|
+
* Generated TOTP code
|
|
1419
|
+
*/
|
|
1420
|
+
code: string;
|
|
1421
|
+
/**
|
|
1422
|
+
* Time period
|
|
1423
|
+
*/
|
|
1424
|
+
period: number;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
export interface DecryptError extends Error {
|
|
1428
|
+
name: "DecryptError";
|
|
1429
|
+
variant: "Crypto";
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
export function isDecryptError(error: any): error is DecryptError;
|
|
1433
|
+
|
|
1434
|
+
export interface EncryptError extends Error {
|
|
1435
|
+
name: "EncryptError";
|
|
1436
|
+
variant: "Crypto" | "MissingUserId";
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
export function isEncryptError(error: any): error is EncryptError;
|
|
1440
|
+
|
|
1441
|
+
export interface Attachment {
|
|
1442
|
+
id: string | undefined;
|
|
1443
|
+
url: string | undefined;
|
|
1444
|
+
size: string | undefined;
|
|
1445
|
+
/**
|
|
1446
|
+
* Readable size, ex: \"4.2 KB\" or \"1.43 GB\
|
|
1447
|
+
*/
|
|
1448
|
+
sizeName: string | undefined;
|
|
1449
|
+
fileName: EncString | undefined;
|
|
1450
|
+
key: EncString | undefined;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
export interface AttachmentView {
|
|
1454
|
+
id: string | undefined;
|
|
1455
|
+
url: string | undefined;
|
|
1456
|
+
size: string | undefined;
|
|
1457
|
+
sizeName: string | undefined;
|
|
1458
|
+
fileName: string | undefined;
|
|
1459
|
+
key: EncString | undefined;
|
|
1460
|
+
/**
|
|
1461
|
+
* The decrypted attachmentkey in base64 format.
|
|
1462
|
+
*
|
|
1463
|
+
* **TEMPORARY FIELD**: This field is a temporary workaround to provide
|
|
1464
|
+
* decrypted attachment keys to the TypeScript client during the migration
|
|
1465
|
+
* process. It will be removed once the encryption/decryption logic is
|
|
1466
|
+
* fully migrated to the SDK.
|
|
1467
|
+
*
|
|
1468
|
+
* **Ticket**: <https://bitwarden.atlassian.net/browse/PM-23005>
|
|
1469
|
+
*
|
|
1470
|
+
* Do not rely on this field for long-term use.
|
|
1471
|
+
*/
|
|
1472
|
+
decryptedKey: string | undefined;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
export interface LocalData {
|
|
1476
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
|
1477
|
+
lastLaunched: DateTime<Utc> | undefined;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
export interface LocalDataView {
|
|
1481
|
+
lastUsedDate: DateTime<Utc> | undefined;
|
|
1482
|
+
lastLaunched: DateTime<Utc> | undefined;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
export interface SecureNoteView {
|
|
1486
|
+
type: SecureNoteType;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
export interface SecureNote {
|
|
1490
|
+
type: SecureNoteType;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
export interface GetCipherError extends Error {
|
|
1494
|
+
name: "GetCipherError";
|
|
1495
|
+
variant: "ItemNotFound" | "Crypto" | "Repository";
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
export function isGetCipherError(error: any): error is GetCipherError;
|
|
1499
|
+
|
|
1500
|
+
export interface EditCipherError extends Error {
|
|
1501
|
+
name: "EditCipherError";
|
|
1502
|
+
variant:
|
|
1503
|
+
| "ItemNotFound"
|
|
1504
|
+
| "Crypto"
|
|
1505
|
+
| "Api"
|
|
1506
|
+
| "VaultParse"
|
|
1507
|
+
| "MissingField"
|
|
1508
|
+
| "NotAuthenticated"
|
|
1509
|
+
| "Repository"
|
|
1510
|
+
| "Uuid";
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
export function isEditCipherError(error: any): error is EditCipherError;
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Request to edit a cipher.
|
|
1517
|
+
*/
|
|
1518
|
+
export interface CipherEditRequest {
|
|
1519
|
+
id: CipherId;
|
|
1520
|
+
organizationId: OrganizationId | undefined;
|
|
1521
|
+
folderId: FolderId | undefined;
|
|
1522
|
+
favorite: boolean;
|
|
1523
|
+
reprompt: CipherRepromptType;
|
|
1524
|
+
name: string;
|
|
1525
|
+
notes: string | undefined;
|
|
1526
|
+
fields: FieldView[];
|
|
1527
|
+
type: CipherViewType;
|
|
1528
|
+
revisionDate: DateTime<Utc>;
|
|
1529
|
+
archivedDate: DateTime<Utc> | undefined;
|
|
1530
|
+
attachments: AttachmentView[];
|
|
1531
|
+
key: EncString | undefined;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
export interface GetOrganizationCiphersAdminError extends Error {
|
|
1535
|
+
name: "GetOrganizationCiphersAdminError";
|
|
1536
|
+
variant: "Crypto" | "VaultParse" | "Api";
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
export function isGetOrganizationCiphersAdminError(
|
|
1540
|
+
error: any,
|
|
1541
|
+
): error is GetOrganizationCiphersAdminError;
|
|
1542
|
+
|
|
1543
|
+
export interface EditCipherAdminError extends Error {
|
|
1544
|
+
name: "EditCipherAdminError";
|
|
1545
|
+
variant:
|
|
1546
|
+
| "ItemNotFound"
|
|
1547
|
+
| "Crypto"
|
|
1548
|
+
| "Api"
|
|
1549
|
+
| "VaultParse"
|
|
1550
|
+
| "MissingField"
|
|
1551
|
+
| "NotAuthenticated"
|
|
1552
|
+
| "Repository"
|
|
1553
|
+
| "Uuid"
|
|
1554
|
+
| "Decrypt";
|
|
1555
|
+
}
|
|
252
1556
|
|
|
253
|
-
export
|
|
254
|
-
|
|
255
|
-
|
|
1557
|
+
export function isEditCipherAdminError(error: any): error is EditCipherAdminError;
|
|
1558
|
+
|
|
1559
|
+
export interface CreateCipherAdminError extends Error {
|
|
1560
|
+
name: "CreateCipherAdminError";
|
|
1561
|
+
variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated";
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
export function isCreateCipherAdminError(error: any): error is CreateCipherAdminError;
|
|
1565
|
+
|
|
1566
|
+
export interface DeleteCipherAdminError extends Error {
|
|
1567
|
+
name: "DeleteCipherAdminError";
|
|
1568
|
+
variant: "Api";
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
export function isDeleteCipherAdminError(error: any): error is DeleteCipherAdminError;
|
|
1572
|
+
|
|
1573
|
+
export interface RestoreCipherAdminError extends Error {
|
|
1574
|
+
name: "RestoreCipherAdminError";
|
|
1575
|
+
variant: "Api" | "VaultParse" | "Crypto";
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
export function isRestoreCipherAdminError(error: any): error is RestoreCipherAdminError;
|
|
1579
|
+
|
|
1580
|
+
export interface CreateCipherError extends Error {
|
|
1581
|
+
name: "CreateCipherError";
|
|
1582
|
+
variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
export function isCreateCipherError(error: any): error is CreateCipherError;
|
|
1586
|
+
|
|
1587
|
+
/**
|
|
1588
|
+
* Request to add a cipher.
|
|
1589
|
+
*/
|
|
1590
|
+
export interface CipherCreateRequest {
|
|
1591
|
+
organizationId: OrganizationId | undefined;
|
|
1592
|
+
collectionIds: CollectionId[];
|
|
1593
|
+
folderId: FolderId | undefined;
|
|
1594
|
+
name: string;
|
|
1595
|
+
notes: string | undefined;
|
|
1596
|
+
favorite: boolean;
|
|
1597
|
+
reprompt: CipherRepromptType;
|
|
1598
|
+
type: CipherViewType;
|
|
1599
|
+
fields: FieldView[];
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
export interface DeleteCipherError extends Error {
|
|
1603
|
+
name: "DeleteCipherError";
|
|
1604
|
+
variant: "Api" | "Repository";
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
export function isDeleteCipherError(error: any): error is DeleteCipherError;
|
|
1608
|
+
|
|
1609
|
+
export interface RestoreCipherError extends Error {
|
|
1610
|
+
name: "RestoreCipherError";
|
|
1611
|
+
variant: "Api" | "VaultParse" | "Repository" | "Crypto";
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
export function isRestoreCipherError(error: any): error is RestoreCipherError;
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* Represents the inner data of a cipher view.
|
|
1618
|
+
*/
|
|
1619
|
+
export type CipherViewType =
|
|
1620
|
+
| { login: LoginView }
|
|
1621
|
+
| { card: CardView }
|
|
1622
|
+
| { identity: IdentityView }
|
|
1623
|
+
| { secureNote: SecureNoteView }
|
|
1624
|
+
| { sshKey: SshKeyView };
|
|
1625
|
+
|
|
1626
|
+
export interface DecryptFileError extends Error {
|
|
1627
|
+
name: "DecryptFileError";
|
|
1628
|
+
variant: "Decrypt" | "Io";
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
export function isDecryptFileError(error: any): error is DecryptFileError;
|
|
1632
|
+
|
|
1633
|
+
export interface EncryptFileError extends Error {
|
|
1634
|
+
name: "EncryptFileError";
|
|
1635
|
+
variant: "Encrypt" | "Io";
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
export function isEncryptFileError(error: any): error is EncryptFileError;
|
|
1639
|
+
|
|
1640
|
+
export interface CipherPermissions {
|
|
1641
|
+
delete: boolean;
|
|
1642
|
+
restore: boolean;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
export interface CardView {
|
|
1646
|
+
cardholderName: string | undefined;
|
|
1647
|
+
expMonth: string | undefined;
|
|
1648
|
+
expYear: string | undefined;
|
|
1649
|
+
code: string | undefined;
|
|
1650
|
+
brand: string | undefined;
|
|
1651
|
+
number: string | undefined;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
export interface Card {
|
|
1655
|
+
cardholderName: EncString | undefined;
|
|
1656
|
+
expMonth: EncString | undefined;
|
|
1657
|
+
expYear: EncString | undefined;
|
|
1658
|
+
code: EncString | undefined;
|
|
1659
|
+
brand: EncString | undefined;
|
|
1660
|
+
number: EncString | undefined;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Minimal CardView only including the needed details for list views
|
|
1665
|
+
*/
|
|
1666
|
+
export interface CardListView {
|
|
1667
|
+
/**
|
|
1668
|
+
* The brand of the card, e.g. Visa, Mastercard, etc.
|
|
1669
|
+
*/
|
|
1670
|
+
brand: string | undefined;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
export interface FieldView {
|
|
1674
|
+
name: string | undefined;
|
|
1675
|
+
value: string | undefined;
|
|
1676
|
+
type: FieldType;
|
|
1677
|
+
linkedId: LinkedIdType | undefined;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
export interface Field {
|
|
1681
|
+
name: EncString | undefined;
|
|
1682
|
+
value: EncString | undefined;
|
|
1683
|
+
type: FieldType;
|
|
1684
|
+
linkedId: LinkedIdType | undefined;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
export interface LoginUriView {
|
|
1688
|
+
uri: string | undefined;
|
|
1689
|
+
match: UriMatchType | undefined;
|
|
1690
|
+
uriChecksum: string | undefined;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
export interface LoginUri {
|
|
1694
|
+
uri: EncString | undefined;
|
|
1695
|
+
match: UriMatchType | undefined;
|
|
1696
|
+
uriChecksum: EncString | undefined;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
export interface Fido2CredentialView {
|
|
1700
|
+
credentialId: string;
|
|
1701
|
+
keyType: string;
|
|
1702
|
+
keyAlgorithm: string;
|
|
1703
|
+
keyCurve: string;
|
|
1704
|
+
keyValue: EncString;
|
|
1705
|
+
rpId: string;
|
|
1706
|
+
userHandle: string | undefined;
|
|
1707
|
+
userName: string | undefined;
|
|
1708
|
+
counter: string;
|
|
1709
|
+
rpName: string | undefined;
|
|
1710
|
+
userDisplayName: string | undefined;
|
|
1711
|
+
discoverable: string;
|
|
1712
|
+
creationDate: DateTime<Utc>;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
export interface Fido2CredentialNewView {
|
|
1716
|
+
credentialId: string;
|
|
1717
|
+
keyType: string;
|
|
1718
|
+
keyAlgorithm: string;
|
|
1719
|
+
keyCurve: string;
|
|
1720
|
+
rpId: string;
|
|
1721
|
+
userHandle: string | undefined;
|
|
1722
|
+
userName: string | undefined;
|
|
1723
|
+
counter: string;
|
|
1724
|
+
rpName: string | undefined;
|
|
1725
|
+
userDisplayName: string | undefined;
|
|
1726
|
+
creationDate: DateTime<Utc>;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
export interface Fido2CredentialFullView {
|
|
1730
|
+
credentialId: string;
|
|
1731
|
+
keyType: string;
|
|
1732
|
+
keyAlgorithm: string;
|
|
1733
|
+
keyCurve: string;
|
|
1734
|
+
keyValue: string;
|
|
1735
|
+
rpId: string;
|
|
1736
|
+
userHandle: string | undefined;
|
|
1737
|
+
userName: string | undefined;
|
|
1738
|
+
counter: string;
|
|
1739
|
+
rpName: string | undefined;
|
|
1740
|
+
userDisplayName: string | undefined;
|
|
1741
|
+
discoverable: string;
|
|
1742
|
+
creationDate: DateTime<Utc>;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
export interface LoginView {
|
|
1746
|
+
username: string | undefined;
|
|
1747
|
+
password: string | undefined;
|
|
1748
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
|
1749
|
+
uris: LoginUriView[] | undefined;
|
|
1750
|
+
totp: string | undefined;
|
|
1751
|
+
autofillOnPageLoad: boolean | undefined;
|
|
1752
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
export interface Fido2Credential {
|
|
1756
|
+
credentialId: EncString;
|
|
1757
|
+
keyType: EncString;
|
|
1758
|
+
keyAlgorithm: EncString;
|
|
1759
|
+
keyCurve: EncString;
|
|
1760
|
+
keyValue: EncString;
|
|
1761
|
+
rpId: EncString;
|
|
1762
|
+
userHandle: EncString | undefined;
|
|
1763
|
+
userName: EncString | undefined;
|
|
1764
|
+
counter: EncString;
|
|
1765
|
+
rpName: EncString | undefined;
|
|
1766
|
+
userDisplayName: EncString | undefined;
|
|
1767
|
+
discoverable: EncString;
|
|
1768
|
+
creationDate: DateTime<Utc>;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
export interface LoginListView {
|
|
1772
|
+
fido2Credentials: Fido2CredentialListView[] | undefined;
|
|
1773
|
+
hasFido2: boolean;
|
|
1774
|
+
username: string | undefined;
|
|
1775
|
+
/**
|
|
1776
|
+
* The TOTP key is not decrypted. Useable as is with [`crate::generate_totp_cipher_view`].
|
|
1777
|
+
*/
|
|
1778
|
+
totp: EncString | undefined;
|
|
1779
|
+
uris: LoginUriView[] | undefined;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
export interface Fido2CredentialListView {
|
|
1783
|
+
credentialId: string;
|
|
1784
|
+
rpId: string;
|
|
1785
|
+
userHandle: string | undefined;
|
|
1786
|
+
userName: string | undefined;
|
|
1787
|
+
userDisplayName: string | undefined;
|
|
1788
|
+
counter: string;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
export interface Login {
|
|
1792
|
+
username: EncString | undefined;
|
|
1793
|
+
password: EncString | undefined;
|
|
1794
|
+
passwordRevisionDate: DateTime<Utc> | undefined;
|
|
1795
|
+
uris: LoginUri[] | undefined;
|
|
1796
|
+
totp: EncString | undefined;
|
|
1797
|
+
autofillOnPageLoad: boolean | undefined;
|
|
1798
|
+
fido2Credentials: Fido2Credential[] | undefined;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
export interface Cipher {
|
|
1802
|
+
id: CipherId | undefined;
|
|
1803
|
+
organizationId: OrganizationId | undefined;
|
|
1804
|
+
folderId: FolderId | undefined;
|
|
1805
|
+
collectionIds: CollectionId[];
|
|
1806
|
+
/**
|
|
1807
|
+
* More recent ciphers uses individual encryption keys to encrypt the other fields of the
|
|
1808
|
+
* Cipher.
|
|
1809
|
+
*/
|
|
1810
|
+
key: EncString | undefined;
|
|
1811
|
+
name: EncString;
|
|
1812
|
+
notes: EncString | undefined;
|
|
1813
|
+
type: CipherType;
|
|
1814
|
+
login: Login | undefined;
|
|
1815
|
+
identity: Identity | undefined;
|
|
1816
|
+
card: Card | undefined;
|
|
1817
|
+
secureNote: SecureNote | undefined;
|
|
1818
|
+
sshKey: SshKey | undefined;
|
|
1819
|
+
favorite: boolean;
|
|
1820
|
+
reprompt: CipherRepromptType;
|
|
1821
|
+
organizationUseTotp: boolean;
|
|
1822
|
+
edit: boolean;
|
|
1823
|
+
permissions: CipherPermissions | undefined;
|
|
1824
|
+
viewPassword: boolean;
|
|
1825
|
+
localData: LocalData | undefined;
|
|
1826
|
+
attachments: Attachment[] | undefined;
|
|
1827
|
+
fields: Field[] | undefined;
|
|
1828
|
+
passwordHistory: PasswordHistory[] | undefined;
|
|
1829
|
+
creationDate: DateTime<Utc>;
|
|
1830
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
1831
|
+
revisionDate: DateTime<Utc>;
|
|
1832
|
+
archivedDate: DateTime<Utc> | undefined;
|
|
1833
|
+
data: string | undefined;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
export interface CipherListView {
|
|
1837
|
+
id: CipherId | undefined;
|
|
1838
|
+
organizationId: OrganizationId | undefined;
|
|
1839
|
+
folderId: FolderId | undefined;
|
|
1840
|
+
collectionIds: CollectionId[];
|
|
1841
|
+
/**
|
|
1842
|
+
* Temporary, required to support calculating TOTP from CipherListView.
|
|
1843
|
+
*/
|
|
1844
|
+
key: EncString | undefined;
|
|
1845
|
+
name: string;
|
|
1846
|
+
subtitle: string;
|
|
1847
|
+
type: CipherListViewType;
|
|
1848
|
+
favorite: boolean;
|
|
1849
|
+
reprompt: CipherRepromptType;
|
|
1850
|
+
organizationUseTotp: boolean;
|
|
1851
|
+
edit: boolean;
|
|
1852
|
+
permissions: CipherPermissions | undefined;
|
|
1853
|
+
viewPassword: boolean;
|
|
1854
|
+
/**
|
|
1855
|
+
* The number of attachments
|
|
1856
|
+
*/
|
|
1857
|
+
attachments: number;
|
|
1858
|
+
/**
|
|
1859
|
+
* Indicates if the cipher has old attachments that need to be re-uploaded
|
|
1860
|
+
*/
|
|
1861
|
+
hasOldAttachments: boolean;
|
|
1862
|
+
creationDate: DateTime<Utc>;
|
|
1863
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
1864
|
+
revisionDate: DateTime<Utc>;
|
|
1865
|
+
archivedDate: DateTime<Utc> | undefined;
|
|
1866
|
+
/**
|
|
1867
|
+
* Hints for the presentation layer for which fields can be copied.
|
|
1868
|
+
*/
|
|
1869
|
+
copyableFields: CopyableCipherFields[];
|
|
1870
|
+
localData: LocalDataView | undefined;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Represents the result of decrypting a list of ciphers.
|
|
1875
|
+
*
|
|
1876
|
+
* This struct contains two vectors: `successes` and `failures`.
|
|
1877
|
+
* `successes` contains the decrypted `CipherListView` objects,
|
|
1878
|
+
* while `failures` contains the original `Cipher` objects that failed to decrypt.
|
|
1879
|
+
*/
|
|
1880
|
+
export interface DecryptCipherListResult {
|
|
1881
|
+
/**
|
|
1882
|
+
* The decrypted `CipherListView` objects.
|
|
1883
|
+
*/
|
|
1884
|
+
successes: CipherListView[];
|
|
1885
|
+
/**
|
|
1886
|
+
* The original `Cipher` objects that failed to decrypt.
|
|
1887
|
+
*/
|
|
1888
|
+
failures: Cipher[];
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
export type CipherListViewType =
|
|
1892
|
+
| { login: LoginListView }
|
|
1893
|
+
| "secureNote"
|
|
1894
|
+
| { card: CardListView }
|
|
1895
|
+
| "identity"
|
|
1896
|
+
| "sshKey";
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* Available fields on a cipher and can be copied from a the list view in the UI.
|
|
1900
|
+
*/
|
|
1901
|
+
export type CopyableCipherFields =
|
|
1902
|
+
| "LoginUsername"
|
|
1903
|
+
| "LoginPassword"
|
|
1904
|
+
| "LoginTotp"
|
|
1905
|
+
| "CardNumber"
|
|
1906
|
+
| "CardSecurityCode"
|
|
1907
|
+
| "IdentityUsername"
|
|
1908
|
+
| "IdentityEmail"
|
|
1909
|
+
| "IdentityPhone"
|
|
1910
|
+
| "IdentityAddress"
|
|
1911
|
+
| "SshKey"
|
|
1912
|
+
| "SecureNotes";
|
|
1913
|
+
|
|
1914
|
+
export interface CipherError extends Error {
|
|
1915
|
+
name: "CipherError";
|
|
1916
|
+
variant:
|
|
1917
|
+
| "MissingField"
|
|
1918
|
+
| "Crypto"
|
|
1919
|
+
| "Decrypt"
|
|
1920
|
+
| "Encrypt"
|
|
1921
|
+
| "AttachmentsWithoutKeys"
|
|
1922
|
+
| "OrganizationAlreadySet"
|
|
1923
|
+
| "Repository"
|
|
1924
|
+
| "Chrono"
|
|
1925
|
+
| "SerdeJson"
|
|
1926
|
+
| "Api";
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
export function isCipherError(error: any): error is CipherError;
|
|
1930
|
+
|
|
1931
|
+
export interface EncryptionContext {
|
|
1932
|
+
/**
|
|
1933
|
+
* The Id of the user that encrypted the cipher. It should always represent a UserId, even for
|
|
1934
|
+
* Organization-owned ciphers
|
|
1935
|
+
*/
|
|
1936
|
+
encryptedFor: UserId;
|
|
1937
|
+
cipher: Cipher;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
export interface CipherView {
|
|
1941
|
+
id: CipherId | undefined;
|
|
1942
|
+
organizationId: OrganizationId | undefined;
|
|
1943
|
+
folderId: FolderId | undefined;
|
|
1944
|
+
collectionIds: CollectionId[];
|
|
1945
|
+
/**
|
|
1946
|
+
* Temporary, required to support re-encrypting existing items.
|
|
1947
|
+
*/
|
|
1948
|
+
key: EncString | undefined;
|
|
1949
|
+
name: string;
|
|
1950
|
+
notes: string | undefined;
|
|
1951
|
+
type: CipherType;
|
|
1952
|
+
login: LoginView | undefined;
|
|
1953
|
+
identity: IdentityView | undefined;
|
|
1954
|
+
card: CardView | undefined;
|
|
1955
|
+
secureNote: SecureNoteView | undefined;
|
|
1956
|
+
sshKey: SshKeyView | undefined;
|
|
1957
|
+
favorite: boolean;
|
|
1958
|
+
reprompt: CipherRepromptType;
|
|
1959
|
+
organizationUseTotp: boolean;
|
|
1960
|
+
edit: boolean;
|
|
1961
|
+
permissions: CipherPermissions | undefined;
|
|
1962
|
+
viewPassword: boolean;
|
|
1963
|
+
localData: LocalDataView | undefined;
|
|
1964
|
+
attachments: AttachmentView[] | undefined;
|
|
1965
|
+
/**
|
|
1966
|
+
* Attachments that failed to decrypt. Only present when there are decryption failures.
|
|
1967
|
+
*/
|
|
1968
|
+
attachmentDecryptionFailures?: AttachmentView[];
|
|
1969
|
+
fields: FieldView[] | undefined;
|
|
1970
|
+
passwordHistory: PasswordHistoryView[] | undefined;
|
|
1971
|
+
creationDate: DateTime<Utc>;
|
|
1972
|
+
deletedDate: DateTime<Utc> | undefined;
|
|
1973
|
+
revisionDate: DateTime<Utc>;
|
|
1974
|
+
archivedDate: DateTime<Utc> | undefined;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
/**
|
|
1978
|
+
* NewType wrapper for `CipherId`
|
|
1979
|
+
*/
|
|
1980
|
+
export type CipherId = Tagged<Uuid, "CipherId">;
|
|
1981
|
+
|
|
1982
|
+
export interface SshKey {
|
|
1983
|
+
/**
|
|
1984
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
|
1985
|
+
*/
|
|
1986
|
+
privateKey: EncString;
|
|
1987
|
+
/**
|
|
1988
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
|
1989
|
+
*/
|
|
1990
|
+
publicKey: EncString;
|
|
1991
|
+
/**
|
|
1992
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
|
1993
|
+
*/
|
|
1994
|
+
fingerprint: EncString;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
export interface SshKeyView {
|
|
1998
|
+
/**
|
|
1999
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
|
2000
|
+
*/
|
|
2001
|
+
privateKey: string;
|
|
2002
|
+
/**
|
|
2003
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
|
2004
|
+
*/
|
|
2005
|
+
publicKey: string;
|
|
2006
|
+
/**
|
|
2007
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
|
2008
|
+
*/
|
|
2009
|
+
fingerprint: string;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
export interface Identity {
|
|
2013
|
+
title: EncString | undefined;
|
|
2014
|
+
firstName: EncString | undefined;
|
|
2015
|
+
middleName: EncString | undefined;
|
|
2016
|
+
lastName: EncString | undefined;
|
|
2017
|
+
address1: EncString | undefined;
|
|
2018
|
+
address2: EncString | undefined;
|
|
2019
|
+
address3: EncString | undefined;
|
|
2020
|
+
city: EncString | undefined;
|
|
2021
|
+
state: EncString | undefined;
|
|
2022
|
+
postalCode: EncString | undefined;
|
|
2023
|
+
country: EncString | undefined;
|
|
2024
|
+
company: EncString | undefined;
|
|
2025
|
+
email: EncString | undefined;
|
|
2026
|
+
phone: EncString | undefined;
|
|
2027
|
+
ssn: EncString | undefined;
|
|
2028
|
+
username: EncString | undefined;
|
|
2029
|
+
passportNumber: EncString | undefined;
|
|
2030
|
+
licenseNumber: EncString | undefined;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
export interface IdentityView {
|
|
2034
|
+
title: string | undefined;
|
|
2035
|
+
firstName: string | undefined;
|
|
2036
|
+
middleName: string | undefined;
|
|
2037
|
+
lastName: string | undefined;
|
|
2038
|
+
address1: string | undefined;
|
|
2039
|
+
address2: string | undefined;
|
|
2040
|
+
address3: string | undefined;
|
|
2041
|
+
city: string | undefined;
|
|
2042
|
+
state: string | undefined;
|
|
2043
|
+
postalCode: string | undefined;
|
|
2044
|
+
country: string | undefined;
|
|
2045
|
+
company: string | undefined;
|
|
2046
|
+
email: string | undefined;
|
|
2047
|
+
phone: string | undefined;
|
|
2048
|
+
ssn: string | undefined;
|
|
2049
|
+
username: string | undefined;
|
|
2050
|
+
passportNumber: string | undefined;
|
|
2051
|
+
licenseNumber: string | undefined;
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
export type LinkedIdType = LoginLinkedIdType | CardLinkedIdType | IdentityLinkedIdType;
|
|
2055
|
+
|
|
2056
|
+
export interface FolderView {
|
|
2057
|
+
id: FolderId | undefined;
|
|
2058
|
+
name: string;
|
|
2059
|
+
revisionDate: DateTime<Utc>;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
export interface Folder {
|
|
2063
|
+
id: FolderId | undefined;
|
|
2064
|
+
name: EncString;
|
|
2065
|
+
revisionDate: DateTime<Utc>;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
/**
|
|
2069
|
+
* NewType wrapper for `FolderId`
|
|
2070
|
+
*/
|
|
2071
|
+
export type FolderId = Tagged<Uuid, "FolderId">;
|
|
2072
|
+
|
|
2073
|
+
export interface EditFolderError extends Error {
|
|
2074
|
+
name: "EditFolderError";
|
|
2075
|
+
variant:
|
|
2076
|
+
| "ItemNotFound"
|
|
2077
|
+
| "Crypto"
|
|
2078
|
+
| "Api"
|
|
2079
|
+
| "VaultParse"
|
|
2080
|
+
| "MissingField"
|
|
2081
|
+
| "Repository"
|
|
2082
|
+
| "Uuid";
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
export function isEditFolderError(error: any): error is EditFolderError;
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Request to add or edit a folder.
|
|
2089
|
+
*/
|
|
2090
|
+
export interface FolderAddEditRequest {
|
|
2091
|
+
/**
|
|
2092
|
+
* The new name of the folder.
|
|
2093
|
+
*/
|
|
2094
|
+
name: string;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
export interface CreateFolderError extends Error {
|
|
2098
|
+
name: "CreateFolderError";
|
|
2099
|
+
variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "Repository";
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
export function isCreateFolderError(error: any): error is CreateFolderError;
|
|
2103
|
+
|
|
2104
|
+
export interface GetFolderError extends Error {
|
|
2105
|
+
name: "GetFolderError";
|
|
2106
|
+
variant: "ItemNotFound" | "Crypto" | "Repository";
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
export function isGetFolderError(error: any): error is GetFolderError;
|
|
2110
|
+
|
|
2111
|
+
export class AttachmentsClient {
|
|
2112
|
+
private constructor();
|
|
2113
|
+
free(): void;
|
|
2114
|
+
[Symbol.dispose](): void;
|
|
2115
|
+
decrypt_buffer(
|
|
2116
|
+
cipher: Cipher,
|
|
2117
|
+
attachment: AttachmentView,
|
|
2118
|
+
encrypted_buffer: Uint8Array,
|
|
2119
|
+
): Uint8Array;
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Subclient containing auth functionality.
|
|
2123
|
+
*/
|
|
2124
|
+
export class AuthClient {
|
|
2125
|
+
private constructor();
|
|
2126
|
+
free(): void;
|
|
2127
|
+
[Symbol.dispose](): void;
|
|
2128
|
+
/**
|
|
2129
|
+
* Client for send access functionality
|
|
2130
|
+
*/
|
|
2131
|
+
send_access(): SendAccessClient;
|
|
2132
|
+
/**
|
|
2133
|
+
* Client for initializing user account cryptography and unlock methods after JIT provisioning
|
|
2134
|
+
*/
|
|
2135
|
+
registration(): RegistrationClient;
|
|
2136
|
+
/**
|
|
2137
|
+
* Client for identity functionality
|
|
2138
|
+
*/
|
|
2139
|
+
identity(): IdentityClient;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Client for performing admin operations on ciphers. Unlike the regular CiphersClient,
|
|
2143
|
+
* this client uses the admin server API endpoints, and does not modify local state.
|
|
2144
|
+
*/
|
|
2145
|
+
export class CipherAdminClient {
|
|
2146
|
+
private constructor();
|
|
2147
|
+
free(): void;
|
|
2148
|
+
[Symbol.dispose](): void;
|
|
2149
|
+
list_org_ciphers(
|
|
2150
|
+
org_id: OrganizationId,
|
|
2151
|
+
include_member_items: boolean,
|
|
2152
|
+
): Promise<DecryptCipherListResult>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Adds the cipher matched by [CipherId] to any number of collections on the server.
|
|
2155
|
+
*/
|
|
2156
|
+
update_collection(cipher_id: CipherId, collection_ids: CollectionId[]): Promise<CipherView>;
|
|
2157
|
+
/**
|
|
2158
|
+
* Edit an existing [Cipher] and save it to the server.
|
|
2159
|
+
*/
|
|
2160
|
+
edit(request: CipherEditRequest, original_cipher_view: CipherView): Promise<CipherView>;
|
|
2161
|
+
/**
|
|
2162
|
+
* Creates a new [Cipher] for an organization, using the admin server endpoints.
|
|
2163
|
+
* Creates the Cipher on the server only, does not store it to local state.
|
|
2164
|
+
*/
|
|
2165
|
+
create(request: CipherCreateRequest): Promise<CipherView>;
|
|
2166
|
+
/**
|
|
2167
|
+
* Deletes all Cipher objects with a matching CipherId from the server, using the admin
|
|
2168
|
+
* endpoint. Affects server data only, does not modify local state.
|
|
2169
|
+
*/
|
|
2170
|
+
delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
|
|
2171
|
+
/**
|
|
2172
|
+
* Soft-deletes the Cipher with the matching CipherId from the server, using the admin
|
|
2173
|
+
* endpoint. Affects server data only, does not modify local state.
|
|
2174
|
+
*/
|
|
2175
|
+
soft_delete(cipher_id: CipherId): Promise<void>;
|
|
2176
|
+
/**
|
|
2177
|
+
* Soft-deletes all Cipher objects for the given CipherIds from the server, using the admin
|
|
2178
|
+
* endpoint. Affects server data only, does not modify local state.
|
|
2179
|
+
*/
|
|
2180
|
+
soft_delete_many(cipher_ids: CipherId[], organization_id: OrganizationId): Promise<void>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Deletes the Cipher with the matching CipherId from the server, using the admin endpoint.
|
|
2183
|
+
* Affects server data only, does not modify local state.
|
|
2184
|
+
*/
|
|
2185
|
+
delete(cipher_id: CipherId): Promise<void>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Restores multiple soft-deleted ciphers on the server.
|
|
2188
|
+
*/
|
|
2189
|
+
restore_many(cipher_ids: CipherId[], org_id: OrganizationId): Promise<DecryptCipherListResult>;
|
|
2190
|
+
/**
|
|
2191
|
+
* Restores a soft-deleted cipher on the server, using the admin endpoint.
|
|
2192
|
+
*/
|
|
2193
|
+
restore(cipher_id: CipherId): Promise<CipherView>;
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Client for evaluating credential risk for login ciphers.
|
|
2197
|
+
*/
|
|
2198
|
+
export class CipherRiskClient {
|
|
2199
|
+
private constructor();
|
|
2200
|
+
free(): void;
|
|
2201
|
+
[Symbol.dispose](): void;
|
|
2202
|
+
/**
|
|
2203
|
+
* Evaluate security risks for multiple login ciphers concurrently.
|
|
2204
|
+
*
|
|
2205
|
+
* For each cipher:
|
|
2206
|
+
* 1. Calculates password strength (0-4) using zxcvbn with cipher-specific context
|
|
2207
|
+
* 2. Optionally checks if the password has been exposed via Have I Been Pwned API
|
|
2208
|
+
* 3. Counts how many times the password is reused in the provided `password_map`
|
|
2209
|
+
*
|
|
2210
|
+
* Returns a vector of `CipherRisk` results, one for each input cipher.
|
|
2211
|
+
*
|
|
2212
|
+
* ## HIBP Check Results (`exposed_result` field)
|
|
2213
|
+
*
|
|
2214
|
+
* The `exposed_result` field uses the `ExposedPasswordResult` enum with three possible states:
|
|
2215
|
+
* - `NotChecked`: Password exposure check was not performed because:
|
|
2216
|
+
* - `check_exposed` option was `false`, or
|
|
2217
|
+
* - Password was empty
|
|
2218
|
+
* - `Found(n)`: Successfully checked via HIBP API, password appears in `n` data breaches
|
|
2219
|
+
* - `Error(msg)`: HIBP API request failed with error message `msg`
|
|
2220
|
+
*
|
|
2221
|
+
* # Errors
|
|
2222
|
+
*
|
|
2223
|
+
* This method only returns `Err` for internal logic failures. HIBP API errors are
|
|
2224
|
+
* captured per-cipher in the `exposed_result` field as `ExposedPasswordResult::Error(msg)`.
|
|
2225
|
+
*/
|
|
2226
|
+
compute_risk(
|
|
2227
|
+
login_details: CipherLoginDetails[],
|
|
2228
|
+
options: CipherRiskOptions,
|
|
2229
|
+
): Promise<CipherRiskResult[]>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Build password reuse map for a list of login ciphers.
|
|
2232
|
+
*
|
|
2233
|
+
* Returns a map where keys are passwords and values are the number of times
|
|
2234
|
+
* each password appears in the provided list. This map can be passed to `compute_risk()`
|
|
2235
|
+
* to enable password reuse detection.
|
|
2236
|
+
*/
|
|
2237
|
+
password_reuse_map(login_details: CipherLoginDetails[]): PasswordReuseMap;
|
|
2238
|
+
}
|
|
2239
|
+
export class CiphersClient {
|
|
2240
|
+
private constructor();
|
|
2241
|
+
free(): void;
|
|
2242
|
+
[Symbol.dispose](): void;
|
|
2243
|
+
/**
|
|
2244
|
+
* Moves a cipher into an organization, adds it to collections, and calls the share_cipher API.
|
|
2245
|
+
*/
|
|
2246
|
+
share_cipher(
|
|
2247
|
+
cipher_view: CipherView,
|
|
2248
|
+
organization_id: OrganizationId,
|
|
2249
|
+
collection_ids: CollectionId[],
|
|
2250
|
+
original_cipher?: Cipher | null,
|
|
2251
|
+
): Promise<Cipher>;
|
|
2252
|
+
/**
|
|
2253
|
+
* Moves a group of ciphers into an organization, adds them to collections, and calls the
|
|
2254
|
+
* share_ciphers API.
|
|
2255
|
+
*/
|
|
2256
|
+
share_ciphers_bulk(
|
|
2257
|
+
cipher_views: CipherView[],
|
|
2258
|
+
organization_id: OrganizationId,
|
|
2259
|
+
collection_ids: CollectionId[],
|
|
2260
|
+
): Promise<Cipher[]>;
|
|
2261
|
+
decrypt_list(ciphers: Cipher[]): CipherListView[];
|
|
2262
|
+
move_to_organization(cipher_view: CipherView, organization_id: OrganizationId): CipherView;
|
|
2263
|
+
/**
|
|
2264
|
+
* Temporary method used to re-encrypt FIDO2 credentials for a cipher view.
|
|
2265
|
+
* Necessary until the TS clients utilize the SDK entirely for FIDO2 credentials management.
|
|
2266
|
+
* TS clients create decrypted FIDO2 credentials that need to be encrypted manually when
|
|
2267
|
+
* encrypting the rest of the CipherView.
|
|
2268
|
+
* TODO: Remove once TS passkey provider implementation uses SDK - PM-8313
|
|
2269
|
+
*/
|
|
2270
|
+
set_fido2_credentials(
|
|
2271
|
+
cipher_view: CipherView,
|
|
2272
|
+
fido2_credentials: Fido2CredentialFullView[],
|
|
2273
|
+
): CipherView;
|
|
2274
|
+
decrypt_fido2_credentials(cipher_view: CipherView): Fido2CredentialView[];
|
|
2275
|
+
decrypt_fido2_private_key(cipher_view: CipherView): string;
|
|
2276
|
+
/**
|
|
2277
|
+
* Decrypt cipher list with failures
|
|
2278
|
+
* Returns both successfully decrypted ciphers and any that failed to decrypt
|
|
2279
|
+
*/
|
|
2280
|
+
decrypt_list_with_failures(ciphers: Cipher[]): DecryptCipherListResult;
|
|
2281
|
+
/**
|
|
2282
|
+
* Encrypt a cipher with the provided key. This should only be used when rotating encryption
|
|
2283
|
+
* keys in the Web client.
|
|
2284
|
+
*
|
|
2285
|
+
* Until key rotation is fully implemented in the SDK, this method must be provided the new
|
|
2286
|
+
* symmetric key in base64 format. See PM-23084
|
|
2287
|
+
*
|
|
2288
|
+
* If the cipher has a CipherKey, it will be re-encrypted with the new key.
|
|
2289
|
+
* If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
|
|
2290
|
+
* generated using the new key. Otherwise, the cipher's data will be encrypted with the new
|
|
2291
|
+
* key directly.
|
|
2292
|
+
*/
|
|
2293
|
+
encrypt_cipher_for_rotation(cipher_view: CipherView, new_key: B64): EncryptionContext;
|
|
2294
|
+
/**
|
|
2295
|
+
* Returns a new client for performing admin operations.
|
|
2296
|
+
* Uses the admin server API endpoints and does not modify local state.
|
|
2297
|
+
*/
|
|
2298
|
+
admin(): CipherAdminClient;
|
|
2299
|
+
decrypt(cipher: Cipher): CipherView;
|
|
2300
|
+
encrypt(cipher_view: CipherView): EncryptionContext;
|
|
2301
|
+
/**
|
|
2302
|
+
* Get [Cipher] by ID from state and decrypt it to a [CipherView].
|
|
2303
|
+
*/
|
|
2304
|
+
get(cipher_id: string): Promise<CipherView>;
|
|
2305
|
+
/**
|
|
2306
|
+
* Get all ciphers from state and decrypt them, returning both successes and failures.
|
|
2307
|
+
* This method will not fail when some ciphers fail to decrypt, allowing for graceful
|
|
2308
|
+
* handling of corrupted or problematic cipher data.
|
|
2309
|
+
*/
|
|
2310
|
+
list(): Promise<DecryptCipherListResult>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Adds the cipher matched by [CipherId] to any number of collections on the server.
|
|
2313
|
+
*/
|
|
2314
|
+
update_collection(
|
|
2315
|
+
cipher_id: CipherId,
|
|
2316
|
+
collection_ids: CollectionId[],
|
|
2317
|
+
is_admin: boolean,
|
|
2318
|
+
): Promise<CipherView>;
|
|
2319
|
+
/**
|
|
2320
|
+
* Edit an existing [Cipher] and save it to the server.
|
|
2321
|
+
*/
|
|
2322
|
+
edit(request: CipherEditRequest): Promise<CipherView>;
|
|
2323
|
+
/**
|
|
2324
|
+
* Creates a new [Cipher] and saves it to the server.
|
|
2325
|
+
*/
|
|
2326
|
+
create(request: CipherCreateRequest): Promise<CipherView>;
|
|
2327
|
+
/**
|
|
2328
|
+
* Deletes all [Cipher] objects with a matching [CipherId] from the server.
|
|
2329
|
+
*/
|
|
2330
|
+
delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
|
|
2331
|
+
/**
|
|
2332
|
+
* Soft-deletes the [Cipher] with the matching [CipherId] from the server.
|
|
2333
|
+
*/
|
|
2334
|
+
soft_delete(cipher_id: CipherId): Promise<void>;
|
|
2335
|
+
/**
|
|
2336
|
+
* Soft-deletes all [Cipher] objects for the given [CipherId]s from the server.
|
|
2337
|
+
*/
|
|
2338
|
+
soft_delete_many(cipher_ids: CipherId[], organization_id?: OrganizationId | null): Promise<void>;
|
|
2339
|
+
/**
|
|
2340
|
+
* Deletes the [Cipher] with the matching [CipherId] from the server.
|
|
2341
|
+
*/
|
|
2342
|
+
delete(cipher_id: CipherId): Promise<void>;
|
|
2343
|
+
/**
|
|
2344
|
+
* Restores multiple soft-deleted ciphers on the server.
|
|
2345
|
+
*/
|
|
2346
|
+
restore_many(cipher_ids: CipherId[]): Promise<DecryptCipherListResult>;
|
|
2347
|
+
/**
|
|
2348
|
+
* Restores a soft-deleted cipher on the server.
|
|
2349
|
+
*/
|
|
2350
|
+
restore(cipher_id: CipherId): Promise<CipherView>;
|
|
256
2351
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
2352
|
+
export class CollectionViewNodeItem {
|
|
2353
|
+
private constructor();
|
|
2354
|
+
free(): void;
|
|
2355
|
+
[Symbol.dispose](): void;
|
|
2356
|
+
get_parent(): CollectionView | undefined;
|
|
2357
|
+
get_children(): CollectionView[];
|
|
2358
|
+
get_ancestors(): AncestorMap;
|
|
2359
|
+
get_item(): CollectionView;
|
|
264
2360
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
2361
|
+
export class CollectionViewTree {
|
|
2362
|
+
private constructor();
|
|
2363
|
+
free(): void;
|
|
2364
|
+
[Symbol.dispose](): void;
|
|
2365
|
+
get_flat_items(): CollectionViewNodeItem[];
|
|
2366
|
+
get_root_items(): CollectionViewNodeItem[];
|
|
2367
|
+
get_item_for_view(collection_view: CollectionView): CollectionViewNodeItem | undefined;
|
|
270
2368
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
2369
|
+
export class CollectionsClient {
|
|
2370
|
+
private constructor();
|
|
2371
|
+
free(): void;
|
|
2372
|
+
[Symbol.dispose](): void;
|
|
2373
|
+
decrypt_list(collections: Collection[]): CollectionView[];
|
|
2374
|
+
/**
|
|
2375
|
+
*
|
|
2376
|
+
* Returns the vector of CollectionView objects in a tree structure based on its implemented
|
|
2377
|
+
* path().
|
|
2378
|
+
*/
|
|
2379
|
+
get_collection_tree(collections: CollectionView[]): CollectionViewTree;
|
|
2380
|
+
decrypt(collection: Collection): CollectionView;
|
|
274
2381
|
}
|
|
275
|
-
|
|
276
|
-
export function isTestError(error: any): error is TestError;
|
|
277
|
-
|
|
278
|
-
export type Uuid = string;
|
|
279
|
-
|
|
280
2382
|
/**
|
|
281
|
-
*
|
|
282
|
-
* @typeParam T - Not used in JavaScript.
|
|
2383
|
+
* A client for the crypto operations.
|
|
283
2384
|
*/
|
|
284
|
-
export
|
|
285
|
-
|
|
2385
|
+
export class CryptoClient {
|
|
2386
|
+
private constructor();
|
|
2387
|
+
free(): void;
|
|
2388
|
+
[Symbol.dispose](): void;
|
|
2389
|
+
/**
|
|
2390
|
+
* Protects the current user key with the provided PIN. The result can be stored and later
|
|
2391
|
+
* used to initialize another client instance by using the PIN and the PIN key with
|
|
2392
|
+
* `initialize_user_crypto`.
|
|
2393
|
+
*/
|
|
2394
|
+
enroll_pin(pin: string): EnrollPinResponse;
|
|
2395
|
+
/**
|
|
2396
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
|
2397
|
+
* Crypto initialization not required.
|
|
2398
|
+
*/
|
|
2399
|
+
make_key_pair(user_key: B64): MakeKeyPairResponse;
|
|
2400
|
+
/**
|
|
2401
|
+
* Create the data necessary to update the user's kdf settings. The user's encryption key is
|
|
2402
|
+
* re-encrypted for the password under the new kdf settings. This returns the re-encrypted
|
|
2403
|
+
* user key and the new password hash but does not update sdk state.
|
|
2404
|
+
*/
|
|
2405
|
+
make_update_kdf(password: string, kdf: Kdf): UpdateKdfResponse;
|
|
2406
|
+
/**
|
|
2407
|
+
* Initialization method for the organization crypto. Needs to be called after
|
|
2408
|
+
* `initialize_user_crypto` but before any other crypto operations.
|
|
2409
|
+
*/
|
|
2410
|
+
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
|
2411
|
+
/**
|
|
2412
|
+
* Initialization method for the user crypto. Needs to be called before any other crypto
|
|
2413
|
+
* operations.
|
|
2414
|
+
*/
|
|
2415
|
+
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
|
2416
|
+
/**
|
|
2417
|
+
* Verifies a user's asymmetric keys by decrypting the private key with the provided user
|
|
2418
|
+
* key. Returns if the private key is decryptable and if it is a valid matching key.
|
|
2419
|
+
* Crypto initialization not required.
|
|
2420
|
+
*/
|
|
2421
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
|
2422
|
+
/**
|
|
2423
|
+
* Creates a rotated set of account keys for the current state
|
|
2424
|
+
*/
|
|
2425
|
+
get_v2_rotated_account_keys(): UserCryptoV2KeysResponse;
|
|
2426
|
+
/**
|
|
2427
|
+
* Makes a new signing key pair and signs the public key for the user
|
|
2428
|
+
*/
|
|
2429
|
+
make_keys_for_user_crypto_v2(): UserCryptoV2KeysResponse;
|
|
2430
|
+
/**
|
|
2431
|
+
* Protects the current user key with the provided PIN. The result can be stored and later
|
|
2432
|
+
* used to initialize another client instance by using the PIN and the PIN key with
|
|
2433
|
+
* `initialize_user_crypto`. The provided pin is encrypted with the user key.
|
|
2434
|
+
*/
|
|
2435
|
+
enroll_pin_with_encrypted_pin(encrypted_pin: string): EnrollPinResponse;
|
|
2436
|
+
/**
|
|
2437
|
+
* Decrypts a `PasswordProtectedKeyEnvelope`, returning the user key, if successful.
|
|
2438
|
+
* This is a stop-gap solution, until initialization of the SDK is used.
|
|
2439
|
+
*/
|
|
2440
|
+
unseal_password_protected_key_envelope(pin: string, envelope: string): Uint8Array;
|
|
2441
|
+
}
|
|
2442
|
+
export class ExporterClient {
|
|
2443
|
+
private constructor();
|
|
2444
|
+
free(): void;
|
|
2445
|
+
[Symbol.dispose](): void;
|
|
2446
|
+
/**
|
|
2447
|
+
* Credential Exchange Format (CXF)
|
|
2448
|
+
*
|
|
2449
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
|
2450
|
+
*
|
|
2451
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
|
2452
|
+
* Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
|
2453
|
+
*/
|
|
2454
|
+
export_cxf(account: Account, ciphers: Cipher[]): string;
|
|
2455
|
+
/**
|
|
2456
|
+
* Credential Exchange Format (CXF)
|
|
2457
|
+
*
|
|
2458
|
+
* *Warning:* Expect this API to be unstable, and it will change in the future.
|
|
2459
|
+
*
|
|
2460
|
+
* For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
|
|
2461
|
+
* Ideally, the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
|
|
2462
|
+
*/
|
|
2463
|
+
import_cxf(payload: string): Cipher[];
|
|
2464
|
+
export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
|
|
2465
|
+
export_organization_vault(
|
|
2466
|
+
collections: Collection[],
|
|
2467
|
+
ciphers: Cipher[],
|
|
2468
|
+
format: ExportFormat,
|
|
2469
|
+
): string;
|
|
2470
|
+
}
|
|
286
2471
|
/**
|
|
287
|
-
*
|
|
2472
|
+
* Wrapper for folder specific functionality.
|
|
288
2473
|
*/
|
|
289
|
-
export
|
|
290
|
-
|
|
2474
|
+
export class FoldersClient {
|
|
2475
|
+
private constructor();
|
|
2476
|
+
free(): void;
|
|
2477
|
+
[Symbol.dispose](): void;
|
|
2478
|
+
/**
|
|
2479
|
+
* Decrypt a list of [Folder]s to a list of [FolderView]s.
|
|
2480
|
+
*/
|
|
2481
|
+
decrypt_list(folders: Folder[]): FolderView[];
|
|
2482
|
+
/**
|
|
2483
|
+
* Get a specific [Folder] by its ID from state and decrypt it to a [FolderView].
|
|
2484
|
+
*/
|
|
2485
|
+
get(folder_id: FolderId): Promise<FolderView>;
|
|
2486
|
+
/**
|
|
2487
|
+
* Edit the [Folder] and save it to the server.
|
|
2488
|
+
*/
|
|
2489
|
+
edit(folder_id: FolderId, request: FolderAddEditRequest): Promise<FolderView>;
|
|
2490
|
+
/**
|
|
2491
|
+
* Get all folders from state and decrypt them to a list of [FolderView].
|
|
2492
|
+
*/
|
|
2493
|
+
list(): Promise<FolderView[]>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Create a new [Folder] and save it to the server.
|
|
2496
|
+
*/
|
|
2497
|
+
create(request: FolderAddEditRequest): Promise<FolderView>;
|
|
2498
|
+
/**
|
|
2499
|
+
* Encrypt a [Folder] to [FolderView].
|
|
2500
|
+
*/
|
|
2501
|
+
decrypt(folder: Folder): FolderView;
|
|
2502
|
+
/**
|
|
2503
|
+
* Encrypt a [FolderView] to a [Folder].
|
|
2504
|
+
*/
|
|
2505
|
+
encrypt(folder_view: FolderView): Folder;
|
|
2506
|
+
}
|
|
2507
|
+
export class GeneratorClient {
|
|
2508
|
+
private constructor();
|
|
2509
|
+
free(): void;
|
|
2510
|
+
[Symbol.dispose](): void;
|
|
2511
|
+
/**
|
|
2512
|
+
* Generates a random passphrase.
|
|
2513
|
+
* A passphrase is a combination of random words separated by a character.
|
|
2514
|
+
* An example of passphrase is `correct horse battery staple`.
|
|
2515
|
+
*
|
|
2516
|
+
* The number of words and their case, the word separator, and the inclusion of
|
|
2517
|
+
* a number in the passphrase can be customized using the `input` parameter.
|
|
2518
|
+
*
|
|
2519
|
+
* # Examples
|
|
2520
|
+
*
|
|
2521
|
+
* ```
|
|
2522
|
+
* use bitwarden_core::Client;
|
|
2523
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PassphraseGeneratorRequest};
|
|
2524
|
+
*
|
|
2525
|
+
* async fn test() -> Result<(), PassphraseError> {
|
|
2526
|
+
* let input = PassphraseGeneratorRequest {
|
|
2527
|
+
* num_words: 4,
|
|
2528
|
+
* ..Default::default()
|
|
2529
|
+
* };
|
|
2530
|
+
* let passphrase = Client::new(None).generator().passphrase(input).unwrap();
|
|
2531
|
+
* println!("{}", passphrase);
|
|
2532
|
+
* Ok(())
|
|
2533
|
+
* }
|
|
2534
|
+
* ```
|
|
2535
|
+
*/
|
|
2536
|
+
passphrase(input: PassphraseGeneratorRequest): string;
|
|
2537
|
+
/**
|
|
2538
|
+
* Generates a random password.
|
|
2539
|
+
*
|
|
2540
|
+
* The character sets and password length can be customized using the `input` parameter.
|
|
2541
|
+
*
|
|
2542
|
+
* # Examples
|
|
2543
|
+
*
|
|
2544
|
+
* ```
|
|
2545
|
+
* use bitwarden_core::Client;
|
|
2546
|
+
* use bitwarden_generators::{GeneratorClientsExt, PassphraseError, PasswordGeneratorRequest};
|
|
2547
|
+
*
|
|
2548
|
+
* async fn test() -> Result<(), PassphraseError> {
|
|
2549
|
+
* let input = PasswordGeneratorRequest {
|
|
2550
|
+
* lowercase: true,
|
|
2551
|
+
* uppercase: true,
|
|
2552
|
+
* numbers: true,
|
|
2553
|
+
* length: 20,
|
|
2554
|
+
* ..Default::default()
|
|
2555
|
+
* };
|
|
2556
|
+
* let password = Client::new(None).generator().password(input).unwrap();
|
|
2557
|
+
* println!("{}", password);
|
|
2558
|
+
* Ok(())
|
|
2559
|
+
* }
|
|
2560
|
+
* ```
|
|
2561
|
+
*/
|
|
2562
|
+
password(input: PasswordGeneratorRequest): string;
|
|
2563
|
+
}
|
|
291
2564
|
/**
|
|
292
|
-
*
|
|
2565
|
+
* The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
|
|
293
2566
|
*/
|
|
294
|
-
export
|
|
295
|
-
|
|
296
|
-
|
|
2567
|
+
export class IdentityClient {
|
|
2568
|
+
private constructor();
|
|
2569
|
+
free(): void;
|
|
2570
|
+
[Symbol.dispose](): void;
|
|
2571
|
+
}
|
|
2572
|
+
export class IncomingMessage {
|
|
2573
|
+
free(): void;
|
|
2574
|
+
[Symbol.dispose](): void;
|
|
2575
|
+
/**
|
|
2576
|
+
* Try to parse the payload as JSON.
|
|
2577
|
+
* @returns The parsed JSON value, or undefined if the payload is not valid JSON.
|
|
2578
|
+
*/
|
|
2579
|
+
parse_payload_as_json(): any;
|
|
2580
|
+
constructor(payload: Uint8Array, destination: Endpoint, source: Endpoint, topic?: string | null);
|
|
2581
|
+
payload: Uint8Array;
|
|
2582
|
+
destination: Endpoint;
|
|
2583
|
+
source: Endpoint;
|
|
2584
|
+
get topic(): string | undefined;
|
|
2585
|
+
set topic(value: string | null | undefined);
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* JavaScript wrapper around the IPC client. For more information, see the
|
|
2589
|
+
* [IpcClient] documentation.
|
|
2590
|
+
*/
|
|
2591
|
+
export class IpcClient {
|
|
2592
|
+
private constructor();
|
|
2593
|
+
free(): void;
|
|
2594
|
+
[Symbol.dispose](): void;
|
|
2595
|
+
isRunning(): Promise<boolean>;
|
|
2596
|
+
/**
|
|
2597
|
+
* Create a new `IpcClient` instance with an in-memory session repository for saving
|
|
2598
|
+
* sessions within the SDK.
|
|
2599
|
+
*/
|
|
2600
|
+
static newWithSdkInMemorySessions(communication_provider: IpcCommunicationBackend): IpcClient;
|
|
2601
|
+
/**
|
|
2602
|
+
* Create a new `IpcClient` instance with a client-managed session repository for saving
|
|
2603
|
+
* sessions using State Provider.
|
|
2604
|
+
*/
|
|
2605
|
+
static newWithClientManagedSessions(
|
|
2606
|
+
communication_provider: IpcCommunicationBackend,
|
|
2607
|
+
session_repository: IpcSessionRepository,
|
|
2608
|
+
): IpcClient;
|
|
2609
|
+
send(message: OutgoingMessage): Promise<void>;
|
|
2610
|
+
start(): Promise<void>;
|
|
2611
|
+
subscribe(): Promise<IpcClientSubscription>;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* JavaScript wrapper around the IPC client subscription. For more information, see the
|
|
2615
|
+
* [IpcClientSubscription](crate::IpcClientSubscription) documentation.
|
|
2616
|
+
*/
|
|
2617
|
+
export class IpcClientSubscription {
|
|
2618
|
+
private constructor();
|
|
2619
|
+
free(): void;
|
|
2620
|
+
[Symbol.dispose](): void;
|
|
2621
|
+
receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
|
|
2622
|
+
}
|
|
2623
|
+
/**
|
|
2624
|
+
* JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
|
|
2625
|
+
*/
|
|
2626
|
+
export class IpcCommunicationBackend {
|
|
2627
|
+
free(): void;
|
|
2628
|
+
[Symbol.dispose](): void;
|
|
2629
|
+
/**
|
|
2630
|
+
* Creates a new instance of the JavaScript communication backend.
|
|
2631
|
+
*/
|
|
2632
|
+
constructor(sender: IpcCommunicationBackendSender);
|
|
2633
|
+
/**
|
|
2634
|
+
* Used by JavaScript to provide an incoming message to the IPC framework.
|
|
2635
|
+
*/
|
|
2636
|
+
receive(message: IncomingMessage): void;
|
|
2637
|
+
}
|
|
2638
|
+
export class OutgoingMessage {
|
|
2639
|
+
free(): void;
|
|
2640
|
+
[Symbol.dispose](): void;
|
|
2641
|
+
/**
|
|
2642
|
+
* Create a new message and encode the payload as JSON.
|
|
2643
|
+
*/
|
|
2644
|
+
static new_json_payload(
|
|
2645
|
+
payload: any,
|
|
2646
|
+
destination: Endpoint,
|
|
2647
|
+
topic?: string | null,
|
|
2648
|
+
): OutgoingMessage;
|
|
2649
|
+
constructor(payload: Uint8Array, destination: Endpoint, topic?: string | null);
|
|
2650
|
+
payload: Uint8Array;
|
|
2651
|
+
destination: Endpoint;
|
|
2652
|
+
get topic(): string | undefined;
|
|
2653
|
+
set topic(value: string | null | undefined);
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* The main entry point for the Bitwarden SDK in WebAssembly environments
|
|
2657
|
+
*/
|
|
2658
|
+
export class PasswordManagerClient {
|
|
297
2659
|
free(): void;
|
|
298
|
-
|
|
2660
|
+
[Symbol.dispose](): void;
|
|
2661
|
+
/**
|
|
2662
|
+
* Initialize a new instance of the SDK client
|
|
2663
|
+
*/
|
|
2664
|
+
constructor(token_provider: any, settings?: ClientSettings | null);
|
|
2665
|
+
/**
|
|
2666
|
+
* Auth related operations.
|
|
2667
|
+
*/
|
|
2668
|
+
auth(): AuthClient;
|
|
299
2669
|
/**
|
|
300
2670
|
* Test method, echoes back the input
|
|
301
2671
|
*/
|
|
302
2672
|
echo(msg: string): string;
|
|
303
|
-
|
|
2673
|
+
/**
|
|
2674
|
+
* Test method, always throws an error
|
|
2675
|
+
*/
|
|
304
2676
|
throw(msg: string): void;
|
|
2677
|
+
/**
|
|
2678
|
+
* Vault item related operations.
|
|
2679
|
+
*/
|
|
2680
|
+
vault(): VaultClient;
|
|
2681
|
+
/**
|
|
2682
|
+
* Crypto related operations.
|
|
2683
|
+
*/
|
|
2684
|
+
crypto(): CryptoClient;
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns the current SDK version
|
|
2687
|
+
*/
|
|
2688
|
+
version(): string;
|
|
305
2689
|
/**
|
|
306
2690
|
* Test method, calls http endpoint
|
|
307
2691
|
*/
|
|
308
2692
|
http_get(url: string): Promise<string>;
|
|
309
|
-
|
|
310
|
-
|
|
2693
|
+
/**
|
|
2694
|
+
* Constructs a specific client for platform-specific functionality
|
|
2695
|
+
*/
|
|
2696
|
+
platform(): PlatformClient;
|
|
2697
|
+
/**
|
|
2698
|
+
* Exporter related operations.
|
|
2699
|
+
*/
|
|
2700
|
+
exporters(): ExporterClient;
|
|
2701
|
+
/**
|
|
2702
|
+
* Constructs a specific client for generating passwords and passphrases
|
|
2703
|
+
*/
|
|
2704
|
+
generator(): GeneratorClient;
|
|
311
2705
|
}
|
|
312
|
-
export class
|
|
2706
|
+
export class PlatformClient {
|
|
313
2707
|
private constructor();
|
|
314
2708
|
free(): void;
|
|
2709
|
+
[Symbol.dispose](): void;
|
|
315
2710
|
/**
|
|
316
|
-
*
|
|
2711
|
+
* Load feature flags into the client
|
|
317
2712
|
*/
|
|
318
|
-
|
|
2713
|
+
load_flags(flags: FeatureFlags): void;
|
|
2714
|
+
state(): StateClient;
|
|
319
2715
|
}
|
|
320
|
-
|
|
2716
|
+
/**
|
|
2717
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
|
2718
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
|
2719
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
|
2720
|
+
* responsible for state and keys.
|
|
2721
|
+
*/
|
|
2722
|
+
export class PureCrypto {
|
|
321
2723
|
private constructor();
|
|
322
2724
|
free(): void;
|
|
2725
|
+
[Symbol.dispose](): void;
|
|
323
2726
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
2727
|
+
* Decrypts data using RSAES-OAEP with SHA-1
|
|
2728
|
+
* HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
|
|
326
2729
|
*/
|
|
327
|
-
|
|
2730
|
+
static rsa_decrypt_data(encrypted_data: Uint8Array, private_key: Uint8Array): Uint8Array;
|
|
328
2731
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
2732
|
+
* Encrypts data using RSAES-OAEP with SHA-1
|
|
2733
|
+
* HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
|
|
331
2734
|
*/
|
|
332
|
-
|
|
2735
|
+
static rsa_encrypt_data(plain_data: Uint8Array, public_key: Uint8Array): Uint8Array;
|
|
333
2736
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
2737
|
+
* DEPRECATED: Use `symmetric_decrypt_string` instead.
|
|
2738
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
|
336
2739
|
*/
|
|
337
|
-
|
|
2740
|
+
static symmetric_decrypt(enc_string: string, key: Uint8Array): string;
|
|
338
2741
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* Crypto initialization not required.
|
|
2742
|
+
* Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key
|
|
2743
|
+
* as an EncString.
|
|
342
2744
|
*/
|
|
343
|
-
|
|
2745
|
+
static wrap_symmetric_key(key_to_be_wrapped: Uint8Array, wrapping_key: Uint8Array): string;
|
|
2746
|
+
/**
|
|
2747
|
+
* Derive output of the KDF for a [bitwarden_crypto::Kdf] configuration.
|
|
2748
|
+
*/
|
|
2749
|
+
static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
|
|
2750
|
+
/**
|
|
2751
|
+
* Generates a new RSA key pair and returns the private key
|
|
2752
|
+
* HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
|
|
2753
|
+
*/
|
|
2754
|
+
static rsa_generate_keypair(): Uint8Array;
|
|
2755
|
+
/**
|
|
2756
|
+
* Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the
|
|
2757
|
+
* unwrapped key as a serialized byte array.
|
|
2758
|
+
*/
|
|
2759
|
+
static unwrap_symmetric_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
2760
|
+
/**
|
|
2761
|
+
* Given a decrypted private RSA key PKCS8 DER this
|
|
2762
|
+
* returns the corresponding public RSA key in DER format.
|
|
2763
|
+
* HAZMAT WARNING: Do not use outside of implementing cryptofunctionservice
|
|
2764
|
+
*/
|
|
2765
|
+
static rsa_extract_public_key(private_key: Uint8Array): Uint8Array;
|
|
2766
|
+
/**
|
|
2767
|
+
* Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping
|
|
2768
|
+
* key,
|
|
2769
|
+
*/
|
|
2770
|
+
static wrap_decapsulation_key(decapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
|
2771
|
+
/**
|
|
2772
|
+
* Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping
|
|
2773
|
+
* key. Note: Usually, a public key is - by definition - public, so this should not be
|
|
2774
|
+
* used. The specific use-case for this function is to enable rotateable key sets, where
|
|
2775
|
+
* the "public key" is not public, with the intent of preventing the server from being able
|
|
2776
|
+
* to overwrite the user key unlocked by the rotateable keyset.
|
|
2777
|
+
*/
|
|
2778
|
+
static wrap_encapsulation_key(encapsulation_key: Uint8Array, wrapping_key: Uint8Array): string;
|
|
2779
|
+
static symmetric_decrypt_bytes(enc_string: string, key: Uint8Array): Uint8Array;
|
|
2780
|
+
/**
|
|
2781
|
+
* DEPRECATED: Only used by send keys
|
|
2782
|
+
*/
|
|
2783
|
+
static symmetric_encrypt_bytes(plain: Uint8Array, key: Uint8Array): string;
|
|
2784
|
+
/**
|
|
2785
|
+
* Decapsulates (decrypts) a symmetric key using an decapsulation-key/private-key in PKCS8
|
|
2786
|
+
* DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the
|
|
2787
|
+
* recipient.
|
|
2788
|
+
*/
|
|
2789
|
+
static decapsulate_key_unsigned(
|
|
2790
|
+
encapsulated_key: string,
|
|
2791
|
+
decapsulation_key: Uint8Array,
|
|
2792
|
+
): Uint8Array;
|
|
2793
|
+
/**
|
|
2794
|
+
* Encapsulates (encrypts) a symmetric key using an public-key/encapsulation-key
|
|
2795
|
+
* in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so
|
|
2796
|
+
* the sender's authenticity cannot be verified by the recipient.
|
|
2797
|
+
*/
|
|
2798
|
+
static encapsulate_key_unsigned(shared_key: Uint8Array, encapsulation_key: Uint8Array): string;
|
|
2799
|
+
static symmetric_decrypt_string(enc_string: string, key: Uint8Array): string;
|
|
2800
|
+
static symmetric_encrypt_string(plain: string, key: Uint8Array): string;
|
|
2801
|
+
/**
|
|
2802
|
+
* Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric
|
|
2803
|
+
* wrapping key.
|
|
2804
|
+
*/
|
|
2805
|
+
static unwrap_decapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
2806
|
+
/**
|
|
2807
|
+
* Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric
|
|
2808
|
+
* wrapping key.
|
|
2809
|
+
*/
|
|
2810
|
+
static unwrap_encapsulation_key(wrapped_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
2811
|
+
static symmetric_decrypt_filedata(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
|
2812
|
+
static symmetric_encrypt_filedata(plain: Uint8Array, key: Uint8Array): Uint8Array;
|
|
2813
|
+
static make_user_key_aes256_cbc_hmac(): Uint8Array;
|
|
2814
|
+
/**
|
|
2815
|
+
* Given a wrapped signing key and the symmetric key it is wrapped with, this returns
|
|
2816
|
+
* the corresponding verifying key.
|
|
2817
|
+
*/
|
|
2818
|
+
static verifying_key_for_signing_key(signing_key: string, wrapping_key: Uint8Array): Uint8Array;
|
|
2819
|
+
/**
|
|
2820
|
+
* DEPRECATED: Use `symmetric_decrypt_filedata` instead.
|
|
2821
|
+
* Cleanup ticket: <https://bitwarden.atlassian.net/browse/PM-21247>
|
|
2822
|
+
*/
|
|
2823
|
+
static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key: Uint8Array): Uint8Array;
|
|
2824
|
+
/**
|
|
2825
|
+
* Returns the algorithm used for the given verifying key.
|
|
2826
|
+
*/
|
|
2827
|
+
static key_algorithm_for_verifying_key(verifying_key: Uint8Array): SignatureAlgorithm;
|
|
2828
|
+
static decrypt_user_key_with_master_key(
|
|
2829
|
+
encrypted_user_key: string,
|
|
2830
|
+
master_key: Uint8Array,
|
|
2831
|
+
): Uint8Array;
|
|
2832
|
+
static make_user_key_xchacha20_poly1305(): Uint8Array;
|
|
2833
|
+
/**
|
|
2834
|
+
* For a given signing identity (verifying key), this function verifies that the signing
|
|
2835
|
+
* identity claimed ownership of the public key. This is a one-sided claim and merely shows
|
|
2836
|
+
* that the signing identity has the intent to receive messages encrypted to the public
|
|
2837
|
+
* key.
|
|
2838
|
+
*/
|
|
2839
|
+
static verify_and_unwrap_signed_public_key(
|
|
2840
|
+
signed_public_key: Uint8Array,
|
|
2841
|
+
verifying_key: Uint8Array,
|
|
2842
|
+
): Uint8Array;
|
|
2843
|
+
static decrypt_user_key_with_master_password(
|
|
2844
|
+
encrypted_user_key: string,
|
|
2845
|
+
master_password: string,
|
|
2846
|
+
email: string,
|
|
2847
|
+
kdf: Kdf,
|
|
2848
|
+
): Uint8Array;
|
|
2849
|
+
static encrypt_user_key_with_master_password(
|
|
2850
|
+
user_key: Uint8Array,
|
|
2851
|
+
master_password: string,
|
|
2852
|
+
email: string,
|
|
2853
|
+
kdf: Kdf,
|
|
2854
|
+
): string;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Client for initializing a user account.
|
|
2858
|
+
*/
|
|
2859
|
+
export class RegistrationClient {
|
|
2860
|
+
private constructor();
|
|
2861
|
+
free(): void;
|
|
2862
|
+
[Symbol.dispose](): void;
|
|
2863
|
+
/**
|
|
2864
|
+
* Initializes a new cryptographic state for a user and posts it to the server; enrolls in
|
|
2865
|
+
* admin password reset and finally enrolls the user to TDE unlock.
|
|
2866
|
+
*/
|
|
2867
|
+
post_keys_for_tde_registration(request: TdeRegistrationRequest): Promise<TdeRegistrationResponse>;
|
|
2868
|
+
/**
|
|
2869
|
+
* Initializes a new cryptographic state for a user and posts it to the server;
|
|
2870
|
+
* enrolls the user to master password unlock.
|
|
2871
|
+
*/
|
|
2872
|
+
post_keys_for_jit_password_registration(
|
|
2873
|
+
request: JitMasterPasswordRegistrationRequest,
|
|
2874
|
+
): Promise<JitMasterPasswordRegistrationResponse>;
|
|
2875
|
+
/**
|
|
2876
|
+
* Initializes a new cryptographic state for a user and posts it to the server; enrolls the
|
|
2877
|
+
* user to key connector unlock.
|
|
2878
|
+
*/
|
|
2879
|
+
post_keys_for_key_connector_registration(
|
|
2880
|
+
key_connector_url: string,
|
|
2881
|
+
sso_org_identifier: string,
|
|
2882
|
+
user_id: UserId,
|
|
2883
|
+
): Promise<KeyConnectorRegistrationResult>;
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
|
|
2887
|
+
*/
|
|
2888
|
+
export class SendAccessClient {
|
|
2889
|
+
private constructor();
|
|
2890
|
+
free(): void;
|
|
2891
|
+
[Symbol.dispose](): void;
|
|
2892
|
+
/**
|
|
2893
|
+
* Requests a new send access token.
|
|
2894
|
+
*/
|
|
2895
|
+
request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
|
|
2896
|
+
}
|
|
2897
|
+
export class StateClient {
|
|
2898
|
+
private constructor();
|
|
2899
|
+
free(): void;
|
|
2900
|
+
[Symbol.dispose](): void;
|
|
2901
|
+
/**
|
|
2902
|
+
* Initialize the database for SDK managed repositories.
|
|
2903
|
+
*/
|
|
2904
|
+
initialize_state(configuration: IndexedDbConfiguration): Promise<void>;
|
|
2905
|
+
register_cipher_repository(cipher_repository: any): void;
|
|
2906
|
+
register_folder_repository(store: any): void;
|
|
2907
|
+
register_client_managed_repositories(repositories: Repositories): void;
|
|
2908
|
+
}
|
|
2909
|
+
export class TotpClient {
|
|
2910
|
+
private constructor();
|
|
2911
|
+
free(): void;
|
|
2912
|
+
[Symbol.dispose](): void;
|
|
2913
|
+
/**
|
|
2914
|
+
* Generates a TOTP code from a provided key
|
|
2915
|
+
*
|
|
2916
|
+
* # Arguments
|
|
2917
|
+
* - `key` - Can be:
|
|
2918
|
+
* - A base32 encoded string
|
|
2919
|
+
* - OTP Auth URI
|
|
2920
|
+
* - Steam URI
|
|
2921
|
+
* - `time_ms` - Optional timestamp in milliseconds
|
|
2922
|
+
*/
|
|
2923
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
|
344
2924
|
}
|
|
345
2925
|
export class VaultClient {
|
|
346
2926
|
private constructor();
|
|
347
2927
|
free(): void;
|
|
348
|
-
|
|
2928
|
+
[Symbol.dispose](): void;
|
|
2929
|
+
/**
|
|
2930
|
+
* Attachment related operations.
|
|
2931
|
+
*/
|
|
2932
|
+
attachments(): AttachmentsClient;
|
|
2933
|
+
/**
|
|
2934
|
+
* Cipher risk evaluation operations.
|
|
2935
|
+
*/
|
|
2936
|
+
cipher_risk(): CipherRiskClient;
|
|
2937
|
+
/**
|
|
2938
|
+
* Collection related operations.
|
|
2939
|
+
*/
|
|
2940
|
+
collections(): CollectionsClient;
|
|
2941
|
+
/**
|
|
2942
|
+
* TOTP related operations.
|
|
2943
|
+
*/
|
|
2944
|
+
totp(): TotpClient;
|
|
2945
|
+
/**
|
|
2946
|
+
* Cipher related operations.
|
|
2947
|
+
*/
|
|
2948
|
+
ciphers(): CiphersClient;
|
|
2949
|
+
/**
|
|
2950
|
+
* Folder related operations.
|
|
2951
|
+
*/
|
|
2952
|
+
folders(): FoldersClient;
|
|
349
2953
|
}
|