@bitwarden/sdk-internal 0.2.0-main.1 → 0.2.0-main.100
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/LICENSE +674 -295
- package/VERSION +1 -0
- package/bitwarden_wasm_internal.d.ts +224 -35
- package/bitwarden_wasm_internal.js +1 -0
- package/bitwarden_wasm_internal_bg.js +765 -484
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +52 -25
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +224 -35
- package/node/bitwarden_wasm_internal.js +769 -485
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +52 -25
- package/package.json +5 -4
|
@@ -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): 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
|
|
28
|
+
*/
|
|
29
|
+
export function import_ssh_key(imported_key: string, password?: string | null): SshKeyView;
|
|
3
30
|
export enum LogLevel {
|
|
4
31
|
Trace = 0,
|
|
5
32
|
Debug = 1,
|
|
@@ -51,6 +78,50 @@ export interface InitOrgCryptoRequest {
|
|
|
51
78
|
organizationKeys: Map<Uuid, AsymmetricEncString>;
|
|
52
79
|
}
|
|
53
80
|
|
|
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;
|
|
90
|
+
}
|
|
91
|
+
|
|
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
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface EncryptionSettingsError extends Error {
|
|
119
|
+
name: "EncryptionSettingsError";
|
|
120
|
+
variant: "Crypto" | "InvalidBase64" | "VaultLocked" | "InvalidPrivateKey" | "MissingPrivateKey";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function isEncryptionSettingsError(error: any): error is EncryptionSettingsError;
|
|
124
|
+
|
|
54
125
|
export type DeviceType =
|
|
55
126
|
| "Android"
|
|
56
127
|
| "iOS"
|
|
@@ -129,6 +200,52 @@ export type Kdf =
|
|
|
129
200
|
| { pBKDF2: { iterations: NonZeroU32 } }
|
|
130
201
|
| { argon2id: { iterations: NonZeroU32; memory: NonZeroU32; parallelism: NonZeroU32 } };
|
|
131
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 type KeyAlgorithm = "Ed25519" | "Rsa3072" | "Rsa4096";
|
|
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
|
+
|
|
242
|
+
export interface KeyGenerationError extends Error {
|
|
243
|
+
name: "KeyGenerationError";
|
|
244
|
+
variant: "KeyGenerationError" | "KeyConversionError";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function isKeyGenerationError(error: any): error is KeyGenerationError;
|
|
248
|
+
|
|
132
249
|
export interface Folder {
|
|
133
250
|
id: Uuid | undefined;
|
|
134
251
|
name: EncString;
|
|
@@ -141,6 +258,67 @@ export interface FolderView {
|
|
|
141
258
|
revisionDate: DateTime<Utc>;
|
|
142
259
|
}
|
|
143
260
|
|
|
261
|
+
export interface DecryptFileError extends Error {
|
|
262
|
+
name: "DecryptFileError";
|
|
263
|
+
variant: "Decrypt" | "Io";
|
|
264
|
+
}
|
|
265
|
+
|
|
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
|
+
}
|
|
321
|
+
|
|
144
322
|
export type Uuid = string;
|
|
145
323
|
|
|
146
324
|
/**
|
|
@@ -159,72 +337,83 @@ export type Utc = unknown;
|
|
|
159
337
|
*/
|
|
160
338
|
export type NonZeroU32 = number;
|
|
161
339
|
|
|
340
|
+
export interface TestError extends Error {
|
|
341
|
+
name: "TestError";
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function isTestError(error: any): error is TestError;
|
|
345
|
+
|
|
162
346
|
export class BitwardenClient {
|
|
163
347
|
free(): void;
|
|
164
|
-
|
|
165
|
-
* @param {ClientSettings | undefined} [settings]
|
|
166
|
-
* @param {LogLevel | undefined} [log_level]
|
|
167
|
-
*/
|
|
168
|
-
constructor(settings?: ClientSettings, log_level?: LogLevel);
|
|
348
|
+
constructor(settings?: ClientSettings | null, log_level?: LogLevel | null);
|
|
169
349
|
/**
|
|
170
350
|
* Test method, echoes back the input
|
|
171
|
-
* @param {string} msg
|
|
172
|
-
* @returns {string}
|
|
173
351
|
*/
|
|
174
352
|
echo(msg: string): string;
|
|
175
|
-
/**
|
|
176
|
-
* @returns {string}
|
|
177
|
-
*/
|
|
178
353
|
version(): string;
|
|
179
|
-
/**
|
|
180
|
-
* @param {string} msg
|
|
181
|
-
*/
|
|
182
354
|
throw(msg: string): void;
|
|
183
355
|
/**
|
|
184
356
|
* Test method, calls http endpoint
|
|
185
|
-
* @param {string} url
|
|
186
|
-
* @returns {Promise<string>}
|
|
187
357
|
*/
|
|
188
358
|
http_get(url: string): Promise<string>;
|
|
359
|
+
crypto(): CryptoClient;
|
|
360
|
+
vault(): VaultClient;
|
|
361
|
+
}
|
|
362
|
+
export class ClientFolders {
|
|
363
|
+
private constructor();
|
|
364
|
+
free(): void;
|
|
189
365
|
/**
|
|
190
|
-
*
|
|
366
|
+
* Decrypt folder
|
|
191
367
|
*/
|
|
192
|
-
|
|
368
|
+
decrypt(folder: Folder): FolderView;
|
|
369
|
+
}
|
|
370
|
+
export class ClientTotp {
|
|
371
|
+
private constructor();
|
|
372
|
+
free(): void;
|
|
193
373
|
/**
|
|
194
|
-
*
|
|
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
|
|
195
386
|
*/
|
|
196
|
-
|
|
387
|
+
generate_totp(key: string, time_ms?: number | null): TotpResponse;
|
|
197
388
|
}
|
|
198
|
-
export class
|
|
389
|
+
export class CryptoClient {
|
|
390
|
+
private constructor();
|
|
199
391
|
free(): void;
|
|
200
392
|
/**
|
|
201
393
|
* Initialization method for the user crypto. Needs to be called before any other crypto
|
|
202
394
|
* operations.
|
|
203
|
-
* @param {InitUserCryptoRequest} req
|
|
204
|
-
* @returns {Promise<void>}
|
|
205
395
|
*/
|
|
206
396
|
initialize_user_crypto(req: InitUserCryptoRequest): Promise<void>;
|
|
207
397
|
/**
|
|
208
398
|
* Initialization method for the organization crypto. Needs to be called after
|
|
209
399
|
* `initialize_user_crypto` but before any other crypto operations.
|
|
210
|
-
* @param {InitOrgCryptoRequest} req
|
|
211
|
-
* @returns {Promise<void>}
|
|
212
400
|
*/
|
|
213
401
|
initialize_org_crypto(req: InitOrgCryptoRequest): Promise<void>;
|
|
214
|
-
}
|
|
215
|
-
export class ClientFolders {
|
|
216
|
-
free(): void;
|
|
217
402
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* @returns {FolderView}
|
|
403
|
+
* Generates a new key pair and encrypts the private key with the provided user key.
|
|
404
|
+
* Crypto initialization not required.
|
|
221
405
|
*/
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
export class ClientVault {
|
|
225
|
-
free(): void;
|
|
406
|
+
make_key_pair(user_key: string): MakeKeyPairResponse;
|
|
226
407
|
/**
|
|
227
|
-
*
|
|
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.
|
|
228
411
|
*/
|
|
412
|
+
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
|
413
|
+
}
|
|
414
|
+
export class VaultClient {
|
|
415
|
+
private constructor();
|
|
416
|
+
free(): void;
|
|
229
417
|
folders(): ClientFolders;
|
|
418
|
+
totp(): ClientTotp;
|
|
230
419
|
}
|