@kya-os/checkpoint-wasm-runtime 1.0.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/adapters.d.mts +257 -0
  3. package/dist/adapters.d.ts +257 -0
  4. package/dist/adapters.js +603 -0
  5. package/dist/adapters.js.map +1 -0
  6. package/dist/adapters.mjs +586 -0
  7. package/dist/adapters.mjs.map +1 -0
  8. package/dist/dynamic-loader-cS-pUisw.d.ts +65 -0
  9. package/dist/dynamic-loader-qGJacfEC.d.mts +65 -0
  10. package/dist/edge.d.mts +22 -0
  11. package/dist/edge.d.ts +22 -0
  12. package/dist/edge.js +1403 -0
  13. package/dist/edge.js.map +1 -0
  14. package/dist/edge.mjs +1391 -0
  15. package/dist/edge.mjs.map +1 -0
  16. package/dist/engine-edge.d.mts +58 -0
  17. package/dist/engine-edge.d.ts +58 -0
  18. package/dist/engine-edge.js +537 -0
  19. package/dist/engine-edge.js.map +1 -0
  20. package/dist/engine-edge.mjs +533 -0
  21. package/dist/engine-edge.mjs.map +1 -0
  22. package/dist/engine.d.mts +34 -0
  23. package/dist/engine.d.ts +34 -0
  24. package/dist/engine.js +11 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/engine.mjs +9 -0
  27. package/dist/engine.mjs.map +1 -0
  28. package/dist/index.d.mts +58 -0
  29. package/dist/index.d.ts +58 -0
  30. package/dist/index.js +1652 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/index.mjs +1637 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/dist/node.d.mts +26 -0
  35. package/dist/node.d.ts +26 -0
  36. package/dist/node.js +972 -0
  37. package/dist/node.js.map +1 -0
  38. package/dist/node.mjs +960 -0
  39. package/dist/node.mjs.map +1 -0
  40. package/dist/orchestrator-edge.d.mts +243 -0
  41. package/dist/orchestrator-edge.d.ts +243 -0
  42. package/dist/orchestrator-edge.js +1076 -0
  43. package/dist/orchestrator-edge.js.map +1 -0
  44. package/dist/orchestrator-edge.mjs +1065 -0
  45. package/dist/orchestrator-edge.mjs.map +1 -0
  46. package/dist/orchestrator.d.mts +50 -0
  47. package/dist/orchestrator.d.ts +50 -0
  48. package/dist/orchestrator.js +1185 -0
  49. package/dist/orchestrator.js.map +1 -0
  50. package/dist/orchestrator.mjs +1172 -0
  51. package/dist/orchestrator.mjs.map +1 -0
  52. package/dist/rules-detector-DjbTJ1-Q.d.mts +470 -0
  53. package/dist/rules-detector-DjbTJ1-Q.d.ts +470 -0
  54. package/dist/static-loader-C1hUlksK.d.ts +72 -0
  55. package/dist/static-loader-Ds4iNw7c.d.mts +72 -0
  56. package/dist/types-D0j85fF0.d.mts +163 -0
  57. package/dist/types-D0j85fF0.d.ts +163 -0
  58. package/package.json +141 -0
  59. package/wasm/agentshield_wasm.d.ts +485 -0
  60. package/wasm/agentshield_wasm.js +1551 -0
  61. package/wasm/agentshield_wasm_bg.wasm +0 -0
  62. package/wasm/agentshield_wasm_bg.wasm.d.ts +97 -0
  63. package/wasm/kya-os-engine/kya_os_engine.d.ts +24 -0
  64. package/wasm/kya-os-engine/kya_os_engine.js +517 -0
  65. package/wasm/kya-os-engine/kya_os_engine_bg.wasm +0 -0
  66. package/wasm/kya-os-engine/kya_os_engine_bg.wasm.d.ts +8 -0
  67. package/wasm/kya-os-engine-web/kya_os_engine.d.ts +56 -0
  68. package/wasm/kya-os-engine-web/kya_os_engine.js +574 -0
  69. package/wasm/kya-os-engine-web/kya_os_engine_bg.wasm +0 -0
  70. package/wasm/kya-os-engine-web/kya_os_engine_bg.wasm.d.ts +8 -0
  71. package/wasm/package.json +30 -0
@@ -0,0 +1,1076 @@
1
+ 'use strict';
2
+
3
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __esm = (fn, res) => function __init() {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+
14
+ // wasm/kya-os-engine-web/kya_os_engine.js
15
+ var kya_os_engine_exports = {};
16
+ __export(kya_os_engine_exports, {
17
+ default: () => kya_os_engine_default,
18
+ initSync: () => initSync,
19
+ verify: () => verify
20
+ });
21
+ function getUint8ArrayMemory0() {
22
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
23
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
24
+ }
25
+ return cachedUint8ArrayMemory0;
26
+ }
27
+ function decodeText(ptr, len) {
28
+ numBytesDecoded += len;
29
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
30
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
31
+ cachedTextDecoder.decode();
32
+ numBytesDecoded = len;
33
+ }
34
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
35
+ }
36
+ function getStringFromWasm0(ptr, len) {
37
+ ptr = ptr >>> 0;
38
+ return decodeText(ptr, len);
39
+ }
40
+ function addHeapObject(obj) {
41
+ if (heap_next === heap.length) heap.push(heap.length + 1);
42
+ const idx = heap_next;
43
+ heap_next = heap[idx];
44
+ heap[idx] = obj;
45
+ return idx;
46
+ }
47
+ function getObject(idx) {
48
+ return heap[idx];
49
+ }
50
+ function passStringToWasm0(arg, malloc, realloc) {
51
+ if (realloc === void 0) {
52
+ const buf = cachedTextEncoder.encode(arg);
53
+ const ptr2 = malloc(buf.length, 1) >>> 0;
54
+ getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
55
+ WASM_VECTOR_LEN = buf.length;
56
+ return ptr2;
57
+ }
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+ const mem = getUint8ArrayMemory0();
61
+ let offset = 0;
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 127) break;
65
+ mem[ptr + offset] = code;
66
+ }
67
+ if (offset !== len) {
68
+ if (offset !== 0) {
69
+ arg = arg.slice(offset);
70
+ }
71
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
72
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
73
+ const ret = cachedTextEncoder.encodeInto(arg, view);
74
+ offset += ret.written;
75
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
76
+ }
77
+ WASM_VECTOR_LEN = offset;
78
+ return ptr;
79
+ }
80
+ function getDataViewMemory0() {
81
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
82
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
83
+ }
84
+ return cachedDataViewMemory0;
85
+ }
86
+ function isLikeNone(x) {
87
+ return x === void 0 || x === null;
88
+ }
89
+ function debugString(val) {
90
+ const type = typeof val;
91
+ if (type == "number" || type == "boolean" || val == null) {
92
+ return `${val}`;
93
+ }
94
+ if (type == "string") {
95
+ return `"${val}"`;
96
+ }
97
+ if (type == "symbol") {
98
+ const description = val.description;
99
+ if (description == null) {
100
+ return "Symbol";
101
+ } else {
102
+ return `Symbol(${description})`;
103
+ }
104
+ }
105
+ if (type == "function") {
106
+ const name = val.name;
107
+ if (typeof name == "string" && name.length > 0) {
108
+ return `Function(${name})`;
109
+ } else {
110
+ return "Function";
111
+ }
112
+ }
113
+ if (Array.isArray(val)) {
114
+ const length = val.length;
115
+ let debug = "[";
116
+ if (length > 0) {
117
+ debug += debugString(val[0]);
118
+ }
119
+ for (let i = 1; i < length; i++) {
120
+ debug += ", " + debugString(val[i]);
121
+ }
122
+ debug += "]";
123
+ return debug;
124
+ }
125
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
126
+ let className;
127
+ if (builtInMatches && builtInMatches.length > 1) {
128
+ className = builtInMatches[1];
129
+ } else {
130
+ return toString.call(val);
131
+ }
132
+ if (className == "Object") {
133
+ try {
134
+ return "Object(" + JSON.stringify(val) + ")";
135
+ } catch (_) {
136
+ return "Object";
137
+ }
138
+ }
139
+ if (val instanceof Error) {
140
+ return `${val.name}: ${val.message}
141
+ ${val.stack}`;
142
+ }
143
+ return className;
144
+ }
145
+ function handleError(f, args) {
146
+ try {
147
+ return f.apply(this, args);
148
+ } catch (e) {
149
+ wasm.__wbindgen_export3(addHeapObject(e));
150
+ }
151
+ }
152
+ function getArrayU8FromWasm0(ptr, len) {
153
+ ptr = ptr >>> 0;
154
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
155
+ }
156
+ function dropObject(idx) {
157
+ if (idx < 132) return;
158
+ heap[idx] = heap_next;
159
+ heap_next = idx;
160
+ }
161
+ function takeObject(idx) {
162
+ const ret = getObject(idx);
163
+ dropObject(idx);
164
+ return ret;
165
+ }
166
+ function verify(input_js, ctx_js) {
167
+ try {
168
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
169
+ wasm.verify(retptr, addHeapObject(input_js), addHeapObject(ctx_js));
170
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
171
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
172
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
173
+ if (r2) {
174
+ throw takeObject(r1);
175
+ }
176
+ return takeObject(r0);
177
+ } finally {
178
+ wasm.__wbindgen_add_to_stack_pointer(16);
179
+ }
180
+ }
181
+ async function __wbg_load(module, imports) {
182
+ if (typeof Response === "function" && module instanceof Response) {
183
+ if (typeof WebAssembly.instantiateStreaming === "function") {
184
+ try {
185
+ return await WebAssembly.instantiateStreaming(module, imports);
186
+ } catch (e) {
187
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
188
+ if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
189
+ 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);
190
+ } else {
191
+ throw e;
192
+ }
193
+ }
194
+ }
195
+ const bytes = await module.arrayBuffer();
196
+ return await WebAssembly.instantiate(bytes, imports);
197
+ } else {
198
+ const instance = await WebAssembly.instantiate(module, imports);
199
+ if (instance instanceof WebAssembly.Instance) {
200
+ return { instance, module };
201
+ } else {
202
+ return instance;
203
+ }
204
+ }
205
+ }
206
+ function __wbg_get_imports() {
207
+ const imports = {};
208
+ imports.wbg = {};
209
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
210
+ const ret = Error(getStringFromWasm0(arg0, arg1));
211
+ return addHeapObject(ret);
212
+ };
213
+ imports.wbg.__wbg_Number_bb48ca12f395cd08 = function(arg0) {
214
+ const ret = Number(getObject(arg0));
215
+ return ret;
216
+ };
217
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
218
+ const ret = String(getObject(arg1));
219
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
220
+ const len1 = WASM_VECTOR_LEN;
221
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
222
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
223
+ };
224
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd = function(arg0, arg1) {
225
+ const v = getObject(arg1);
226
+ const ret = typeof v === "bigint" ? v : void 0;
227
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
228
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
229
+ };
230
+ imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
231
+ const v = getObject(arg0);
232
+ const ret = typeof v === "boolean" ? v : void 0;
233
+ return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
234
+ };
235
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
236
+ const ret = debugString(getObject(arg1));
237
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
238
+ const len1 = WASM_VECTOR_LEN;
239
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
240
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
241
+ };
242
+ imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
243
+ const ret = getObject(arg0) in getObject(arg1);
244
+ return ret;
245
+ };
246
+ imports.wbg.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) {
247
+ const ret = typeof getObject(arg0) === "bigint";
248
+ return ret;
249
+ };
250
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
251
+ const ret = typeof getObject(arg0) === "function";
252
+ return ret;
253
+ };
254
+ imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
255
+ const val = getObject(arg0);
256
+ const ret = typeof val === "object" && val !== null;
257
+ return ret;
258
+ };
259
+ imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
260
+ const ret = typeof getObject(arg0) === "string";
261
+ return ret;
262
+ };
263
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
264
+ const ret = getObject(arg0) === void 0;
265
+ return ret;
266
+ };
267
+ imports.wbg.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50 = function(arg0, arg1) {
268
+ const ret = getObject(arg0) === getObject(arg1);
269
+ return ret;
270
+ };
271
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
272
+ const ret = getObject(arg0) == getObject(arg1);
273
+ return ret;
274
+ };
275
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
276
+ const obj = getObject(arg1);
277
+ const ret = typeof obj === "number" ? obj : void 0;
278
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
279
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
280
+ };
281
+ imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
282
+ const obj = getObject(arg1);
283
+ const ret = typeof obj === "string" ? obj : void 0;
284
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
285
+ var len1 = WASM_VECTOR_LEN;
286
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
287
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
288
+ };
289
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
290
+ throw new Error(getStringFromWasm0(arg0, arg1));
291
+ };
292
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() {
293
+ return handleError(function(arg0, arg1) {
294
+ const ret = getObject(arg0).call(getObject(arg1));
295
+ return addHeapObject(ret);
296
+ }, arguments);
297
+ };
298
+ imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
299
+ const ret = getObject(arg0).done;
300
+ return ret;
301
+ };
302
+ imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
303
+ const ret = Object.entries(getObject(arg0));
304
+ return addHeapObject(ret);
305
+ };
306
+ imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
307
+ const ret = getObject(arg0)[arg1 >>> 0];
308
+ return addHeapObject(ret);
309
+ };
310
+ imports.wbg.__wbg_get_efcb449f58ec27c2 = function() {
311
+ return handleError(function(arg0, arg1) {
312
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
313
+ return addHeapObject(ret);
314
+ }, arguments);
315
+ };
316
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
317
+ const ret = getObject(arg0)[getObject(arg1)];
318
+ return addHeapObject(ret);
319
+ };
320
+ imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
321
+ let result;
322
+ try {
323
+ result = getObject(arg0) instanceof ArrayBuffer;
324
+ } catch (_) {
325
+ result = false;
326
+ }
327
+ const ret = result;
328
+ return ret;
329
+ };
330
+ imports.wbg.__wbg_instanceof_Map_8579b5e2ab5437c7 = function(arg0) {
331
+ let result;
332
+ try {
333
+ result = getObject(arg0) instanceof Map;
334
+ } catch (_) {
335
+ result = false;
336
+ }
337
+ const ret = result;
338
+ return ret;
339
+ };
340
+ imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
341
+ let result;
342
+ try {
343
+ result = getObject(arg0) instanceof Uint8Array;
344
+ } catch (_) {
345
+ result = false;
346
+ }
347
+ const ret = result;
348
+ return ret;
349
+ };
350
+ imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
351
+ const ret = Array.isArray(getObject(arg0));
352
+ return ret;
353
+ };
354
+ imports.wbg.__wbg_isSafeInteger_d216eda7911dde36 = function(arg0) {
355
+ const ret = Number.isSafeInteger(getObject(arg0));
356
+ return ret;
357
+ };
358
+ imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
359
+ const ret = Symbol.iterator;
360
+ return addHeapObject(ret);
361
+ };
362
+ imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
363
+ const ret = getObject(arg0).length;
364
+ return ret;
365
+ };
366
+ imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
367
+ const ret = getObject(arg0).length;
368
+ return ret;
369
+ };
370
+ imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
371
+ const ret = new Object();
372
+ return addHeapObject(ret);
373
+ };
374
+ imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
375
+ const ret = new Uint8Array(getObject(arg0));
376
+ return addHeapObject(ret);
377
+ };
378
+ imports.wbg.__wbg_new_68651c719dcda04e = function() {
379
+ const ret = /* @__PURE__ */ new Map();
380
+ return addHeapObject(ret);
381
+ };
382
+ imports.wbg.__wbg_new_e17d9f43105b08be = function() {
383
+ const ret = new Array();
384
+ return addHeapObject(ret);
385
+ };
386
+ imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() {
387
+ return handleError(function(arg0) {
388
+ const ret = getObject(arg0).next();
389
+ return addHeapObject(ret);
390
+ }, arguments);
391
+ };
392
+ imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
393
+ const ret = getObject(arg0).next;
394
+ return addHeapObject(ret);
395
+ };
396
+ imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
397
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
398
+ };
399
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
400
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
401
+ };
402
+ imports.wbg.__wbg_set_907fb406c34a251d = function(arg0, arg1, arg2) {
403
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
404
+ return addHeapObject(ret);
405
+ };
406
+ imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
407
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
408
+ };
409
+ imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
410
+ const ret = getObject(arg0).value;
411
+ return addHeapObject(ret);
412
+ };
413
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
414
+ const ret = getStringFromWasm0(arg0, arg1);
415
+ return addHeapObject(ret);
416
+ };
417
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
418
+ const ret = BigInt.asUintN(64, arg0);
419
+ return addHeapObject(ret);
420
+ };
421
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
422
+ const ret = arg0;
423
+ return addHeapObject(ret);
424
+ };
425
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
426
+ const ret = arg0;
427
+ return addHeapObject(ret);
428
+ };
429
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
430
+ const ret = getObject(arg0);
431
+ return addHeapObject(ret);
432
+ };
433
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
434
+ takeObject(arg0);
435
+ };
436
+ return imports;
437
+ }
438
+ function __wbg_finalize_init(instance, module) {
439
+ wasm = instance.exports;
440
+ __wbg_init.__wbindgen_wasm_module = module;
441
+ cachedDataViewMemory0 = null;
442
+ cachedUint8ArrayMemory0 = null;
443
+ return wasm;
444
+ }
445
+ function initSync(module) {
446
+ if (wasm !== void 0) return wasm;
447
+ if (typeof module !== "undefined") {
448
+ if (Object.getPrototypeOf(module) === Object.prototype) {
449
+ ({ module } = module);
450
+ } else {
451
+ console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
452
+ }
453
+ }
454
+ const imports = __wbg_get_imports();
455
+ if (!(module instanceof WebAssembly.Module)) {
456
+ module = new WebAssembly.Module(module);
457
+ }
458
+ const instance = new WebAssembly.Instance(module, imports);
459
+ return __wbg_finalize_init(instance, module);
460
+ }
461
+ async function __wbg_init(module_or_path) {
462
+ if (wasm !== void 0) return wasm;
463
+ if (typeof module_or_path !== "undefined") {
464
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
465
+ ({ module_or_path } = module_or_path);
466
+ } else {
467
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
468
+ }
469
+ }
470
+ if (typeof module_or_path === "undefined") {
471
+ module_or_path = new URL("kya_os_engine_bg.wasm", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('orchestrator-edge.js', document.baseURI).href)));
472
+ }
473
+ const imports = __wbg_get_imports();
474
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
475
+ module_or_path = fetch(module_or_path);
476
+ }
477
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
478
+ return __wbg_finalize_init(instance, module);
479
+ }
480
+ var wasm, cachedUint8ArrayMemory0, cachedTextDecoder, MAX_SAFARI_DECODE_BYTES, numBytesDecoded, heap, heap_next, WASM_VECTOR_LEN, cachedTextEncoder, cachedDataViewMemory0, EXPECTED_RESPONSE_TYPES, kya_os_engine_default;
481
+ var init_kya_os_engine = __esm({
482
+ "wasm/kya-os-engine-web/kya_os_engine.js"() {
483
+ cachedUint8ArrayMemory0 = null;
484
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
485
+ cachedTextDecoder.decode();
486
+ MAX_SAFARI_DECODE_BYTES = 2146435072;
487
+ numBytesDecoded = 0;
488
+ heap = new Array(128).fill(void 0);
489
+ heap.push(void 0, null, true, false);
490
+ heap_next = heap.length;
491
+ WASM_VECTOR_LEN = 0;
492
+ cachedTextEncoder = new TextEncoder();
493
+ if (!("encodeInto" in cachedTextEncoder)) {
494
+ cachedTextEncoder.encodeInto = function(arg, view) {
495
+ const buf = cachedTextEncoder.encode(arg);
496
+ view.set(buf);
497
+ return {
498
+ read: arg.length,
499
+ written: buf.length
500
+ };
501
+ };
502
+ }
503
+ cachedDataViewMemory0 = null;
504
+ EXPECTED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["basic", "cors", "default"]);
505
+ kya_os_engine_default = __wbg_init;
506
+ }
507
+ });
508
+
509
+ // src/engine/adapters/outbound-url-policy.ts
510
+ var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "metadata", "metadata.google.internal"]);
511
+ var UnsafeOutboundUrl = class extends Error {
512
+ kind = "UnsafeOutboundUrl";
513
+ };
514
+ function assertSafeHttpsUrl(rawUrl, label = "outbound URL") {
515
+ let parsed;
516
+ try {
517
+ parsed = new URL(rawUrl);
518
+ } catch {
519
+ throw new UnsafeOutboundUrl(`${label} must be a valid URL: ${rawUrl}`);
520
+ }
521
+ if (parsed.protocol !== "https:") {
522
+ throw new UnsafeOutboundUrl(`${label} must use https: ${rawUrl}`);
523
+ }
524
+ if (parsed.username || parsed.password) {
525
+ throw new UnsafeOutboundUrl(`${label} must not contain credentials: ${rawUrl}`);
526
+ }
527
+ const hostname = normalizeHostname(parsed.hostname);
528
+ if (!hostname || isBlockedHostname(hostname)) {
529
+ throw new UnsafeOutboundUrl(`${label} targets a local or private host: ${rawUrl}`);
530
+ }
531
+ return rawUrl;
532
+ }
533
+ function normalizeHostname(hostname) {
534
+ let normalized = hostname.trim().toLowerCase();
535
+ if (normalized.startsWith("[") && normalized.endsWith("]")) {
536
+ normalized = normalized.slice(1, -1);
537
+ }
538
+ while (normalized.endsWith(".")) {
539
+ normalized = normalized.slice(0, -1);
540
+ }
541
+ return normalized;
542
+ }
543
+ function isBlockedHostname(hostname) {
544
+ if (BLOCKED_HOSTNAMES.has(hostname) || hostname.endsWith(".localhost")) {
545
+ return true;
546
+ }
547
+ const ipv4 = parseIpv4(hostname);
548
+ if (ipv4) {
549
+ return isBlockedIpv4(ipv4);
550
+ }
551
+ return isBlockedIpv6(hostname);
552
+ }
553
+ function parseIpv4(hostname) {
554
+ const parts = hostname.split(".");
555
+ if (parts.length !== 4) return null;
556
+ const octets = parts.map((part) => {
557
+ if (!/^\d{1,3}$/.test(part)) return Number.NaN;
558
+ const value = Number(part);
559
+ return value >= 0 && value <= 255 ? value : Number.NaN;
560
+ });
561
+ if (octets.some(Number.isNaN)) return null;
562
+ return octets;
563
+ }
564
+ function isBlockedIpv4([a, b]) {
565
+ return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a >= 224;
566
+ }
567
+ function isBlockedIpv6(hostname) {
568
+ if (!hostname.includes(":")) return false;
569
+ const ipv4Mapped = hostname.match(/(?:^|:)ffff:(\d{1,3}(?:\.\d{1,3}){3})$/);
570
+ if (ipv4Mapped) {
571
+ const ipv4 = parseIpv4(ipv4Mapped[1]);
572
+ return ipv4 ? isBlockedIpv4(ipv4) : true;
573
+ }
574
+ if (hostname === "::" || hostname === "::1" || hostname === "0:0:0:0:0:0:0:1") {
575
+ return true;
576
+ }
577
+ const firstSegment = Number.parseInt(hostname.split(":")[0] || "0", 16);
578
+ if (Number.isNaN(firstSegment)) return true;
579
+ return (firstSegment & 65024) === 64512 || // unique local fc00::/7
580
+ (firstSegment & 65472) === 65152 || // link-local fe80::/10
581
+ (firstSegment & 65280) === 65280;
582
+ }
583
+
584
+ // src/engine/edge.ts
585
+ var initialised = null;
586
+ function initEngineEdge(moduleOrPath) {
587
+ return ensureReady(moduleOrPath).then(() => void 0);
588
+ }
589
+ function ensureReady(moduleOrPath) {
590
+ if (initialised) return initialised;
591
+ const pending = (async () => {
592
+ const mod = await Promise.resolve().then(() => (init_kya_os_engine(), kya_os_engine_exports));
593
+ await mod.default(moduleOrPath !== void 0 ? { module_or_path: moduleOrPath } : void 0);
594
+ return mod.verify;
595
+ })();
596
+ initialised = pending;
597
+ pending.catch(() => {
598
+ if (initialised === pending) {
599
+ initialised = null;
600
+ }
601
+ });
602
+ return initialised;
603
+ }
604
+ async function engineVerifyEdge(input, ctx) {
605
+ const verify2 = await ensureReady();
606
+ return verify2(input, ctx);
607
+ }
608
+
609
+ // src/engine/adapters/util.ts
610
+ function base64UrlDecode(input) {
611
+ const padded = input.replace(/-/g, "+").replace(/_/g, "/");
612
+ const padding = padded.length % 4 === 0 ? "" : "=".repeat(4 - padded.length % 4);
613
+ return new Uint8Array(Buffer.from(padded + padding, "base64"));
614
+ }
615
+
616
+ // src/engine/orchestrator/build-agent-request.ts
617
+ function buildAgentRequest(req, opts = {}) {
618
+ const mcpI = tryBuildMcpIFromBody(req);
619
+ if (mcpI) {
620
+ return { protocol: "McpI", request: mcpI };
621
+ }
622
+ if (opts.legacyEnvelopeFallback) {
623
+ const legacyMcpI = tryBuildMcpIFromLegacyHeader(req);
624
+ if (legacyMcpI) {
625
+ return { protocol: "McpI", request: legacyMcpI };
626
+ }
627
+ }
628
+ if (getHeader(req, "signature-input")) {
629
+ return { protocol: "HttpSigned", request: buildHttpSigned(req) };
630
+ }
631
+ return { protocol: "PlainHttp", request: buildPlainHttp(req) };
632
+ }
633
+ function hasMalformedJwsBody(req) {
634
+ const parsed = parseBodyAsObject(req.body);
635
+ if (!parsed || typeof parsed !== "object") return false;
636
+ const meta = parsed._meta;
637
+ if (!meta || typeof meta !== "object") return false;
638
+ const proof = meta.proof;
639
+ if (!proof || typeof proof !== "object") return false;
640
+ const jws = proof.jws;
641
+ if (typeof jws !== "string" || jws.length === 0) return false;
642
+ const raw = Array.from(Buffer.from(jws, "utf8"));
643
+ return parseJwsPayloadStruct(raw) === null;
644
+ }
645
+ function extractIssuer(request) {
646
+ if (request.protocol === "McpI") return request.request.payload.iss || null;
647
+ return null;
648
+ }
649
+ function extractAgentDid(request) {
650
+ if (request.protocol === "McpI") return request.request.payload.sub || null;
651
+ return null;
652
+ }
653
+ function extractCredentialStatusUrl(request) {
654
+ if (request.protocol !== "McpI") return null;
655
+ const raw = decodeJwsPayloadJson(request.request.raw);
656
+ if (!raw) return null;
657
+ const vc = raw.vc;
658
+ if (!vc || typeof vc !== "object") return null;
659
+ const credentialStatus = vc.credentialStatus;
660
+ if (!credentialStatus || typeof credentialStatus !== "object") return null;
661
+ const id = credentialStatus.id;
662
+ return typeof id === "string" ? id : null;
663
+ }
664
+ function tryBuildMcpIFromBody(req) {
665
+ const parsed = parseBodyAsObject(req.body);
666
+ if (!parsed) return null;
667
+ const meta = parsed._meta;
668
+ if (!meta || typeof meta !== "object") return null;
669
+ const proof = meta.proof;
670
+ if (!proof || typeof proof !== "object") return null;
671
+ const jws = proof.jws;
672
+ if (typeof jws !== "string" || jws.length === 0) return null;
673
+ const raw = Array.from(Buffer.from(jws, "utf8"));
674
+ const payload = parseJwsPayloadStruct(raw);
675
+ if (!payload) return null;
676
+ return { raw, payload };
677
+ }
678
+ function parseBodyAsObject(body) {
679
+ if (!body) return null;
680
+ if (Buffer.isBuffer(body)) {
681
+ try {
682
+ return JSON.parse(body.toString("utf8"));
683
+ } catch {
684
+ return null;
685
+ }
686
+ }
687
+ if (typeof body === "string") {
688
+ try {
689
+ return JSON.parse(body);
690
+ } catch {
691
+ return null;
692
+ }
693
+ }
694
+ if (typeof body === "object") return body;
695
+ return null;
696
+ }
697
+ function tryBuildMcpIFromLegacyHeader(req) {
698
+ const header = getHeader(req, "kya-delegation");
699
+ if (!header) return null;
700
+ let parsed;
701
+ try {
702
+ parsed = JSON.parse(header);
703
+ } catch {
704
+ return null;
705
+ }
706
+ if (!parsed || typeof parsed !== "object") return null;
707
+ const obj = parsed;
708
+ const protectedSeg = obj.protected;
709
+ const payloadSeg = obj.payload;
710
+ const signatureSeg = obj.signature;
711
+ if (typeof protectedSeg !== "string" || typeof payloadSeg !== "string" || typeof signatureSeg !== "string") {
712
+ return null;
713
+ }
714
+ const compact = `${protectedSeg}.${payloadSeg}.${signatureSeg}`;
715
+ const raw = Array.from(Buffer.from(compact, "utf8"));
716
+ const payload = parseJwsPayloadStruct(raw);
717
+ if (!payload) return null;
718
+ return { raw, payload };
719
+ }
720
+ function parseJwsPayloadStruct(rawBytes) {
721
+ const json = decodeJwsPayloadJson(rawBytes);
722
+ if (!json || typeof json !== "object") return null;
723
+ return projectMcpIPayload(json);
724
+ }
725
+ function decodeJwsPayloadJson(rawBytes) {
726
+ const text = Buffer.from(rawBytes).toString("utf8");
727
+ const segments = text.split(".");
728
+ if (segments.length !== 3) return null;
729
+ let decoded;
730
+ try {
731
+ decoded = base64UrlDecode(segments[1]);
732
+ } catch {
733
+ return null;
734
+ }
735
+ try {
736
+ return JSON.parse(Buffer.from(decoded).toString("utf8"));
737
+ } catch {
738
+ return null;
739
+ }
740
+ }
741
+ function projectMcpIPayload(raw) {
742
+ const aud = raw.aud;
743
+ const iss = raw.iss;
744
+ const sub = raw.sub;
745
+ const nonce = raw.nonce;
746
+ const sessionId = raw.sessionId;
747
+ const ts = raw.ts;
748
+ const requestHash = raw.requestHash;
749
+ const responseHash = raw.responseHash;
750
+ if (typeof aud !== "string" || typeof iss !== "string" || typeof sub !== "string" || typeof nonce !== "string" || typeof sessionId !== "string" || typeof ts !== "number" || typeof requestHash !== "string" || typeof responseHash !== "string") {
751
+ return null;
752
+ }
753
+ return { aud, iss, sub, nonce, sessionId, ts, requestHash, responseHash };
754
+ }
755
+ function buildHttpSigned(req) {
756
+ return {
757
+ raw: bodyAsBytes(req.body),
758
+ method: req.method,
759
+ path: req.url,
760
+ headers: flattenHeaders(req.headers)
761
+ };
762
+ }
763
+ function buildPlainHttp(req) {
764
+ return {
765
+ raw: bodyAsBytes(req.body),
766
+ method: req.method,
767
+ path: req.url,
768
+ headers: flattenHeaders(req.headers),
769
+ userAgent: getHeader(req, "user-agent") ?? null,
770
+ remoteIp: req.remoteAddress ?? null
771
+ };
772
+ }
773
+ function getHeader(req, name) {
774
+ const lowered = name.toLowerCase();
775
+ for (const [key, value] of Object.entries(req.headers)) {
776
+ if (key.toLowerCase() !== lowered) continue;
777
+ if (Array.isArray(value)) return value[0] ?? null;
778
+ if (typeof value === "string") return value;
779
+ }
780
+ return null;
781
+ }
782
+ function flattenHeaders(headers) {
783
+ const out = [];
784
+ for (const [key, value] of Object.entries(headers)) {
785
+ if (value === void 0) continue;
786
+ if (Array.isArray(value)) {
787
+ for (const v of value) out.push([key, v]);
788
+ } else {
789
+ out.push([key, value]);
790
+ }
791
+ }
792
+ return out;
793
+ }
794
+ function bodyAsBytes(body) {
795
+ if (!body) return [];
796
+ if (Buffer.isBuffer(body)) return Array.from(body);
797
+ if (typeof body === "string") return Array.from(Buffer.from(body, "utf8"));
798
+ if (typeof body === "object") return Array.from(Buffer.from(JSON.stringify(body), "utf8"));
799
+ return [];
800
+ }
801
+
802
+ // src/engine/orchestrator/render-decision.ts
803
+ function renderDecisionAsResponse(result) {
804
+ const baseHeaders = buildBaseHeaders(result);
805
+ if (result.enforcementMode === "observe") {
806
+ return {
807
+ status: null,
808
+ headers: {
809
+ ...baseHeaders,
810
+ "X-Checkpoint-Mode": "observe",
811
+ "X-Checkpoint-Would-Have-Been": result.decision.kind,
812
+ ...wouldHaveBeenReasonHeader(result)
813
+ }
814
+ };
815
+ }
816
+ switch (result.decision.kind) {
817
+ case "Permit":
818
+ return {
819
+ status: null,
820
+ headers: { ...baseHeaders, "X-Checkpoint-Decision": "permit" }
821
+ };
822
+ case "Block": {
823
+ const reason = result.decision.reason;
824
+ return {
825
+ status: httpStatusForBlockReason(reason),
826
+ headers: {
827
+ ...baseHeaders,
828
+ ...blockHeaders(reason),
829
+ "X-Checkpoint-Decision": "block",
830
+ "X-Checkpoint-Reason": reason.kind
831
+ },
832
+ body: blockResponseBody(reason)
833
+ };
834
+ }
835
+ case "Challenge": {
836
+ const params = result.decision.params;
837
+ return {
838
+ status: 401,
839
+ headers: {
840
+ ...baseHeaders,
841
+ "X-Checkpoint-Decision": "challenge",
842
+ "X-Checkpoint-Challenge": params.nonce
843
+ },
844
+ body: {
845
+ challenge: params
846
+ }
847
+ };
848
+ }
849
+ case "Redirect": {
850
+ const target = result.decision.target;
851
+ return {
852
+ status: 302,
853
+ headers: {
854
+ ...baseHeaders,
855
+ "X-Checkpoint-Decision": "redirect",
856
+ Location: target.url,
857
+ "X-Checkpoint-Redirect-Reason": target.reason
858
+ }
859
+ };
860
+ }
861
+ case "Instruct": {
862
+ const payload = result.decision.payload;
863
+ return {
864
+ status: 422,
865
+ headers: {
866
+ ...baseHeaders,
867
+ "X-Checkpoint-Decision": "instruct",
868
+ "Content-Type": "application/problem+json"
869
+ },
870
+ body: {
871
+ type: payload.problem,
872
+ title: payload.title,
873
+ suggestedActions: payload.suggestedActions
874
+ }
875
+ };
876
+ }
877
+ }
878
+ }
879
+ function buildBaseHeaders(result) {
880
+ const headers = {
881
+ "X-Checkpoint-Engine": result.engineInfo.name,
882
+ "X-Checkpoint-Engine-Version": result.engineInfo.version
883
+ };
884
+ if (result.engineInfo.rulesetHash) {
885
+ headers["X-Checkpoint-Ruleset-Hash"] = result.engineInfo.rulesetHash;
886
+ }
887
+ return headers;
888
+ }
889
+ function httpStatusForBlockReason(reason) {
890
+ switch (reason.kind) {
891
+ case "Unauthenticated":
892
+ case "Expired":
893
+ return 401;
894
+ case "ParseError":
895
+ return 400;
896
+ case "InvalidSignature":
897
+ case "Revoked":
898
+ case "OutOfScope":
899
+ case "LowReputation":
900
+ case "PolicyDenied":
901
+ return 403;
902
+ }
903
+ }
904
+ function blockHeaders(reason) {
905
+ if (reason.kind === "Unauthenticated") {
906
+ return { "WWW-Authenticate": 'KyaProof realm="checkpoint"' };
907
+ }
908
+ return {};
909
+ }
910
+ function blockResponseBody(reason) {
911
+ switch (reason.kind) {
912
+ case "Revoked":
913
+ case "InvalidSignature":
914
+ case "Unauthenticated":
915
+ case "Expired":
916
+ return { error: humanError(reason.kind), reason: reason.kind };
917
+ case "OutOfScope":
918
+ return {
919
+ error: "requested scope is not granted",
920
+ reason: "OutOfScope",
921
+ requested: reason.requested,
922
+ granted: reason.granted
923
+ };
924
+ case "LowReputation":
925
+ return {
926
+ error: "agent reputation below tenant threshold",
927
+ reason: "LowReputation",
928
+ score: reason.score,
929
+ threshold: reason.threshold
930
+ };
931
+ case "PolicyDenied":
932
+ return {
933
+ error: "tenant policy denied the request",
934
+ reason: "PolicyDenied",
935
+ detail: reason.detail
936
+ };
937
+ case "ParseError":
938
+ return {
939
+ error: "request envelope could not be parsed",
940
+ reason: "ParseError",
941
+ detail: reason.detail
942
+ };
943
+ }
944
+ }
945
+ function humanError(kind) {
946
+ switch (kind) {
947
+ case "Revoked":
948
+ return "credential has been revoked";
949
+ case "InvalidSignature":
950
+ return "request signature failed verification";
951
+ case "Unauthenticated":
952
+ return "authentication required";
953
+ case "Expired":
954
+ return "credential is expired";
955
+ }
956
+ }
957
+ function wouldHaveBeenReasonHeader(result) {
958
+ if (result.decision.kind === "Block") {
959
+ return { "X-Checkpoint-Would-Have-Been-Reason": result.decision.reason.kind };
960
+ }
961
+ return {};
962
+ }
963
+
964
+ // src/engine/orchestrator/verify-request-edge.ts
965
+ var DEFAULT_REPUTATION_BASELINE = 1;
966
+ function makeVerifyRequestEdge(opts) {
967
+ let argusWarningLogged = false;
968
+ const log = opts.logger ?? defaultLogger;
969
+ return async function verifyRequestEdge2(req) {
970
+ if (!argusWarningLogged && !opts.argusUrl) {
971
+ log(
972
+ '[Checkpoint] WARNING: Argus URL not configured; reputation will degrade to baseline 1.0 ("trust by default"). Set ARGUS_API_URL to enable.'
973
+ );
974
+ argusWarningLogged = true;
975
+ }
976
+ return verifyRequestEdge_internal(req, opts);
977
+ };
978
+ }
979
+ async function verifyRequestEdge(req, opts) {
980
+ return verifyRequestEdge_internal(req, opts);
981
+ }
982
+ async function verifyRequestEdge_internal(req, opts) {
983
+ if (hasMalformedJwsBody(req)) {
984
+ return blockWithParseError("malformed JWS body", opts.enforcementMode);
985
+ }
986
+ const agentRequest = buildAgentRequest(req, {
987
+ legacyEnvelopeFallback: opts.legacyEnvelopeFallback
988
+ });
989
+ const issuer = extractIssuer(agentRequest);
990
+ const agentDid = extractAgentDid(agentRequest);
991
+ const credentialStatusUrl = extractCredentialStatusUrl(agentRequest);
992
+ const baseline = opts.reputationBaseline ?? DEFAULT_REPUTATION_BASELINE;
993
+ const [didResult, statusResult, repResult] = await Promise.allSettled([
994
+ issuer ? opts.didResolver.resolve(issuer) : Promise.resolve(null),
995
+ credentialStatusUrl ? fetchCredentialStatus(credentialStatusUrl, opts.statusListCache) : Promise.resolve(null),
996
+ agentDid ? opts.reputationOracle.score(agentDid) : Promise.resolve(baseline)
997
+ ]);
998
+ if (didResult.status === "rejected") {
999
+ if (isDidResolverError(didResult.reason)) {
1000
+ return blockWithParseError(
1001
+ didResult.reason instanceof Error ? didResult.reason.message : String(didResult.reason),
1002
+ opts.enforcementMode
1003
+ );
1004
+ }
1005
+ throw didResult.reason;
1006
+ }
1007
+ if (statusResult.status === "rejected") {
1008
+ if (statusResult.reason instanceof UnsafeOutboundUrl) {
1009
+ return blockWithParseError(statusResult.reason.message, opts.enforcementMode);
1010
+ }
1011
+ throw statusResult.reason;
1012
+ }
1013
+ if (repResult.status === "rejected") {
1014
+ throw repResult.reason;
1015
+ }
1016
+ const didDoc = didResult.value;
1017
+ const revokedIndices = statusResult.value;
1018
+ const repScore = repResult.value;
1019
+ const tenantDecision = await opts.policyEvaluator.evaluate({
1020
+ tenantHost: opts.tenantHost,
1021
+ reputation: repScore
1022
+ });
1023
+ await initEngineEdge();
1024
+ const ctx = {
1025
+ didDocs: didDoc && issuer ? { [issuer]: didDoc } : {},
1026
+ revoked: revokedIndices !== null && credentialStatusUrl ? { [credentialStatusUrl]: revokedIndices } : {},
1027
+ reputation: agentDid ? { [agentDid]: repScore } : {},
1028
+ tenantDecision,
1029
+ nowUnix: opts.clock.nowUnix(),
1030
+ enforcementMode: opts.enforcementMode
1031
+ };
1032
+ return engineVerifyEdge(agentRequest, ctx);
1033
+ }
1034
+ async function fetchCredentialStatus(credentialStatusUrl, statusListCache) {
1035
+ assertSafeHttpsUrl(credentialStatusUrl, "credential status URL");
1036
+ return statusListCache.fetch(credentialStatusUrl);
1037
+ }
1038
+ function isDidResolverError(err) {
1039
+ if (!(err instanceof Error)) return false;
1040
+ const kind = err.kind;
1041
+ return kind === "DidNotFound" || kind === "DidResolverTimeout" || kind === "DidResolverError" || kind === "MalformedDid" || kind === "UnsupportedKeyType" || kind === "UnsupportedDidMethod";
1042
+ }
1043
+ function blockWithParseError(detail, enforcementMode) {
1044
+ return {
1045
+ decision: {
1046
+ kind: "Block",
1047
+ reason: {
1048
+ kind: "ParseError",
1049
+ detail
1050
+ }
1051
+ },
1052
+ enforcementMode,
1053
+ engineInfo: {
1054
+ name: "checkpoint-engine-wasm",
1055
+ version: "0.0.0-host-synth",
1056
+ rulesetHash: "sha256:host-synthesized",
1057
+ rulesetVersion: "0.0.0-host-synth",
1058
+ extras: { synthesized: true }
1059
+ }
1060
+ };
1061
+ }
1062
+ function defaultLogger(msg) {
1063
+ console.warn(msg);
1064
+ }
1065
+
1066
+ exports.buildAgentRequest = buildAgentRequest;
1067
+ exports.extractAgentDid = extractAgentDid;
1068
+ exports.extractCredentialStatusUrl = extractCredentialStatusUrl;
1069
+ exports.extractIssuer = extractIssuer;
1070
+ exports.hasMalformedJwsBody = hasMalformedJwsBody;
1071
+ exports.initEngineEdge = initEngineEdge;
1072
+ exports.makeVerifyRequestEdge = makeVerifyRequestEdge;
1073
+ exports.renderDecisionAsResponse = renderDecisionAsResponse;
1074
+ exports.verifyRequestEdge = verifyRequestEdge;
1075
+ //# sourceMappingURL=orchestrator-edge.js.map
1076
+ //# sourceMappingURL=orchestrator-edge.js.map