@bitwarden/sdk-internal 0.2.0-main.9 → 0.2.0-main.90
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 +203 -59
- package/bitwarden_wasm_internal_bg.js +879 -513
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +50 -28
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +203 -59
- package/node/bitwarden_wasm_internal.js +885 -518
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +50 -28
- package/package.json +5 -4
package/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
200018a2c17de4de35f198ce5ad8377f531390f2
|
@@ -1,5 +1,32 @@
|
|
1
1
|
/* tslint:disable */
|
2
2
|
/* eslint-disable */
|
3
|
+
/**
|
4
|
+
* Generate a new SSH key pair
|
5
|
+
*
|
6
|
+
* # Arguments
|
7
|
+
* - `key_algorithm` - The algorithm to use for the key pair
|
8
|
+
*
|
9
|
+
* # Returns
|
10
|
+
* - `Ok(SshKey)` if the key was successfully generated
|
11
|
+
* - `Err(KeyGenerationError)` if the key could not be generated
|
12
|
+
*/
|
13
|
+
export function generate_ssh_key(key_algorithm: KeyAlgorithm): SshKey;
|
14
|
+
/**
|
15
|
+
* Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
|
16
|
+
* to an OpenSSH private key with public key and fingerprint
|
17
|
+
*
|
18
|
+
* # Arguments
|
19
|
+
* - `imported_key` - The private key to convert
|
20
|
+
* - `password` - The password to use for decrypting the key
|
21
|
+
*
|
22
|
+
* # Returns
|
23
|
+
* - `Ok(SshKey)` if the key was successfully coneverted
|
24
|
+
* - `Err(PasswordRequired)` if the key is encrypted and no password was provided
|
25
|
+
* - `Err(WrongPassword)` if the password provided is incorrect
|
26
|
+
* - `Err(ParsingError)` if the key could not be parsed
|
27
|
+
* - `Err(UnsupportedKeyType)` if the key type is not supported
|
28
|
+
*/
|
29
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKey;
|
3
30
|
export enum LogLevel {
|
4
31
|
Trace = 0,
|
5
32
|
Debug = 1,
|
@@ -51,30 +78,42 @@ export interface InitOrgCryptoRequest {
|
|
51
78
|
organizationKeys: Map<Uuid, AsymmetricEncString>;
|
52
79
|
}
|
53
80
|
|
54
|
-
export interface
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
| "IdentityFail"
|
64
|
-
| "Reqwest"
|
65
|
-
| "Serde"
|
66
|
-
| "Io"
|
67
|
-
| "InvalidBase64"
|
68
|
-
| "Chrono"
|
69
|
-
| "ResponseContent"
|
70
|
-
| "ValidationError"
|
71
|
-
| "InvalidStateFileVersion"
|
72
|
-
| "InvalidStateFile"
|
73
|
-
| "Internal"
|
74
|
-
| "EncryptionSettings";
|
81
|
+
export interface MakeKeyPairResponse {
|
82
|
+
/**
|
83
|
+
* The user\'s public key
|
84
|
+
*/
|
85
|
+
userPublicKey: string;
|
86
|
+
/**
|
87
|
+
* User\'s private key, encrypted with the user key
|
88
|
+
*/
|
89
|
+
userKeyEncryptedPrivateKey: EncString;
|
75
90
|
}
|
76
91
|
|
77
|
-
export
|
92
|
+
export interface VerifyAsymmetricKeysRequest {
|
93
|
+
/**
|
94
|
+
* The user\'s user key
|
95
|
+
*/
|
96
|
+
userKey: string;
|
97
|
+
/**
|
98
|
+
* The user\'s public key
|
99
|
+
*/
|
100
|
+
userPublicKey: string;
|
101
|
+
/**
|
102
|
+
* User\'s private key, encrypted with the user key
|
103
|
+
*/
|
104
|
+
userKeyEncryptedPrivateKey: EncString;
|
105
|
+
}
|
106
|
+
|
107
|
+
export interface VerifyAsymmetricKeysResponse {
|
108
|
+
/**
|
109
|
+
* Whether the user\'s private key was decryptable by the user key.
|
110
|
+
*/
|
111
|
+
privateKeyDecryptable: boolean;
|
112
|
+
/**
|
113
|
+
* Whether the user\'s private key was a valid RSA key and matched the public key provided.
|
114
|
+
*/
|
115
|
+
validPrivateKey: boolean;
|
116
|
+
}
|
78
117
|
|
79
118
|
export interface EncryptionSettingsError extends Error {
|
80
119
|
name: "EncryptionSettingsError";
|
@@ -161,6 +200,61 @@ export type Kdf =
|
|
161
200
|
| { pBKDF2: { iterations: NonZeroU32 } }
|
162
201
|
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
163
202
|
|
203
|
+
export interface CryptoError extends Error {
|
204
|
+
name: "CryptoError";
|
205
|
+
variant:
|
206
|
+
| "InvalidKey"
|
207
|
+
| "InvalidMac"
|
208
|
+
| "MacNotProvided"
|
209
|
+
| "KeyDecrypt"
|
210
|
+
| "InvalidKeyLen"
|
211
|
+
| "InvalidUtf8String"
|
212
|
+
| "MissingKey"
|
213
|
+
| "MissingField"
|
214
|
+
| "MissingKeyId"
|
215
|
+
| "ReadOnlyKeyStore"
|
216
|
+
| "InsufficientKdfParameters"
|
217
|
+
| "EncString"
|
218
|
+
| "RsaError"
|
219
|
+
| "FingerprintError"
|
220
|
+
| "ArgonError"
|
221
|
+
| "ZeroNumber";
|
222
|
+
}
|
223
|
+
|
224
|
+
export function isCryptoError(error: any): error is CryptoError;
|
225
|
+
|
226
|
+
export interface SshKey {
|
227
|
+
/**
|
228
|
+
* The private key in OpenSSH format
|
229
|
+
*/
|
230
|
+
private_key: string;
|
231
|
+
public_key: string;
|
232
|
+
key_fingerprint: string;
|
233
|
+
}
|
234
|
+
|
235
|
+
export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
236
|
+
|
237
|
+
export interface SshKeyExportError extends Error {
|
238
|
+
name: "SshKeyExportError";
|
239
|
+
variant: "KeyConversionError";
|
240
|
+
}
|
241
|
+
|
242
|
+
export function isSshKeyExportError(error: any): error is SshKeyExportError;
|
243
|
+
|
244
|
+
export interface SshKeyImportError extends Error {
|
245
|
+
name: "SshKeyImportError";
|
246
|
+
variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
|
247
|
+
}
|
248
|
+
|
249
|
+
export function isSshKeyImportError(error: any): error is SshKeyImportError;
|
250
|
+
|
251
|
+
export interface KeyGenerationError extends Error {
|
252
|
+
name: "KeyGenerationError";
|
253
|
+
variant: "KeyGenerationError" | "KeyConversionError";
|
254
|
+
}
|
255
|
+
|
256
|
+
export function isKeyGenerationError(error: any): error is KeyGenerationError;
|
257
|
+
|
164
258
|
export interface Folder {
|
165
259
|
id: Uuid | undefined;
|
166
260
|
name: EncString;
|
@@ -173,6 +267,52 @@ export interface FolderView {
|
|
173
267
|
revisionDate: DateTime<Utc>;
|
174
268
|
}
|
175
269
|
|
270
|
+
export interface DecryptFileError extends Error {
|
271
|
+
name: "DecryptFileError";
|
272
|
+
variant: "Decrypt" | "Io";
|
273
|
+
}
|
274
|
+
|
275
|
+
export function isDecryptFileError(error: any): error is DecryptFileError;
|
276
|
+
|
277
|
+
export interface EncryptFileError extends Error {
|
278
|
+
name: "EncryptFileError";
|
279
|
+
variant: "Encrypt" | "Io";
|
280
|
+
}
|
281
|
+
|
282
|
+
export function isEncryptFileError(error: any): error is EncryptFileError;
|
283
|
+
|
284
|
+
export interface DecryptError extends Error {
|
285
|
+
name: "DecryptError";
|
286
|
+
variant: "Crypto" | "VaultLocked";
|
287
|
+
}
|
288
|
+
|
289
|
+
export function isDecryptError(error: any): error is DecryptError;
|
290
|
+
|
291
|
+
export interface EncryptError extends Error {
|
292
|
+
name: "EncryptError";
|
293
|
+
variant: "Crypto" | "VaultLocked";
|
294
|
+
}
|
295
|
+
|
296
|
+
export function isEncryptError(error: any): error is EncryptError;
|
297
|
+
|
298
|
+
export interface TotpResponse {
|
299
|
+
/**
|
300
|
+
* Generated TOTP code
|
301
|
+
*/
|
302
|
+
code: string;
|
303
|
+
/**
|
304
|
+
* Time period
|
305
|
+
*/
|
306
|
+
period: number;
|
307
|
+
}
|
308
|
+
|
309
|
+
export interface TotpError extends Error {
|
310
|
+
name: "TotpError";
|
311
|
+
variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
|
312
|
+
}
|
313
|
+
|
314
|
+
export function isTotpError(error: any): error is TotpError;
|
315
|
+
|
176
316
|
export interface TestError extends Error {
|
177
317
|
name: "TestError";
|
178
318
|
}
|
@@ -199,71 +339,75 @@ export type NonZeroU32 = number;
|
|
199
339
|
|
200
340
|
export class BitwardenClient {
|
201
341
|
free(): void;
|
202
|
-
|
203
|
-
* @param {ClientSettings | undefined} [settings]
|
204
|
-
* @param {LogLevel | undefined} [log_level]
|
205
|
-
*/
|
206
|
-
constructor(settings?: ClientSettings, log_level?: LogLevel);
|
342
|
+
constructor(settings?: ClientSettings | null, log_level?: LogLevel | null);
|
207
343
|
/**
|
208
344
|
* Test method, echoes back the input
|
209
|
-
* @param {string} msg
|
210
|
-
* @returns {string}
|
211
345
|
*/
|
212
346
|
echo(msg: string): string;
|
213
|
-
/**
|
214
|
-
* @returns {string}
|
215
|
-
*/
|
216
347
|
version(): string;
|
217
|
-
|
218
|
-
* @param {string} msg
|
219
|
-
* @returns {Promise<void>}
|
220
|
-
*/
|
221
|
-
throw(msg: string): Promise<void>;
|
348
|
+
throw(msg: string): void;
|
222
349
|
/**
|
223
350
|
* Test method, calls http endpoint
|
224
|
-
* @param {string} url
|
225
|
-
* @returns {Promise<string>}
|
226
351
|
*/
|
227
352
|
http_get(url: string): Promise<string>;
|
353
|
+
crypto(): CryptoClient;
|
354
|
+
vault(): VaultClient;
|
355
|
+
}
|
356
|
+
export class ClientFolders {
|
357
|
+
private constructor();
|
358
|
+
free(): void;
|
228
359
|
/**
|
229
|
-
*
|
360
|
+
* Decrypt folder
|
230
361
|
*/
|
231
|
-
|
362
|
+
decrypt(folder: Folder): FolderView;
|
363
|
+
}
|
364
|
+
export class ClientTotp {
|
365
|
+
private constructor();
|
366
|
+
free(): void;
|
232
367
|
/**
|
233
|
-
*
|
368
|
+
* Generates a TOTP code from a provided key
|
369
|
+
*
|
370
|
+
* # Arguments
|
371
|
+
* - `key` - Can be:
|
372
|
+
* - A base32 encoded string
|
373
|
+
* - OTP Auth URI
|
374
|
+
* - Steam URI
|
375
|
+
* - `time_ms` - Optional timestamp in milliseconds
|
376
|
+
*
|
377
|
+
* # Returns
|
378
|
+
* - `Ok(TotpResponse)` containing the generated code and period
|
379
|
+
* - `Err(TotpError)` if code generation fails
|
234
380
|
*/
|
235
|
-
|
381
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
236
382
|
}
|
237
|
-
export class
|
383
|
+
export class CryptoClient {
|
384
|
+
private constructor();
|
238
385
|
free(): void;
|
239
386
|
/**
|
240
387
|
* Initialization method for the user crypto. Needs to be called before any other crypto
|
241
388
|
* operations.
|
242
|
-
* @param {InitUserCryptoRequest} req
|
243
|
-
* @returns {Promise<void>}
|
244
389
|
*/
|
245
390
|
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
246
391
|
/**
|
247
392
|
* Initialization method for the organization crypto. Needs to be called after
|
248
393
|
* `initialize_user_crypto` but before any other crypto operations.
|
249
|
-
* @param {InitOrgCryptoRequest} req
|
250
|
-
* @returns {Promise<void>}
|
251
394
|
*/
|
252
395
|
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
253
|
-
}
|
254
|
-
export class ClientFolders {
|
255
|
-
free(): void;
|
256
396
|
/**
|
257
|
-
*
|
258
|
-
*
|
259
|
-
* @returns {FolderView}
|
397
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
398
|
+
* Crypto initialization not required.
|
260
399
|
*/
|
261
|
-
|
262
|
-
}
|
263
|
-
export class ClientVault {
|
264
|
-
free(): void;
|
400
|
+
make_key_pair(user_key: string): MakeKeyPairResponse;
|
265
401
|
/**
|
266
|
-
*
|
402
|
+
* Verifies a user's asymmetric keys by decrypting the private key with the provided user
|
403
|
+
* key. Returns if the private key is decryptable and if it is a valid matching key.
|
404
|
+
* Crypto initialization not required.
|
267
405
|
*/
|
406
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
407
|
+
}
|
408
|
+
export class VaultClient {
|
409
|
+
private constructor();
|
410
|
+
free(): void;
|
268
411
|
folders(): ClientFolders;
|
412
|
+
totp(): ClientTotp;
|
269
413
|
}
|