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