@aws/dogwood-wasm 0.0.0-stage → 1.1.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 +202 -0
- package/NOTICE +2 -0
- package/README.md +217 -2
- package/THIRD-PARTY-NOTICES +4960 -0
- package/dogwood_wasm.d.ts +597 -0
- package/dogwood_wasm.js +895 -0
- package/dogwood_wasm_bg.wasm +0 -0
- package/package.json +18 -4
package/dogwood_wasm.js
ADDED
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
/* @ts-self-types="./dogwood_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A **stateful, live** Dogwood authorizer: lower a policy set once, then feed
|
|
5
|
+
* events as they happen and get a decision per event, with temporal history
|
|
6
|
+
* accumulating across calls.
|
|
7
|
+
*
|
|
8
|
+
* This is the counterpart to the one-shot [`replay`](crate::replay): same
|
|
9
|
+
* engine and same lowering, but the caller drives the loop. Because it holds
|
|
10
|
+
* temporal state, one instance corresponds to one history — see
|
|
11
|
+
* [`reset`](DogwoodAuthorizer::reset).
|
|
12
|
+
*/
|
|
13
|
+
class DogwoodAuthorizer {
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
DogwoodAuthorizerFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_dogwoodauthorizer_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every **fully qualified** action id this instance can decide
|
|
26
|
+
* (`["Drupe::Action::Read", …]`) — the actions the action schema declares.
|
|
27
|
+
* An event naming anything else is rejected, so a host that maps its own
|
|
28
|
+
* operation names onto Cedar actions can check the mapping against this
|
|
29
|
+
* once at startup rather than discovering a gap one denied request at a
|
|
30
|
+
* time.
|
|
31
|
+
* @returns {string[]}
|
|
32
|
+
*/
|
|
33
|
+
get actions() {
|
|
34
|
+
const ret = wasm.dogwoodauthorizer_actions(this.__wbg_ptr);
|
|
35
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
36
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
37
|
+
return v1;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How many decisions this instance has returned — the `index` the next
|
|
41
|
+
* decision will carry.
|
|
42
|
+
* @returns {number}
|
|
43
|
+
*/
|
|
44
|
+
get decisionCount() {
|
|
45
|
+
const ret = wasm.dogwoodauthorizer_decisionCount(this.__wbg_ptr);
|
|
46
|
+
return ret >>> 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The event kinds that are decision points under this instance's event
|
|
50
|
+
* schema (`["request"]` by default) — the kinds for which
|
|
51
|
+
* [`isAuthorized`](Self::is_authorized) returns a decision rather than
|
|
52
|
+
* `undefined`.
|
|
53
|
+
*
|
|
54
|
+
* A kind in [`eventKinds`](Self::event_kinds) but not here is history-only:
|
|
55
|
+
* it is accepted, it updates temporal state, and it yields no verdict.
|
|
56
|
+
* @returns {string[]}
|
|
57
|
+
*/
|
|
58
|
+
get decisionKinds() {
|
|
59
|
+
const ret = wasm.dogwoodauthorizer_decisionKinds(this.__wbg_ptr);
|
|
60
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
61
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
62
|
+
return v1;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Every event kind this instance's event schema declares, decision points
|
|
66
|
+
* and history-only alike (`["error", "request", "response"]` by default).
|
|
67
|
+
* Any other kind is rejected — see [`isAuthorized`](Self::is_authorized).
|
|
68
|
+
* @returns {string[]}
|
|
69
|
+
*/
|
|
70
|
+
get eventKinds() {
|
|
71
|
+
const ret = wasm.dogwoodauthorizer_eventKinds(this.__wbg_ptr);
|
|
72
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
73
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
74
|
+
return v1;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Authorize one event.
|
|
78
|
+
*
|
|
79
|
+
* Returns the [`AuthorizerDecision`] for a decision-kind event (by
|
|
80
|
+
* default, `kind: "request"`), or `undefined` for a history-only event —
|
|
81
|
+
* which still updates temporal history, and is how a host records the
|
|
82
|
+
* `response` half of a call so later policies can correlate against it.
|
|
83
|
+
*
|
|
84
|
+
* Throws a `DogwoodError` if the event is malformed (a missing `action`, a
|
|
85
|
+
* bad `__entity` tag, a wrong-typed field), **too large** (a value nested
|
|
86
|
+
* deeper than 128 levels, or past the size limits in `bounds`), or
|
|
87
|
+
* **rejected** by
|
|
88
|
+
* [`check`](Self::check) — an action or kind the schema does not declare, or
|
|
89
|
+
* a timestamp before the previous event's. Either way the instance is left
|
|
90
|
+
* **usable** and the temporal history untouched: the event is validated
|
|
91
|
+
* before it is observed, so a failed call is a no-op and the next call
|
|
92
|
+
* decides normally.
|
|
93
|
+
*
|
|
94
|
+
* A *policy* problem is never thrown: an evaluation failure comes back as a
|
|
95
|
+
* fail-closed `deny` with the cause in
|
|
96
|
+
* [`errors`](AuthorizerDecision::errors).
|
|
97
|
+
*
|
|
98
|
+
* The parameter is taken as a `JsValue` and deserialized here rather than
|
|
99
|
+
* declared as `EventInput` directly, which is load-bearing: wasm-bindgen
|
|
100
|
+
* acquires the `&mut self` borrow *before* converting arguments, so a
|
|
101
|
+
* conversion that fails propagates the exception without releasing the
|
|
102
|
+
* borrow — permanently poisoning the instance (every later call, `free()`
|
|
103
|
+
* included, then fails with "recursive use of an object"). Converting
|
|
104
|
+
* inside the body means the failure is an ordinary `Err` return and the
|
|
105
|
+
* borrow is released. `unchecked_param_type` keeps the TypeScript
|
|
106
|
+
* signature `EventInput`.
|
|
107
|
+
* @param {EventInput} event
|
|
108
|
+
* @returns {AuthorizerDecision | undefined}
|
|
109
|
+
*/
|
|
110
|
+
isAuthorized(event) {
|
|
111
|
+
const ret = wasm.dogwoodauthorizer_isAuthorized(this.__wbg_ptr, event);
|
|
112
|
+
if (ret[2]) {
|
|
113
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
114
|
+
}
|
|
115
|
+
return takeFromExternrefTable0(ret[0]);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The timestamp of the most recent event observed, or `undefined` before
|
|
119
|
+
* the first (and after a [`reset`](Self::reset)). The next event's
|
|
120
|
+
* timestamp must be at least this.
|
|
121
|
+
*
|
|
122
|
+
* Widened to `f64` so the TypeScript type is `number`, matching
|
|
123
|
+
* [`AuthorizerDecision::timestamp`] and the `timestamp` a host passes in.
|
|
124
|
+
* An `i64` would come back a `BigInt`, which compares false against every
|
|
125
|
+
* plain number it is likely to be compared with (`5n == 5` is true but
|
|
126
|
+
* `5n === 5` is false, and mixed arithmetic throws) — a needless trap on a
|
|
127
|
+
* value that is a count of seconds and so nowhere near `f64`'s exact-integer
|
|
128
|
+
* limit.
|
|
129
|
+
* @returns {number | undefined}
|
|
130
|
+
*/
|
|
131
|
+
get lastTimestamp() {
|
|
132
|
+
const ret = wasm.dogwoodauthorizer_lastTimestamp(this.__wbg_ptr);
|
|
133
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Lower `source` against `actionSchema` and build a fresh authorizer with
|
|
137
|
+
* empty temporal history. Throws a `DogwoodError` (with `.diagnostic`) on
|
|
138
|
+
* a parse, macro, lowering, or schema failure — the same error contract as
|
|
139
|
+
* every other operation in these bindings.
|
|
140
|
+
*
|
|
141
|
+
* The trailing arguments are the optional service-schema overrides
|
|
142
|
+
* (event-schema DSL text, `providers.json` text, macro-library text);
|
|
143
|
+
* omit them for the defaults.
|
|
144
|
+
* @param {string} source
|
|
145
|
+
* @param {string} action_schema
|
|
146
|
+
* @param {string | null} [event_schema]
|
|
147
|
+
* @param {string | null} [providers]
|
|
148
|
+
* @param {string | null} [macros]
|
|
149
|
+
*/
|
|
150
|
+
constructor(source, action_schema, event_schema, providers, macros) {
|
|
151
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
152
|
+
const len0 = WASM_VECTOR_LEN;
|
|
153
|
+
const ptr1 = passStringToWasm0(action_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len1 = WASM_VECTOR_LEN;
|
|
155
|
+
var ptr2 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
156
|
+
var len2 = WASM_VECTOR_LEN;
|
|
157
|
+
var ptr3 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
158
|
+
var len3 = WASM_VECTOR_LEN;
|
|
159
|
+
var ptr4 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
160
|
+
var len4 = WASM_VECTOR_LEN;
|
|
161
|
+
const ret = wasm.dogwoodauthorizer_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
162
|
+
if (ret[2]) {
|
|
163
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
164
|
+
}
|
|
165
|
+
this.__wbg_ptr = ret[0];
|
|
166
|
+
DogwoodAuthorizerFinalization.register(this, this.__wbg_ptr, this);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Drop all accumulated temporal history and start over, re-lowering the
|
|
171
|
+
* original sources. Cheaper than constructing a new instance only in that
|
|
172
|
+
* the caller need not keep the sources around; the lowering cost is the
|
|
173
|
+
* same. The decision index restarts at 0.
|
|
174
|
+
*/
|
|
175
|
+
reset() {
|
|
176
|
+
const ret = wasm.dogwoodauthorizer_reset(this.__wbg_ptr);
|
|
177
|
+
if (ret[1]) {
|
|
178
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (Symbol.dispose) DogwoodAuthorizer.prototype[Symbol.dispose] = DogwoodAuthorizer.prototype.free;
|
|
183
|
+
exports.DogwoodAuthorizer = DogwoodAuthorizer;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Check a Cedar action schema (`.cedarschema`) in isolation.
|
|
187
|
+
* @param {string} source
|
|
188
|
+
* @returns {SchemaCheckReport}
|
|
189
|
+
*/
|
|
190
|
+
function checkActionSchema(source) {
|
|
191
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
const ret = wasm.checkActionSchema(ptr0, len0);
|
|
194
|
+
if (ret[2]) {
|
|
195
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
196
|
+
}
|
|
197
|
+
return takeFromExternrefTable0(ret[0]);
|
|
198
|
+
}
|
|
199
|
+
exports.checkActionSchema = checkActionSchema;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check an event-schema DSL (`.dwschema`) in isolation.
|
|
203
|
+
* @param {string} source
|
|
204
|
+
* @returns {SchemaCheckReport}
|
|
205
|
+
*/
|
|
206
|
+
function checkEventSchema(source) {
|
|
207
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
209
|
+
const ret = wasm.checkEventSchema(ptr0, len0);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
}
|
|
215
|
+
exports.checkEventSchema = checkEventSchema;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Parse and macro-expand a `.dw` policy set, reporting syntax/macro errors and
|
|
219
|
+
* per-policy structural summaries. Needs no action schema.
|
|
220
|
+
* @param {string} source
|
|
221
|
+
* @param {string | null} [event_schema]
|
|
222
|
+
* @param {string | null} [providers]
|
|
223
|
+
* @param {string | null} [macros]
|
|
224
|
+
* @returns {CheckParseReport}
|
|
225
|
+
*/
|
|
226
|
+
function checkParse(source, event_schema, providers, macros) {
|
|
227
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
229
|
+
var ptr1 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
var len1 = WASM_VECTOR_LEN;
|
|
231
|
+
var ptr2 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
var len2 = WASM_VECTOR_LEN;
|
|
233
|
+
var ptr3 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
+
var len3 = WASM_VECTOR_LEN;
|
|
235
|
+
const ret = wasm.checkParse(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
236
|
+
if (ret[2]) {
|
|
237
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
238
|
+
}
|
|
239
|
+
return takeFromExternrefTable0(ret[0]);
|
|
240
|
+
}
|
|
241
|
+
exports.checkParse = checkParse;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Check an information-provider declarations file (`providers.json`) in
|
|
245
|
+
* isolation.
|
|
246
|
+
* @param {string} json
|
|
247
|
+
* @returns {SchemaCheckReport}
|
|
248
|
+
*/
|
|
249
|
+
function checkProviders(json) {
|
|
250
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
const ret = wasm.checkProviders(ptr0, len0);
|
|
253
|
+
if (ret[2]) {
|
|
254
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
255
|
+
}
|
|
256
|
+
return takeFromExternrefTable0(ret[0]);
|
|
257
|
+
}
|
|
258
|
+
exports.checkProviders = checkProviders;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Parse (with macro expansion) and informalize a `.dw` policy set into
|
|
262
|
+
* deterministic semi-English, rule by rule. The action schema is optional:
|
|
263
|
+
* with it, the single declared namespace is dropped from names. Nothing is
|
|
264
|
+
* validated — an invalid-but-parsable policy is still explained.
|
|
265
|
+
* @param {string} source
|
|
266
|
+
* @param {string | null} [action_schema]
|
|
267
|
+
* @param {string | null} [event_schema]
|
|
268
|
+
* @param {string | null} [providers]
|
|
269
|
+
* @param {string | null} [macros]
|
|
270
|
+
* @returns {ExplainReport}
|
|
271
|
+
*/
|
|
272
|
+
function explain(source, action_schema, event_schema, providers, macros) {
|
|
273
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
274
|
+
const len0 = WASM_VECTOR_LEN;
|
|
275
|
+
var ptr1 = isLikeNone(action_schema) ? 0 : passStringToWasm0(action_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
+
var len1 = WASM_VECTOR_LEN;
|
|
277
|
+
var ptr2 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
var len2 = WASM_VECTOR_LEN;
|
|
279
|
+
var ptr3 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
280
|
+
var len3 = WASM_VECTOR_LEN;
|
|
281
|
+
var ptr4 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
282
|
+
var len4 = WASM_VECTOR_LEN;
|
|
283
|
+
const ret = wasm.explain(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
284
|
+
if (ret[2]) {
|
|
285
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
286
|
+
}
|
|
287
|
+
return takeFromExternrefTable0(ret[0]);
|
|
288
|
+
}
|
|
289
|
+
exports.explain = explain;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Module start hook, invoked automatically on load. In a development build
|
|
293
|
+
* (feature `dev`, `npm run build:dev`) it installs a panic hook so a Rust panic
|
|
294
|
+
* surfaces as a readable `console.error`; a release build installs nothing,
|
|
295
|
+
* and a panic aborts with an opaque `unreachable` without logging its message.
|
|
296
|
+
*/
|
|
297
|
+
function init() {
|
|
298
|
+
wasm.init();
|
|
299
|
+
}
|
|
300
|
+
exports.init = init;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Lower a `.dw` policy set to Cedar and return the emitted artifacts (policies
|
|
304
|
+
* and augmented schema, in text and Cedar-JSON forms).
|
|
305
|
+
* @param {string} source
|
|
306
|
+
* @param {string} action_schema
|
|
307
|
+
* @param {string | null} [event_schema]
|
|
308
|
+
* @param {string | null} [providers]
|
|
309
|
+
* @param {string | null} [macros]
|
|
310
|
+
* @returns {LowerArtifacts}
|
|
311
|
+
*/
|
|
312
|
+
function lower(source, action_schema, event_schema, providers, macros) {
|
|
313
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
const ptr1 = passStringToWasm0(action_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
317
|
+
var ptr2 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
var len2 = WASM_VECTOR_LEN;
|
|
319
|
+
var ptr3 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
var len3 = WASM_VECTOR_LEN;
|
|
321
|
+
var ptr4 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
322
|
+
var len4 = WASM_VECTOR_LEN;
|
|
323
|
+
const ret = wasm.lower(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
324
|
+
if (ret[2]) {
|
|
325
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
326
|
+
}
|
|
327
|
+
return takeFromExternrefTable0(ret[0]);
|
|
328
|
+
}
|
|
329
|
+
exports.lower = lower;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Generate a Cedar action schema (`.cedarschema` text) from an MCP
|
|
333
|
+
* `tools/list` manifest, layered on the embedded Drupe template.
|
|
334
|
+
* @param {string} manifest_json
|
|
335
|
+
* @returns {string}
|
|
336
|
+
*/
|
|
337
|
+
function mcpToCedarSchema(manifest_json) {
|
|
338
|
+
let deferred3_0;
|
|
339
|
+
let deferred3_1;
|
|
340
|
+
try {
|
|
341
|
+
const ptr0 = passStringToWasm0(manifest_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
342
|
+
const len0 = WASM_VECTOR_LEN;
|
|
343
|
+
const ret = wasm.mcpToCedarSchema(ptr0, len0);
|
|
344
|
+
var ptr2 = ret[0];
|
|
345
|
+
var len2 = ret[1];
|
|
346
|
+
if (ret[3]) {
|
|
347
|
+
ptr2 = 0; len2 = 0;
|
|
348
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
349
|
+
}
|
|
350
|
+
deferred3_0 = ptr2;
|
|
351
|
+
deferred3_1 = len2;
|
|
352
|
+
return getStringFromWasm0(ptr2, len2);
|
|
353
|
+
} finally {
|
|
354
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
exports.mcpToCedarSchema = mcpToCedarSchema;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Lower, then drive a `.log` event trace through a stateful authorizer,
|
|
361
|
+
* returning the per-decision verdict stream.
|
|
362
|
+
*
|
|
363
|
+
* Any evaluation error forces a deny, exactly as in
|
|
364
|
+
* `DogwoodAuthorizer::isAuthorized` (see [`fail_closed`]).
|
|
365
|
+
* @param {string} source
|
|
366
|
+
* @param {string} action_schema
|
|
367
|
+
* @param {string} log
|
|
368
|
+
* @param {string | null} [event_schema]
|
|
369
|
+
* @param {string | null} [providers]
|
|
370
|
+
* @param {string | null} [macros]
|
|
371
|
+
* @returns {ReplayReport}
|
|
372
|
+
*/
|
|
373
|
+
function replay(source, action_schema, log, event_schema, providers, macros) {
|
|
374
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
375
|
+
const len0 = WASM_VECTOR_LEN;
|
|
376
|
+
const ptr1 = passStringToWasm0(action_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
377
|
+
const len1 = WASM_VECTOR_LEN;
|
|
378
|
+
const ptr2 = passStringToWasm0(log, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
379
|
+
const len2 = WASM_VECTOR_LEN;
|
|
380
|
+
var ptr3 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
381
|
+
var len3 = WASM_VECTOR_LEN;
|
|
382
|
+
var ptr4 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
383
|
+
var len4 = WASM_VECTOR_LEN;
|
|
384
|
+
var ptr5 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
385
|
+
var len5 = WASM_VECTOR_LEN;
|
|
386
|
+
const ret = wasm.replay(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
|
|
387
|
+
if (ret[2]) {
|
|
388
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
389
|
+
}
|
|
390
|
+
return takeFromExternrefTable0(ret[0]);
|
|
391
|
+
}
|
|
392
|
+
exports.replay = replay;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Lower against the Cedar action schema and type-check. Fatal parse/lower
|
|
396
|
+
* errors throw; a successful lower with type findings returns the report.
|
|
397
|
+
* @param {string} source
|
|
398
|
+
* @param {string} action_schema
|
|
399
|
+
* @param {string | null} [event_schema]
|
|
400
|
+
* @param {string | null} [providers]
|
|
401
|
+
* @param {string | null} [macros]
|
|
402
|
+
* @returns {ValidateReport}
|
|
403
|
+
*/
|
|
404
|
+
function validate(source, action_schema, event_schema, providers, macros) {
|
|
405
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
|
+
const len0 = WASM_VECTOR_LEN;
|
|
407
|
+
const ptr1 = passStringToWasm0(action_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
|
+
const len1 = WASM_VECTOR_LEN;
|
|
409
|
+
var ptr2 = isLikeNone(event_schema) ? 0 : passStringToWasm0(event_schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
410
|
+
var len2 = WASM_VECTOR_LEN;
|
|
411
|
+
var ptr3 = isLikeNone(providers) ? 0 : passStringToWasm0(providers, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
412
|
+
var len3 = WASM_VECTOR_LEN;
|
|
413
|
+
var ptr4 = isLikeNone(macros) ? 0 : passStringToWasm0(macros, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
414
|
+
var len4 = WASM_VECTOR_LEN;
|
|
415
|
+
const ret = wasm.validate(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
416
|
+
if (ret[2]) {
|
|
417
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
418
|
+
}
|
|
419
|
+
return takeFromExternrefTable0(ret[0]);
|
|
420
|
+
}
|
|
421
|
+
exports.validate = validate;
|
|
422
|
+
function __wbg_get_imports() {
|
|
423
|
+
const import0 = {
|
|
424
|
+
__proto__: null,
|
|
425
|
+
__wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
|
|
426
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
427
|
+
return ret;
|
|
428
|
+
},
|
|
429
|
+
__wbg_Number_14af1003b8dd5ead: function(arg0) {
|
|
430
|
+
const ret = Number(arg0);
|
|
431
|
+
return ret;
|
|
432
|
+
},
|
|
433
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
434
|
+
const ret = String(arg1);
|
|
435
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
436
|
+
const len1 = WASM_VECTOR_LEN;
|
|
437
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
438
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
439
|
+
},
|
|
440
|
+
__wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c: function(arg0, arg1) {
|
|
441
|
+
const v = arg1;
|
|
442
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
443
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
444
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
445
|
+
},
|
|
446
|
+
__wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
|
|
447
|
+
const v = arg0;
|
|
448
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
449
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
450
|
+
},
|
|
451
|
+
__wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
|
|
452
|
+
const ret = debugString(arg1);
|
|
453
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
454
|
+
const len1 = WASM_VECTOR_LEN;
|
|
455
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
456
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
457
|
+
},
|
|
458
|
+
__wbg___wbindgen_in_92f62ee1427d9e49: function(arg0, arg1) {
|
|
459
|
+
const ret = arg0 in arg1;
|
|
460
|
+
return ret;
|
|
461
|
+
},
|
|
462
|
+
__wbg___wbindgen_is_bigint_b123553bed3bb382: function(arg0) {
|
|
463
|
+
const ret = typeof(arg0) === 'bigint';
|
|
464
|
+
return ret;
|
|
465
|
+
},
|
|
466
|
+
__wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
|
|
467
|
+
const ret = typeof(arg0) === 'function';
|
|
468
|
+
return ret;
|
|
469
|
+
},
|
|
470
|
+
__wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
|
|
471
|
+
const val = arg0;
|
|
472
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
473
|
+
return ret;
|
|
474
|
+
},
|
|
475
|
+
__wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
|
|
476
|
+
const ret = typeof(arg0) === 'string';
|
|
477
|
+
return ret;
|
|
478
|
+
},
|
|
479
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
480
|
+
const ret = arg0 === undefined;
|
|
481
|
+
return ret;
|
|
482
|
+
},
|
|
483
|
+
__wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
|
|
484
|
+
const ret = arg0 === arg1;
|
|
485
|
+
return ret;
|
|
486
|
+
},
|
|
487
|
+
__wbg___wbindgen_jsval_loose_eq_677f21e468d6b461: function(arg0, arg1) {
|
|
488
|
+
const ret = arg0 == arg1;
|
|
489
|
+
return ret;
|
|
490
|
+
},
|
|
491
|
+
__wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
|
|
492
|
+
const obj = arg1;
|
|
493
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
494
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
495
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
496
|
+
},
|
|
497
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
498
|
+
const obj = arg1;
|
|
499
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
500
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
|
+
var len1 = WASM_VECTOR_LEN;
|
|
502
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
503
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
504
|
+
},
|
|
505
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
506
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
507
|
+
},
|
|
508
|
+
__wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
|
|
509
|
+
const ret = arg0.call(arg1);
|
|
510
|
+
return ret;
|
|
511
|
+
}, arguments); },
|
|
512
|
+
__wbg_done_b41a1d26cdb37fb6: function(arg0) {
|
|
513
|
+
const ret = arg0.done;
|
|
514
|
+
return ret;
|
|
515
|
+
},
|
|
516
|
+
__wbg_entries_fb6397112b1de25f: function(arg0) {
|
|
517
|
+
const ret = Object.entries(arg0);
|
|
518
|
+
return ret;
|
|
519
|
+
},
|
|
520
|
+
__wbg_forEach_7ad975c8e42636ed: function(arg0, arg1, arg2) {
|
|
521
|
+
try {
|
|
522
|
+
var state0 = {a: arg1, b: arg2};
|
|
523
|
+
var cb0 = (arg0, arg1) => {
|
|
524
|
+
const a = state0.a;
|
|
525
|
+
state0.a = 0;
|
|
526
|
+
try {
|
|
527
|
+
return wasm_bindgen_cfade1c0cc745d74___convert__closures_____invoke___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
528
|
+
} finally {
|
|
529
|
+
state0.a = a;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
arg0.forEach(cb0);
|
|
533
|
+
} finally {
|
|
534
|
+
state0.a = 0;
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
__wbg_getRandomValues_a608c4436c19407a: function() { return handleError(function (arg0, arg1) {
|
|
538
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
539
|
+
}, arguments); },
|
|
540
|
+
__wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
|
|
541
|
+
const ret = Reflect.get(arg0, arg1);
|
|
542
|
+
return ret;
|
|
543
|
+
}, arguments); },
|
|
544
|
+
__wbg_get_6c896e0571ddae51: function(arg0, arg1) {
|
|
545
|
+
const ret = arg0[arg1 >>> 0];
|
|
546
|
+
return ret;
|
|
547
|
+
},
|
|
548
|
+
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
549
|
+
const ret = arg0[arg1 >>> 0];
|
|
550
|
+
return ret;
|
|
551
|
+
},
|
|
552
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
553
|
+
const ret = arg0[arg1];
|
|
554
|
+
return ret;
|
|
555
|
+
},
|
|
556
|
+
__wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
|
|
557
|
+
let result;
|
|
558
|
+
try {
|
|
559
|
+
result = arg0 instanceof ArrayBuffer;
|
|
560
|
+
} catch (_) {
|
|
561
|
+
result = false;
|
|
562
|
+
}
|
|
563
|
+
const ret = result;
|
|
564
|
+
return ret;
|
|
565
|
+
},
|
|
566
|
+
__wbg_instanceof_Map_b2611749102d7ba3: function(arg0) {
|
|
567
|
+
let result;
|
|
568
|
+
try {
|
|
569
|
+
result = arg0 instanceof Map;
|
|
570
|
+
} catch (_) {
|
|
571
|
+
result = false;
|
|
572
|
+
}
|
|
573
|
+
const ret = result;
|
|
574
|
+
return ret;
|
|
575
|
+
},
|
|
576
|
+
__wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
|
|
577
|
+
let result;
|
|
578
|
+
try {
|
|
579
|
+
result = arg0 instanceof Uint8Array;
|
|
580
|
+
} catch (_) {
|
|
581
|
+
result = false;
|
|
582
|
+
}
|
|
583
|
+
const ret = result;
|
|
584
|
+
return ret;
|
|
585
|
+
},
|
|
586
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
587
|
+
const ret = Array.isArray(arg0);
|
|
588
|
+
return ret;
|
|
589
|
+
},
|
|
590
|
+
__wbg_isSafeInteger_717808ad6a54bd9e: function(arg0) {
|
|
591
|
+
const ret = Number.isSafeInteger(arg0);
|
|
592
|
+
return ret;
|
|
593
|
+
},
|
|
594
|
+
__wbg_iterator_e3c31c892080e444: function() {
|
|
595
|
+
const ret = Symbol.iterator;
|
|
596
|
+
return ret;
|
|
597
|
+
},
|
|
598
|
+
__wbg_length_78dac82682e59660: function(arg0) {
|
|
599
|
+
const ret = arg0.length;
|
|
600
|
+
return ret;
|
|
601
|
+
},
|
|
602
|
+
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
603
|
+
const ret = arg0.length;
|
|
604
|
+
return ret;
|
|
605
|
+
},
|
|
606
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
607
|
+
const ret = arg0.length;
|
|
608
|
+
return ret;
|
|
609
|
+
},
|
|
610
|
+
__wbg_new_1dbf7428bba60a42: function(arg0) {
|
|
611
|
+
const ret = new Uint8Array(arg0);
|
|
612
|
+
return ret;
|
|
613
|
+
},
|
|
614
|
+
__wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
|
|
615
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
616
|
+
return ret;
|
|
617
|
+
},
|
|
618
|
+
__wbg_new_617a8cdb8bb1130e: function() {
|
|
619
|
+
const ret = new Object();
|
|
620
|
+
return ret;
|
|
621
|
+
},
|
|
622
|
+
__wbg_new_ee2291f50781bf1d: function() {
|
|
623
|
+
const ret = new Array();
|
|
624
|
+
return ret;
|
|
625
|
+
},
|
|
626
|
+
__wbg_next_33784799010f1bbe: function(arg0) {
|
|
627
|
+
const ret = arg0.next;
|
|
628
|
+
return ret;
|
|
629
|
+
},
|
|
630
|
+
__wbg_next_f4aac29c42af995c: function() { return handleError(function (arg0) {
|
|
631
|
+
const ret = arg0.next();
|
|
632
|
+
return ret;
|
|
633
|
+
}, arguments); },
|
|
634
|
+
__wbg_parse_0fc53dead14b3b42: function() { return handleError(function (arg0, arg1) {
|
|
635
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
636
|
+
return ret;
|
|
637
|
+
}, arguments); },
|
|
638
|
+
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
639
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
640
|
+
},
|
|
641
|
+
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
642
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
643
|
+
return ret;
|
|
644
|
+
}, arguments); },
|
|
645
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
646
|
+
arg0[arg1] = arg2;
|
|
647
|
+
},
|
|
648
|
+
__wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
|
|
649
|
+
arg0[arg1 >>> 0] = arg2;
|
|
650
|
+
},
|
|
651
|
+
__wbg_set_name_2c630595dc90a7aa: function(arg0, arg1, arg2) {
|
|
652
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
653
|
+
},
|
|
654
|
+
__wbg_size_c2498a9484dc789c: function(arg0) {
|
|
655
|
+
const ret = arg0.size;
|
|
656
|
+
return ret;
|
|
657
|
+
},
|
|
658
|
+
__wbg_value_f3c585ee8f5ba40c: function(arg0) {
|
|
659
|
+
const ret = arg0.value;
|
|
660
|
+
return ret;
|
|
661
|
+
},
|
|
662
|
+
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
663
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
664
|
+
const ret = arg0;
|
|
665
|
+
return ret;
|
|
666
|
+
},
|
|
667
|
+
__wbindgen_generic_0000000000000002: function(arg0) {
|
|
668
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
669
|
+
const ret = arg0;
|
|
670
|
+
return ret;
|
|
671
|
+
},
|
|
672
|
+
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
673
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
674
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
675
|
+
return ret;
|
|
676
|
+
},
|
|
677
|
+
__wbindgen_generic_0000000000000004: function(arg0) {
|
|
678
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
679
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
680
|
+
return ret;
|
|
681
|
+
},
|
|
682
|
+
__wbindgen_init_externref_table: function() {
|
|
683
|
+
const table = wasm.__wbindgen_externrefs;
|
|
684
|
+
const offset = table.grow(4);
|
|
685
|
+
table.set(0, undefined);
|
|
686
|
+
table.set(offset + 0, undefined);
|
|
687
|
+
table.set(offset + 1, null);
|
|
688
|
+
table.set(offset + 2, true);
|
|
689
|
+
table.set(offset + 3, false);
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
return {
|
|
693
|
+
__proto__: null,
|
|
694
|
+
"./dogwood_wasm_bg.js": import0,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function wasm_bindgen_cfade1c0cc745d74___convert__closures_____invoke___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
|
|
699
|
+
wasm.wasm_bindgen_cfade1c0cc745d74___convert__closures_____invoke___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined___js_sys_a2eda7c66b84933c___Function_fn_wasm_bindgen_cfade1c0cc745d74___JsValue_____wasm_bindgen_cfade1c0cc745d74___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const DogwoodAuthorizerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
703
|
+
? { register: () => {}, unregister: () => {} }
|
|
704
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_dogwoodauthorizer_free(ptr, 1));
|
|
705
|
+
|
|
706
|
+
function addToExternrefTable0(obj) {
|
|
707
|
+
const idx = wasm.__externref_table_alloc();
|
|
708
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
709
|
+
return idx;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function debugString(val) {
|
|
713
|
+
// primitive types
|
|
714
|
+
const type = typeof val;
|
|
715
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
716
|
+
return `${val}`;
|
|
717
|
+
}
|
|
718
|
+
if (type == 'string') {
|
|
719
|
+
return `"${val}"`;
|
|
720
|
+
}
|
|
721
|
+
if (type == 'symbol') {
|
|
722
|
+
const description = val.description;
|
|
723
|
+
if (description == null) {
|
|
724
|
+
return 'Symbol';
|
|
725
|
+
} else {
|
|
726
|
+
return `Symbol(${description})`;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (type == 'function') {
|
|
730
|
+
const name = val.name;
|
|
731
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
732
|
+
return `Function(${name})`;
|
|
733
|
+
} else {
|
|
734
|
+
return 'Function';
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
// objects
|
|
738
|
+
if (Array.isArray(val)) {
|
|
739
|
+
const length = val.length;
|
|
740
|
+
let debug = '[';
|
|
741
|
+
if (length > 0) {
|
|
742
|
+
debug += debugString(val[0]);
|
|
743
|
+
}
|
|
744
|
+
for(let i = 1; i < length; i++) {
|
|
745
|
+
debug += ', ' + debugString(val[i]);
|
|
746
|
+
}
|
|
747
|
+
debug += ']';
|
|
748
|
+
return debug;
|
|
749
|
+
}
|
|
750
|
+
// Test for built-in
|
|
751
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
752
|
+
let className;
|
|
753
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
754
|
+
className = builtInMatches[1];
|
|
755
|
+
} else {
|
|
756
|
+
// Failed to match the standard '[object ClassName]'
|
|
757
|
+
return toString.call(val);
|
|
758
|
+
}
|
|
759
|
+
if (className == 'Object') {
|
|
760
|
+
// we're a user defined class or Object
|
|
761
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
762
|
+
// easier than looping through ownProperties of `val`.
|
|
763
|
+
try {
|
|
764
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
765
|
+
} catch (_) {
|
|
766
|
+
return 'Object';
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
// errors
|
|
770
|
+
if (val instanceof Error) {
|
|
771
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
772
|
+
}
|
|
773
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
774
|
+
return className;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
778
|
+
ptr = ptr >>> 0;
|
|
779
|
+
const mem = getDataViewMemory0();
|
|
780
|
+
const result = [];
|
|
781
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
782
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
783
|
+
}
|
|
784
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
789
|
+
ptr = ptr >>> 0;
|
|
790
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
let cachedDataViewMemory0 = null;
|
|
794
|
+
function getDataViewMemory0() {
|
|
795
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
796
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
797
|
+
}
|
|
798
|
+
return cachedDataViewMemory0;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function getStringFromWasm0(ptr, len) {
|
|
802
|
+
return decodeText(ptr >>> 0, len);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
let cachedUint8ArrayMemory0 = null;
|
|
806
|
+
function getUint8ArrayMemory0() {
|
|
807
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
808
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
809
|
+
}
|
|
810
|
+
return cachedUint8ArrayMemory0;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
function handleError(f, args) {
|
|
814
|
+
try {
|
|
815
|
+
return f.apply(this, args);
|
|
816
|
+
} catch (e) {
|
|
817
|
+
const idx = addToExternrefTable0(e);
|
|
818
|
+
wasm.__wbindgen_exn_store(idx);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function isLikeNone(x) {
|
|
823
|
+
return x === undefined || x === null;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
827
|
+
if (realloc === undefined) {
|
|
828
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
829
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
830
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
831
|
+
WASM_VECTOR_LEN = buf.length;
|
|
832
|
+
return ptr;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
let len = arg.length;
|
|
836
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
837
|
+
|
|
838
|
+
const mem = getUint8ArrayMemory0();
|
|
839
|
+
|
|
840
|
+
let offset = 0;
|
|
841
|
+
|
|
842
|
+
for (; offset < len; offset++) {
|
|
843
|
+
const code = arg.charCodeAt(offset);
|
|
844
|
+
if (code > 0x7F) break;
|
|
845
|
+
mem[ptr + offset] = code;
|
|
846
|
+
}
|
|
847
|
+
if (offset !== len) {
|
|
848
|
+
if (offset !== 0) {
|
|
849
|
+
arg = arg.slice(offset);
|
|
850
|
+
}
|
|
851
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
852
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
853
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
854
|
+
|
|
855
|
+
offset += ret.written;
|
|
856
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
WASM_VECTOR_LEN = offset;
|
|
860
|
+
return ptr;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
function takeFromExternrefTable0(idx) {
|
|
864
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
865
|
+
wasm.__externref_table_dealloc(idx);
|
|
866
|
+
return value;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
870
|
+
cachedTextDecoder.decode();
|
|
871
|
+
function decodeText(ptr, len) {
|
|
872
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
const cachedTextEncoder = new TextEncoder();
|
|
876
|
+
|
|
877
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
878
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
879
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
880
|
+
view.set(buf);
|
|
881
|
+
return {
|
|
882
|
+
read: arg.length,
|
|
883
|
+
written: buf.length
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
let WASM_VECTOR_LEN = 0;
|
|
889
|
+
|
|
890
|
+
const wasmPath = `${__dirname}/dogwood_wasm_bg.wasm`;
|
|
891
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
892
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
893
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
894
|
+
let wasm = wasmInstance.exports;
|
|
895
|
+
wasm.__wbindgen_start();
|