cas-wasm 0.1.0 → 0.1.1
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 +201 -0
- package/cas_wasm.d.ts +0 -51
- package/cas_wasm.js +7 -435
- package/cas_wasm_bg.js +338 -0
- package/package.json +5 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Mike Mulchrone
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/cas_wasm.d.ts
CHANGED
|
@@ -26,54 +26,3 @@ export class RSAWrapper {
|
|
|
26
26
|
*/
|
|
27
27
|
verify(public_key: string, data: Uint8Array, signature: Uint8Array): boolean;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
31
|
-
|
|
32
|
-
export interface InitOutput {
|
|
33
|
-
readonly memory: WebAssembly.Memory;
|
|
34
|
-
readonly __wbg_rsakeypair_free: (a: number, b: number) => void;
|
|
35
|
-
readonly rsakeypair_privateKey: (a: number) => [number, number];
|
|
36
|
-
readonly rsakeypair_publicKey: (a: number) => [number, number];
|
|
37
|
-
readonly __wbg_rsawrapper_free: (a: number, b: number) => void;
|
|
38
|
-
readonly rsawrapper_generateRsaKeys: (a: number, b: number) => number;
|
|
39
|
-
readonly rsawrapper_sign: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
40
|
-
readonly rsawrapper_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
41
|
-
readonly rsawrapper_new: () => number;
|
|
42
|
-
readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
43
|
-
readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
44
|
-
readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
45
|
-
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
46
|
-
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
|
47
|
-
readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
48
|
-
readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
49
|
-
readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
50
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
51
|
-
readonly __externref_table_alloc: () => number;
|
|
52
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
53
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
54
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
55
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
56
|
-
readonly __wbindgen_start: () => void;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
63
|
-
* a precompiled `WebAssembly.Module`.
|
|
64
|
-
*
|
|
65
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
66
|
-
*
|
|
67
|
-
* @returns {InitOutput}
|
|
68
|
-
*/
|
|
69
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
73
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
74
|
-
*
|
|
75
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
76
|
-
*
|
|
77
|
-
* @returns {Promise<InitOutput>}
|
|
78
|
-
*/
|
|
79
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/cas_wasm.js
CHANGED
|
@@ -1,437 +1,9 @@
|
|
|
1
1
|
/* @ts-self-types="./cas_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
__destroy_into_raw() {
|
|
12
|
-
const ptr = this.__wbg_ptr;
|
|
13
|
-
this.__wbg_ptr = 0;
|
|
14
|
-
RSAKeyPairFinalization.unregister(this);
|
|
15
|
-
return ptr;
|
|
16
|
-
}
|
|
17
|
-
free() {
|
|
18
|
-
const ptr = this.__destroy_into_raw();
|
|
19
|
-
wasm.__wbg_rsakeypair_free(ptr, 0);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
get privateKey() {
|
|
25
|
-
let deferred1_0;
|
|
26
|
-
let deferred1_1;
|
|
27
|
-
try {
|
|
28
|
-
const ret = wasm.rsakeypair_privateKey(this.__wbg_ptr);
|
|
29
|
-
deferred1_0 = ret[0];
|
|
30
|
-
deferred1_1 = ret[1];
|
|
31
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
32
|
-
} finally {
|
|
33
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @returns {string}
|
|
38
|
-
*/
|
|
39
|
-
get publicKey() {
|
|
40
|
-
let deferred1_0;
|
|
41
|
-
let deferred1_1;
|
|
42
|
-
try {
|
|
43
|
-
const ret = wasm.rsakeypair_publicKey(this.__wbg_ptr);
|
|
44
|
-
deferred1_0 = ret[0];
|
|
45
|
-
deferred1_1 = ret[1];
|
|
46
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
47
|
-
} finally {
|
|
48
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (Symbol.dispose) RSAKeyPair.prototype[Symbol.dispose] = RSAKeyPair.prototype.free;
|
|
53
|
-
|
|
54
|
-
export class RSAWrapper {
|
|
55
|
-
__destroy_into_raw() {
|
|
56
|
-
const ptr = this.__wbg_ptr;
|
|
57
|
-
this.__wbg_ptr = 0;
|
|
58
|
-
RSAWrapperFinalization.unregister(this);
|
|
59
|
-
return ptr;
|
|
60
|
-
}
|
|
61
|
-
free() {
|
|
62
|
-
const ptr = this.__destroy_into_raw();
|
|
63
|
-
wasm.__wbg_rsawrapper_free(ptr, 0);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Generates an RSA key pair based of parameter sent in 1024, 2048, and 4096 are supported.
|
|
67
|
-
* @param {number} key_size
|
|
68
|
-
* @returns {RSAKeyPair}
|
|
69
|
-
*/
|
|
70
|
-
generateRsaKeys(key_size) {
|
|
71
|
-
const ret = wasm.rsawrapper_generateRsaKeys(this.__wbg_ptr, key_size);
|
|
72
|
-
return RSAKeyPair.__wrap(ret);
|
|
73
|
-
}
|
|
74
|
-
constructor() {
|
|
75
|
-
const ret = wasm.rsawrapper_new();
|
|
76
|
-
this.__wbg_ptr = ret >>> 0;
|
|
77
|
-
RSAWrapperFinalization.register(this, this.__wbg_ptr, this);
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Signs a byte array with an RSA private key for verification.
|
|
82
|
-
* @param {string} private_key
|
|
83
|
-
* @param {Uint8Array} data
|
|
84
|
-
* @returns {Uint8Array}
|
|
85
|
-
*/
|
|
86
|
-
sign(private_key, data) {
|
|
87
|
-
const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
-
const len0 = WASM_VECTOR_LEN;
|
|
89
|
-
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
90
|
-
const len1 = WASM_VECTOR_LEN;
|
|
91
|
-
const ret = wasm.rsawrapper_sign(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
92
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
93
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
94
|
-
return v3;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Verifies signed data by the corresponding private key with an RSA public key.
|
|
98
|
-
* @param {string} public_key
|
|
99
|
-
* @param {Uint8Array} data
|
|
100
|
-
* @param {Uint8Array} signature
|
|
101
|
-
* @returns {boolean}
|
|
102
|
-
*/
|
|
103
|
-
verify(public_key, data, signature) {
|
|
104
|
-
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
-
const len0 = WASM_VECTOR_LEN;
|
|
106
|
-
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
107
|
-
const len1 = WASM_VECTOR_LEN;
|
|
108
|
-
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
109
|
-
const len2 = WASM_VECTOR_LEN;
|
|
110
|
-
const ret = wasm.rsawrapper_verify(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
111
|
-
return ret !== 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (Symbol.dispose) RSAWrapper.prototype[Symbol.dispose] = RSAWrapper.prototype.free;
|
|
115
|
-
|
|
116
|
-
function __wbg_get_imports() {
|
|
117
|
-
const import0 = {
|
|
118
|
-
__proto__: null,
|
|
119
|
-
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
|
120
|
-
const ret = typeof(arg0) === 'function';
|
|
121
|
-
return ret;
|
|
122
|
-
},
|
|
123
|
-
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
124
|
-
const val = arg0;
|
|
125
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
126
|
-
return ret;
|
|
127
|
-
},
|
|
128
|
-
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
|
129
|
-
const ret = typeof(arg0) === 'string';
|
|
130
|
-
return ret;
|
|
131
|
-
},
|
|
132
|
-
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
133
|
-
const ret = arg0 === undefined;
|
|
134
|
-
return ret;
|
|
135
|
-
},
|
|
136
|
-
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
137
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
138
|
-
},
|
|
139
|
-
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
140
|
-
const ret = arg0.call(arg1, arg2);
|
|
141
|
-
return ret;
|
|
142
|
-
}, arguments); },
|
|
143
|
-
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
144
|
-
const ret = arg0.crypto;
|
|
145
|
-
return ret;
|
|
146
|
-
},
|
|
147
|
-
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
148
|
-
arg0.getRandomValues(arg1);
|
|
149
|
-
}, arguments); },
|
|
150
|
-
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
151
|
-
const ret = arg0.length;
|
|
152
|
-
return ret;
|
|
153
|
-
},
|
|
154
|
-
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
155
|
-
const ret = arg0.msCrypto;
|
|
156
|
-
return ret;
|
|
157
|
-
},
|
|
158
|
-
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
|
159
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
160
|
-
return ret;
|
|
161
|
-
},
|
|
162
|
-
__wbg_node_84ea875411254db1: function(arg0) {
|
|
163
|
-
const ret = arg0.node;
|
|
164
|
-
return ret;
|
|
165
|
-
},
|
|
166
|
-
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
167
|
-
const ret = arg0.process;
|
|
168
|
-
return ret;
|
|
169
|
-
},
|
|
170
|
-
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
171
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
172
|
-
},
|
|
173
|
-
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
174
|
-
arg0.randomFillSync(arg1);
|
|
175
|
-
}, arguments); },
|
|
176
|
-
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
177
|
-
const ret = module.require;
|
|
178
|
-
return ret;
|
|
179
|
-
}, arguments); },
|
|
180
|
-
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
|
|
181
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
182
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
183
|
-
},
|
|
184
|
-
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
|
|
185
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
186
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
187
|
-
},
|
|
188
|
-
__wbg_static_accessor_SELF_f207c857566db248: function() {
|
|
189
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
190
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
191
|
-
},
|
|
192
|
-
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
|
|
193
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
194
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
195
|
-
},
|
|
196
|
-
__wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
|
|
197
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
198
|
-
return ret;
|
|
199
|
-
},
|
|
200
|
-
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
201
|
-
const ret = arg0.versions;
|
|
202
|
-
return ret;
|
|
203
|
-
},
|
|
204
|
-
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
205
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
206
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
207
|
-
return ret;
|
|
208
|
-
},
|
|
209
|
-
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
210
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
211
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
212
|
-
return ret;
|
|
213
|
-
},
|
|
214
|
-
__wbindgen_init_externref_table: function() {
|
|
215
|
-
const table = wasm.__wbindgen_externrefs;
|
|
216
|
-
const offset = table.grow(4);
|
|
217
|
-
table.set(0, undefined);
|
|
218
|
-
table.set(offset + 0, undefined);
|
|
219
|
-
table.set(offset + 1, null);
|
|
220
|
-
table.set(offset + 2, true);
|
|
221
|
-
table.set(offset + 3, false);
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
return {
|
|
225
|
-
__proto__: null,
|
|
226
|
-
"./cas_wasm_bg.js": import0,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const RSAKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
231
|
-
? { register: () => {}, unregister: () => {} }
|
|
232
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_rsakeypair_free(ptr >>> 0, 1));
|
|
233
|
-
const RSAWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
234
|
-
? { register: () => {}, unregister: () => {} }
|
|
235
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_rsawrapper_free(ptr >>> 0, 1));
|
|
236
|
-
|
|
237
|
-
function addToExternrefTable0(obj) {
|
|
238
|
-
const idx = wasm.__externref_table_alloc();
|
|
239
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
240
|
-
return idx;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
244
|
-
ptr = ptr >>> 0;
|
|
245
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function getStringFromWasm0(ptr, len) {
|
|
249
|
-
ptr = ptr >>> 0;
|
|
250
|
-
return decodeText(ptr, len);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
let cachedUint8ArrayMemory0 = null;
|
|
254
|
-
function getUint8ArrayMemory0() {
|
|
255
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
256
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
257
|
-
}
|
|
258
|
-
return cachedUint8ArrayMemory0;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function handleError(f, args) {
|
|
262
|
-
try {
|
|
263
|
-
return f.apply(this, args);
|
|
264
|
-
} catch (e) {
|
|
265
|
-
const idx = addToExternrefTable0(e);
|
|
266
|
-
wasm.__wbindgen_exn_store(idx);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function isLikeNone(x) {
|
|
271
|
-
return x === undefined || x === null;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
275
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
276
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
277
|
-
WASM_VECTOR_LEN = arg.length;
|
|
278
|
-
return ptr;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
282
|
-
if (realloc === undefined) {
|
|
283
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
284
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
285
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
286
|
-
WASM_VECTOR_LEN = buf.length;
|
|
287
|
-
return ptr;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
let len = arg.length;
|
|
291
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
292
|
-
|
|
293
|
-
const mem = getUint8ArrayMemory0();
|
|
294
|
-
|
|
295
|
-
let offset = 0;
|
|
296
|
-
|
|
297
|
-
for (; offset < len; offset++) {
|
|
298
|
-
const code = arg.charCodeAt(offset);
|
|
299
|
-
if (code > 0x7F) break;
|
|
300
|
-
mem[ptr + offset] = code;
|
|
301
|
-
}
|
|
302
|
-
if (offset !== len) {
|
|
303
|
-
if (offset !== 0) {
|
|
304
|
-
arg = arg.slice(offset);
|
|
305
|
-
}
|
|
306
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
307
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
308
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
309
|
-
|
|
310
|
-
offset += ret.written;
|
|
311
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
WASM_VECTOR_LEN = offset;
|
|
315
|
-
return ptr;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
319
|
-
cachedTextDecoder.decode();
|
|
320
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
321
|
-
let numBytesDecoded = 0;
|
|
322
|
-
function decodeText(ptr, len) {
|
|
323
|
-
numBytesDecoded += len;
|
|
324
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
325
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
326
|
-
cachedTextDecoder.decode();
|
|
327
|
-
numBytesDecoded = len;
|
|
328
|
-
}
|
|
329
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const cachedTextEncoder = new TextEncoder();
|
|
333
|
-
|
|
334
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
335
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
336
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
337
|
-
view.set(buf);
|
|
338
|
-
return {
|
|
339
|
-
read: arg.length,
|
|
340
|
-
written: buf.length
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
let WASM_VECTOR_LEN = 0;
|
|
346
|
-
|
|
347
|
-
let wasmModule, wasm;
|
|
348
|
-
function __wbg_finalize_init(instance, module) {
|
|
349
|
-
wasm = instance.exports;
|
|
350
|
-
wasmModule = module;
|
|
351
|
-
cachedUint8ArrayMemory0 = null;
|
|
352
|
-
wasm.__wbindgen_start();
|
|
353
|
-
return wasm;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
async function __wbg_load(module, imports) {
|
|
357
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
358
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
359
|
-
try {
|
|
360
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
361
|
-
} catch (e) {
|
|
362
|
-
const validResponse = module.ok && expectedResponseType(module.type);
|
|
363
|
-
|
|
364
|
-
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
365
|
-
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
366
|
-
|
|
367
|
-
} else { throw e; }
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const bytes = await module.arrayBuffer();
|
|
372
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
373
|
-
} else {
|
|
374
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
375
|
-
|
|
376
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
377
|
-
return { instance, module };
|
|
378
|
-
} else {
|
|
379
|
-
return instance;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function expectedResponseType(type) {
|
|
384
|
-
switch (type) {
|
|
385
|
-
case 'basic': case 'cors': case 'default': return true;
|
|
386
|
-
}
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function initSync(module) {
|
|
392
|
-
if (wasm !== undefined) return wasm;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (module !== undefined) {
|
|
396
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
397
|
-
({module} = module)
|
|
398
|
-
} else {
|
|
399
|
-
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
const imports = __wbg_get_imports();
|
|
404
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
405
|
-
module = new WebAssembly.Module(module);
|
|
406
|
-
}
|
|
407
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
408
|
-
return __wbg_finalize_init(instance, module);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
async function __wbg_init(module_or_path) {
|
|
412
|
-
if (wasm !== undefined) return wasm;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (module_or_path !== undefined) {
|
|
416
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
417
|
-
({module_or_path} = module_or_path)
|
|
418
|
-
} else {
|
|
419
|
-
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (module_or_path === undefined) {
|
|
424
|
-
module_or_path = new URL('cas_wasm_bg.wasm', import.meta.url);
|
|
425
|
-
}
|
|
426
|
-
const imports = __wbg_get_imports();
|
|
427
|
-
|
|
428
|
-
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
429
|
-
module_or_path = fetch(module_or_path);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
433
|
-
|
|
434
|
-
return __wbg_finalize_init(instance, module);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export { initSync, __wbg_init as default };
|
|
3
|
+
import * as wasm from "./cas_wasm_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./cas_wasm_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
RSAKeyPair, RSAWrapper
|
|
9
|
+
} from "./cas_wasm_bg.js";
|
package/cas_wasm_bg.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
export class RSAKeyPair {
|
|
2
|
+
static __wrap(ptr) {
|
|
3
|
+
ptr = ptr >>> 0;
|
|
4
|
+
const obj = Object.create(RSAKeyPair.prototype);
|
|
5
|
+
obj.__wbg_ptr = ptr;
|
|
6
|
+
RSAKeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
RSAKeyPairFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_rsakeypair_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
get privateKey() {
|
|
23
|
+
let deferred1_0;
|
|
24
|
+
let deferred1_1;
|
|
25
|
+
try {
|
|
26
|
+
const ret = wasm.rsakeypair_privateKey(this.__wbg_ptr);
|
|
27
|
+
deferred1_0 = ret[0];
|
|
28
|
+
deferred1_1 = ret[1];
|
|
29
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
30
|
+
} finally {
|
|
31
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
get publicKey() {
|
|
38
|
+
let deferred1_0;
|
|
39
|
+
let deferred1_1;
|
|
40
|
+
try {
|
|
41
|
+
const ret = wasm.rsakeypair_publicKey(this.__wbg_ptr);
|
|
42
|
+
deferred1_0 = ret[0];
|
|
43
|
+
deferred1_1 = ret[1];
|
|
44
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
45
|
+
} finally {
|
|
46
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (Symbol.dispose) RSAKeyPair.prototype[Symbol.dispose] = RSAKeyPair.prototype.free;
|
|
51
|
+
|
|
52
|
+
export class RSAWrapper {
|
|
53
|
+
__destroy_into_raw() {
|
|
54
|
+
const ptr = this.__wbg_ptr;
|
|
55
|
+
this.__wbg_ptr = 0;
|
|
56
|
+
RSAWrapperFinalization.unregister(this);
|
|
57
|
+
return ptr;
|
|
58
|
+
}
|
|
59
|
+
free() {
|
|
60
|
+
const ptr = this.__destroy_into_raw();
|
|
61
|
+
wasm.__wbg_rsawrapper_free(ptr, 0);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generates an RSA key pair based of parameter sent in 1024, 2048, and 4096 are supported.
|
|
65
|
+
* @param {number} key_size
|
|
66
|
+
* @returns {RSAKeyPair}
|
|
67
|
+
*/
|
|
68
|
+
generateRsaKeys(key_size) {
|
|
69
|
+
const ret = wasm.rsawrapper_generateRsaKeys(this.__wbg_ptr, key_size);
|
|
70
|
+
return RSAKeyPair.__wrap(ret);
|
|
71
|
+
}
|
|
72
|
+
constructor() {
|
|
73
|
+
const ret = wasm.rsawrapper_new();
|
|
74
|
+
this.__wbg_ptr = ret >>> 0;
|
|
75
|
+
RSAWrapperFinalization.register(this, this.__wbg_ptr, this);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Signs a byte array with an RSA private key for verification.
|
|
80
|
+
* @param {string} private_key
|
|
81
|
+
* @param {Uint8Array} data
|
|
82
|
+
* @returns {Uint8Array}
|
|
83
|
+
*/
|
|
84
|
+
sign(private_key, data) {
|
|
85
|
+
const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
88
|
+
const len1 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.rsawrapper_sign(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
90
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
91
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
92
|
+
return v3;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Verifies signed data by the corresponding private key with an RSA public key.
|
|
96
|
+
* @param {string} public_key
|
|
97
|
+
* @param {Uint8Array} data
|
|
98
|
+
* @param {Uint8Array} signature
|
|
99
|
+
* @returns {boolean}
|
|
100
|
+
*/
|
|
101
|
+
verify(public_key, data, signature) {
|
|
102
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
106
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
107
|
+
const len2 = WASM_VECTOR_LEN;
|
|
108
|
+
const ret = wasm.rsawrapper_verify(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
109
|
+
return ret !== 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (Symbol.dispose) RSAWrapper.prototype[Symbol.dispose] = RSAWrapper.prototype.free;
|
|
113
|
+
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
114
|
+
const ret = typeof(arg0) === 'function';
|
|
115
|
+
return ret;
|
|
116
|
+
}
|
|
117
|
+
export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
118
|
+
const val = arg0;
|
|
119
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
120
|
+
return ret;
|
|
121
|
+
}
|
|
122
|
+
export function __wbg___wbindgen_is_string_7ef6b97b02428fae(arg0) {
|
|
123
|
+
const ret = typeof(arg0) === 'string';
|
|
124
|
+
return ret;
|
|
125
|
+
}
|
|
126
|
+
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
127
|
+
const ret = arg0 === undefined;
|
|
128
|
+
return ret;
|
|
129
|
+
}
|
|
130
|
+
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
131
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
132
|
+
}
|
|
133
|
+
export function __wbg_call_2d781c1f4d5c0ef8() { return handleError(function (arg0, arg1, arg2) {
|
|
134
|
+
const ret = arg0.call(arg1, arg2);
|
|
135
|
+
return ret;
|
|
136
|
+
}, arguments); }
|
|
137
|
+
export function __wbg_crypto_38df2bab126b63dc(arg0) {
|
|
138
|
+
const ret = arg0.crypto;
|
|
139
|
+
return ret;
|
|
140
|
+
}
|
|
141
|
+
export function __wbg_getRandomValues_c44a50d8cfdaebeb() { return handleError(function (arg0, arg1) {
|
|
142
|
+
arg0.getRandomValues(arg1);
|
|
143
|
+
}, arguments); }
|
|
144
|
+
export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
145
|
+
const ret = arg0.length;
|
|
146
|
+
return ret;
|
|
147
|
+
}
|
|
148
|
+
export function __wbg_msCrypto_bd5a034af96bcba6(arg0) {
|
|
149
|
+
const ret = arg0.msCrypto;
|
|
150
|
+
return ret;
|
|
151
|
+
}
|
|
152
|
+
export function __wbg_new_with_length_825018a1616e9e55(arg0) {
|
|
153
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
154
|
+
return ret;
|
|
155
|
+
}
|
|
156
|
+
export function __wbg_node_84ea875411254db1(arg0) {
|
|
157
|
+
const ret = arg0.node;
|
|
158
|
+
return ret;
|
|
159
|
+
}
|
|
160
|
+
export function __wbg_process_44c7a14e11e9f69e(arg0) {
|
|
161
|
+
const ret = arg0.process;
|
|
162
|
+
return ret;
|
|
163
|
+
}
|
|
164
|
+
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
165
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
166
|
+
}
|
|
167
|
+
export function __wbg_randomFillSync_6c25eac9869eb53c() { return handleError(function (arg0, arg1) {
|
|
168
|
+
arg0.randomFillSync(arg1);
|
|
169
|
+
}, arguments); }
|
|
170
|
+
export function __wbg_require_b4edbdcf3e2a1ef0() { return handleError(function () {
|
|
171
|
+
const ret = module.require;
|
|
172
|
+
return ret;
|
|
173
|
+
}, arguments); }
|
|
174
|
+
export function __wbg_static_accessor_GLOBAL_8adb955bd33fac2f() {
|
|
175
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
176
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
177
|
+
}
|
|
178
|
+
export function __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913() {
|
|
179
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
180
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
181
|
+
}
|
|
182
|
+
export function __wbg_static_accessor_SELF_f207c857566db248() {
|
|
183
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
184
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
185
|
+
}
|
|
186
|
+
export function __wbg_static_accessor_WINDOW_bb9f1ba69d61b386() {
|
|
187
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
188
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
189
|
+
}
|
|
190
|
+
export function __wbg_subarray_a068d24e39478a8a(arg0, arg1, arg2) {
|
|
191
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
192
|
+
return ret;
|
|
193
|
+
}
|
|
194
|
+
export function __wbg_versions_276b2795b1c6a219(arg0) {
|
|
195
|
+
const ret = arg0.versions;
|
|
196
|
+
return ret;
|
|
197
|
+
}
|
|
198
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
199
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
200
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
201
|
+
return ret;
|
|
202
|
+
}
|
|
203
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
204
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
205
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
export function __wbindgen_init_externref_table() {
|
|
209
|
+
const table = wasm.__wbindgen_externrefs;
|
|
210
|
+
const offset = table.grow(4);
|
|
211
|
+
table.set(0, undefined);
|
|
212
|
+
table.set(offset + 0, undefined);
|
|
213
|
+
table.set(offset + 1, null);
|
|
214
|
+
table.set(offset + 2, true);
|
|
215
|
+
table.set(offset + 3, false);
|
|
216
|
+
}
|
|
217
|
+
const RSAKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
218
|
+
? { register: () => {}, unregister: () => {} }
|
|
219
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rsakeypair_free(ptr >>> 0, 1));
|
|
220
|
+
const RSAWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
221
|
+
? { register: () => {}, unregister: () => {} }
|
|
222
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rsawrapper_free(ptr >>> 0, 1));
|
|
223
|
+
|
|
224
|
+
function addToExternrefTable0(obj) {
|
|
225
|
+
const idx = wasm.__externref_table_alloc();
|
|
226
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
227
|
+
return idx;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
231
|
+
ptr = ptr >>> 0;
|
|
232
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function getStringFromWasm0(ptr, len) {
|
|
236
|
+
ptr = ptr >>> 0;
|
|
237
|
+
return decodeText(ptr, len);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
let cachedUint8ArrayMemory0 = null;
|
|
241
|
+
function getUint8ArrayMemory0() {
|
|
242
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
243
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
244
|
+
}
|
|
245
|
+
return cachedUint8ArrayMemory0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function handleError(f, args) {
|
|
249
|
+
try {
|
|
250
|
+
return f.apply(this, args);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
const idx = addToExternrefTable0(e);
|
|
253
|
+
wasm.__wbindgen_exn_store(idx);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function isLikeNone(x) {
|
|
258
|
+
return x === undefined || x === null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
262
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
263
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
264
|
+
WASM_VECTOR_LEN = arg.length;
|
|
265
|
+
return ptr;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
269
|
+
if (realloc === undefined) {
|
|
270
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
271
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
272
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
273
|
+
WASM_VECTOR_LEN = buf.length;
|
|
274
|
+
return ptr;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let len = arg.length;
|
|
278
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
279
|
+
|
|
280
|
+
const mem = getUint8ArrayMemory0();
|
|
281
|
+
|
|
282
|
+
let offset = 0;
|
|
283
|
+
|
|
284
|
+
for (; offset < len; offset++) {
|
|
285
|
+
const code = arg.charCodeAt(offset);
|
|
286
|
+
if (code > 0x7F) break;
|
|
287
|
+
mem[ptr + offset] = code;
|
|
288
|
+
}
|
|
289
|
+
if (offset !== len) {
|
|
290
|
+
if (offset !== 0) {
|
|
291
|
+
arg = arg.slice(offset);
|
|
292
|
+
}
|
|
293
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
294
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
295
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
296
|
+
|
|
297
|
+
offset += ret.written;
|
|
298
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
WASM_VECTOR_LEN = offset;
|
|
302
|
+
return ptr;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
306
|
+
cachedTextDecoder.decode();
|
|
307
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
308
|
+
let numBytesDecoded = 0;
|
|
309
|
+
function decodeText(ptr, len) {
|
|
310
|
+
numBytesDecoded += len;
|
|
311
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
312
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
313
|
+
cachedTextDecoder.decode();
|
|
314
|
+
numBytesDecoded = len;
|
|
315
|
+
}
|
|
316
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const cachedTextEncoder = new TextEncoder();
|
|
320
|
+
|
|
321
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
322
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
323
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
324
|
+
view.set(buf);
|
|
325
|
+
return {
|
|
326
|
+
read: arg.length,
|
|
327
|
+
written: buf.length
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let WASM_VECTOR_LEN = 0;
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
let wasm;
|
|
336
|
+
export function __wbg_set_wasm(val) {
|
|
337
|
+
wasm = val;
|
|
338
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cas-wasm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"
|
|
4
|
+
"description": "A function wrapper layer for RustCrypto and Dalek-Cryptography.",
|
|
5
|
+
"version": "0.1.1",
|
|
6
|
+
"license": "Apache-2.0",
|
|
5
7
|
"files": [
|
|
6
8
|
"cas_wasm_bg.wasm",
|
|
7
9
|
"cas_wasm.js",
|
|
10
|
+
"cas_wasm_bg.js",
|
|
8
11
|
"cas_wasm.d.ts"
|
|
9
12
|
],
|
|
10
13
|
"main": "cas_wasm.js",
|
|
11
14
|
"types": "cas_wasm.d.ts",
|
|
12
15
|
"sideEffects": [
|
|
16
|
+
"./cas_wasm.js",
|
|
13
17
|
"./snippets/*"
|
|
14
18
|
]
|
|
15
19
|
}
|