@rankcli/cli 0.0.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/README.md +319 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1901 -0
- package/dist/index.mjs +1913 -0
- package/dist/wasm-engine.d.mts +62 -0
- package/dist/wasm-engine.d.ts +62 -0
- package/dist/wasm-engine.js +198 -0
- package/dist/wasm-engine.mjs +161 -0
- package/package.json +75 -0
- package/wasm/rankcli_audit_engine.d.ts +45 -0
- package/wasm/rankcli_audit_engine.js +274 -0
- package/wasm/rankcli_audit_engine_bg.wasm +0 -0
- package/wasm/rankcli_audit_engine_bg.wasm.d.ts +17 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/* @ts-self-types="./rankcli_audit_engine.d.ts" */
|
|
2
|
+
|
|
3
|
+
//#region exports
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get checks limit for current tier
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
function get_checks_limit() {
|
|
10
|
+
const ret = wasm.get_checks_limit();
|
|
11
|
+
return ret >>> 0;
|
|
12
|
+
}
|
|
13
|
+
exports.get_checks_limit = get_checks_limit;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get the decrypted JavaScript code for execution.
|
|
17
|
+
* This is called by the Node.js wrapper which runs it in a VM sandbox.
|
|
18
|
+
* The code is ONLY available after successful init_engine() with valid license.
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
function get_decrypted_code() {
|
|
22
|
+
let deferred2_0;
|
|
23
|
+
let deferred2_1;
|
|
24
|
+
try {
|
|
25
|
+
const ret = wasm.get_decrypted_code();
|
|
26
|
+
var ptr1 = ret[0];
|
|
27
|
+
var len1 = ret[1];
|
|
28
|
+
if (ret[3]) {
|
|
29
|
+
ptr1 = 0; len1 = 0;
|
|
30
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
31
|
+
}
|
|
32
|
+
deferred2_0 = ptr1;
|
|
33
|
+
deferred2_1 = len1;
|
|
34
|
+
return getStringFromWasm0(ptr1, len1);
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.get_decrypted_code = get_decrypted_code;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get size of encrypted payload (for debugging)
|
|
43
|
+
* @returns {number}
|
|
44
|
+
*/
|
|
45
|
+
function get_encrypted_size() {
|
|
46
|
+
const ret = wasm.get_encrypted_size();
|
|
47
|
+
return ret >>> 0;
|
|
48
|
+
}
|
|
49
|
+
exports.get_encrypted_size = get_encrypted_size;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get current tier
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
function get_tier() {
|
|
56
|
+
let deferred1_0;
|
|
57
|
+
let deferred1_1;
|
|
58
|
+
try {
|
|
59
|
+
const ret = wasm.get_tier();
|
|
60
|
+
deferred1_0 = ret[0];
|
|
61
|
+
deferred1_1 = ret[1];
|
|
62
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
63
|
+
} finally {
|
|
64
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.get_tier = get_tier;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initialize the engine with a license key.
|
|
71
|
+
* Decrypts the embedded checks and stores them for execution.
|
|
72
|
+
* @param {string} license_key
|
|
73
|
+
* @returns {boolean}
|
|
74
|
+
*/
|
|
75
|
+
function init_engine(license_key) {
|
|
76
|
+
const ptr0 = passStringToWasm0(license_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
77
|
+
const len0 = WASM_VECTOR_LEN;
|
|
78
|
+
const ret = wasm.init_engine(ptr0, len0);
|
|
79
|
+
if (ret[2]) {
|
|
80
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
81
|
+
}
|
|
82
|
+
return ret[0] !== 0;
|
|
83
|
+
}
|
|
84
|
+
exports.init_engine = init_engine;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check if engine is initialized
|
|
88
|
+
* @returns {boolean}
|
|
89
|
+
*/
|
|
90
|
+
function is_initialized() {
|
|
91
|
+
const ret = wasm.is_initialized();
|
|
92
|
+
return ret !== 0;
|
|
93
|
+
}
|
|
94
|
+
exports.is_initialized = is_initialized;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Validate a license key and return the tier
|
|
98
|
+
* @param {string} license_key
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
function validate_license(license_key) {
|
|
102
|
+
let deferred2_0;
|
|
103
|
+
let deferred2_1;
|
|
104
|
+
try {
|
|
105
|
+
const ptr0 = passStringToWasm0(license_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ret = wasm.validate_license(ptr0, len0);
|
|
108
|
+
deferred2_0 = ret[0];
|
|
109
|
+
deferred2_1 = ret[1];
|
|
110
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
111
|
+
} finally {
|
|
112
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.validate_license = validate_license;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get version info
|
|
119
|
+
* @returns {string}
|
|
120
|
+
*/
|
|
121
|
+
function version() {
|
|
122
|
+
let deferred1_0;
|
|
123
|
+
let deferred1_1;
|
|
124
|
+
try {
|
|
125
|
+
const ret = wasm.version();
|
|
126
|
+
deferred1_0 = ret[0];
|
|
127
|
+
deferred1_1 = ret[1];
|
|
128
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
129
|
+
} finally {
|
|
130
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.version = version;
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
|
|
137
|
+
//#region wasm imports
|
|
138
|
+
|
|
139
|
+
function __wbg_get_imports() {
|
|
140
|
+
const import0 = {
|
|
141
|
+
__proto__: null,
|
|
142
|
+
__wbg_Error_8c4e43fe74559d73: function() { return logError(function (arg0, arg1) {
|
|
143
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
144
|
+
return ret;
|
|
145
|
+
}, arguments); },
|
|
146
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
147
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
148
|
+
},
|
|
149
|
+
__wbindgen_init_externref_table: function() {
|
|
150
|
+
const table = wasm.__wbindgen_externrefs;
|
|
151
|
+
const offset = table.grow(4);
|
|
152
|
+
table.set(0, undefined);
|
|
153
|
+
table.set(offset + 0, undefined);
|
|
154
|
+
table.set(offset + 1, null);
|
|
155
|
+
table.set(offset + 2, true);
|
|
156
|
+
table.set(offset + 3, false);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
__proto__: null,
|
|
161
|
+
"./rankcli_audit_engine_bg.js": import0,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
|
|
168
|
+
//#region intrinsics
|
|
169
|
+
function getStringFromWasm0(ptr, len) {
|
|
170
|
+
ptr = ptr >>> 0;
|
|
171
|
+
return decodeText(ptr, len);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let cachedUint8ArrayMemory0 = null;
|
|
175
|
+
function getUint8ArrayMemory0() {
|
|
176
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
177
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
178
|
+
}
|
|
179
|
+
return cachedUint8ArrayMemory0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function logError(f, args) {
|
|
183
|
+
try {
|
|
184
|
+
return f.apply(this, args);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
let error = (function () {
|
|
187
|
+
try {
|
|
188
|
+
return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
|
|
189
|
+
} catch(_) {
|
|
190
|
+
return "<failed to stringify thrown value>";
|
|
191
|
+
}
|
|
192
|
+
}());
|
|
193
|
+
console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
|
|
194
|
+
throw e;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
199
|
+
if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
|
|
200
|
+
if (realloc === undefined) {
|
|
201
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
202
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
203
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
204
|
+
WASM_VECTOR_LEN = buf.length;
|
|
205
|
+
return ptr;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let len = arg.length;
|
|
209
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
210
|
+
|
|
211
|
+
const mem = getUint8ArrayMemory0();
|
|
212
|
+
|
|
213
|
+
let offset = 0;
|
|
214
|
+
|
|
215
|
+
for (; offset < len; offset++) {
|
|
216
|
+
const code = arg.charCodeAt(offset);
|
|
217
|
+
if (code > 0x7F) break;
|
|
218
|
+
mem[ptr + offset] = code;
|
|
219
|
+
}
|
|
220
|
+
if (offset !== len) {
|
|
221
|
+
if (offset !== 0) {
|
|
222
|
+
arg = arg.slice(offset);
|
|
223
|
+
}
|
|
224
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
225
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
226
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
227
|
+
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
|
228
|
+
offset += ret.written;
|
|
229
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
WASM_VECTOR_LEN = offset;
|
|
233
|
+
return ptr;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function takeFromExternrefTable0(idx) {
|
|
237
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
238
|
+
wasm.__externref_table_dealloc(idx);
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
243
|
+
cachedTextDecoder.decode();
|
|
244
|
+
function decodeText(ptr, len) {
|
|
245
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const cachedTextEncoder = new TextEncoder();
|
|
249
|
+
|
|
250
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
251
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
252
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
253
|
+
view.set(buf);
|
|
254
|
+
return {
|
|
255
|
+
read: arg.length,
|
|
256
|
+
written: buf.length
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let WASM_VECTOR_LEN = 0;
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
|
|
266
|
+
//#region wasm loading
|
|
267
|
+
const wasmPath = `${__dirname}/rankcli_audit_engine_bg.wasm`;
|
|
268
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
269
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
270
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
271
|
+
wasm.__wbindgen_start();
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
exports.__wasm = wasm;
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const get_checks_limit: () => number;
|
|
5
|
+
export const get_decrypted_code: () => [number, number, number, number];
|
|
6
|
+
export const get_encrypted_size: () => number;
|
|
7
|
+
export const get_tier: () => [number, number];
|
|
8
|
+
export const init_engine: (a: number, b: number) => [number, number, number];
|
|
9
|
+
export const is_initialized: () => number;
|
|
10
|
+
export const validate_license: (a: number, b: number) => [number, number];
|
|
11
|
+
export const version: () => [number, number];
|
|
12
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
14
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
+
export const __wbindgen_start: () => void;
|