@bitwarden/sdk-internal 0.2.0-main.109 → 0.2.0-main.110
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 -1
- package/bitwarden_wasm_internal.d.ts +15 -0
- package/bitwarden_wasm_internal_bg.js +148 -3
- package/bitwarden_wasm_internal_bg.wasm +0 -0
- package/bitwarden_wasm_internal_bg.wasm.d.ts +31 -0
- package/bitwarden_wasm_internal_bg.wasm.js +1 -1
- package/node/bitwarden_wasm_internal.d.ts +15 -0
- package/node/bitwarden_wasm_internal.js +149 -3
- package/node/bitwarden_wasm_internal_bg.wasm +0 -0
- package/node/bitwarden_wasm_internal_bg.wasm.d.ts +31 -0
- package/package.json +1 -1
|
@@ -415,6 +415,21 @@ export class CryptoClient {
|
|
|
415
415
|
*/
|
|
416
416
|
verify_asymmetric_keys(request: VerifyAsymmetricKeysRequest): VerifyAsymmetricKeysResponse;
|
|
417
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
|
420
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
|
421
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
|
422
|
+
* responsible for state and keys.
|
|
423
|
+
*/
|
|
424
|
+
export class PureCrypto {
|
|
425
|
+
private constructor();
|
|
426
|
+
free(): void;
|
|
427
|
+
static symmetric_decrypt(enc_string: string, key_b64: string): string;
|
|
428
|
+
static symmetric_decrypt_to_bytes(enc_string: string, key_b64: string): Uint8Array;
|
|
429
|
+
static symmetric_decrypt_array_buffer(enc_bytes: Uint8Array, key_b64: string): Uint8Array;
|
|
430
|
+
static symmetric_encrypt(plain: string, key_b64: string): string;
|
|
431
|
+
static symmetric_encrypt_to_array_buffer(plain: Uint8Array, key_b64: string): Uint8Array;
|
|
432
|
+
}
|
|
418
433
|
export class VaultClient {
|
|
419
434
|
private constructor();
|
|
420
435
|
free(): void;
|
|
@@ -317,6 +317,17 @@ module.exports.init_sdk = function (log_level) {
|
|
|
317
317
|
wasm.init_sdk(isLikeNone(log_level) ? 5 : log_level);
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
321
|
+
ptr = ptr >>> 0;
|
|
322
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
326
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
327
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
328
|
+
WASM_VECTOR_LEN = arg.length;
|
|
329
|
+
return ptr;
|
|
330
|
+
}
|
|
320
331
|
/**
|
|
321
332
|
* Generate a new SSH key pair
|
|
322
333
|
*
|
|
@@ -382,7 +393,7 @@ function __wbg_adapter_42(arg0, arg1, arg2) {
|
|
|
382
393
|
wasm.closure544_externref_shim(arg0, arg1, arg2);
|
|
383
394
|
}
|
|
384
395
|
|
|
385
|
-
function
|
|
396
|
+
function __wbg_adapter_152(arg0, arg1, arg2, arg3) {
|
|
386
397
|
wasm.closure402_externref_shim(arg0, arg1, arg2, arg3);
|
|
387
398
|
}
|
|
388
399
|
|
|
@@ -682,6 +693,141 @@ class CryptoClient {
|
|
|
682
693
|
}
|
|
683
694
|
module.exports.CryptoClient = CryptoClient;
|
|
684
695
|
|
|
696
|
+
const PureCryptoFinalization =
|
|
697
|
+
typeof FinalizationRegistry === "undefined"
|
|
698
|
+
? { register: () => {}, unregister: () => {} }
|
|
699
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_purecrypto_free(ptr >>> 0, 1));
|
|
700
|
+
/**
|
|
701
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
|
702
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
|
703
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
|
704
|
+
* responsible for state and keys.
|
|
705
|
+
*/
|
|
706
|
+
class PureCrypto {
|
|
707
|
+
__destroy_into_raw() {
|
|
708
|
+
const ptr = this.__wbg_ptr;
|
|
709
|
+
this.__wbg_ptr = 0;
|
|
710
|
+
PureCryptoFinalization.unregister(this);
|
|
711
|
+
return ptr;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
free() {
|
|
715
|
+
const ptr = this.__destroy_into_raw();
|
|
716
|
+
wasm.__wbg_purecrypto_free(ptr, 0);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* @param {string} enc_string
|
|
720
|
+
* @param {string} key_b64
|
|
721
|
+
* @returns {string}
|
|
722
|
+
*/
|
|
723
|
+
static symmetric_decrypt(enc_string, key_b64) {
|
|
724
|
+
let deferred4_0;
|
|
725
|
+
let deferred4_1;
|
|
726
|
+
try {
|
|
727
|
+
const ptr0 = passStringToWasm0(enc_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
728
|
+
const len0 = WASM_VECTOR_LEN;
|
|
729
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
730
|
+
const len1 = WASM_VECTOR_LEN;
|
|
731
|
+
const ret = wasm.purecrypto_symmetric_decrypt(ptr0, len0, ptr1, len1);
|
|
732
|
+
var ptr3 = ret[0];
|
|
733
|
+
var len3 = ret[1];
|
|
734
|
+
if (ret[3]) {
|
|
735
|
+
ptr3 = 0;
|
|
736
|
+
len3 = 0;
|
|
737
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
738
|
+
}
|
|
739
|
+
deferred4_0 = ptr3;
|
|
740
|
+
deferred4_1 = len3;
|
|
741
|
+
return getStringFromWasm0(ptr3, len3);
|
|
742
|
+
} finally {
|
|
743
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* @param {string} enc_string
|
|
748
|
+
* @param {string} key_b64
|
|
749
|
+
* @returns {Uint8Array}
|
|
750
|
+
*/
|
|
751
|
+
static symmetric_decrypt_to_bytes(enc_string, key_b64) {
|
|
752
|
+
const ptr0 = passStringToWasm0(enc_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
753
|
+
const len0 = WASM_VECTOR_LEN;
|
|
754
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
755
|
+
const len1 = WASM_VECTOR_LEN;
|
|
756
|
+
const ret = wasm.purecrypto_symmetric_decrypt_to_bytes(ptr0, len0, ptr1, len1);
|
|
757
|
+
if (ret[3]) {
|
|
758
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
759
|
+
}
|
|
760
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
761
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
762
|
+
return v3;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* @param {Uint8Array} enc_bytes
|
|
766
|
+
* @param {string} key_b64
|
|
767
|
+
* @returns {Uint8Array}
|
|
768
|
+
*/
|
|
769
|
+
static symmetric_decrypt_array_buffer(enc_bytes, key_b64) {
|
|
770
|
+
const ptr0 = passArray8ToWasm0(enc_bytes, wasm.__wbindgen_malloc);
|
|
771
|
+
const len0 = WASM_VECTOR_LEN;
|
|
772
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
773
|
+
const len1 = WASM_VECTOR_LEN;
|
|
774
|
+
const ret = wasm.purecrypto_symmetric_decrypt_array_buffer(ptr0, len0, ptr1, len1);
|
|
775
|
+
if (ret[3]) {
|
|
776
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
777
|
+
}
|
|
778
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
779
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
780
|
+
return v3;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* @param {string} plain
|
|
784
|
+
* @param {string} key_b64
|
|
785
|
+
* @returns {string}
|
|
786
|
+
*/
|
|
787
|
+
static symmetric_encrypt(plain, key_b64) {
|
|
788
|
+
let deferred4_0;
|
|
789
|
+
let deferred4_1;
|
|
790
|
+
try {
|
|
791
|
+
const ptr0 = passStringToWasm0(plain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
792
|
+
const len0 = WASM_VECTOR_LEN;
|
|
793
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
794
|
+
const len1 = WASM_VECTOR_LEN;
|
|
795
|
+
const ret = wasm.purecrypto_symmetric_encrypt(ptr0, len0, ptr1, len1);
|
|
796
|
+
var ptr3 = ret[0];
|
|
797
|
+
var len3 = ret[1];
|
|
798
|
+
if (ret[3]) {
|
|
799
|
+
ptr3 = 0;
|
|
800
|
+
len3 = 0;
|
|
801
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
802
|
+
}
|
|
803
|
+
deferred4_0 = ptr3;
|
|
804
|
+
deferred4_1 = len3;
|
|
805
|
+
return getStringFromWasm0(ptr3, len3);
|
|
806
|
+
} finally {
|
|
807
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* @param {Uint8Array} plain
|
|
812
|
+
* @param {string} key_b64
|
|
813
|
+
* @returns {Uint8Array}
|
|
814
|
+
*/
|
|
815
|
+
static symmetric_encrypt_to_array_buffer(plain, key_b64) {
|
|
816
|
+
const ptr0 = passArray8ToWasm0(plain, wasm.__wbindgen_malloc);
|
|
817
|
+
const len0 = WASM_VECTOR_LEN;
|
|
818
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
819
|
+
const len1 = WASM_VECTOR_LEN;
|
|
820
|
+
const ret = wasm.purecrypto_symmetric_encrypt_to_array_buffer(ptr0, len0, ptr1, len1);
|
|
821
|
+
if (ret[3]) {
|
|
822
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
823
|
+
}
|
|
824
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
825
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
826
|
+
return v3;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
module.exports.PureCrypto = PureCrypto;
|
|
830
|
+
|
|
685
831
|
const VaultClientFinalization =
|
|
686
832
|
typeof FinalizationRegistry === "undefined"
|
|
687
833
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -949,7 +1095,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
|
|
|
949
1095
|
const a = state0.a;
|
|
950
1096
|
state0.a = 0;
|
|
951
1097
|
try {
|
|
952
|
-
return
|
|
1098
|
+
return __wbg_adapter_152(a, state0.b, arg0, arg1);
|
|
953
1099
|
} finally {
|
|
954
1100
|
state0.a = a;
|
|
955
1101
|
}
|
|
@@ -1266,7 +1412,7 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
|
|
|
1266
1412
|
return ret;
|
|
1267
1413
|
};
|
|
1268
1414
|
|
|
1269
|
-
module.exports.
|
|
1415
|
+
module.exports.__wbindgen_closure_wrapper2142 = function (arg0, arg1, arg2) {
|
|
1270
1416
|
const ret = makeMutClosure(arg0, arg1, 545, __wbg_adapter_42);
|
|
1271
1417
|
return ret;
|
|
1272
1418
|
};
|
|
Binary file
|
|
@@ -28,6 +28,37 @@ export const cryptoclient_make_key_pair: (
|
|
|
28
28
|
export const cryptoclient_verify_asymmetric_keys: (a: number, b: any) => [number, number, number];
|
|
29
29
|
export const set_log_level: (a: number) => void;
|
|
30
30
|
export const init_sdk: (a: number) => void;
|
|
31
|
+
export const __wbg_purecrypto_free: (a: number, b: number) => void;
|
|
32
|
+
export const purecrypto_symmetric_decrypt: (
|
|
33
|
+
a: number,
|
|
34
|
+
b: number,
|
|
35
|
+
c: number,
|
|
36
|
+
d: number,
|
|
37
|
+
) => [number, number, number, number];
|
|
38
|
+
export const purecrypto_symmetric_decrypt_to_bytes: (
|
|
39
|
+
a: number,
|
|
40
|
+
b: number,
|
|
41
|
+
c: number,
|
|
42
|
+
d: number,
|
|
43
|
+
) => [number, number, number, number];
|
|
44
|
+
export const purecrypto_symmetric_decrypt_array_buffer: (
|
|
45
|
+
a: number,
|
|
46
|
+
b: number,
|
|
47
|
+
c: number,
|
|
48
|
+
d: number,
|
|
49
|
+
) => [number, number, number, number];
|
|
50
|
+
export const purecrypto_symmetric_encrypt: (
|
|
51
|
+
a: number,
|
|
52
|
+
b: number,
|
|
53
|
+
c: number,
|
|
54
|
+
d: number,
|
|
55
|
+
) => [number, number, number, number];
|
|
56
|
+
export const purecrypto_symmetric_encrypt_to_array_buffer: (
|
|
57
|
+
a: number,
|
|
58
|
+
b: number,
|
|
59
|
+
c: number,
|
|
60
|
+
d: number,
|
|
61
|
+
) => [number, number, number, number];
|
|
31
62
|
export const generate_ssh_key: (a: any) => [number, number, number];
|
|
32
63
|
export const import_ssh_key: (
|
|
33
64
|
a: number,
|