/* tslint:disable */ /* eslint-disable */ /** * Cross-boundary handle to a compiled Cedar policy bundle. * * Wraps a [`CedarPolicyEvaluator`] so a JS host can compile a tenant * policy once and authorize many requests against it. Construction * compiles the bundle; each [`authorize`][Self::authorize] call evaluates * a single owned request and never re-parses policy text. */ export class PolicyEvaluator { free(): void; [Symbol.dispose](): void; /** * Authorize one owned request against the compiled policy bundle. * * The JS host calls `evaluator.authorize(input)` with an * [`AuthorizeInput`]-shaped object (camelCase keys); it gets back a * [`Decision`][crate::types::Decision] JSON object. The evaluator owns * the fail-closed posture — a request it cannot marshal, or one * matching no `permit`, comes back as a * [`Decision::Block`][crate::types::Decision::Block], not a thrown * error. * * # Errors * * Returns a thrown JS error only for boundary faults: a malformed * `input_js` that fails [`AuthorizeInput`] deserialisation, or a * failure serialising the resulting `Decision`. Authorization * *verdicts* never throw — they surface inside the returned value. * * # JS signature * * ```ts * authorize(input: AuthorizeInput): Decision; * ``` */ authorize(input_js: any): any; /** * Compile `policy_text` into a reusable evaluator. * * The Cedar policy bundle is parsed and compiled exactly once here; * the resulting evaluator is held for the lifetime of the handle and * reused by every [`authorize`][Self::authorize] call. * * # Errors * * Returns a thrown JS error whose message names the failure when * `policy_text` is not syntactically valid Cedar * ([`PolicyEvaluationError::Malformed`][crate::error::PolicyEvaluationError::Malformed]). * A malformed bundle is an infrastructure fault surfaced at * construction, never as a per-request deny. */ constructor(policy_text: string); } /** * Verify a signed rule bundle against the keys compiled into this build * and, only if every check passes, swap in the vendor IP ranges and * extend the pinned vendor-key expiries it carries. * * The host owns the fetch and the clock (`nowUnix`, whole seconds); the * engine decides what may be adopted. Never throws: anything that fails * verification comes back as `{ ok: false, code }` and leaves the * compiled-in data, or the last good bundle, in effect. See * [`crate::rule_bundle`]. * * # JS signature * * ```ts * type RuleBundleReport = * | { ok: true; version: number; unchanged: boolean; expiresAt: number; * ipVendorsUpdated: string[]; vendorsIgnored: string[]; * keyOutcomes: ReinstateOutcome[] } * | { ok: false; code: string; message: string }; * * function applyRuleBundle(bundleJson: string, nowUnix: number): RuleBundleReport; * ``` */ export function applyRuleBundle(bundle_json: string, now_unix: number): any; /** * Cross-boundary `engineInfo` wrapper: this build's [`EngineManifest`] * (attribution stamp plus the capabilities it enforces). * * [`EngineManifest`]: crate::capabilities::EngineManifest * * # JS signature * * ```ts * function engineInfo(): EngineManifest; * ``` */ export function engineInfo(): any; export function feedAttemptFinished(outcome: string): boolean; export function feedDemand(now_unix: number): string | undefined; export function feedNoteMiss(keyid: string, reason: string): boolean; export function feedStatus(now_unix: number): any; /** * Cross-boundary `render` wrapper: turn a `VerifyResult` into the * kya-os/http answer (status, ordered headers, body). See * [`crate::render::render`]. * * The input crosses as JSON text (`JSON.stringify`), so a key whose value is * `undefined` is absent exactly as it is for the WASI and uniffi bindings, * which share [`crate::render::render_json`]. Never throws: a failure comes * back as `{ success: false, error: { code, message } }`. * * # JS signature * * ```ts * function render(input: { result: VerifyResult; options?: RenderOptions }): RenderEnvelope; * ``` */ export function render(input_js: any): any; /** * Cross-boundary `rootNeeds` wrapper: the DID-document needs of every * trusted root, which a host that warms a cache registers at startup. See * [`crate::resolution::root_needs_json`]. Never throws. * * # JS signature * * ```ts * function rootNeeds(contextJson: string): { needs: Need[] } | { error: string }; * ``` */ export function rootNeeds(context_json: string): any; /** * Validate a tenant Cedar bundle against the canonical schema WITHOUT throwing * or denying (E4.7 / #3076). Returns a `PolicyValidation` JSON object * (`{ valid, errors, warnings }`) so the dashboard's /policy-compose authoring * surface can show a typo'd attribute / wrong-type / unknown-key as a LOUD * error before the bundle is ever deployed — instead of the runtime's silent * fail-closed deny. A malformed bundle is reported inside the result, never * thrown; this is a pure author-time gate that changes no authorization verdict. * * # Errors * * Returns a thrown JS error only if serialising the result fails. * * # JS signature * * ```ts * validatePolicy(policyText: string): { valid: boolean; errors: string[]; warnings: string[] }; * ``` */ export function validatePolicy(policy_text: string): any; export function vendorKeys(): any; /** * Cross-boundary `verify` wrapper. The JS host calls `engine.verify(input, * ctxSpec)`; on success it gets a [`VerifyResult`] JSON object; on * infrastructure failure (or malformed input) it gets a thrown JS error * whose message names the failure mode. * * **Error semantics**: * * - Verification *verdicts* (Block/Challenge/etc.) surface inside the * returned `VerifyResult` — they are not thrown. * - Engine [`VerifyError`][crate::error::VerifyError] (resolver / cache / * reputation / policy infra failures) surface as thrown JS errors. * - Serde deserialisation failures (malformed JS input) surface as thrown * JS errors too, mirroring the typed-vs-thrown split. * * With `ctx.resolution: "engine-directed"` the result is either a * `VerifyResult` or `{ needs: Need[] }` (see [`crate::resolution`]); a host * tells them apart by the `needs` key. * * # JS signature * * ```ts * function verify(input: AgentRequest, ctx: ContextSpec): VerifyResult | { needs: Need[] }; * ``` */ export function verify(input_js: any, ctx_js: any): any; /** * Cross-boundary `verifyDelegation` wrapper — the standalone Layer-2-only * (`Authorization: Bearer `) path, `draft-kya-http-02` * §4.3 (issue #3344). The JS host calls * `engine.verifyDelegation(input, ctxSpec)` where `input` is a * [`DelegationVerifyInput`] (`{ credential, requiredScopes }`) and the * credential was extracted from wherever it arrived (the engine reads no * transport header). The resource server's own org DID rides on the same * [`ContextSpec`] as `resourceOrgDid`. * * Same error semantics as [`verify_wasm`]: verdicts (Permit/Block) ride * inside the returned `VerifyResult`; infra failures + malformed input throw. * Engine-directed mode answers as [`verify_wasm`] does. * * # JS signature * * ```ts * function verifyDelegation( * input: DelegationVerifyInput, * ctx: ContextSpec, * ): VerifyResult | { needs: Need[] }; * ``` */ export function verifyDelegation(input_js: any, ctx_js: any): any; /** * Cross-boundary `verifyStatusList` wrapper: verify a fetched status list * against its issuer's DID document and return its set indices. See * [`crate::status_list::verify_status_list_json`] for the request and the * result; the WASI and uniffi bindings share it. * * The request crosses as JSON text so the envelope and DID document reach * the engine as the exact response bodies the host fetched. Never throws: * every failure comes back as `{ ok: false, code, message }`. * * # JS signature * * ```ts * type StatusListResult = * | { ok: true; envelope: 'StatusList2021' | 'BitstringStatusList'; url: string; * issuer: string; issuedAt: number; expiresAt: number; setIndices: number[] } * | { ok: false; code: string; message: string }; * * function verifyStatusList(requestJson: string): StatusListResult; * ``` */ export function verifyStatusList(request_json: string): any; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_policyevaluator_free: (a: number, b: number) => void; readonly applyRuleBundle: (a: number, b: number, c: number) => number; readonly engineInfo: () => number; readonly feedAttemptFinished: (a: number, b: number) => number; readonly feedDemand: (a: number, b: number) => void; readonly feedNoteMiss: (a: number, b: number, c: number, d: number) => number; readonly feedStatus: (a: number) => number; readonly policyevaluator_authorize: (a: number, b: number, c: number) => void; readonly policyevaluator_new: (a: number, b: number, c: number) => void; readonly render: (a: number) => number; readonly rootNeeds: (a: number, b: number) => number; readonly validatePolicy: (a: number, b: number, c: number) => void; readonly vendorKeys: () => number; readonly verify: (a: number, b: number, c: number) => void; readonly verifyDelegation: (a: number, b: number, c: number) => void; readonly verifyStatusList: (a: number, b: number) => number; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export3: (a: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export4: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;