@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
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
131cbfae6dbd68f3ee53e94181fcbb4646e372ae
|
|
@@ -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;
|
|
@@ -323,6 +323,17 @@ export function init_sdk(log_level) {
|
|
|
323
323
|
wasm.init_sdk(isLikeNone(log_level) ? 5 : log_level);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
327
|
+
ptr = ptr >>> 0;
|
|
328
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
332
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
333
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
334
|
+
WASM_VECTOR_LEN = arg.length;
|
|
335
|
+
return ptr;
|
|
336
|
+
}
|
|
326
337
|
/**
|
|
327
338
|
* Generate a new SSH key pair
|
|
328
339
|
*
|
|
@@ -388,7 +399,7 @@ function __wbg_adapter_42(arg0, arg1, arg2) {
|
|
|
388
399
|
wasm.closure544_externref_shim(arg0, arg1, arg2);
|
|
389
400
|
}
|
|
390
401
|
|
|
391
|
-
function
|
|
402
|
+
function __wbg_adapter_152(arg0, arg1, arg2, arg3) {
|
|
392
403
|
wasm.closure402_externref_shim(arg0, arg1, arg2, arg3);
|
|
393
404
|
}
|
|
394
405
|
|
|
@@ -684,6 +695,140 @@ export class CryptoClient {
|
|
|
684
695
|
}
|
|
685
696
|
}
|
|
686
697
|
|
|
698
|
+
const PureCryptoFinalization =
|
|
699
|
+
typeof FinalizationRegistry === "undefined"
|
|
700
|
+
? { register: () => {}, unregister: () => {} }
|
|
701
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_purecrypto_free(ptr >>> 0, 1));
|
|
702
|
+
/**
|
|
703
|
+
* This module represents a stopgap solution to provide access to primitive crypto functions for JS
|
|
704
|
+
* clients. It is not intended to be used outside of the JS clients and this pattern should not be
|
|
705
|
+
* proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully
|
|
706
|
+
* responsible for state and keys.
|
|
707
|
+
*/
|
|
708
|
+
export class PureCrypto {
|
|
709
|
+
__destroy_into_raw() {
|
|
710
|
+
const ptr = this.__wbg_ptr;
|
|
711
|
+
this.__wbg_ptr = 0;
|
|
712
|
+
PureCryptoFinalization.unregister(this);
|
|
713
|
+
return ptr;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
free() {
|
|
717
|
+
const ptr = this.__destroy_into_raw();
|
|
718
|
+
wasm.__wbg_purecrypto_free(ptr, 0);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* @param {string} enc_string
|
|
722
|
+
* @param {string} key_b64
|
|
723
|
+
* @returns {string}
|
|
724
|
+
*/
|
|
725
|
+
static symmetric_decrypt(enc_string, key_b64) {
|
|
726
|
+
let deferred4_0;
|
|
727
|
+
let deferred4_1;
|
|
728
|
+
try {
|
|
729
|
+
const ptr0 = passStringToWasm0(enc_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
730
|
+
const len0 = WASM_VECTOR_LEN;
|
|
731
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
732
|
+
const len1 = WASM_VECTOR_LEN;
|
|
733
|
+
const ret = wasm.purecrypto_symmetric_decrypt(ptr0, len0, ptr1, len1);
|
|
734
|
+
var ptr3 = ret[0];
|
|
735
|
+
var len3 = ret[1];
|
|
736
|
+
if (ret[3]) {
|
|
737
|
+
ptr3 = 0;
|
|
738
|
+
len3 = 0;
|
|
739
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
740
|
+
}
|
|
741
|
+
deferred4_0 = ptr3;
|
|
742
|
+
deferred4_1 = len3;
|
|
743
|
+
return getStringFromWasm0(ptr3, len3);
|
|
744
|
+
} finally {
|
|
745
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* @param {string} enc_string
|
|
750
|
+
* @param {string} key_b64
|
|
751
|
+
* @returns {Uint8Array}
|
|
752
|
+
*/
|
|
753
|
+
static symmetric_decrypt_to_bytes(enc_string, key_b64) {
|
|
754
|
+
const ptr0 = passStringToWasm0(enc_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
755
|
+
const len0 = WASM_VECTOR_LEN;
|
|
756
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
757
|
+
const len1 = WASM_VECTOR_LEN;
|
|
758
|
+
const ret = wasm.purecrypto_symmetric_decrypt_to_bytes(ptr0, len0, ptr1, len1);
|
|
759
|
+
if (ret[3]) {
|
|
760
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
761
|
+
}
|
|
762
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
763
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
764
|
+
return v3;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* @param {Uint8Array} enc_bytes
|
|
768
|
+
* @param {string} key_b64
|
|
769
|
+
* @returns {Uint8Array}
|
|
770
|
+
*/
|
|
771
|
+
static symmetric_decrypt_array_buffer(enc_bytes, key_b64) {
|
|
772
|
+
const ptr0 = passArray8ToWasm0(enc_bytes, wasm.__wbindgen_malloc);
|
|
773
|
+
const len0 = WASM_VECTOR_LEN;
|
|
774
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
775
|
+
const len1 = WASM_VECTOR_LEN;
|
|
776
|
+
const ret = wasm.purecrypto_symmetric_decrypt_array_buffer(ptr0, len0, ptr1, len1);
|
|
777
|
+
if (ret[3]) {
|
|
778
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
779
|
+
}
|
|
780
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
781
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
782
|
+
return v3;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* @param {string} plain
|
|
786
|
+
* @param {string} key_b64
|
|
787
|
+
* @returns {string}
|
|
788
|
+
*/
|
|
789
|
+
static symmetric_encrypt(plain, key_b64) {
|
|
790
|
+
let deferred4_0;
|
|
791
|
+
let deferred4_1;
|
|
792
|
+
try {
|
|
793
|
+
const ptr0 = passStringToWasm0(plain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
794
|
+
const len0 = WASM_VECTOR_LEN;
|
|
795
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
796
|
+
const len1 = WASM_VECTOR_LEN;
|
|
797
|
+
const ret = wasm.purecrypto_symmetric_encrypt(ptr0, len0, ptr1, len1);
|
|
798
|
+
var ptr3 = ret[0];
|
|
799
|
+
var len3 = ret[1];
|
|
800
|
+
if (ret[3]) {
|
|
801
|
+
ptr3 = 0;
|
|
802
|
+
len3 = 0;
|
|
803
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
804
|
+
}
|
|
805
|
+
deferred4_0 = ptr3;
|
|
806
|
+
deferred4_1 = len3;
|
|
807
|
+
return getStringFromWasm0(ptr3, len3);
|
|
808
|
+
} finally {
|
|
809
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* @param {Uint8Array} plain
|
|
814
|
+
* @param {string} key_b64
|
|
815
|
+
* @returns {Uint8Array}
|
|
816
|
+
*/
|
|
817
|
+
static symmetric_encrypt_to_array_buffer(plain, key_b64) {
|
|
818
|
+
const ptr0 = passArray8ToWasm0(plain, wasm.__wbindgen_malloc);
|
|
819
|
+
const len0 = WASM_VECTOR_LEN;
|
|
820
|
+
const ptr1 = passStringToWasm0(key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
821
|
+
const len1 = WASM_VECTOR_LEN;
|
|
822
|
+
const ret = wasm.purecrypto_symmetric_encrypt_to_array_buffer(ptr0, len0, ptr1, len1);
|
|
823
|
+
if (ret[3]) {
|
|
824
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
825
|
+
}
|
|
826
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
827
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
828
|
+
return v3;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
687
832
|
const VaultClientFinalization =
|
|
688
833
|
typeof FinalizationRegistry === "undefined"
|
|
689
834
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -950,7 +1095,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
|
|
|
950
1095
|
const a = state0.a;
|
|
951
1096
|
state0.a = 0;
|
|
952
1097
|
try {
|
|
953
|
-
return
|
|
1098
|
+
return __wbg_adapter_152(a, state0.b, arg0, arg1);
|
|
954
1099
|
} finally {
|
|
955
1100
|
state0.a = a;
|
|
956
1101
|
}
|
|
@@ -1267,7 +1412,7 @@ export function __wbindgen_cb_drop(arg0) {
|
|
|
1267
1412
|
return ret;
|
|
1268
1413
|
}
|
|
1269
1414
|
|
|
1270
|
-
export function
|
|
1415
|
+
export function __wbindgen_closure_wrapper2142(arg0, arg1, arg2) {
|
|
1271
1416
|
const ret = makeMutClosure(arg0, arg1, 545, __wbg_adapter_42);
|
|
1272
1417
|
return ret;
|
|
1273
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,
|