@t3foundry/tasra-sdk 0.0.0-stage → 0.3.1-next.1
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/CHANGELOG.md +148 -0
- package/LICENSE +202 -0
- package/NOTICE +94 -0
- package/README.md +137 -2
- package/SECURITY.md +115 -0
- package/dist/app/approvals.d.ts +50 -0
- package/dist/app/approvals.js +90 -0
- package/dist/app/authorization.d.ts +19 -0
- package/dist/app/authorization.js +20 -0
- package/dist/app/client.d.ts +231 -0
- package/dist/app/client.js +272 -0
- package/dist/app/creation.d.ts +73 -0
- package/dist/app/creation.js +77 -0
- package/dist/app/deployment.d.ts +36 -0
- package/dist/app/deployment.js +18 -0
- package/dist/app/identity.d.ts +211 -0
- package/dist/app/identity.js +287 -0
- package/dist/app/index.d.ts +22 -0
- package/dist/app/index.js +12 -0
- package/dist/app/manifest.d.ts +74 -0
- package/dist/app/manifest.js +120 -0
- package/dist/app/node.d.ts +30 -0
- package/dist/app/node.js +159 -0
- package/dist/app/ready-slot.d.ts +157 -0
- package/dist/app/ready-slot.js +199 -0
- package/dist/app/tasra-client.d.ts +125 -0
- package/dist/app/tasra-client.js +79 -0
- package/dist/app/viem.d.ts +10 -0
- package/dist/app/viem.js +32 -0
- package/dist/app/wallet.d.ts +126 -0
- package/dist/app/wallet.js +137 -0
- package/dist/auth/dpop.d.ts +86 -0
- package/dist/auth/dpop.js +142 -0
- package/dist/auth/holderProof.d.ts +102 -0
- package/dist/auth/holderProof.js +161 -0
- package/dist/auth/identityScope.d.ts +19 -0
- package/dist/auth/identityScope.js +82 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/oid4vp.d.ts +230 -0
- package/dist/auth/oid4vp.js +780 -0
- package/dist/auth/rego/wasm/PINS.json +11 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.d.ts +76 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm.js +379 -0
- package/dist/auth/rego/wasm/keykeeper_rego_wasm_bg.wasm +0 -0
- package/dist/auth/rego.d.ts +192 -0
- package/dist/auth/rego.js +492 -0
- package/dist/auth/verifier.d.ts +166 -0
- package/dist/auth/verifier.js +211 -0
- package/dist/chain/abis/accountantSetRegistry.d.ts +441 -0
- package/dist/chain/abis/accountantSetRegistry.js +574 -0
- package/dist/chain/abis/accountantSlashing.d.ts +2071 -0
- package/dist/chain/abis/accountantSlashing.js +2670 -0
- package/dist/chain/abis/bondingCurve.d.ts +398 -0
- package/dist/chain/abis/bondingCurve.js +521 -0
- package/dist/chain/abis/equivocationSlasher.d.ts +292 -0
- package/dist/chain/abis/equivocationSlasher.js +379 -0
- package/dist/chain/abis/fixedTasraPriceOracle.d.ts +52 -0
- package/dist/chain/abis/fixedTasraPriceOracle.js +72 -0
- package/dist/chain/abis/index.d.ts +12801 -0
- package/dist/chain/abis/index.js +64 -0
- package/dist/chain/abis/keeperShareRegistry.d.ts +519 -0
- package/dist/chain/abis/keeperShareRegistry.js +675 -0
- package/dist/chain/abis/keyRegistry.d.ts +2421 -0
- package/dist/chain/abis/keyRegistry.js +3114 -0
- package/dist/chain/abis/livenessRegistry.d.ts +402 -0
- package/dist/chain/abis/livenessRegistry.js +524 -0
- package/dist/chain/abis/mockEurc.d.ts +210 -0
- package/dist/chain/abis/mockEurc.js +276 -0
- package/dist/chain/abis/nodeRegistry.d.ts +1630 -0
- package/dist/chain/abis/nodeRegistry.js +2113 -0
- package/dist/chain/abis/platformExecutor.d.ts +328 -0
- package/dist/chain/abis/platformExecutor.js +429 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.d.ts +16 -0
- package/dist/chain/abis/prevrandaoSaltBeacon.js +24 -0
- package/dist/chain/abis/serviceRegistry.d.ts +556 -0
- package/dist/chain/abis/serviceRegistry.js +719 -0
- package/dist/chain/abis/settlement.d.ts +1624 -0
- package/dist/chain/abis/settlement.js +2096 -0
- package/dist/chain/abis/tasraSwapRouter.d.ts +92 -0
- package/dist/chain/abis/tasraSwapRouter.js +122 -0
- package/dist/chain/abis/tasraToken.d.ts +455 -0
- package/dist/chain/abis/tasraToken.js +599 -0
- package/dist/chain/abis/tasraVestingVault.d.ts +165 -0
- package/dist/chain/abis/tasraVestingVault.js +215 -0
- package/dist/chain/abis/thresholdRandomBeacon.d.ts +378 -0
- package/dist/chain/abis/thresholdRandomBeacon.js +494 -0
- package/dist/chain/abis/treasury.d.ts +301 -0
- package/dist/chain/abis/treasury.js +390 -0
- package/dist/chain/abis/verifierSetRegistry.d.ts +445 -0
- package/dist/chain/abis/verifierSetRegistry.js +579 -0
- package/dist/chain/client.d.ts +212 -0
- package/dist/chain/client.js +576 -0
- package/dist/chain/commitmentRecovery.d.ts +21 -0
- package/dist/chain/commitmentRecovery.js +44 -0
- package/dist/chain/committeeClient.d.ts +102 -0
- package/dist/chain/committeeClient.js +137 -0
- package/dist/chain/deployments.d.ts +56 -0
- package/dist/chain/deployments.js +269 -0
- package/dist/chain/discovery.d.ts +49 -0
- package/dist/chain/discovery.js +107 -0
- package/dist/chain/events.d.ts +58 -0
- package/dist/chain/events.js +125 -0
- package/dist/chain/format.d.ts +25 -0
- package/dist/chain/format.js +51 -0
- package/dist/chain/index.d.ts +41 -0
- package/dist/chain/index.js +56 -0
- package/dist/chain/manifest.d.ts +165 -0
- package/dist/chain/manifest.js +132 -0
- package/dist/chain/network-profiles.json +75 -0
- package/dist/chain/networks.d.ts +73 -0
- package/dist/chain/networks.js +62 -0
- package/dist/chain/node.d.ts +44 -0
- package/dist/chain/node.js +176 -0
- package/dist/chain/offchain.d.ts +149 -0
- package/dist/chain/offchain.js +73 -0
- package/dist/chain/provisionRule.d.ts +164 -0
- package/dist/chain/provisionRule.js +212 -0
- package/dist/chain/registeredAgent.d.ts +64 -0
- package/dist/chain/registeredAgent.js +140 -0
- package/dist/chain/registeredOperation.d.ts +49 -0
- package/dist/chain/registeredOperation.js +136 -0
- package/dist/chain/registeredRelay.d.ts +206 -0
- package/dist/chain/registeredRelay.js +312 -0
- package/dist/chain/revertReason.d.ts +14 -0
- package/dist/chain/revertReason.js +62 -0
- package/dist/chain/ruleAmendment.d.ts +80 -0
- package/dist/chain/ruleAmendment.js +195 -0
- package/dist/chain/ruleAmendmentCore.d.ts +129 -0
- package/dist/chain/ruleAmendmentCore.js +152 -0
- package/dist/chain/ruleInput.d.ts +10 -0
- package/dist/chain/ruleInput.js +13 -0
- package/dist/chain/serviceIdentity.d.ts +176 -0
- package/dist/chain/serviceIdentity.js +237 -0
- package/dist/chain/serviceProfiles.d.ts +39 -0
- package/dist/chain/serviceProfiles.js +74 -0
- package/dist/chain/services.d.ts +141 -0
- package/dist/chain/services.js +79 -0
- package/dist/chain/slotClient.d.ts +55 -0
- package/dist/chain/slotClient.js +62 -0
- package/dist/chain/slotSeed.d.ts +31 -0
- package/dist/chain/slotSeed.js +98 -0
- package/dist/chain/write.d.ts +431 -0
- package/dist/chain/write.js +958 -0
- package/dist/client/client.d.ts +112 -0
- package/dist/client/client.js +111 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/session.d.ts +67 -0
- package/dist/client/session.js +238 -0
- package/dist/committee/client.d.ts +284 -0
- package/dist/committee/client.js +351 -0
- package/dist/committee/dual-sign.d.ts +110 -0
- package/dist/committee/dual-sign.js +202 -0
- package/dist/committee/ecdsa.d.ts +36 -0
- package/dist/committee/ecdsa.js +45 -0
- package/dist/committee/extraction.d.ts +82 -0
- package/dist/committee/extraction.js +96 -0
- package/dist/committee/index.d.ts +19 -0
- package/dist/committee/index.js +13 -0
- package/dist/committee/oauth.d.ts +51 -0
- package/dist/committee/oauth.js +90 -0
- package/dist/committee/receipts.d.ts +51 -0
- package/dist/committee/receipts.js +59 -0
- package/dist/committee/request.d.ts +264 -0
- package/dist/committee/request.js +305 -0
- package/dist/committee/token.d.ts +274 -0
- package/dist/committee/token.js +418 -0
- package/dist/crypto/constants.d.ts +10 -0
- package/dist/crypto/constants.js +32 -0
- package/dist/crypto/detect.d.ts +20 -0
- package/dist/crypto/detect.js +44 -0
- package/dist/crypto/envelope.d.ts +60 -0
- package/dist/crypto/envelope.js +243 -0
- package/dist/crypto/frost.d.ts +49 -0
- package/dist/crypto/frost.js +152 -0
- package/dist/crypto/hex.d.ts +7 -0
- package/dist/crypto/hex.js +24 -0
- package/dist/crypto/ibe-blob.d.ts +114 -0
- package/dist/crypto/ibe-blob.js +208 -0
- package/dist/crypto/ibe.d.ts +88 -0
- package/dist/crypto/ibe.js +262 -0
- package/dist/crypto/index.d.ts +12 -0
- package/dist/crypto/index.js +12 -0
- package/dist/crypto/kem.d.ts +55 -0
- package/dist/crypto/kem.js +241 -0
- package/dist/decryption/client.d.ts +64 -0
- package/dist/decryption/client.js +82 -0
- package/dist/decryption/index.d.ts +2 -0
- package/dist/decryption/index.js +2 -0
- package/dist/errors.d.ts +124 -0
- package/dist/errors.js +167 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +98 -0
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.js +4 -0
- package/dist/keys/node-client.d.ts +27 -0
- package/dist/keys/node-client.js +97 -0
- package/dist/oid4vp/binding.d.ts +76 -0
- package/dist/oid4vp/binding.js +118 -0
- package/dist/oid4vp/did-web.d.ts +49 -0
- package/dist/oid4vp/did-web.js +57 -0
- package/dist/oid4vp/index.d.ts +9 -0
- package/dist/oid4vp/index.js +10 -0
- package/dist/oid4vp/jose.d.ts +166 -0
- package/dist/oid4vp/jose.js +242 -0
- package/dist/oid4vp/jwe.d.ts +30 -0
- package/dist/oid4vp/jwe.js +93 -0
- package/dist/oid4vp/oid4vci.d.ts +84 -0
- package/dist/oid4vp/oid4vci.js +85 -0
- package/dist/oid4vp/request-object.d.ts +109 -0
- package/dist/oid4vp/request-object.js +96 -0
- package/dist/oid4vp/sd-jwt.d.ts +177 -0
- package/dist/oid4vp/sd-jwt.js +208 -0
- package/dist/oid4vp/verifier-agent.d.ts +161 -0
- package/dist/oid4vp/verifier-agent.js +132 -0
- package/dist/oid4vp/wallet.d.ts +116 -0
- package/dist/oid4vp/wallet.js +108 -0
- package/dist/recipient/store.d.ts +67 -0
- package/dist/recipient/store.js +98 -0
- package/dist/signing/ecdsa.d.ts +49 -0
- package/dist/signing/ecdsa.js +79 -0
- package/dist/signing/frost.d.ts +88 -0
- package/dist/signing/frost.js +145 -0
- package/dist/signing/index.d.ts +4 -0
- package/dist/signing/index.js +3 -0
- package/dist/slots/faucet.d.ts +23 -0
- package/dist/slots/faucet.js +35 -0
- package/dist/slots/index.d.ts +2 -0
- package/dist/slots/index.js +4 -0
- package/dist/verifier-agent/index.d.ts +241 -0
- package/dist/verifier-agent/index.js +411 -0
- package/docs/DEVELOPER-EXPERIENCE.md +62 -0
- package/docs/README.md +33 -0
- package/docs/access-control.md +76 -0
- package/docs/ai-development.md +292 -0
- package/docs/api.md +338 -0
- package/docs/application-api.md +335 -0
- package/docs/architecture.md +65 -0
- package/docs/basics.md +48 -0
- package/docs/capabilities.md +86 -0
- package/docs/chain.md +153 -0
- package/docs/compatibility.md +36 -0
- package/docs/consumer-migrations.md +80 -0
- package/docs/create-slot.md +104 -0
- package/docs/document-signing.md +243 -0
- package/docs/encrypted-notes.md +129 -0
- package/docs/encryption.md +100 -0
- package/docs/errors.md +76 -0
- package/docs/flows.md +289 -0
- package/docs/fuji.md +127 -0
- package/docs/funding.md +126 -0
- package/docs/getting-started.md +94 -0
- package/docs/glossary.md +44 -0
- package/docs/installation.md +132 -0
- package/docs/manage-slot.md +95 -0
- package/docs/native-approvals.md +124 -0
- package/docs/prerequisites.md +137 -0
- package/docs/read-slot.md +41 -0
- package/docs/reference/README.md +30 -0
- package/docs/reference/app-node.md +102 -0
- package/docs/reference/app.md +1737 -0
- package/docs/reference/chain-node.md +159 -0
- package/docs/reference/chain.md +3609 -0
- package/docs/reference/committee.md +2176 -0
- package/docs/reference/main.md +4068 -0
- package/docs/reference/oid4vp.md +2547 -0
- package/docs/reference/verifier-agent.md +498 -0
- package/docs/shared-account.md +168 -0
- package/docs/signing-and-encryption.md +52 -0
- package/docs/signing.md +172 -0
- package/examples/committee-slot.ts +16 -0
- package/examples/connect-fuji.ts +41 -0
- package/examples/connect-network.ts +14 -0
- package/examples/credential-approvals.ts +46 -0
- package/examples/document-signing/README.md +59 -0
- package/examples/document-signing/backend.ts +132 -0
- package/examples/document-signing/build.mjs +19 -0
- package/examples/document-signing/config.ts +34 -0
- package/examples/document-signing/gitignore.template +9 -0
- package/examples/document-signing/model.ts +140 -0
- package/examples/document-signing/network.ts +58 -0
- package/examples/document-signing/package.json +25 -0
- package/examples/document-signing/public/index.html +27 -0
- package/examples/document-signing/public/sample.pdf +31 -0
- package/examples/document-signing/public/styles.css +531 -0
- package/examples/document-signing/server.ts +358 -0
- package/examples/document-signing/setup.ts +111 -0
- package/examples/document-signing/store.ts +105 -0
- package/examples/document-signing/tsconfig.json +24 -0
- package/examples/document-signing/verify.ts +24 -0
- package/examples/document-signing/web/app.ts +312 -0
- package/examples/document-signing/web/preview.ts +67 -0
- package/examples/document-signing/web/wallet.ts +146 -0
- package/examples/document-signing/workflow.test.ts +228 -0
- package/examples/document-signing/workflow.ts +241 -0
- package/examples/document-signing.ts +96 -0
- package/examples/encrypted-notes.ts +86 -0
- package/examples/ethers-signer.ts +204 -0
- package/examples/fund-slot.ts +73 -0
- package/examples/getting-started.ts +25 -0
- package/examples/learning-authorize.ts +23 -0
- package/examples/learning-cancel-slot.ts +11 -0
- package/examples/learning-context.ts +28 -0
- package/examples/learning-create-slot.ts +25 -0
- package/examples/learning-read-slot.ts +8 -0
- package/examples/learning-renew-slot.ts +12 -0
- package/examples/learning-sign.ts +8 -0
- package/examples/live-config.ts +71 -0
- package/examples/minimal.ts +6 -0
- package/examples/native-approvals.ts +57 -0
- package/examples/network.ts +58 -0
- package/examples/offline.ts +16 -0
- package/examples/personal-vault.ts +20 -0
- package/examples/provision-slot.ts +47 -0
- package/examples/shared-account.ts +46 -0
- package/examples/slot-address.ts +13 -0
- package/examples/slot-creation.ts +9 -0
- package/examples/tutorial-negative.ts +26 -0
- package/examples/tutorial-support.ts +76 -0
- package/examples/viem-account.ts +203 -0
- package/package.json +303 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"network_commit": "d41df79ea2ef051c18ecc9817f27a269a5d14fcb",
|
|
3
|
+
"network_tree_dirty": false,
|
|
4
|
+
"rustc": "1.97.1",
|
|
5
|
+
"wasm_bindgen": "0.2.121",
|
|
6
|
+
"regorus": "0.12.0",
|
|
7
|
+
"sha256": {
|
|
8
|
+
"keykeeper_rego_wasm_bg.wasm": "853cdecd788069b9c881904c67d4c7c2ec340386ae3a76054e0fdcfbfb112f88",
|
|
9
|
+
"keykeeper_rego_wasm.js": "d99278d5f40d7c8ae96fd32b0e02a35c4c746ccb44cc5eeb8f7a4f264ede66e4"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The allow-list this build enforces (the corpus pins it).
|
|
6
|
+
*/
|
|
7
|
+
export function allowlistV1(): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Evaluate `rule` against a presentation `{"holder": "...", "credentials": [{"format",
|
|
11
|
+
* "issuer", "claims"}]}` - the shape the fault bridge projects a sealed presentation onto.
|
|
12
|
+
* `{"ok": true}` iff the policy allows; a refusal carries the network's generic reason.
|
|
13
|
+
*/
|
|
14
|
+
export function evaluate(rule: string, presentation_json: string): string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Is `rule` a `kk_oauth` envelope? The SAME structural test every network dispatch site asks
|
|
18
|
+
* (`keykeeper_dcql::grammar`).
|
|
19
|
+
*/
|
|
20
|
+
export function isOauthEnvelope(rule: string): boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Authoring check (schema + gate, any phase) plus whether a keeper would ADMIT it today.
|
|
24
|
+
* `{"ok": true, "report": {...}, "admissible": bool, "admission_error": "..."|null}`.
|
|
25
|
+
*/
|
|
26
|
+
export function lint(envelope: string): string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Pack `(source, tokens JSON text, entrypoint)` into the committed (RFC 8785) envelope.
|
|
30
|
+
* `{"ok": true, "envelope": "<packed>"}`.
|
|
31
|
+
*/
|
|
32
|
+
export function pack(source: string, tokens_json: string, entrypoint: string): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `{"ok": true, "source": "...", "tokens": {...}, "entrypoint": "..."}`.
|
|
36
|
+
*/
|
|
37
|
+
export function unpack(envelope: string): string;
|
|
38
|
+
|
|
39
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
40
|
+
|
|
41
|
+
export interface InitOutput {
|
|
42
|
+
readonly memory: WebAssembly.Memory;
|
|
43
|
+
readonly allowlistV1: (a: number) => void;
|
|
44
|
+
readonly evaluate: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
45
|
+
readonly isOauthEnvelope: (a: number, b: number) => number;
|
|
46
|
+
readonly lint: (a: number, b: number, c: number) => void;
|
|
47
|
+
readonly pack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
48
|
+
readonly unpack: (a: number, b: number, c: number) => void;
|
|
49
|
+
readonly __wbindgen_export: (a: number) => void;
|
|
50
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
51
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
52
|
+
readonly __wbindgen_export3: (a: number, b: number) => number;
|
|
53
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
60
|
+
* a precompiled `WebAssembly.Module`.
|
|
61
|
+
*
|
|
62
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
63
|
+
*
|
|
64
|
+
* @returns {InitOutput}
|
|
65
|
+
*/
|
|
66
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
70
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
71
|
+
*
|
|
72
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
73
|
+
*
|
|
74
|
+
* @returns {Promise<InitOutput>}
|
|
75
|
+
*/
|
|
76
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/* @ts-self-types="./keykeeper_rego_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The allow-list this build enforces (the corpus pins it).
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function allowlistV1() {
|
|
8
|
+
let deferred1_0;
|
|
9
|
+
let deferred1_1;
|
|
10
|
+
try {
|
|
11
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
12
|
+
wasm.allowlistV1(retptr);
|
|
13
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
15
|
+
deferred1_0 = r0;
|
|
16
|
+
deferred1_1 = r1;
|
|
17
|
+
return getStringFromWasm0(r0, r1);
|
|
18
|
+
} finally {
|
|
19
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
20
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate `rule` against a presentation `{"holder": "...", "credentials": [{"format",
|
|
26
|
+
* "issuer", "claims"}]}` - the shape the fault bridge projects a sealed presentation onto.
|
|
27
|
+
* `{"ok": true}` iff the policy allows; a refusal carries the network's generic reason.
|
|
28
|
+
* @param {string} rule
|
|
29
|
+
* @param {string} presentation_json
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function evaluate(rule, presentation_json) {
|
|
33
|
+
let deferred3_0;
|
|
34
|
+
let deferred3_1;
|
|
35
|
+
try {
|
|
36
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
37
|
+
const ptr0 = passStringToWasm0(rule, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ptr1 = passStringToWasm0(presentation_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
40
|
+
const len1 = WASM_VECTOR_LEN;
|
|
41
|
+
wasm.evaluate(retptr, ptr0, len0, ptr1, len1);
|
|
42
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
43
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
44
|
+
deferred3_0 = r0;
|
|
45
|
+
deferred3_1 = r1;
|
|
46
|
+
return getStringFromWasm0(r0, r1);
|
|
47
|
+
} finally {
|
|
48
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
49
|
+
wasm.__wbindgen_export2(deferred3_0, deferred3_1, 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Is `rule` a `kk_oauth` envelope? The SAME structural test every network dispatch site asks
|
|
55
|
+
* (`keykeeper_dcql::grammar`).
|
|
56
|
+
* @param {string} rule
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
export function isOauthEnvelope(rule) {
|
|
60
|
+
const ptr0 = passStringToWasm0(rule, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
61
|
+
const len0 = WASM_VECTOR_LEN;
|
|
62
|
+
const ret = wasm.isOauthEnvelope(ptr0, len0);
|
|
63
|
+
return ret !== 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Authoring check (schema + gate, any phase) plus whether a keeper would ADMIT it today.
|
|
68
|
+
* `{"ok": true, "report": {...}, "admissible": bool, "admission_error": "..."|null}`.
|
|
69
|
+
* @param {string} envelope
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
export function lint(envelope) {
|
|
73
|
+
let deferred2_0;
|
|
74
|
+
let deferred2_1;
|
|
75
|
+
try {
|
|
76
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
77
|
+
const ptr0 = passStringToWasm0(envelope, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
wasm.lint(retptr, ptr0, len0);
|
|
80
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
81
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
82
|
+
deferred2_0 = r0;
|
|
83
|
+
deferred2_1 = r1;
|
|
84
|
+
return getStringFromWasm0(r0, r1);
|
|
85
|
+
} finally {
|
|
86
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
87
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Pack `(source, tokens JSON text, entrypoint)` into the committed (RFC 8785) envelope.
|
|
93
|
+
* `{"ok": true, "envelope": "<packed>"}`.
|
|
94
|
+
* @param {string} source
|
|
95
|
+
* @param {string} tokens_json
|
|
96
|
+
* @param {string} entrypoint
|
|
97
|
+
* @returns {string}
|
|
98
|
+
*/
|
|
99
|
+
export function pack(source, tokens_json, entrypoint) {
|
|
100
|
+
let deferred4_0;
|
|
101
|
+
let deferred4_1;
|
|
102
|
+
try {
|
|
103
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
104
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
105
|
+
const len0 = WASM_VECTOR_LEN;
|
|
106
|
+
const ptr1 = passStringToWasm0(tokens_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
107
|
+
const len1 = WASM_VECTOR_LEN;
|
|
108
|
+
const ptr2 = passStringToWasm0(entrypoint, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
109
|
+
const len2 = WASM_VECTOR_LEN;
|
|
110
|
+
wasm.pack(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
111
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
112
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
113
|
+
deferred4_0 = r0;
|
|
114
|
+
deferred4_1 = r1;
|
|
115
|
+
return getStringFromWasm0(r0, r1);
|
|
116
|
+
} finally {
|
|
117
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
118
|
+
wasm.__wbindgen_export2(deferred4_0, deferred4_1, 1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* `{"ok": true, "source": "...", "tokens": {...}, "entrypoint": "..."}`.
|
|
124
|
+
* @param {string} envelope
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
export function unpack(envelope) {
|
|
128
|
+
let deferred2_0;
|
|
129
|
+
let deferred2_1;
|
|
130
|
+
try {
|
|
131
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
132
|
+
const ptr0 = passStringToWasm0(envelope, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
133
|
+
const len0 = WASM_VECTOR_LEN;
|
|
134
|
+
wasm.unpack(retptr, ptr0, len0);
|
|
135
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
136
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
137
|
+
deferred2_0 = r0;
|
|
138
|
+
deferred2_1 = r1;
|
|
139
|
+
return getStringFromWasm0(r0, r1);
|
|
140
|
+
} finally {
|
|
141
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
142
|
+
wasm.__wbindgen_export2(deferred2_0, deferred2_1, 1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function __wbg_get_imports() {
|
|
146
|
+
const import0 = {
|
|
147
|
+
__proto__: null,
|
|
148
|
+
__wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
|
|
149
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
150
|
+
}, arguments); },
|
|
151
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
152
|
+
takeObject(arg0);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
__proto__: null,
|
|
157
|
+
"./keykeeper_rego_wasm_bg.js": import0,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function addHeapObject(obj) {
|
|
162
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
163
|
+
const idx = heap_next;
|
|
164
|
+
heap_next = heap[idx];
|
|
165
|
+
|
|
166
|
+
heap[idx] = obj;
|
|
167
|
+
return idx;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function dropObject(idx) {
|
|
171
|
+
if (idx < 1028) return;
|
|
172
|
+
heap[idx] = heap_next;
|
|
173
|
+
heap_next = idx;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
177
|
+
ptr = ptr >>> 0;
|
|
178
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let cachedDataViewMemory0 = null;
|
|
182
|
+
function getDataViewMemory0() {
|
|
183
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
184
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
185
|
+
}
|
|
186
|
+
return cachedDataViewMemory0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function getStringFromWasm0(ptr, len) {
|
|
190
|
+
return decodeText(ptr >>> 0, len);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
let cachedUint8ArrayMemory0 = null;
|
|
194
|
+
function getUint8ArrayMemory0() {
|
|
195
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
196
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
197
|
+
}
|
|
198
|
+
return cachedUint8ArrayMemory0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getObject(idx) { return heap[idx]; }
|
|
202
|
+
|
|
203
|
+
function handleError(f, args) {
|
|
204
|
+
try {
|
|
205
|
+
return f.apply(this, args);
|
|
206
|
+
} catch (e) {
|
|
207
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let heap = new Array(1024).fill(undefined);
|
|
212
|
+
heap.push(undefined, null, true, false);
|
|
213
|
+
|
|
214
|
+
let heap_next = heap.length;
|
|
215
|
+
|
|
216
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
217
|
+
if (realloc === undefined) {
|
|
218
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
219
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
220
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
221
|
+
WASM_VECTOR_LEN = buf.length;
|
|
222
|
+
return ptr;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let len = arg.length;
|
|
226
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
227
|
+
|
|
228
|
+
const mem = getUint8ArrayMemory0();
|
|
229
|
+
|
|
230
|
+
let offset = 0;
|
|
231
|
+
|
|
232
|
+
for (; offset < len; offset++) {
|
|
233
|
+
const code = arg.charCodeAt(offset);
|
|
234
|
+
if (code > 0x7F) break;
|
|
235
|
+
mem[ptr + offset] = code;
|
|
236
|
+
}
|
|
237
|
+
if (offset !== len) {
|
|
238
|
+
if (offset !== 0) {
|
|
239
|
+
arg = arg.slice(offset);
|
|
240
|
+
}
|
|
241
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
242
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
243
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
244
|
+
|
|
245
|
+
offset += ret.written;
|
|
246
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
WASM_VECTOR_LEN = offset;
|
|
250
|
+
return ptr;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function takeObject(idx) {
|
|
254
|
+
const ret = getObject(idx);
|
|
255
|
+
dropObject(idx);
|
|
256
|
+
return ret;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
260
|
+
cachedTextDecoder.decode();
|
|
261
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
262
|
+
let numBytesDecoded = 0;
|
|
263
|
+
function decodeText(ptr, len) {
|
|
264
|
+
numBytesDecoded += len;
|
|
265
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
266
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
267
|
+
cachedTextDecoder.decode();
|
|
268
|
+
numBytesDecoded = len;
|
|
269
|
+
}
|
|
270
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const cachedTextEncoder = new TextEncoder();
|
|
274
|
+
|
|
275
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
276
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
277
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
278
|
+
view.set(buf);
|
|
279
|
+
return {
|
|
280
|
+
read: arg.length,
|
|
281
|
+
written: buf.length
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
let WASM_VECTOR_LEN = 0;
|
|
287
|
+
|
|
288
|
+
let wasmModule, wasmInstance, wasm;
|
|
289
|
+
function __wbg_finalize_init(instance, module) {
|
|
290
|
+
wasmInstance = instance;
|
|
291
|
+
wasm = instance.exports;
|
|
292
|
+
wasmModule = module;
|
|
293
|
+
cachedDataViewMemory0 = null;
|
|
294
|
+
cachedUint8ArrayMemory0 = null;
|
|
295
|
+
return wasm;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function __wbg_load(module, imports) {
|
|
299
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
300
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
301
|
+
try {
|
|
302
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
305
|
+
|
|
306
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
307
|
+
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);
|
|
308
|
+
|
|
309
|
+
} else { throw e; }
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const bytes = await module.arrayBuffer();
|
|
314
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
315
|
+
} else {
|
|
316
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
317
|
+
|
|
318
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
319
|
+
return { instance, module };
|
|
320
|
+
} else {
|
|
321
|
+
return instance;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function expectedResponseType(type) {
|
|
326
|
+
switch (type) {
|
|
327
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
328
|
+
}
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function initSync(module) {
|
|
334
|
+
if (wasm !== undefined) return wasm;
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
if (module !== undefined) {
|
|
338
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
339
|
+
({module} = module)
|
|
340
|
+
} else {
|
|
341
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const imports = __wbg_get_imports();
|
|
346
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
347
|
+
module = new WebAssembly.Module(module);
|
|
348
|
+
}
|
|
349
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
350
|
+
return __wbg_finalize_init(instance, module);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async function __wbg_init(module_or_path) {
|
|
354
|
+
if (wasm !== undefined) return wasm;
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
if (module_or_path !== undefined) {
|
|
358
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
359
|
+
({module_or_path} = module_or_path)
|
|
360
|
+
} else {
|
|
361
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (module_or_path === undefined) {
|
|
366
|
+
module_or_path = new URL('keykeeper_rego_wasm_bg.wasm', import.meta.url);
|
|
367
|
+
}
|
|
368
|
+
const imports = __wbg_get_imports();
|
|
369
|
+
|
|
370
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
371
|
+
module_or_path = fetch(module_or_path);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
375
|
+
|
|
376
|
+
return __wbg_finalize_init(instance, module);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { TasraError } from '../errors.js';
|
|
2
|
+
/** The single top-level member that marks a rule as an OAuth policy envelope. */
|
|
3
|
+
export declare const OAUTH_ENVELOPE_KEY = "kk_oauth";
|
|
4
|
+
/** Entrypoint the network's example policies use (`package tasra.slot`). */
|
|
5
|
+
export declare const DEFAULT_REGO_ENTRYPOINT = "data.tasra.slot.allow";
|
|
6
|
+
/**
|
|
7
|
+
* The refusal text a holder sees when an envelope's policy denies. Deliberately generic: rule
|
|
8
|
+
* contents are confidential to the operator set, so a refusal never names a claim or clause.
|
|
9
|
+
*/
|
|
10
|
+
export declare const REGO_POLICY_REFUSED = "kk_oauth policy refused";
|
|
11
|
+
/**
|
|
12
|
+
* SHA-256 of the vendored `keykeeper_rego_wasm_bg.wasm`, as recorded in its PINS.json.
|
|
13
|
+
* `scripts/check-rego-pins.mjs` asserts the two agree, so this constant cannot drift from the
|
|
14
|
+
* pinned build.
|
|
15
|
+
*/
|
|
16
|
+
export declare const REGO_WASM_SHA256 = "853cdecd788069b9c881904c67d4c7c2ec340386ae3a76054e0fdcfbfb112f88";
|
|
17
|
+
/**
|
|
18
|
+
* Whether `rule` is a `kk_oauth` policy envelope: a JSON object whose only member is
|
|
19
|
+
* `kk_oauth`. Structural only - the envelope's contents are not validated (use
|
|
20
|
+
* {@link lintEnvelope}). Total: never throws.
|
|
21
|
+
*
|
|
22
|
+
* Matches the network's grammar dispatch exactly, so the SDK commits an envelope the same way
|
|
23
|
+
* every keeper and verifier re-derives it. A duplicated `kk_oauth` member is not an envelope,
|
|
24
|
+
* and neither is anything longer than `MAX_RULE_LEN` UTF-8 bytes.
|
|
25
|
+
*
|
|
26
|
+
* @param rule - Clear rule text to classify.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isOauthEnvelope(rule: string): boolean;
|
|
29
|
+
/** One token an envelope trusts: its format, issuers, audiences and freshness bound. */
|
|
30
|
+
export interface OauthTokenSpec {
|
|
31
|
+
/** Token format; phase 1 admits `oauth+access-token+dpop` only. */
|
|
32
|
+
format: string;
|
|
33
|
+
/** Accepted issuers, each byte-equal to the IdP's discovery `issuer`. */
|
|
34
|
+
iss: string[];
|
|
35
|
+
/** Audiences the token must carry (the platform audience the tenant registered). */
|
|
36
|
+
aud: string[];
|
|
37
|
+
/** Maximum token age in seconds (1..=86400). */
|
|
38
|
+
max_age_secs: number;
|
|
39
|
+
/** Top-level claim names also exposed lower-cased under `claims_ci`. */
|
|
40
|
+
ci_claims?: string[];
|
|
41
|
+
}
|
|
42
|
+
/** The envelope's token map: token id (`^[a-z][a-z0-9_]{0,31}$`) to its specification. */
|
|
43
|
+
export type OauthTokens = Record<string, OauthTokenSpec>;
|
|
44
|
+
/** The authored parts of an envelope. */
|
|
45
|
+
export interface OauthPolicyInput {
|
|
46
|
+
/** Rego v1 module source, committed byte for byte. */
|
|
47
|
+
policy: string;
|
|
48
|
+
/** Token specifications, as an object or as the JSON text of one. */
|
|
49
|
+
tokens: OauthTokens | string;
|
|
50
|
+
/** Rule to evaluate; defaults to {@link DEFAULT_REGO_ENTRYPOINT}. */
|
|
51
|
+
entrypoint?: string;
|
|
52
|
+
}
|
|
53
|
+
/** An envelope taken apart: the exact policy source, its tokens and its entrypoint. */
|
|
54
|
+
export interface UnpackedEnvelope {
|
|
55
|
+
/** Rego source exactly as committed. */
|
|
56
|
+
policy: string;
|
|
57
|
+
/** Token specifications. */
|
|
58
|
+
tokens: OauthTokens;
|
|
59
|
+
/** Entrypoint rule. */
|
|
60
|
+
entrypoint: string;
|
|
61
|
+
}
|
|
62
|
+
/** What the static gate found in a policy. */
|
|
63
|
+
export interface EnvelopeGateReport {
|
|
64
|
+
/** The module's package. */
|
|
65
|
+
package: string;
|
|
66
|
+
/** Number of rules defined. */
|
|
67
|
+
rules: number;
|
|
68
|
+
/** User-defined function names. */
|
|
69
|
+
functions: string[];
|
|
70
|
+
/** Builtins the policy calls (all from the allow-list). */
|
|
71
|
+
builtins: string[];
|
|
72
|
+
/** Token ids the policy reads. */
|
|
73
|
+
tokensRead: string[];
|
|
74
|
+
/** Deepest iteration nesting. */
|
|
75
|
+
maxIterDepth: number;
|
|
76
|
+
}
|
|
77
|
+
/** Result of {@link lintEnvelope}. */
|
|
78
|
+
export interface EnvelopeLint {
|
|
79
|
+
/** The gate's report. */
|
|
80
|
+
report: EnvelopeGateReport;
|
|
81
|
+
/** Whether a keeper would store this envelope today (current phase limits included). */
|
|
82
|
+
admissible: boolean;
|
|
83
|
+
/** Why it is not admissible, when it is not. */
|
|
84
|
+
admissionError?: string;
|
|
85
|
+
}
|
|
86
|
+
/** The presentation an envelope is evaluated against: the verified claims of each token. */
|
|
87
|
+
export interface OauthPresentation {
|
|
88
|
+
/** Stable holder identity (`{iss}#{sub}` on the network). */
|
|
89
|
+
holder: string;
|
|
90
|
+
/** One entry per presented token. */
|
|
91
|
+
credentials: {
|
|
92
|
+
/** Token format, e.g. `oauth+access-token+dpop`. */
|
|
93
|
+
format: string;
|
|
94
|
+
/** The token's `iss`. */
|
|
95
|
+
issuer: string;
|
|
96
|
+
/** The token's verified payload. */
|
|
97
|
+
claims: Record<string, unknown>;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A local evaluation verdict. `reject`: the policy (or a platform pin such as issuer or
|
|
102
|
+
* audience) refused this presentation. `malformed`: the rule itself is unusable.
|
|
103
|
+
*/
|
|
104
|
+
export type EnvelopeVerdict = {
|
|
105
|
+
/** The policy allows this presentation. */
|
|
106
|
+
allow: true;
|
|
107
|
+
} | {
|
|
108
|
+
/** The policy does not allow this presentation. */
|
|
109
|
+
allow: false;
|
|
110
|
+
/** `reject` for a refused presentation, `malformed` for an unusable rule or input. */
|
|
111
|
+
kind: 'reject' | 'malformed';
|
|
112
|
+
/** The network's refusal text; a policy refusal is the generic {@link REGO_POLICY_REFUSED}. */
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
/** A refused envelope operation: the rule or its authored parts are malformed. */
|
|
116
|
+
export declare class RegoEnvelopeError extends TasraError {
|
|
117
|
+
/** `malformed` for a schema or gate failure; `reject` never reaches this class. */
|
|
118
|
+
readonly kind: 'malformed' | 'reject';
|
|
119
|
+
constructor(kind: 'malformed' | 'reject', message: string);
|
|
120
|
+
}
|
|
121
|
+
/** The loaded engine. Every method is synchronous once loaded. */
|
|
122
|
+
export interface RegoEngine {
|
|
123
|
+
/** Pack authored parts into the canonical envelope; throws {@link RegoEnvelopeError}. */
|
|
124
|
+
pack(input: OauthPolicyInput): string;
|
|
125
|
+
/** Take an envelope apart; throws {@link RegoEnvelopeError}. */
|
|
126
|
+
unpack(envelope: string): UnpackedEnvelope;
|
|
127
|
+
/** Schema + gate report and admissibility; throws {@link RegoEnvelopeError} when malformed. */
|
|
128
|
+
lint(envelope: string): EnvelopeLint;
|
|
129
|
+
/**
|
|
130
|
+
* Evaluate the policy against a presentation (an object, or its JSON text verbatim - the
|
|
131
|
+
* lossless form for claims holding integers beyond 2^53). Never throws for a refusal.
|
|
132
|
+
*/
|
|
133
|
+
evaluate(rule: string, presentation: OauthPresentation | string): EnvelopeVerdict;
|
|
134
|
+
/** The builtin allow-list this build enforces. */
|
|
135
|
+
allowlistV1(): string[];
|
|
136
|
+
}
|
|
137
|
+
/** Where {@link loadRego} reads the module from. */
|
|
138
|
+
export interface LoadRegoOptions {
|
|
139
|
+
/**
|
|
140
|
+
* The .wasm bytes, or a URL to fetch them from. Defaults to the module shipped beside this
|
|
141
|
+
* file. Whatever the source, the bytes must hash to {@link REGO_WASM_SHA256}.
|
|
142
|
+
*/
|
|
143
|
+
wasm?: BufferSource | URL | string;
|
|
144
|
+
/** HTTP implementation used for a non-`file:` URL. */
|
|
145
|
+
fetchImpl?: typeof fetch;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Load the policy engine once and reuse it. The module's SHA-256 is verified before it is
|
|
149
|
+
* instantiated; a mismatch refuses to load. Concurrent callers share one load.
|
|
150
|
+
*
|
|
151
|
+
* In a bundler that does not emit assets referenced through `new URL(..., import.meta.url)`,
|
|
152
|
+
* pass `wasm` explicitly (bytes or a URL).
|
|
153
|
+
*
|
|
154
|
+
* @param opts - Optional module source and HTTP implementation.
|
|
155
|
+
*/
|
|
156
|
+
export declare function loadRego(opts?: LoadRegoOptions): Promise<RegoEngine>;
|
|
157
|
+
/**
|
|
158
|
+
* Pack a Rego policy and its token specifications into the canonical (RFC 8785) envelope a
|
|
159
|
+
* slot commits to. The policy source is committed byte for byte - reformatting it is an
|
|
160
|
+
* amendment. Refuses (with {@link RegoEnvelopeError}) anything the static gate refuses.
|
|
161
|
+
*
|
|
162
|
+
* @param policy - Rego v1 module source.
|
|
163
|
+
* @param tokens - Token specifications (object or JSON text). Duplicate keys in JSON text are refused.
|
|
164
|
+
* @param entrypoint - Rule to evaluate; defaults to {@link DEFAULT_REGO_ENTRYPOINT}.
|
|
165
|
+
* @returns The envelope string to pass as the slot's rule.
|
|
166
|
+
*/
|
|
167
|
+
export declare function packEnvelope(policy: string, tokens: OauthTokens | string, entrypoint?: string): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Take an envelope apart into its exact policy source, tokens and entrypoint.
|
|
170
|
+
* `packEnvelope(unpacked.policy, unpacked.tokens, unpacked.entrypoint)` reproduces it.
|
|
171
|
+
*
|
|
172
|
+
* @param envelope - Envelope rule text.
|
|
173
|
+
*/
|
|
174
|
+
export declare function unpackEnvelope(envelope: string): Promise<UnpackedEnvelope>;
|
|
175
|
+
/**
|
|
176
|
+
* Run the schema and static gate and report whether a keeper would store the envelope today.
|
|
177
|
+
* Throws {@link RegoEnvelopeError} when the envelope is malformed; an envelope valid in a later
|
|
178
|
+
* phase but not admissible now returns `admissible: false` with the reason.
|
|
179
|
+
*
|
|
180
|
+
* @param envelope - Envelope rule text.
|
|
181
|
+
*/
|
|
182
|
+
export declare function lintEnvelope(envelope: string): Promise<EnvelopeLint>;
|
|
183
|
+
/**
|
|
184
|
+
* Evaluate an envelope against a presentation locally - the same gate and evaluator the
|
|
185
|
+
* network's verifiers run. Advisory: the network still verifies the token, its DPoP proof,
|
|
186
|
+
* its age and audience before any policy runs, which this does not.
|
|
187
|
+
*
|
|
188
|
+
* @param rule - Envelope rule text.
|
|
189
|
+
* @param presentation - Holder and the verified claims of each presented token, or its JSON
|
|
190
|
+
* text passed verbatim (keeps integers beyond 2^53 exact, as the network reads them).
|
|
191
|
+
*/
|
|
192
|
+
export declare function evaluateEnvelope(rule: string, presentation: OauthPresentation | string): Promise<EnvelopeVerdict>;
|