@bitwarden/sdk-internal 0.2.0-main.74 → 0.2.0-main.76

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.
@@ -269,6 +269,24 @@ export interface FolderView {
269
269
  revisionDate: DateTime<Utc>;
270
270
  }
271
271
 
272
+ export interface TotpResponse {
273
+ /**
274
+ * Generated TOTP code
275
+ */
276
+ code: string;
277
+ /**
278
+ * Time period
279
+ */
280
+ period: number;
281
+ }
282
+
283
+ export interface TotpError extends Error {
284
+ name: "TotpError";
285
+ variant: "InvalidOtpauth" | "MissingSecret" | "CryptoError" | "VaultLocked";
286
+ }
287
+
288
+ export function isTotpError(error: any): error is TotpError;
289
+
272
290
  export interface TestError extends Error {
273
291
  name: "TestError";
274
292
  }
@@ -317,6 +335,25 @@ export class ClientFolders {
317
335
  */
318
336
  decrypt(folder: Folder): FolderView;
319
337
  }
338
+ export class ClientTotp {
339
+ private constructor();
340
+ free(): void;
341
+ /**
342
+ * Generates a TOTP code from a provided key
343
+ *
344
+ * # Arguments
345
+ * - `key` - Can be:
346
+ * - A base32 encoded string
347
+ * - OTP Auth URI
348
+ * - Steam URI
349
+ * - `time_ms` - Optional timestamp in milliseconds
350
+ *
351
+ * # Returns
352
+ * - `Ok(TotpResponse)` containing the generated code and period
353
+ * - `Err(TotpError)` if code generation fails
354
+ */
355
+ generate_totp(key: string, time_ms?: number | null): TotpResponse;
356
+ }
320
357
  export class CryptoClient {
321
358
  private constructor();
322
359
  free(): void;
@@ -346,4 +383,5 @@ export class VaultClient {
346
383
  private constructor();
347
384
  free(): void;
348
385
  folders(): ClientFolders;
386
+ totp(): ClientTotp;
349
387
  }
@@ -305,6 +305,19 @@ module.exports.isKeyGenerationError = function (error) {
305
305
  }
306
306
  };
307
307
 
308
+ /**
309
+ * @param {any} error
310
+ * @returns {boolean}
311
+ */
312
+ module.exports.isTotpError = function (error) {
313
+ try {
314
+ const ret = wasm.isTotpError(addBorrowedObject(error));
315
+ return ret !== 0;
316
+ } finally {
317
+ heap[stack_pointer++] = undefined;
318
+ }
319
+ };
320
+
308
321
  /**
309
322
  * @param {any} error
310
323
  * @returns {boolean}
@@ -386,7 +399,7 @@ module.exports.import_ssh_key = function (imported_key, password) {
386
399
  }
387
400
  };
388
401
 
389
- function __wbg_adapter_38(arg0, arg1, arg2) {
402
+ function __wbg_adapter_40(arg0, arg1, arg2) {
390
403
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8fd8a25b4840f267(
391
404
  arg0,
392
405
  arg1,
@@ -394,7 +407,7 @@ function __wbg_adapter_38(arg0, arg1, arg2) {
394
407
  );
395
408
  }
396
409
 
397
- function __wbg_adapter_130(arg0, arg1, arg2, arg3) {
410
+ function __wbg_adapter_139(arg0, arg1, arg2, arg3) {
398
411
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h2b4228b75de6bd5e(
399
412
  arg0,
400
413
  arg1,
@@ -589,6 +602,75 @@ class ClientFolders {
589
602
  }
590
603
  module.exports.ClientFolders = ClientFolders;
591
604
 
605
+ const ClientTotpFinalization =
606
+ typeof FinalizationRegistry === "undefined"
607
+ ? { register: () => {}, unregister: () => {} }
608
+ : new FinalizationRegistry((ptr) => wasm.__wbg_clienttotp_free(ptr >>> 0, 1));
609
+
610
+ class ClientTotp {
611
+ static __wrap(ptr) {
612
+ ptr = ptr >>> 0;
613
+ const obj = Object.create(ClientTotp.prototype);
614
+ obj.__wbg_ptr = ptr;
615
+ ClientTotpFinalization.register(obj, obj.__wbg_ptr, obj);
616
+ return obj;
617
+ }
618
+
619
+ __destroy_into_raw() {
620
+ const ptr = this.__wbg_ptr;
621
+ this.__wbg_ptr = 0;
622
+ ClientTotpFinalization.unregister(this);
623
+ return ptr;
624
+ }
625
+
626
+ free() {
627
+ const ptr = this.__destroy_into_raw();
628
+ wasm.__wbg_clienttotp_free(ptr, 0);
629
+ }
630
+ /**
631
+ * Generates a TOTP code from a provided key
632
+ *
633
+ * # Arguments
634
+ * - `key` - Can be:
635
+ * - A base32 encoded string
636
+ * - OTP Auth URI
637
+ * - Steam URI
638
+ * - `time_ms` - Optional timestamp in milliseconds
639
+ *
640
+ * # Returns
641
+ * - `Ok(TotpResponse)` containing the generated code and period
642
+ * - `Err(TotpError)` if code generation fails
643
+ * @param {string} key
644
+ * @param {number | null} [time_ms]
645
+ * @returns {TotpResponse}
646
+ */
647
+ generate_totp(key, time_ms) {
648
+ try {
649
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
650
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
651
+ const len0 = WASM_VECTOR_LEN;
652
+ wasm.clienttotp_generate_totp(
653
+ retptr,
654
+ this.__wbg_ptr,
655
+ ptr0,
656
+ len0,
657
+ !isLikeNone(time_ms),
658
+ isLikeNone(time_ms) ? 0 : time_ms,
659
+ );
660
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
661
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
662
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
663
+ if (r2) {
664
+ throw takeObject(r1);
665
+ }
666
+ return takeObject(r0);
667
+ } finally {
668
+ wasm.__wbindgen_add_to_stack_pointer(16);
669
+ }
670
+ }
671
+ }
672
+ module.exports.ClientTotp = ClientTotp;
673
+
592
674
  const CryptoClientFinalization =
593
675
  typeof FinalizationRegistry === "undefined"
594
676
  ? { register: () => {}, unregister: () => {} }
@@ -714,6 +796,13 @@ class VaultClient {
714
796
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
715
797
  return ClientFolders.__wrap(ret);
716
798
  }
799
+ /**
800
+ * @returns {ClientTotp}
801
+ */
802
+ totp() {
803
+ const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
804
+ return ClientTotp.__wrap(ret);
805
+ }
717
806
  }
718
807
  module.exports.VaultClient = VaultClient;
719
808
 
@@ -827,6 +916,11 @@ module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function () {
827
916
  }, arguments);
828
917
  };
829
918
 
919
+ module.exports.__wbg_getTime_46267b1c24877e30 = function (arg0) {
920
+ const ret = getObject(arg0).getTime();
921
+ return ret;
922
+ };
923
+
830
924
  module.exports.__wbg_get_67b2ba62fc30de12 = function () {
831
925
  return handleError(function (arg0, arg1) {
832
926
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
@@ -922,6 +1016,11 @@ module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function (arg0) {
922
1016
  return addHeapObject(ret);
923
1017
  };
924
1018
 
1019
+ module.exports.__wbg_new0_f788a2397c7ca929 = function () {
1020
+ const ret = new Date();
1021
+ return addHeapObject(ret);
1022
+ };
1023
+
925
1024
  module.exports.__wbg_new_018dcc2d6c8c2f6a = function () {
926
1025
  return handleError(function () {
927
1026
  const ret = new Headers();
@@ -936,7 +1035,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
936
1035
  const a = state0.a;
937
1036
  state0.a = 0;
938
1037
  try {
939
- return __wbg_adapter_130(a, state0.b, arg0, arg1);
1038
+ return __wbg_adapter_139(a, state0.b, arg0, arg1);
940
1039
  } finally {
941
1040
  state0.a = a;
942
1041
  }
@@ -1253,8 +1352,8 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
1253
1352
  return ret;
1254
1353
  };
1255
1354
 
1256
- module.exports.__wbindgen_closure_wrapper2045 = function (arg0, arg1, arg2) {
1257
- const ret = makeMutClosure(arg0, arg1, 552, __wbg_adapter_38);
1355
+ module.exports.__wbindgen_closure_wrapper2089 = function (arg0, arg1, arg2) {
1356
+ const ret = makeMutClosure(arg0, arg1, 564, __wbg_adapter_40);
1258
1357
  return addHeapObject(ret);
1259
1358
  };
1260
1359
 
@@ -1314,6 +1413,11 @@ module.exports.__wbindgen_number_get = function (arg0, arg1) {
1314
1413
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1315
1414
  };
1316
1415
 
1416
+ module.exports.__wbindgen_number_new = function (arg0) {
1417
+ const ret = arg0;
1418
+ return addHeapObject(ret);
1419
+ };
1420
+
1317
1421
  module.exports.__wbindgen_object_clone_ref = function (arg0) {
1318
1422
  const ret = getObject(arg0);
1319
1423
  return addHeapObject(ret);
@@ -6,6 +6,7 @@ export const isEncryptionSettingsError: (a: number) => number;
6
6
  export const isSshKeyExportError: (a: number) => number;
7
7
  export const isSshKeyImportError: (a: number) => number;
8
8
  export const isKeyGenerationError: (a: number) => number;
9
+ export const isTotpError: (a: number) => number;
9
10
  export const __wbg_bitwardenclient_free: (a: number, b: number) => void;
10
11
  export const bitwardenclient_new: (a: number, b: number) => number;
11
12
  export const bitwardenclient_echo: (a: number, b: number, c: number, d: number) => void;
@@ -21,11 +22,21 @@ export const cryptoclient_verify_asymmetric_keys: (a: number, b: number, c: numb
21
22
  export const generate_ssh_key: (a: number, b: number) => void;
22
23
  export const import_ssh_key: (a: number, b: number, c: number, d: number, e: number) => void;
23
24
  export const clientfolders_decrypt: (a: number, b: number, c: number) => void;
25
+ export const clienttotp_generate_totp: (
26
+ a: number,
27
+ b: number,
28
+ c: number,
29
+ d: number,
30
+ e: number,
31
+ f: number,
32
+ ) => void;
24
33
  export const __wbg_cryptoclient_free: (a: number, b: number) => void;
25
34
  export const __wbg_clientfolders_free: (a: number, b: number) => void;
35
+ export const __wbg_clienttotp_free: (a: number, b: number) => void;
26
36
  export const __wbg_vaultclient_free: (a: number, b: number) => void;
27
37
  export const bitwardenclient_vault: (a: number) => number;
28
38
  export const vaultclient_folders: (a: number) => number;
39
+ export const vaultclient_totp: (a: number) => number;
29
40
  export const __wbindgen_malloc: (a: number, b: number) => number;
30
41
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
42
  export const __wbindgen_exn_store: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.74",
3
+ "version": "0.2.0-main.76",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",