@bitwarden/sdk-internal 0.2.0-main.146 → 0.2.0-main.148

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.
@@ -309,6 +309,35 @@ export interface CryptoError extends Error {
309
309
 
310
310
  export function isCryptoError(error: any): error is CryptoError;
311
311
 
312
+ /**
313
+ * Temporary struct to hold metadata related to current account
314
+ *
315
+ * Eventually the SDK itself should have this state and we get rid of this struct.
316
+ */
317
+ export interface Account {
318
+ id: Uuid;
319
+ email: string;
320
+ name: string | undefined;
321
+ }
322
+
323
+ export type ExportFormat = "Csv" | "Json" | { EncryptedJson: { password: string } };
324
+
325
+ export interface ExportError extends Error {
326
+ name: "ExportError";
327
+ variant:
328
+ | "MissingField"
329
+ | "NotAuthenticated"
330
+ | "VaultLocked"
331
+ | "Csv"
332
+ | "CxfError"
333
+ | "Json"
334
+ | "EncryptedJsonError"
335
+ | "BitwardenCryptoError"
336
+ | "CipherError";
337
+ }
338
+
339
+ export function isExportError(error: any): error is ExportError;
340
+
312
341
  /**
313
342
  * Password generator request options.
314
343
  */
@@ -714,6 +743,16 @@ export interface PasswordHistory {
714
743
  lastUsedDate: DateTime<Utc>;
715
744
  }
716
745
 
746
+ export interface Collection {
747
+ id: Uuid | undefined;
748
+ organizationId: Uuid;
749
+ name: EncString;
750
+ externalId: string | undefined;
751
+ hidePasswords: boolean;
752
+ readOnly: boolean;
753
+ manage: boolean;
754
+ }
755
+
717
756
  export interface SshKeyView {
718
757
  /**
719
758
  * SSH private key (ed25519/rsa) in unencrypted openssh private key format [OpenSSH private key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key)
@@ -904,6 +943,7 @@ export class BitwardenClient {
904
943
  * Constructs a specific client for generating passwords and passphrases
905
944
  */
906
945
  generator(): GeneratorClient;
946
+ exporters(): ExporterClient;
907
947
  }
908
948
  export class ClientAttachments {
909
949
  private constructor();
@@ -1027,6 +1067,34 @@ export class CryptoClient {
1027
1067
  */
1028
1068
  verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
1029
1069
  }
1070
+ export class ExporterClient {
1071
+ private constructor();
1072
+ free(): void;
1073
+ export_vault(folders: Folder[], ciphers: Cipher[], format: ExportFormat): string;
1074
+ export_organization_vault(
1075
+ collections: Collection[],
1076
+ ciphers: Cipher[],
1077
+ format: ExportFormat,
1078
+ ): string;
1079
+ /**
1080
+ * Credential Exchange Format (CXF)
1081
+ *
1082
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1083
+ *
1084
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1085
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1086
+ */
1087
+ export_cxf(account: Account, ciphers: Cipher[]): string;
1088
+ /**
1089
+ * Credential Exchange Format (CXF)
1090
+ *
1091
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1092
+ *
1093
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1094
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1095
+ */
1096
+ import_cxf(payload: string): Cipher[];
1097
+ }
1030
1098
  export class GeneratorClient {
1031
1099
  private constructor();
1032
1100
  free(): void;
@@ -120,6 +120,11 @@ function handleError(f, args) {
120
120
  }
121
121
  }
122
122
 
123
+ function getArrayU8FromWasm0(ptr, len) {
124
+ ptr = ptr >>> 0;
125
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
126
+ }
127
+
123
128
  function dropObject(idx) {
124
129
  if (idx < 132) return;
125
130
  heap[idx] = heap_next;
@@ -266,6 +271,38 @@ module.exports.isCryptoError = function (error) {
266
271
  }
267
272
  };
268
273
 
274
+ function passArrayJsValueToWasm0(array, malloc) {
275
+ const ptr = malloc(array.length * 4, 4) >>> 0;
276
+ const mem = getDataViewMemory0();
277
+ for (let i = 0; i < array.length; i++) {
278
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
279
+ }
280
+ WASM_VECTOR_LEN = array.length;
281
+ return ptr;
282
+ }
283
+
284
+ function getArrayJsValueFromWasm0(ptr, len) {
285
+ ptr = ptr >>> 0;
286
+ const mem = getDataViewMemory0();
287
+ const result = [];
288
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
289
+ result.push(takeObject(mem.getUint32(i, true)));
290
+ }
291
+ return result;
292
+ }
293
+ /**
294
+ * @param {any} error
295
+ * @returns {boolean}
296
+ */
297
+ module.exports.isExportError = function (error) {
298
+ try {
299
+ const ret = wasm.isExportError(addBorrowedObject(error));
300
+ return ret !== 0;
301
+ } finally {
302
+ heap[stack_pointer++] = undefined;
303
+ }
304
+ };
305
+
269
306
  /**
270
307
  * @param {any} error
271
308
  * @returns {boolean}
@@ -292,11 +329,6 @@ module.exports.isPassphraseError = function (error) {
292
329
  }
293
330
  };
294
331
 
295
- function getArrayU8FromWasm0(ptr, len) {
296
- ptr = ptr >>> 0;
297
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
298
- }
299
-
300
332
  function passArray8ToWasm0(arg, malloc) {
301
333
  const ptr = malloc(arg.length * 1, 1) >>> 0;
302
334
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -521,25 +553,6 @@ module.exports.import_ssh_key = function (imported_key, password) {
521
553
  }
522
554
  };
523
555
 
524
- function passArrayJsValueToWasm0(array, malloc) {
525
- const ptr = malloc(array.length * 4, 4) >>> 0;
526
- const mem = getDataViewMemory0();
527
- for (let i = 0; i < array.length; i++) {
528
- mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
529
- }
530
- WASM_VECTOR_LEN = array.length;
531
- return ptr;
532
- }
533
-
534
- function getArrayJsValueFromWasm0(ptr, len) {
535
- ptr = ptr >>> 0;
536
- const mem = getDataViewMemory0();
537
- const result = [];
538
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
539
- result.push(takeObject(mem.getUint32(i, true)));
540
- }
541
- return result;
542
- }
543
556
  /**
544
557
  * @param {any} error
545
558
  * @returns {boolean}
@@ -554,15 +567,15 @@ module.exports.isTestError = function (error) {
554
567
  };
555
568
 
556
569
  function __wbg_adapter_50(arg0, arg1, arg2) {
557
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8ef26cc0e999965d(
570
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h365c00e76c805d42(
558
571
  arg0,
559
572
  arg1,
560
573
  addHeapObject(arg2),
561
574
  );
562
575
  }
563
576
 
564
- function __wbg_adapter_224(arg0, arg1, arg2, arg3) {
565
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h33defb2ea0fdb769(
577
+ function __wbg_adapter_230(arg0, arg1, arg2, arg3) {
578
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h7df9ebaef0b1c102(
566
579
  arg0,
567
580
  arg1,
568
581
  addHeapObject(arg2),
@@ -839,6 +852,13 @@ class BitwardenClient {
839
852
  const ret = wasm.bitwardenclient_generator(this.__wbg_ptr);
840
853
  return GeneratorClient.__wrap(ret);
841
854
  }
855
+ /**
856
+ * @returns {ExporterClient}
857
+ */
858
+ exporters() {
859
+ const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
860
+ return ExporterClient.__wrap(ret);
861
+ }
842
862
  }
843
863
  module.exports.BitwardenClient = BitwardenClient;
844
864
 
@@ -1306,6 +1326,188 @@ class CryptoClient {
1306
1326
  }
1307
1327
  module.exports.CryptoClient = CryptoClient;
1308
1328
 
1329
+ const ExporterClientFinalization =
1330
+ typeof FinalizationRegistry === "undefined"
1331
+ ? { register: () => {}, unregister: () => {} }
1332
+ : new FinalizationRegistry((ptr) => wasm.__wbg_exporterclient_free(ptr >>> 0, 1));
1333
+
1334
+ class ExporterClient {
1335
+ static __wrap(ptr) {
1336
+ ptr = ptr >>> 0;
1337
+ const obj = Object.create(ExporterClient.prototype);
1338
+ obj.__wbg_ptr = ptr;
1339
+ ExporterClientFinalization.register(obj, obj.__wbg_ptr, obj);
1340
+ return obj;
1341
+ }
1342
+
1343
+ __destroy_into_raw() {
1344
+ const ptr = this.__wbg_ptr;
1345
+ this.__wbg_ptr = 0;
1346
+ ExporterClientFinalization.unregister(this);
1347
+ return ptr;
1348
+ }
1349
+
1350
+ free() {
1351
+ const ptr = this.__destroy_into_raw();
1352
+ wasm.__wbg_exporterclient_free(ptr, 0);
1353
+ }
1354
+ /**
1355
+ * @param {Folder[]} folders
1356
+ * @param {Cipher[]} ciphers
1357
+ * @param {ExportFormat} format
1358
+ * @returns {string}
1359
+ */
1360
+ export_vault(folders, ciphers, format) {
1361
+ let deferred4_0;
1362
+ let deferred4_1;
1363
+ try {
1364
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1365
+ const ptr0 = passArrayJsValueToWasm0(folders, wasm.__wbindgen_malloc);
1366
+ const len0 = WASM_VECTOR_LEN;
1367
+ const ptr1 = passArrayJsValueToWasm0(ciphers, wasm.__wbindgen_malloc);
1368
+ const len1 = WASM_VECTOR_LEN;
1369
+ wasm.exporterclient_export_vault(
1370
+ retptr,
1371
+ this.__wbg_ptr,
1372
+ ptr0,
1373
+ len0,
1374
+ ptr1,
1375
+ len1,
1376
+ addHeapObject(format),
1377
+ );
1378
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1379
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1380
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1381
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1382
+ var ptr3 = r0;
1383
+ var len3 = r1;
1384
+ if (r3) {
1385
+ ptr3 = 0;
1386
+ len3 = 0;
1387
+ throw takeObject(r2);
1388
+ }
1389
+ deferred4_0 = ptr3;
1390
+ deferred4_1 = len3;
1391
+ return getStringFromWasm0(ptr3, len3);
1392
+ } finally {
1393
+ wasm.__wbindgen_add_to_stack_pointer(16);
1394
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1395
+ }
1396
+ }
1397
+ /**
1398
+ * @param {Collection[]} collections
1399
+ * @param {Cipher[]} ciphers
1400
+ * @param {ExportFormat} format
1401
+ * @returns {string}
1402
+ */
1403
+ export_organization_vault(collections, ciphers, format) {
1404
+ let deferred4_0;
1405
+ let deferred4_1;
1406
+ try {
1407
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1408
+ const ptr0 = passArrayJsValueToWasm0(collections, wasm.__wbindgen_malloc);
1409
+ const len0 = WASM_VECTOR_LEN;
1410
+ const ptr1 = passArrayJsValueToWasm0(ciphers, wasm.__wbindgen_malloc);
1411
+ const len1 = WASM_VECTOR_LEN;
1412
+ wasm.exporterclient_export_organization_vault(
1413
+ retptr,
1414
+ this.__wbg_ptr,
1415
+ ptr0,
1416
+ len0,
1417
+ ptr1,
1418
+ len1,
1419
+ addHeapObject(format),
1420
+ );
1421
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1422
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1423
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1424
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1425
+ var ptr3 = r0;
1426
+ var len3 = r1;
1427
+ if (r3) {
1428
+ ptr3 = 0;
1429
+ len3 = 0;
1430
+ throw takeObject(r2);
1431
+ }
1432
+ deferred4_0 = ptr3;
1433
+ deferred4_1 = len3;
1434
+ return getStringFromWasm0(ptr3, len3);
1435
+ } finally {
1436
+ wasm.__wbindgen_add_to_stack_pointer(16);
1437
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1438
+ }
1439
+ }
1440
+ /**
1441
+ * Credential Exchange Format (CXF)
1442
+ *
1443
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1444
+ *
1445
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1446
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1447
+ * @param {Account} account
1448
+ * @param {Cipher[]} ciphers
1449
+ * @returns {string}
1450
+ */
1451
+ export_cxf(account, ciphers) {
1452
+ let deferred3_0;
1453
+ let deferred3_1;
1454
+ try {
1455
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1456
+ const ptr0 = passArrayJsValueToWasm0(ciphers, wasm.__wbindgen_malloc);
1457
+ const len0 = WASM_VECTOR_LEN;
1458
+ wasm.exporterclient_export_cxf(retptr, this.__wbg_ptr, addHeapObject(account), ptr0, len0);
1459
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1460
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1461
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1462
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1463
+ var ptr2 = r0;
1464
+ var len2 = r1;
1465
+ if (r3) {
1466
+ ptr2 = 0;
1467
+ len2 = 0;
1468
+ throw takeObject(r2);
1469
+ }
1470
+ deferred3_0 = ptr2;
1471
+ deferred3_1 = len2;
1472
+ return getStringFromWasm0(ptr2, len2);
1473
+ } finally {
1474
+ wasm.__wbindgen_add_to_stack_pointer(16);
1475
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1476
+ }
1477
+ }
1478
+ /**
1479
+ * Credential Exchange Format (CXF)
1480
+ *
1481
+ * *Warning:* Expect this API to be unstable, and it will change in the future.
1482
+ *
1483
+ * For use with Apple using [ASCredentialExportManager](https://developer.apple.com/documentation/authenticationservices/ascredentialexportmanager).
1484
+ * Ideally the input should be immediately serialized from [ASImportableAccount](https://developer.apple.com/documentation/authenticationservices/asimportableaccount).
1485
+ * @param {string} payload
1486
+ * @returns {Cipher[]}
1487
+ */
1488
+ import_cxf(payload) {
1489
+ try {
1490
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1491
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1492
+ const len0 = WASM_VECTOR_LEN;
1493
+ wasm.exporterclient_import_cxf(retptr, this.__wbg_ptr, ptr0, len0);
1494
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1495
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1496
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1497
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1498
+ if (r3) {
1499
+ throw takeObject(r2);
1500
+ }
1501
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
1502
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
1503
+ return v2;
1504
+ } finally {
1505
+ wasm.__wbindgen_add_to_stack_pointer(16);
1506
+ }
1507
+ }
1508
+ }
1509
+ module.exports.ExporterClient = ExporterClient;
1510
+
1309
1511
  const GeneratorClientFinalization =
1310
1512
  typeof FinalizationRegistry === "undefined"
1311
1513
  ? { register: () => {}, unregister: () => {} }
@@ -2192,6 +2394,12 @@ module.exports.__wbg_fetch_509096533071c657 = function (arg0, arg1) {
2192
2394
  return addHeapObject(ret);
2193
2395
  };
2194
2396
 
2397
+ module.exports.__wbg_getRandomValues_7dd14472e5bb087d = function () {
2398
+ return handleError(function (arg0, arg1) {
2399
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2400
+ }, arguments);
2401
+ };
2402
+
2195
2403
  module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function () {
2196
2404
  return handleError(function (arg0, arg1) {
2197
2405
  getObject(arg0).getRandomValues(getObject(arg1));
@@ -2338,7 +2546,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
2338
2546
  const a = state0.a;
2339
2547
  state0.a = 0;
2340
2548
  try {
2341
- return __wbg_adapter_224(a, state0.b, arg0, arg1);
2549
+ return __wbg_adapter_230(a, state0.b, arg0, arg1);
2342
2550
  } finally {
2343
2551
  state0.a = a;
2344
2552
  }
@@ -2707,8 +2915,8 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
2707
2915
  return ret;
2708
2916
  };
2709
2917
 
2710
- module.exports.__wbindgen_closure_wrapper2585 = function (arg0, arg1, arg2) {
2711
- const ret = makeMutClosure(arg0, arg1, 622, __wbg_adapter_50);
2918
+ module.exports.__wbindgen_closure_wrapper3216 = function (arg0, arg1, arg2) {
2919
+ const ret = makeMutClosure(arg0, arg1, 772, __wbg_adapter_50);
2712
2920
  return addHeapObject(ret);
2713
2921
  };
2714
2922
 
@@ -3,6 +3,34 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const isEncryptionSettingsError: (a: number) => number;
5
5
  export const isCryptoError: (a: number) => number;
6
+ export const __wbg_exporterclient_free: (a: number, b: number) => void;
7
+ export const exporterclient_export_vault: (
8
+ a: number,
9
+ b: number,
10
+ c: number,
11
+ d: number,
12
+ e: number,
13
+ f: number,
14
+ g: number,
15
+ ) => void;
16
+ export const exporterclient_export_organization_vault: (
17
+ a: number,
18
+ b: number,
19
+ c: number,
20
+ d: number,
21
+ e: number,
22
+ f: number,
23
+ g: number,
24
+ ) => void;
25
+ export const exporterclient_export_cxf: (
26
+ a: number,
27
+ b: number,
28
+ c: number,
29
+ d: number,
30
+ e: number,
31
+ ) => void;
32
+ export const exporterclient_import_cxf: (a: number, b: number, c: number, d: number) => void;
33
+ export const isExportError: (a: number) => number;
6
34
  export const isPasswordError: (a: number) => number;
7
35
  export const isPassphraseError: (a: number) => number;
8
36
  export const __wbg_outgoingmessage_free: (a: number, b: number) => void;
@@ -145,26 +173,27 @@ export const vaultclient_attachments: (a: number) => number;
145
173
  export const vaultclient_totp: (a: number) => number;
146
174
  export const isTestError: (a: number) => number;
147
175
  export const bitwardenclient_vault: (a: number) => number;
176
+ export const bitwardenclient_exporters: (a: number) => number;
148
177
  export const vaultclient_ciphers: (a: number) => number;
149
178
  export const vaultclient_folders: (a: number) => number;
150
179
  export const __wbg_generatorclient_free: (a: number, b: number) => void;
151
- export const __wbg_cryptoclient_free: (a: number, b: number) => void;
152
180
  export const __wbg_vaultclient_free: (a: number, b: number) => void;
153
181
  export const __wbg_clienttotp_free: (a: number, b: number) => void;
154
182
  export const __wbg_clientfolders_free: (a: number, b: number) => void;
155
183
  export const __wbg_clientciphers_free: (a: number, b: number) => void;
184
+ export const __wbg_cryptoclient_free: (a: number, b: number) => void;
156
185
  export const __wbindgen_malloc: (a: number, b: number) => number;
157
186
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
158
187
  export const __wbindgen_exn_store: (a: number) => void;
159
188
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
160
189
  export const __wbindgen_export_4: WebAssembly.Table;
161
190
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
162
- export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8ef26cc0e999965d: (
191
+ export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h365c00e76c805d42: (
163
192
  a: number,
164
193
  b: number,
165
194
  c: number,
166
195
  ) => void;
167
- export const wasm_bindgen__convert__closures__invoke2_mut__h33defb2ea0fdb769: (
196
+ export const wasm_bindgen__convert__closures__invoke2_mut__h7df9ebaef0b1c102: (
168
197
  a: number,
169
198
  b: number,
170
199
  c: number,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.146",
3
+ "version": "0.2.0-main.148",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",