@ai-ecoverse/jerk-oauth 0.0.0-stage → 0.8.0

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 ADDED
@@ -0,0 +1,191 @@
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 the Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and
59
+ improving the Work, but excluding communication that is conspicuously
60
+ marked or otherwise designated in writing by the copyright owner as
61
+ "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 ai-ecoverse
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # @ai-ecoverse/jerk-oauth
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pure OAuth helpers (PKCE, relay state, capture, exchange, refresh, scopes and backoff) compiled from jerk-oauth to WebAssembly. Used by bios (route (b) sign-ins) and the vault (grant refresh). See [slicc-jerk](https://github.com/ai-ecoverse/slicc-jerk) for details.
@@ -0,0 +1,55 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function beginSignIn(config_json: string, scope: string, now_secs: number, random32: Uint8Array, random16: Uint8Array): any;
5
+
6
+ export function completeSignIn(config_json: string, pending_json: string, captured_url: string): any;
7
+
8
+ export function parseConfig(input: string): any;
9
+
10
+ export function parseTokenResponse(config_json: string, body: string, now_secs: number): any;
11
+
12
+ export function refreshRequest(config_json: string, refresh_token: string): any;
13
+
14
+ export function scopesSatisfied(granted: string, requested: string): boolean;
15
+
16
+ export function shouldBackoff(last_failure_secs: number, now_secs: number): boolean;
17
+
18
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
19
+
20
+ export interface InitOutput {
21
+ readonly memory: WebAssembly.Memory;
22
+ readonly beginSignIn: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
23
+ readonly completeSignIn: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
24
+ readonly parseConfig: (a: number, b: number) => number;
25
+ readonly parseTokenResponse: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
26
+ readonly refreshRequest: (a: number, b: number, c: number, d: number, e: number) => void;
27
+ readonly scopesSatisfied: (a: number, b: number, c: number, d: number) => number;
28
+ readonly shouldBackoff: (a: number, b: number) => number;
29
+ readonly __wbindgen_export: (a: number) => void;
30
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
31
+ readonly __wbindgen_export2: (a: number, b: number) => number;
32
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
33
+ }
34
+
35
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
36
+
37
+ /**
38
+ * Instantiates the given `module`, which can either be bytes or
39
+ * a precompiled `WebAssembly.Module`.
40
+ *
41
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
42
+ *
43
+ * @returns {InitOutput}
44
+ */
45
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
46
+
47
+ /**
48
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
49
+ * for everything else, calls `WebAssembly.instantiate` directly.
50
+ *
51
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
52
+ *
53
+ * @returns {Promise<InitOutput>}
54
+ */
55
+ export default function __wbg_init (module_or_path: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,404 @@
1
+ /* @ts-self-types="./jerk_oauth_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {string} config_json
5
+ * @param {string} scope
6
+ * @param {number} now_secs
7
+ * @param {Uint8Array} random32
8
+ * @param {Uint8Array} random16
9
+ * @returns {any}
10
+ */
11
+ export function beginSignIn(config_json, scope, now_secs, random32, random16) {
12
+ try {
13
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
14
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
15
+ const len0 = WASM_VECTOR_LEN;
16
+ const ptr1 = passStringToWasm0(scope, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
17
+ const len1 = WASM_VECTOR_LEN;
18
+ const ptr2 = passArray8ToWasm0(random32, wasm.__wbindgen_export2);
19
+ const len2 = WASM_VECTOR_LEN;
20
+ const ptr3 = passArray8ToWasm0(random16, wasm.__wbindgen_export2);
21
+ const len3 = WASM_VECTOR_LEN;
22
+ wasm.beginSignIn(retptr, ptr0, len0, ptr1, len1, now_secs, ptr2, len2, ptr3, len3);
23
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
24
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
25
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
26
+ if (r2) {
27
+ throw takeObject(r1);
28
+ }
29
+ return takeObject(r0);
30
+ } finally {
31
+ wasm.__wbindgen_add_to_stack_pointer(16);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @param {string} config_json
37
+ * @param {string} pending_json
38
+ * @param {string} captured_url
39
+ * @returns {any}
40
+ */
41
+ export function completeSignIn(config_json, pending_json, captured_url) {
42
+ try {
43
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
44
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
45
+ const len0 = WASM_VECTOR_LEN;
46
+ const ptr1 = passStringToWasm0(pending_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
47
+ const len1 = WASM_VECTOR_LEN;
48
+ const ptr2 = passStringToWasm0(captured_url, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
49
+ const len2 = WASM_VECTOR_LEN;
50
+ wasm.completeSignIn(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
51
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
52
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
53
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
54
+ if (r2) {
55
+ throw takeObject(r1);
56
+ }
57
+ return takeObject(r0);
58
+ } finally {
59
+ wasm.__wbindgen_add_to_stack_pointer(16);
60
+ }
61
+ }
62
+
63
+ /**
64
+ * @param {string} input
65
+ * @returns {any}
66
+ */
67
+ export function parseConfig(input) {
68
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
69
+ const len0 = WASM_VECTOR_LEN;
70
+ const ret = wasm.parseConfig(ptr0, len0);
71
+ return takeObject(ret);
72
+ }
73
+
74
+ /**
75
+ * @param {string} config_json
76
+ * @param {string} body
77
+ * @param {number} now_secs
78
+ * @returns {any}
79
+ */
80
+ export function parseTokenResponse(config_json, body, now_secs) {
81
+ try {
82
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
83
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
84
+ const len0 = WASM_VECTOR_LEN;
85
+ const ptr1 = passStringToWasm0(body, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
86
+ const len1 = WASM_VECTOR_LEN;
87
+ wasm.parseTokenResponse(retptr, ptr0, len0, ptr1, len1, now_secs);
88
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
89
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
90
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
91
+ if (r2) {
92
+ throw takeObject(r1);
93
+ }
94
+ return takeObject(r0);
95
+ } finally {
96
+ wasm.__wbindgen_add_to_stack_pointer(16);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @param {string} config_json
102
+ * @param {string} refresh_token
103
+ * @returns {any}
104
+ */
105
+ export function refreshRequest(config_json, refresh_token) {
106
+ try {
107
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
108
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
109
+ const len0 = WASM_VECTOR_LEN;
110
+ const ptr1 = passStringToWasm0(refresh_token, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
111
+ const len1 = WASM_VECTOR_LEN;
112
+ wasm.refreshRequest(retptr, ptr0, len0, ptr1, len1);
113
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
114
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
115
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
116
+ if (r2) {
117
+ throw takeObject(r1);
118
+ }
119
+ return takeObject(r0);
120
+ } finally {
121
+ wasm.__wbindgen_add_to_stack_pointer(16);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * @param {string} granted
127
+ * @param {string} requested
128
+ * @returns {boolean}
129
+ */
130
+ export function scopesSatisfied(granted, requested) {
131
+ const ptr0 = passStringToWasm0(granted, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ptr1 = passStringToWasm0(requested, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
134
+ const len1 = WASM_VECTOR_LEN;
135
+ const ret = wasm.scopesSatisfied(ptr0, len0, ptr1, len1);
136
+ return ret !== 0;
137
+ }
138
+
139
+ /**
140
+ * @param {number} last_failure_secs
141
+ * @param {number} now_secs
142
+ * @returns {boolean}
143
+ */
144
+ export function shouldBackoff(last_failure_secs, now_secs) {
145
+ const ret = wasm.shouldBackoff(last_failure_secs, now_secs);
146
+ return ret !== 0;
147
+ }
148
+ function __wbg_get_imports() {
149
+ const import0 = {
150
+ __proto__: null,
151
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
152
+ throw new Error(getStringFromWasm0(arg0, arg1));
153
+ },
154
+ __wbg_new_617a8cdb8bb1130e: function() {
155
+ const ret = new Object();
156
+ return addHeapObject(ret);
157
+ },
158
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
159
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
160
+ return ret;
161
+ }, arguments); },
162
+ __wbindgen_generic_0000000000000001: function(arg0) {
163
+ // Cast intrinsic for `F64 -> Externref`.
164
+ const ret = arg0;
165
+ return addHeapObject(ret);
166
+ },
167
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
168
+ // Cast intrinsic for `Ref(String) -> Externref`.
169
+ const ret = getStringFromWasm0(arg0, arg1);
170
+ return addHeapObject(ret);
171
+ },
172
+ __wbindgen_object_drop_ref: function(arg0) {
173
+ takeObject(arg0);
174
+ },
175
+ };
176
+ return {
177
+ __proto__: null,
178
+ "./jerk_oauth_wasm_bg.js": import0,
179
+ };
180
+ }
181
+
182
+ function addHeapObject(obj) {
183
+ if (heap_next === heap.length) heap.push(heap.length + 1);
184
+ const idx = heap_next;
185
+ heap_next = heap[idx];
186
+
187
+ heap[idx] = obj;
188
+ return idx;
189
+ }
190
+
191
+ function dropObject(idx) {
192
+ if (idx < 1028) return;
193
+ heap[idx] = heap_next;
194
+ heap_next = idx;
195
+ }
196
+
197
+ let cachedDataViewMemory0 = null;
198
+ function getDataViewMemory0() {
199
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
200
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
201
+ }
202
+ return cachedDataViewMemory0;
203
+ }
204
+
205
+ function getStringFromWasm0(ptr, len) {
206
+ return decodeText(ptr >>> 0, len);
207
+ }
208
+
209
+ let cachedUint8ArrayMemory0 = null;
210
+ function getUint8ArrayMemory0() {
211
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
212
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
213
+ }
214
+ return cachedUint8ArrayMemory0;
215
+ }
216
+
217
+ function getObject(idx) { return heap[idx]; }
218
+
219
+ function handleError(f, args) {
220
+ try {
221
+ return f.apply(this, args);
222
+ } catch (e) {
223
+ wasm.__wbindgen_export(addHeapObject(e));
224
+ }
225
+ }
226
+
227
+ let heap = new Array(1024).fill(undefined);
228
+ heap.push(undefined, null, true, false);
229
+
230
+ let heap_next = heap.length;
231
+
232
+ function passArray8ToWasm0(arg, malloc) {
233
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
234
+ getUint8ArrayMemory0().set(arg, ptr / 1);
235
+ WASM_VECTOR_LEN = arg.length;
236
+ return ptr;
237
+ }
238
+
239
+ function passStringToWasm0(arg, malloc, realloc) {
240
+ if (realloc === undefined) {
241
+ const buf = cachedTextEncoder.encode(arg);
242
+ const ptr = malloc(buf.length, 1) >>> 0;
243
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
244
+ WASM_VECTOR_LEN = buf.length;
245
+ return ptr;
246
+ }
247
+
248
+ let len = arg.length;
249
+ let ptr = malloc(len, 1) >>> 0;
250
+
251
+ const mem = getUint8ArrayMemory0();
252
+
253
+ let offset = 0;
254
+
255
+ for (; offset < len; offset++) {
256
+ const code = arg.charCodeAt(offset);
257
+ if (code > 0x7F) break;
258
+ mem[ptr + offset] = code;
259
+ }
260
+ if (offset !== len) {
261
+ if (offset !== 0) {
262
+ arg = arg.slice(offset);
263
+ }
264
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
265
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
266
+ const ret = cachedTextEncoder.encodeInto(arg, view);
267
+
268
+ offset += ret.written;
269
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
270
+ }
271
+
272
+ WASM_VECTOR_LEN = offset;
273
+ return ptr;
274
+ }
275
+
276
+ function takeObject(idx) {
277
+ const ret = getObject(idx);
278
+ dropObject(idx);
279
+ return ret;
280
+ }
281
+
282
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
283
+ cachedTextDecoder.decode();
284
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
285
+ let numBytesDecoded = 0;
286
+ function decodeText(ptr, len) {
287
+ numBytesDecoded += len;
288
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
289
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
290
+ cachedTextDecoder.decode();
291
+ numBytesDecoded = len;
292
+ }
293
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
294
+ }
295
+
296
+ const cachedTextEncoder = new TextEncoder();
297
+
298
+ if (!('encodeInto' in cachedTextEncoder)) {
299
+ cachedTextEncoder.encodeInto = function (arg, view) {
300
+ const buf = cachedTextEncoder.encode(arg);
301
+ view.set(buf);
302
+ return {
303
+ read: arg.length,
304
+ written: buf.length
305
+ };
306
+ };
307
+ }
308
+
309
+ let WASM_VECTOR_LEN = 0;
310
+
311
+ let wasmModule, wasmInstance, wasm;
312
+ function __wbg_finalize_init(instance, module) {
313
+ wasmInstance = instance;
314
+ wasm = instance.exports;
315
+ wasmModule = module;
316
+ cachedDataViewMemory0 = null;
317
+ cachedUint8ArrayMemory0 = null;
318
+ return wasm;
319
+ }
320
+
321
+ async function __wbg_load(module, imports) {
322
+ if (typeof Response === 'function' && module instanceof Response) {
323
+ if (!module.ok) {
324
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
325
+ }
326
+
327
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
328
+ try {
329
+ return await WebAssembly.instantiateStreaming(module, imports);
330
+ } catch (e) {
331
+ const validResponse = expectedResponseType(module.type);
332
+
333
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
334
+ 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);
335
+
336
+ } else { throw e; }
337
+ }
338
+ }
339
+
340
+ const bytes = await module.arrayBuffer();
341
+ return await WebAssembly.instantiate(bytes, imports);
342
+ } else {
343
+ const instance = await WebAssembly.instantiate(module, imports);
344
+
345
+ if (instance instanceof WebAssembly.Instance) {
346
+ return { instance, module };
347
+ } else {
348
+ return instance;
349
+ }
350
+ }
351
+
352
+ function expectedResponseType(type) {
353
+ switch (type) {
354
+ case 'basic': case 'cors': case 'default': return true;
355
+ }
356
+ return false;
357
+ }
358
+ }
359
+
360
+ function initSync(module) {
361
+ if (wasm !== undefined) return wasm;
362
+
363
+
364
+ if (module !== undefined) {
365
+ if (Object.getPrototypeOf(module) === Object.prototype) {
366
+ ({module} = module)
367
+ } else {
368
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
369
+ }
370
+ }
371
+
372
+ const imports = __wbg_get_imports();
373
+ if (!(module instanceof WebAssembly.Module)) {
374
+ module = new WebAssembly.Module(module);
375
+ }
376
+ const instance = new WebAssembly.Instance(module, imports);
377
+ return __wbg_finalize_init(instance, module);
378
+ }
379
+
380
+ async function __wbg_init(module_or_path) {
381
+ if (wasm !== undefined) return wasm;
382
+
383
+
384
+ if (module_or_path !== undefined) {
385
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
386
+ ({module_or_path} = module_or_path)
387
+ } else {
388
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
389
+ }
390
+ }
391
+
392
+
393
+ const imports = __wbg_get_imports();
394
+
395
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
396
+ module_or_path = fetch(module_or_path);
397
+ }
398
+
399
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
400
+
401
+ return __wbg_finalize_init(instance, module);
402
+ }
403
+
404
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const beginSignIn: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
5
+ export const completeSignIn: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
6
+ export const parseConfig: (a: number, b: number) => number;
7
+ export const parseTokenResponse: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
8
+ export const refreshRequest: (a: number, b: number, c: number, d: number, e: number) => void;
9
+ export const scopesSatisfied: (a: number, b: number, c: number, d: number) => number;
10
+ export const shouldBackoff: (a: number, b: number) => number;
11
+ export const __wbindgen_export: (a: number) => void;
12
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
13
+ export const __wbindgen_export2: (a: number, b: number) => number;
14
+ export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/jerk-oauth",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.0",
4
+ "description": "Pure OAuth helpers for jerk, compiled to WebAssembly (ESM, web target)",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ai-ecoverse/slicc-jerk.git"
9
+ },
10
+ "homepage": "https://github.com/ai-ecoverse/slicc-jerk#readme",
11
+ "type": "module",
12
+ "main": "jerk_oauth_wasm.js",
13
+ "types": "jerk_oauth_wasm.d.ts",
14
+ "files": [
15
+ "jerk_oauth_wasm.js",
16
+ "jerk_oauth_wasm.d.ts",
17
+ "jerk_oauth_wasm_bg.wasm",
18
+ "jerk_oauth_wasm_bg.wasm.d.ts"
19
+ ],
20
+ "sideEffects": false
21
+ }