@bitwarden/sdk-internal 0.2.0-main.10 → 0.2.0-main.101
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 +199 -69
- package/bitwarden_wasm_internal.js +1 -0
- package/bitwarden_wasm_internal_bg.js +740 -608
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +52 -30
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +199 -69
- package/node/bitwarden_wasm_internal.js +748 -613
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +52 -30
- package/package.json +5 -4
package/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ec6bfd82fbb75e751bb08ed20674bfada560dbb4
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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): SshKeyView;
|
|
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
|
|
6
28
|
*/
|
|
7
|
-
export function
|
|
29
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
|
|
8
30
|
export enum LogLevel {
|
|
9
31
|
Trace = 0,
|
|
10
32
|
Debug = 1,
|
|
@@ -56,30 +78,42 @@ export interface InitOrgCryptoRequest {
|
|
|
56
78
|
organizationKeys: Map<Uuid, AsymmetricEncString>;
|
|
57
79
|
}
|
|
58
80
|
|
|
59
|
-
export interface
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| "IdentityFail"
|
|
69
|
-
| "Reqwest"
|
|
70
|
-
| "Serde"
|
|
71
|
-
| "Io"
|
|
72
|
-
| "InvalidBase64"
|
|
73
|
-
| "Chrono"
|
|
74
|
-
| "ResponseContent"
|
|
75
|
-
| "ValidationError"
|
|
76
|
-
| "InvalidStateFileVersion"
|
|
77
|
-
| "InvalidStateFile"
|
|
78
|
-
| "Internal"
|
|
79
|
-
| "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;
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
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
|
+
}
|
|
83
117
|
|
|
84
118
|
export interface EncryptionSettingsError extends Error {
|
|
85
119
|
name: "EncryptionSettingsError";
|
|
@@ -166,14 +200,45 @@ export type Kdf =
|
|
|
166
200
|
| { pBKDF2: { iterations: NonZeroU32 } }
|
|
167
201
|
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
|
168
202
|
|
|
169
|
-
export interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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";
|
|
173
222
|
}
|
|
174
223
|
|
|
224
|
+
export function isCryptoError(error: any): error is CryptoError;
|
|
225
|
+
|
|
175
226
|
export type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
|
176
227
|
|
|
228
|
+
export interface SshKeyExportError extends Error {
|
|
229
|
+
name: "SshKeyExportError";
|
|
230
|
+
variant: "KeyConversionError";
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function isSshKeyExportError(error: any): error is SshKeyExportError;
|
|
234
|
+
|
|
235
|
+
export interface SshKeyImportError extends Error {
|
|
236
|
+
name: "SshKeyImportError";
|
|
237
|
+
variant: "ParsingError" | "PasswordRequired" | "WrongPassword" | "UnsupportedKeyType";
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function isSshKeyImportError(error: any): error is SshKeyImportError;
|
|
241
|
+
|
|
177
242
|
export interface KeyGenerationError extends Error {
|
|
178
243
|
name: "KeyGenerationError";
|
|
179
244
|
variant: "KeyGenerationError" | "KeyConversionError";
|
|
@@ -193,11 +258,66 @@ export interface FolderView {
|
|
|
193
258
|
revisionDate: DateTime<Utc>;
|
|
194
259
|
}
|
|
195
260
|
|
|
196
|
-
export interface
|
|
197
|
-
name: "
|
|
261
|
+
export interface DecryptFileError extends Error {
|
|
262
|
+
name: "DecryptFileError";
|
|
263
|
+
variant: "Decrypt" | "Io";
|
|
198
264
|
}
|
|
199
265
|
|
|
200
|
-
export function
|
|
266
|
+
export function isDecryptFileError(error: any): error is DecryptFileError;
|
|
267
|
+
|
|
268
|
+
export interface EncryptFileError extends Error {
|
|
269
|
+
name: "EncryptFileError";
|
|
270
|
+
variant: "Encrypt" | "Io";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function isEncryptFileError(error: any): error is EncryptFileError;
|
|
274
|
+
|
|
275
|
+
export interface DecryptError extends Error {
|
|
276
|
+
name: "DecryptError";
|
|
277
|
+
variant: "Crypto" | "VaultLocked";
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function isDecryptError(error: any): error is DecryptError;
|
|
281
|
+
|
|
282
|
+
export interface EncryptError extends Error {
|
|
283
|
+
name: "EncryptError";
|
|
284
|
+
variant: "Crypto" | "VaultLocked";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function isEncryptError(error: any): error is EncryptError;
|
|
288
|
+
|
|
289
|
+
export interface TotpResponse {
|
|
290
|
+
/**
|
|
291
|
+
* Generated TOTP code
|
|
292
|
+
*/
|
|
293
|
+
code: string;
|
|
294
|
+
/**
|
|
295
|
+
* Time period
|
|
296
|
+
*/
|
|
297
|
+
period: number;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface TotpError extends Error {
|
|
301
|
+
name: "TotpError";
|
|
302
|
+
variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function isTotpError(error: any): error is TotpError;
|
|
306
|
+
|
|
307
|
+
export interface SshKeyView {
|
|
308
|
+
/**
|
|
309
|
+
* SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
|
|
310
|
+
*/
|
|
311
|
+
privateKey: string;
|
|
312
|
+
/**
|
|
313
|
+
* SSH public key (ed25519/rsa) according to [RFC4253](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)
|
|
314
|
+
*/
|
|
315
|
+
publicKey: string;
|
|
316
|
+
/**
|
|
317
|
+
* SSH fingerprint using SHA256 in the format: `SHA256:BASE64_ENCODED_FINGERPRINT`
|
|
318
|
+
*/
|
|
319
|
+
fingerprint: string;
|
|
320
|
+
}
|
|
201
321
|
|
|
202
322
|
export type Uuid = string;
|
|
203
323
|
|
|
@@ -217,73 +337,83 @@ export type Utc = unknown;
|
|
|
217
337
|
*/
|
|
218
338
|
export type NonZeroU32 = number;
|
|
219
339
|
|
|
340
|
+
export interface TestError extends Error {
|
|
341
|
+
name: "TestError";
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function isTestError(error: any): error is TestError;
|
|
345
|
+
|
|
220
346
|
export class BitwardenClient {
|
|
221
347
|
free(): void;
|
|
222
|
-
|
|
223
|
-
* @param {ClientSettings | undefined} [settings]
|
|
224
|
-
* @param {LogLevel | undefined} [log_level]
|
|
225
|
-
*/
|
|
226
|
-
constructor(settings?: ClientSettings, log_level?: LogLevel);
|
|
348
|
+
constructor(settings?: ClientSettings | null, log_level?: LogLevel | null);
|
|
227
349
|
/**
|
|
228
350
|
* Test method, echoes back the input
|
|
229
|
-
* @param {string} msg
|
|
230
|
-
* @returns {string}
|
|
231
351
|
*/
|
|
232
352
|
echo(msg: string): string;
|
|
233
|
-
/**
|
|
234
|
-
* @returns {string}
|
|
235
|
-
*/
|
|
236
353
|
version(): string;
|
|
237
|
-
|
|
238
|
-
* @param {string} msg
|
|
239
|
-
* @returns {Promise<void>}
|
|
240
|
-
*/
|
|
241
|
-
throw(msg: string): Promise<void>;
|
|
354
|
+
throw(msg: string): void;
|
|
242
355
|
/**
|
|
243
356
|
* Test method, calls http endpoint
|
|
244
|
-
* @param {string} url
|
|
245
|
-
* @returns {Promise<string>}
|
|
246
357
|
*/
|
|
247
358
|
http_get(url: string): Promise<string>;
|
|
359
|
+
crypto(): CryptoClient;
|
|
360
|
+
vault(): VaultClient;
|
|
361
|
+
}
|
|
362
|
+
export class ClientFolders {
|
|
363
|
+
private constructor();
|
|
364
|
+
free(): void;
|
|
248
365
|
/**
|
|
249
|
-
*
|
|
366
|
+
* Decrypt folder
|
|
250
367
|
*/
|
|
251
|
-
|
|
368
|
+
decrypt(folder: Folder): FolderView;
|
|
369
|
+
}
|
|
370
|
+
export class ClientTotp {
|
|
371
|
+
private constructor();
|
|
372
|
+
free(): void;
|
|
252
373
|
/**
|
|
253
|
-
*
|
|
374
|
+
* Generates a TOTP code from a provided key
|
|
375
|
+
*
|
|
376
|
+
* # Arguments
|
|
377
|
+
* - `key` - Can be:
|
|
378
|
+
* - A base32 encoded string
|
|
379
|
+
* - OTP Auth URI
|
|
380
|
+
* - Steam URI
|
|
381
|
+
* - `time_ms` - Optional timestamp in milliseconds
|
|
382
|
+
*
|
|
383
|
+
* # Returns
|
|
384
|
+
* - `Ok(TotpResponse)` containing the generated code and period
|
|
385
|
+
* - `Err(TotpError)` if code generation fails
|
|
254
386
|
*/
|
|
255
|
-
|
|
387
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
|
256
388
|
}
|
|
257
|
-
export class
|
|
389
|
+
export class CryptoClient {
|
|
390
|
+
private constructor();
|
|
258
391
|
free(): void;
|
|
259
392
|
/**
|
|
260
393
|
* Initialization method for the user crypto. Needs to be called before any other crypto
|
|
261
394
|
* operations.
|
|
262
|
-
* @param {InitUserCryptoRequest} req
|
|
263
|
-
* @returns {Promise<void>}
|
|
264
395
|
*/
|
|
265
396
|
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
|
266
397
|
/**
|
|
267
398
|
* Initialization method for the organization crypto. Needs to be called after
|
|
268
399
|
* `initialize_user_crypto` but before any other crypto operations.
|
|
269
|
-
* @param {InitOrgCryptoRequest} req
|
|
270
|
-
* @returns {Promise<void>}
|
|
271
400
|
*/
|
|
272
401
|
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
|
273
|
-
}
|
|
274
|
-
export class ClientFolders {
|
|
275
|
-
free(): void;
|
|
276
402
|
/**
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* @returns {FolderView}
|
|
403
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
|
404
|
+
* Crypto initialization not required.
|
|
280
405
|
*/
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
export class ClientVault {
|
|
284
|
-
free(): void;
|
|
406
|
+
make_key_pair(user_key: string): MakeKeyPairResponse;
|
|
285
407
|
/**
|
|
286
|
-
*
|
|
408
|
+
* Verifies a user's asymmetric keys by decrypting the private key with the provided user
|
|
409
|
+
* key. Returns if the private key is decryptable and if it is a valid matching key.
|
|
410
|
+
* Crypto initialization not required.
|
|
287
411
|
*/
|
|
412
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
|
413
|
+
}
|
|
414
|
+
export class VaultClient {
|
|
415
|
+
private constructor();
|
|
416
|
+
free(): void;
|
|
288
417
|
folders(): ClientFolders;
|
|
418
|
+
totp(): ClientTotp;
|
|
289
419
|
}
|