@alienplatform/permissions 3.3.27

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.
@@ -0,0 +1,37 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function operation_permissions_json(request: string): string;
5
+
6
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
7
+
8
+ export interface InitOutput {
9
+ readonly memory: WebAssembly.Memory;
10
+ readonly operation_permissions_json: (a: number, b: number, c: number) => void;
11
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
12
+ readonly __wbindgen_export: (a: number, b: number) => number;
13
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
14
+ readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
15
+ }
16
+
17
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
18
+
19
+ /**
20
+ * Instantiates the given `module`, which can either be bytes or
21
+ * a precompiled `WebAssembly.Module`.
22
+ *
23
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
24
+ *
25
+ * @returns {InitOutput}
26
+ */
27
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
28
+
29
+ /**
30
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
31
+ * for everything else, calls `WebAssembly.instantiate` directly.
32
+ *
33
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
34
+ *
35
+ * @returns {Promise<InitOutput>}
36
+ */
37
+ export default function __wbg_init (module_or_path: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,210 @@
1
+ /* @ts-self-types="./compiler.d.ts" */
2
+
3
+ /**
4
+ * @param {string} request
5
+ * @returns {string}
6
+ */
7
+ export function operation_permissions_json(request) {
8
+ let deferred2_0;
9
+ let deferred2_1;
10
+ try {
11
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
12
+ const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
13
+ const len0 = WASM_VECTOR_LEN;
14
+ wasm.operation_permissions_json(retptr, ptr0, len0);
15
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
16
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
17
+ deferred2_0 = r0;
18
+ deferred2_1 = r1;
19
+ return getStringFromWasm0(r0, r1);
20
+ } finally {
21
+ wasm.__wbindgen_add_to_stack_pointer(16);
22
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
23
+ }
24
+ }
25
+ function __wbg_get_imports() {
26
+ const import0 = {
27
+ __proto__: null,
28
+ };
29
+ return {
30
+ __proto__: null,
31
+ "./compiler_bg.js": import0,
32
+ };
33
+ }
34
+
35
+ let cachedDataViewMemory0 = null;
36
+ function getDataViewMemory0() {
37
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
38
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
39
+ }
40
+ return cachedDataViewMemory0;
41
+ }
42
+
43
+ function getStringFromWasm0(ptr, len) {
44
+ return decodeText(ptr >>> 0, len);
45
+ }
46
+
47
+ let cachedUint8ArrayMemory0 = null;
48
+ function getUint8ArrayMemory0() {
49
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
50
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
51
+ }
52
+ return cachedUint8ArrayMemory0;
53
+ }
54
+
55
+ function passStringToWasm0(arg, malloc, realloc) {
56
+ if (realloc === undefined) {
57
+ const buf = cachedTextEncoder.encode(arg);
58
+ const ptr = malloc(buf.length, 1) >>> 0;
59
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
60
+ WASM_VECTOR_LEN = buf.length;
61
+ return ptr;
62
+ }
63
+
64
+ let len = arg.length;
65
+ let ptr = malloc(len, 1) >>> 0;
66
+
67
+ const mem = getUint8ArrayMemory0();
68
+
69
+ let offset = 0;
70
+
71
+ for (; offset < len; offset++) {
72
+ const code = arg.charCodeAt(offset);
73
+ if (code > 0x7F) break;
74
+ mem[ptr + offset] = code;
75
+ }
76
+ if (offset !== len) {
77
+ if (offset !== 0) {
78
+ arg = arg.slice(offset);
79
+ }
80
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
81
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
82
+ const ret = cachedTextEncoder.encodeInto(arg, view);
83
+
84
+ offset += ret.written;
85
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
86
+ }
87
+
88
+ WASM_VECTOR_LEN = offset;
89
+ return ptr;
90
+ }
91
+
92
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
93
+ cachedTextDecoder.decode();
94
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
95
+ let numBytesDecoded = 0;
96
+ function decodeText(ptr, len) {
97
+ numBytesDecoded += len;
98
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
99
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
100
+ cachedTextDecoder.decode();
101
+ numBytesDecoded = len;
102
+ }
103
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
104
+ }
105
+
106
+ const cachedTextEncoder = new TextEncoder();
107
+
108
+ if (!('encodeInto' in cachedTextEncoder)) {
109
+ cachedTextEncoder.encodeInto = function (arg, view) {
110
+ const buf = cachedTextEncoder.encode(arg);
111
+ view.set(buf);
112
+ return {
113
+ read: arg.length,
114
+ written: buf.length
115
+ };
116
+ };
117
+ }
118
+
119
+ let WASM_VECTOR_LEN = 0;
120
+
121
+ let wasmModule, wasmInstance, wasm;
122
+ function __wbg_finalize_init(instance, module) {
123
+ wasmInstance = instance;
124
+ wasm = instance.exports;
125
+ wasmModule = module;
126
+ cachedDataViewMemory0 = null;
127
+ cachedUint8ArrayMemory0 = null;
128
+ return wasm;
129
+ }
130
+
131
+ async function __wbg_load(module, imports) {
132
+ if (typeof Response === 'function' && module instanceof Response) {
133
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
134
+ try {
135
+ return await WebAssembly.instantiateStreaming(module, imports);
136
+ } catch (e) {
137
+ const validResponse = module.ok && expectedResponseType(module.type);
138
+
139
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
140
+ 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);
141
+
142
+ } else { throw e; }
143
+ }
144
+ }
145
+
146
+ const bytes = await module.arrayBuffer();
147
+ return await WebAssembly.instantiate(bytes, imports);
148
+ } else {
149
+ const instance = await WebAssembly.instantiate(module, imports);
150
+
151
+ if (instance instanceof WebAssembly.Instance) {
152
+ return { instance, module };
153
+ } else {
154
+ return instance;
155
+ }
156
+ }
157
+
158
+ function expectedResponseType(type) {
159
+ switch (type) {
160
+ case 'basic': case 'cors': case 'default': return true;
161
+ }
162
+ return false;
163
+ }
164
+ }
165
+
166
+ function initSync(module) {
167
+ if (wasm !== undefined) return wasm;
168
+
169
+
170
+ if (module !== undefined) {
171
+ if (Object.getPrototypeOf(module) === Object.prototype) {
172
+ ({module} = module)
173
+ } else {
174
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
175
+ }
176
+ }
177
+
178
+ const imports = __wbg_get_imports();
179
+ if (!(module instanceof WebAssembly.Module)) {
180
+ module = new WebAssembly.Module(module);
181
+ }
182
+ const instance = new WebAssembly.Instance(module, imports);
183
+ return __wbg_finalize_init(instance, module);
184
+ }
185
+
186
+ async function __wbg_init(module_or_path) {
187
+ if (wasm !== undefined) return wasm;
188
+
189
+
190
+ if (module_or_path !== undefined) {
191
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
192
+ ({module_or_path} = module_or_path)
193
+ } else {
194
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
195
+ }
196
+ }
197
+
198
+
199
+ const imports = __wbg_get_imports();
200
+
201
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
202
+ module_or_path = fetch(module_or_path);
203
+ }
204
+
205
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
206
+
207
+ return __wbg_finalize_init(instance, module);
208
+ }
209
+
210
+ export { initSync, __wbg_init as default };
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Execute a JSON request with the same Rust implementation used by the CLI. */
2
+ export declare function executeOperationPermissions(request: string): string
package/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { bytes } from "./generated/bytes.js"
2
+ import { initSync, operation_permissions_json } from "./generated/compiler.js"
3
+
4
+ let initialized = false
5
+
6
+ /** Execute a JSON request with the same Rust implementation used by the CLI. */
7
+ export function executeOperationPermissions(request) {
8
+ if (!initialized) {
9
+ initSync({ module: Uint8Array.from(atob(bytes), character => character.charCodeAt(0)) })
10
+ initialized = true
11
+ }
12
+ return operation_permissions_json(request)
13
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@alienplatform/permissions",
3
+ "version": "3.3.27",
4
+ "type": "module",
5
+ "description": "Offline operation permission compilation using alien-permissions",
6
+ "license": "FSL-1.1-Apache-2.0",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "import": "./index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "index.d.ts",
16
+ "generated"
17
+ ],
18
+ "scripts": {
19
+ "generate": "node scripts/generate.mjs",
20
+ "test": "node --test test.mjs"
21
+ }
22
+ }