@aithorized/core 0.1.0 → 0.1.3

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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 The aithorized authors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The aithorized authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,30 +1,30 @@
1
- # @aithorized/core
2
-
3
- The deterministic core of [aithorized](https://aithorized.dev): what the SDK, the MCP proxy and the hooks use to decide whether a tool call may run. No network and no state. Node 20 or later.
4
-
5
- ```bash
6
- npm install @aithorized/core
7
- ```
8
-
9
- Most integrations want [`@aithorized/sdk`](https://www.npmjs.com/package/@aithorized/sdk) instead. Use this package to verify decisions yourself, or to port the protocol to another language.
10
-
11
- ## What is in it
12
-
13
- - **Canonical JSON and hashing**: RFC 8785 (JCS) and the SHA-256 payload hash every signature commits to.
14
- - **Signatures**: ECDSA P-256 for device decisions and Ed25519 for policy bundles, with domain-separated signing inputs.
15
- - **Policy**: loading, matching, evaluation, and a merge that can only make a policy stricter.
16
- - **Verification**: `verifyDecisionBundle` checks a signed decision against the payload that is about to run.
17
- - **Lifecycle helpers**: the local deadline and the redaction of previews.
18
-
19
- | Import | |
20
- |---|---|
21
- | `@aithorized/core` | Everything above |
22
- | `@aithorized/core/policy` | Policy evaluation only, safe for browsers |
23
- | `@aithorized/core/kill-switch` | Local pause helpers |
24
- | `@aithorized/core/vectors` | Loaders for the test vectors |
25
-
26
- ## Test vectors
27
-
28
- `test-vectors/` ships with the package: canonical JSON, payload hashes, signing inputs, policy evaluation and bundle verification, as JSON. An implementation in another language is correct when it reproduces them byte for byte.
29
-
30
- MIT.
1
+ # @aithorized/core
2
+
3
+ The deterministic core of [aithorized](https://aithorized.dev): what the SDK, the MCP proxy and the hooks use to decide whether a tool call may run. No network and no state. Node 20 or later.
4
+
5
+ ```bash
6
+ npm install @aithorized/core
7
+ ```
8
+
9
+ Most integrations want [`@aithorized/sdk`](https://www.npmjs.com/package/@aithorized/sdk) instead. Use this package to verify decisions yourself, or to port the protocol to another language.
10
+
11
+ ## What is in it
12
+
13
+ - **Canonical JSON and hashing**: RFC 8785 (JCS) and the SHA-256 payload hash every signature commits to.
14
+ - **Signatures**: ECDSA P-256 for device decisions and Ed25519 for policy bundles, with domain-separated signing inputs.
15
+ - **Policy**: loading, matching, evaluation, and a merge that can only make a policy stricter.
16
+ - **Verification**: `verifyDecisionBundle` checks a signed decision against the payload that is about to run.
17
+ - **Lifecycle helpers**: the local deadline and the redaction of previews.
18
+
19
+ | Import | |
20
+ |---|---|
21
+ | `@aithorized/core` | Everything above |
22
+ | `@aithorized/core/policy` | Policy evaluation only, safe for browsers |
23
+ | `@aithorized/core/kill-switch` | Local pause helpers |
24
+ | `@aithorized/core/vectors` | Loaders for the test vectors |
25
+
26
+ ## Test vectors
27
+
28
+ `test-vectors/` ships with the package: canonical JSON, payload hashes, signing inputs, policy evaluation and bundle verification, as JSON. An implementation in another language is correct when it reproduces them byte for byte.
29
+
30
+ MIT.
package/dist/index.d.ts CHANGED
@@ -13,12 +13,12 @@ export { DECISION_DOMAIN, ACTION_DOMAIN, HTTP_DOMAIN, WS_DOMAIN, ENROLL_DOMAIN,
13
13
  export { RISK_ORDER, MIN_TTL_SECONDS, MAX_TTL_SECONDS, clampTtl, evaluatePolicy } from './policy/evaluate.js';
14
14
  export { toolMatches, argMatches, ruleMatches, compilePolicyRegex } from './policy/match.js';
15
15
  export { mergePolicies, strictnessOf } from './policy/merge.js';
16
- export { activePause, assertPauseLimits, MAX_PAUSE_MS } from './policy/pause.js';
16
+ export { activePause, assertPauseLimits, MAX_PAUSE_MS, PAUSE_MODES } from './policy/pause.js';
17
17
  export type { MergeOptions } from './policy/merge.js';
18
18
  export { STALE_AFTER_MS, verifyBundle, pinnedKeyFor, bundleStateFromVerification, assertOk, bundleSigningContent } from './policy/bundle.js';
19
19
  export type { BundleStatus, BundleVerification, PinnedPolicyKey, PinnedPolicyKeys } from './policy/bundle.js';
20
20
  export { loadPolicyYaml, parsePolicyJson, validateRules } from './policy/load.js';
21
- export type { RiskLevel, Effect, UnmatchedDefault, ArgPredicate, RuleMatch, PolicyRule, PolicyDefaults, PolicyDocument, AutoRule, Pause, PolicyBundle, EffectivePolicy, EvalInput, EvalFlags, EvalReason, EvalResult } from './policy/types.js';
21
+ export type { RiskLevel, Effect, UnmatchedDefault, ArgPredicate, RuleMatch, PolicyRule, PolicyDefaults, PolicyDocument, AutoRule, Pause, PauseMode, PolicyBundle, EffectivePolicy, EvalInput, EvalFlags, EvalReason, EvalResult } from './policy/types.js';
22
22
  export { CLOCK_SKEW_ALLOWANCE_MS, MAX_CREATE_ATTEMPTS, createLocalDeadline, shouldRetryCreate, awaitResolutionBeforeDeadline } from './lifecycle/deadline.js';
23
23
  export type { LocalDeadline } from './lifecycle/deadline.js';
24
24
  export { verifyDecisionBundle, keyClassCanDecide, KEY_CLASSES, DIRECTORY_DOMAIN, directorySigningInput, verifyDirectory } from './lifecycle/verify.js';
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export { DECISION_DOMAIN, ACTION_DOMAIN, HTTP_DOMAIN, WS_DOMAIN, ENROLL_DOMAIN,
12
12
  export { RISK_ORDER, MIN_TTL_SECONDS, MAX_TTL_SECONDS, clampTtl, evaluatePolicy } from './policy/evaluate.js';
13
13
  export { toolMatches, argMatches, ruleMatches, compilePolicyRegex } from './policy/match.js';
14
14
  export { mergePolicies, strictnessOf } from './policy/merge.js';
15
- export { activePause, assertPauseLimits, MAX_PAUSE_MS } from './policy/pause.js';
15
+ export { activePause, assertPauseLimits, MAX_PAUSE_MS, PAUSE_MODES } from './policy/pause.js';
16
16
  export { STALE_AFTER_MS, verifyBundle, pinnedKeyFor, bundleStateFromVerification, assertOk, bundleSigningContent } from './policy/bundle.js';
17
17
  export { loadPolicyYaml, parsePolicyJson, validateRules } from './policy/load.js';
18
18
  export { CLOCK_SKEW_ALLOWANCE_MS, MAX_CREATE_ATTEMPTS, createLocalDeadline, shouldRetryCreate, awaitResolutionBeforeDeadline } from './lifecycle/deadline.js';
@@ -5,6 +5,6 @@
5
5
  export { loadPolicyYaml, parsePolicyJson, validateRules } from './load.js';
6
6
  export { evaluatePolicy, clampTtl, MIN_TTL_SECONDS, MAX_TTL_SECONDS, RISK_ORDER } from './evaluate.js';
7
7
  export { toolMatches, argMatches, ruleMatches } from './match.js';
8
- export { activePause, MAX_PAUSE_MS } from './pause.js';
8
+ export { activePause, MAX_PAUSE_MS, PAUSE_MODES } from './pause.js';
9
9
  export { PolicyError } from '../errors.js';
10
- export type { ArgPredicate, AutoRule, Effect, EffectivePolicy, EvalFlags, EvalInput, EvalReason, EvalResult, Pause, PolicyDefaults, PolicyDocument, PolicyRule, RiskLevel, RuleMatch, UnmatchedDefault } from './types.js';
10
+ export type { ArgPredicate, AutoRule, Effect, EffectivePolicy, EvalFlags, EvalInput, EvalReason, EvalResult, Pause, PauseMode, PolicyDefaults, PolicyDocument, PolicyRule, RiskLevel, RuleMatch, UnmatchedDefault } from './types.js';
@@ -5,5 +5,5 @@
5
5
  export { loadPolicyYaml, parsePolicyJson, validateRules } from './load.js';
6
6
  export { evaluatePolicy, clampTtl, MIN_TTL_SECONDS, MAX_TTL_SECONDS, RISK_ORDER } from './evaluate.js';
7
7
  export { toolMatches, argMatches, ruleMatches } from './match.js';
8
- export { activePause, MAX_PAUSE_MS } from './pause.js';
8
+ export { activePause, MAX_PAUSE_MS, PAUSE_MODES } from './pause.js';
9
9
  export { PolicyError } from '../errors.js';
@@ -115,6 +115,10 @@ export function evaluatePolicy(policy, input, flags = {}) {
115
115
  if (observeRule) {
116
116
  return { effect: 'OBSERVE', reason: 'OBSERVE_RULE', ruleId: observeRule.id, degraded };
117
117
  }
118
+ const allowRule = firstMatchingRule(rules, (r) => r.effect === 'ALLOW' && ruleMatches(r.match, input));
119
+ if (allowRule) {
120
+ return { effect: 'ALLOW', reason: 'ALLOW_RULE', ruleId: allowRule.id, degraded };
121
+ }
118
122
  const unmatched = policy.defaults.unmatched;
119
123
  if (unmatched === 'ALLOW') {
120
124
  return { effect: 'ALLOW', reason: 'DEFAULT', degraded };
@@ -1,6 +1,7 @@
1
- import type { EffectivePolicy, Pause } from './types.js';
1
+ import type { EffectivePolicy, Pause, PauseMode } from './types.js';
2
2
  /** A pause lasts at most this long after it is set (like a temporary auto-approval, docs/05 T-08). */
3
3
  export declare const MAX_PAUSE_MS: number;
4
+ export declare const PAUSE_MODES: readonly PauseMode[];
4
5
  /**
5
6
  * The pause in force for `agentId` at `nowMs`, if any. Only a pause carried by a valid signed bundle counts: a
6
7
  * degraded policy (stale, invalid or missing bundle) is never paused, and a pause scoped to agents does not
@@ -8,4 +9,4 @@ export declare const MAX_PAUSE_MS: number;
8
9
  */
9
10
  export declare function activePause(policy: EffectivePolicy, agentId: string | undefined, nowMs: number): Pause | undefined;
10
11
  /** Server-side limits on a new pause: a valid `until`, in the future and at most 24 h away. */
11
- export declare function assertPauseLimits(pause: Pick<Pause, 'until' | 'agentIds'>, nowMs: number): void;
12
+ export declare function assertPauseLimits(pause: Pick<Pause, 'until' | 'agentIds' | 'mode' | 'includeCritical'>, nowMs: number): void;
@@ -1,6 +1,7 @@
1
1
  import { PolicyError } from '../errors.js';
2
2
  /** A pause lasts at most this long after it is set (like a temporary auto-approval, docs/05 T-08). */
3
3
  export const MAX_PAUSE_MS = 24 * 60 * 60 * 1000;
4
+ export const PAUSE_MODES = ['PASSTHROUGH', 'AUTO_APPROVE', 'AUTO_DENY'];
4
5
  /**
5
6
  * The pause in force for `agentId` at `nowMs`, if any. Only a pause carried by a valid signed bundle counts: a
6
7
  * degraded policy (stale, invalid or missing bundle) is never paused, and a pause scoped to agents does not
@@ -31,4 +32,10 @@ export function assertPauseLimits(pause, nowMs) {
31
32
  if (pause.agentIds !== undefined && (!Array.isArray(pause.agentIds) || pause.agentIds.some((a) => typeof a !== 'string'))) {
32
33
  throw new PolicyError('POLICY_INVALID', 'pause: agentIds must be a list of agent ids');
33
34
  }
35
+ if (pause.mode !== undefined && !PAUSE_MODES.includes(pause.mode)) {
36
+ throw new PolicyError('POLICY_INVALID', `pause: invalid mode ${String(pause.mode)}`);
37
+ }
38
+ if (pause.includeCritical !== undefined && typeof pause.includeCritical !== 'boolean') {
39
+ throw new PolicyError('POLICY_INVALID', 'pause: includeCritical must be a boolean');
40
+ }
34
41
  }
@@ -65,11 +65,14 @@ export interface AutoRule {
65
65
  /** Uses consumed so far (supplied by the caller; 0 by default). */
66
66
  uses?: number;
67
67
  }
68
+ export type PauseMode = 'PASSTHROUGH' | 'AUTO_APPROVE' | 'AUTO_DENY';
68
69
  /**
69
- * A human-signed pause of the guardrail (replaces the local kill-switch file of spec 005). Set only by a
70
+ * A human-signed pause or temporary override of the guardrail (replaces the local kill-switch file of spec 005). Set only by a
70
71
  * STRONG-signed `pause.activate` from an OWNER or ADMIN phone, carried in the signed bundle, never in a policy
71
- * document (so no YAML, dashboard edit or local policy can add one). While active for an agent, the interception
72
- * layer does not gate its calls. It ends at `until` (at most 24 h after it was set) or when resumed.
72
+ * document (so no YAML, dashboard edit or local policy can add one). While active for an agent, `PASSTHROUGH`
73
+ * (the default) lets calls through ungated, `AUTO_APPROVE` approves `REQUIRE_APPROVAL` calls (respecting `DENY` and,
74
+ * unless `includeCritical` is true, `CRITICAL`), and `AUTO_DENY` blocks `REQUIRE_APPROVAL` calls without revoking keys.
75
+ * It ends at `until` (at most 24 h after it was set) or when resumed.
73
76
  */
74
77
  export interface Pause {
75
78
  id: string;
@@ -79,6 +82,10 @@ export interface Pause {
79
82
  agentIds?: string[];
80
83
  /** User who signed it. */
81
84
  by?: string;
85
+ /** Temporary override mode. Absent means `'PASSTHROUGH'`. */
86
+ mode?: PauseMode;
87
+ /** Only for `mode === 'AUTO_APPROVE'`: whether CRITICAL calls are also auto-approved (default false). */
88
+ includeCritical?: boolean;
82
89
  }
83
90
  /** Signed policy bundle as returned by GET /v1/policies/bundle. */
84
91
  export interface PolicyBundle extends PolicyDocument {
@@ -115,7 +122,7 @@ export interface EvalFlags {
115
122
  /** Circuit breaker state of the agent. */
116
123
  breakerState?: 'ACTIVE' | 'FROZEN';
117
124
  }
118
- export type EvalReason = 'KILL_SWITCH' | 'CIRCUIT_BREAKER' | 'DENY_RULE' | 'AUTO_RULE' | 'APPROVAL_RULE' | 'OBSERVE_RULE' | 'DEFAULT';
125
+ export type EvalReason = 'KILL_SWITCH' | 'CIRCUIT_BREAKER' | 'DENY_RULE' | 'AUTO_RULE' | 'APPROVAL_RULE' | 'OBSERVE_RULE' | 'ALLOW_RULE' | 'DEFAULT';
119
126
  export interface EvalResult {
120
127
  effect: Effect;
121
128
  reason: EvalReason;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aithorized/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Deterministic crypto core and policy engine for aithorized (JCS RFC 8785, payload hashing, domain-separated ECDSA/Ed25519 signatures, fail-closed policy evaluation).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,25 +1,25 @@
1
- # Shared test vectors (`aithorized/test-vector/v1`)
2
-
3
- Cross-language gate for **checklist C-03** (docs/05-threat-model.md): the
4
- TypeScript SDK, the NestJS backend and the mobile app MUST each run these
5
- files in their CI and assert **byte-identical** results.
6
-
7
- | File | Contract |
8
- |---|---|
9
- | `jcs.json` | RFC 8785 canonicalization: `input` (parsed JSON value) -> `expected` (canonical string). Includes the official RFC sort sample, the primitives sample and the Appendix B number table. |
10
- | `payload-hash.json` | `payloadHash(payload) == "sha256:" + base64url(SHA-256(UTF8(JCS(payload))))` (docs/03 section 1.5). `key-order-invariance` must hash identically to `stripe-refund`. |
11
- | `signing.json` | ECDSA P-256, base64url(DER), domain-separated signing inputs (`AITHORIZED-DECISION-V1`, `-ACTION-`, `-HTTP-`, `-WS-`, `-ENROLL-`, docs/03 sections 1.3-1.4). `negatives` pin the rejection behaviour: high-S (C-05), trailing DER bytes, cross-domain replay, tampered objects. |
12
- | `policy-eval.json` | Deterministic evaluation order (docs/02 section 3.4): kill switch -> breaker -> DENY -> auto-rules -> REQUIRE_APPROVAL -> OBSERVE -> default. |
13
- | `bundle-verify.json` | Ed25519 policy-bundle signature over `JCS(bundle without "signature")` (C-06), plus stale/invalid scenarios. |
14
-
15
- ## Regeneration
16
-
17
- Vectors are generated deterministically by:
18
-
19
- ```sh
20
- pnpm --filter @aithorized/core vectors
21
- ```
22
-
23
- The embedded keys are **TEST-ONLY fixture keys** (marked in each file).
24
- Never use them in production, and never replace them silently: downstream
25
- CI in other components depends on the committed values.
1
+ # Shared test vectors (`aithorized/test-vector/v1`)
2
+
3
+ Cross-language gate for **checklist C-03** (docs/05-threat-model.md): the
4
+ TypeScript SDK, the NestJS backend and the mobile app MUST each run these
5
+ files in their CI and assert **byte-identical** results.
6
+
7
+ | File | Contract |
8
+ |---|---|
9
+ | `jcs.json` | RFC 8785 canonicalization: `input` (parsed JSON value) -> `expected` (canonical string). Includes the official RFC sort sample, the primitives sample and the Appendix B number table. |
10
+ | `payload-hash.json` | `payloadHash(payload) == "sha256:" + base64url(SHA-256(UTF8(JCS(payload))))` (docs/03 section 1.5). `key-order-invariance` must hash identically to `stripe-refund`. |
11
+ | `signing.json` | ECDSA P-256, base64url(DER), domain-separated signing inputs (`AITHORIZED-DECISION-V1`, `-ACTION-`, `-HTTP-`, `-WS-`, `-ENROLL-`, docs/03 sections 1.3-1.4). `negatives` pin the rejection behaviour: high-S (C-05), trailing DER bytes, cross-domain replay, tampered objects. |
12
+ | `policy-eval.json` | Deterministic evaluation order (docs/02 section 3.4): kill switch -> breaker -> DENY -> auto-rules -> REQUIRE_APPROVAL -> OBSERVE -> default. |
13
+ | `bundle-verify.json` | Ed25519 policy-bundle signature over `JCS(bundle without "signature")` (C-06), plus stale/invalid scenarios. |
14
+
15
+ ## Regeneration
16
+
17
+ Vectors are generated deterministically by:
18
+
19
+ ```sh
20
+ pnpm --filter @aithorized/core vectors
21
+ ```
22
+
23
+ The embedded keys are **TEST-ONLY fixture keys** (marked in each file).
24
+ Never use them in production, and never replace them silently: downstream
25
+ CI in other components depends on the committed values.
@@ -1,173 +1,173 @@
1
- {
2
- "$schema": "aithorized/test-vector/v1",
3
- "name": "bundle-verify",
4
- "description": "Ed25519 policy bundle verification (checklist C-06). Signature over JCS(bundle without \"signature\").",
5
- "key": {
6
- "note": "TEST-ONLY fixture key. Never use in production or with real keys.",
7
- "keyId": "aithorized-policy-2026",
8
- "privateJwk": {
9
- "kty": "OKP",
10
- "crv": "Ed25519",
11
- "x": "PKuKyLAdhe711wpmrNFLQ3JqJ3aCZ-WwgJhjOStHeEc",
12
- "d": "t-jaWfW9DGW3tFgAKKUEBqp3Bw6sHKgpB2abXnoqUoY"
13
- },
14
- "publicJwk": {
15
- "kty": "OKP",
16
- "crv": "Ed25519",
17
- "x": "PKuKyLAdhe711wpmrNFLQ3JqJ3aCZ-WwgJhjOStHeEc"
18
- }
19
- },
20
- "nowMs": 1795780800000,
21
- "vectors": [
22
- {
23
- "name": "valid",
24
- "bundle": {
25
- "version": 14,
26
- "keyId": "aithorized-policy-2026",
27
- "defaults": {
28
- "unmatched": "OBSERVE",
29
- "ttlSeconds": 300
30
- },
31
- "rules": [
32
- {
33
- "id": "stripe-refund-large",
34
- "match": {
35
- "tool": "stripe.refund",
36
- "args": {
37
- "amount": {
38
- "gt": 10000
39
- }
40
- }
41
- },
42
- "effect": "REQUIRE_APPROVAL",
43
- "riskLevel": "HIGH"
44
- }
45
- ],
46
- "autoRules": [],
47
- "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
48
- },
49
- "lastRefreshMs": 1795780800000,
50
- "expected": "ok"
51
- },
52
- {
53
- "name": "stale-25h",
54
- "bundle": {
55
- "version": 14,
56
- "keyId": "aithorized-policy-2026",
57
- "defaults": {
58
- "unmatched": "OBSERVE",
59
- "ttlSeconds": 300
60
- },
61
- "rules": [
62
- {
63
- "id": "stripe-refund-large",
64
- "match": {
65
- "tool": "stripe.refund",
66
- "args": {
67
- "amount": {
68
- "gt": 10000
69
- }
70
- }
71
- },
72
- "effect": "REQUIRE_APPROVAL",
73
- "riskLevel": "HIGH"
74
- }
75
- ],
76
- "autoRules": [],
77
- "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
78
- },
79
- "lastRefreshMs": 1795690800000,
80
- "expected": "stale"
81
- },
82
- {
83
- "name": "fresh-boundary-23h",
84
- "bundle": {
85
- "version": 14,
86
- "keyId": "aithorized-policy-2026",
87
- "defaults": {
88
- "unmatched": "OBSERVE",
89
- "ttlSeconds": 300
90
- },
91
- "rules": [
92
- {
93
- "id": "stripe-refund-large",
94
- "match": {
95
- "tool": "stripe.refund",
96
- "args": {
97
- "amount": {
98
- "gt": 10000
99
- }
100
- }
101
- },
102
- "effect": "REQUIRE_APPROVAL",
103
- "riskLevel": "HIGH"
104
- }
105
- ],
106
- "autoRules": [],
107
- "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
108
- },
109
- "lastRefreshMs": 1795698000000,
110
- "expected": "ok"
111
- },
112
- {
113
- "name": "tampered-rule",
114
- "bundle": {
115
- "version": 14,
116
- "keyId": "aithorized-policy-2026",
117
- "defaults": {
118
- "unmatched": "OBSERVE",
119
- "ttlSeconds": 300
120
- },
121
- "rules": [
122
- {
123
- "id": "stripe-refund-large",
124
- "match": {
125
- "tool": "stripe.refund",
126
- "args": {
127
- "amount": {
128
- "gt": 10000
129
- }
130
- }
131
- },
132
- "effect": "REQUIRE_APPROVAL",
133
- "riskLevel": "LOW"
134
- }
135
- ],
136
- "autoRules": [],
137
- "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
138
- },
139
- "lastRefreshMs": 1795780800000,
140
- "expected": "invalid"
141
- },
142
- {
143
- "name": "wrong-key-id",
144
- "bundle": {
145
- "version": 14,
146
- "keyId": "other-policy-key",
147
- "defaults": {
148
- "unmatched": "OBSERVE",
149
- "ttlSeconds": 300
150
- },
151
- "rules": [
152
- {
153
- "id": "stripe-refund-large",
154
- "match": {
155
- "tool": "stripe.refund",
156
- "args": {
157
- "amount": {
158
- "gt": 10000
159
- }
160
- }
161
- },
162
- "effect": "REQUIRE_APPROVAL",
163
- "riskLevel": "HIGH"
164
- }
165
- ],
166
- "autoRules": [],
167
- "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
168
- },
169
- "lastRefreshMs": 1795780800000,
170
- "expected": "invalid"
171
- }
172
- ]
173
- }
1
+ {
2
+ "$schema": "aithorized/test-vector/v1",
3
+ "name": "bundle-verify",
4
+ "description": "Ed25519 policy bundle verification (checklist C-06). Signature over JCS(bundle without \"signature\").",
5
+ "key": {
6
+ "note": "TEST-ONLY fixture key. Never use in production or with real keys.",
7
+ "keyId": "aithorized-policy-2026",
8
+ "privateJwk": {
9
+ "kty": "OKP",
10
+ "crv": "Ed25519",
11
+ "x": "PKuKyLAdhe711wpmrNFLQ3JqJ3aCZ-WwgJhjOStHeEc",
12
+ "d": "t-jaWfW9DGW3tFgAKKUEBqp3Bw6sHKgpB2abXnoqUoY"
13
+ },
14
+ "publicJwk": {
15
+ "kty": "OKP",
16
+ "crv": "Ed25519",
17
+ "x": "PKuKyLAdhe711wpmrNFLQ3JqJ3aCZ-WwgJhjOStHeEc"
18
+ }
19
+ },
20
+ "nowMs": 1795780800000,
21
+ "vectors": [
22
+ {
23
+ "name": "valid",
24
+ "bundle": {
25
+ "version": 14,
26
+ "keyId": "aithorized-policy-2026",
27
+ "defaults": {
28
+ "unmatched": "OBSERVE",
29
+ "ttlSeconds": 300
30
+ },
31
+ "rules": [
32
+ {
33
+ "id": "stripe-refund-large",
34
+ "match": {
35
+ "tool": "stripe.refund",
36
+ "args": {
37
+ "amount": {
38
+ "gt": 10000
39
+ }
40
+ }
41
+ },
42
+ "effect": "REQUIRE_APPROVAL",
43
+ "riskLevel": "HIGH"
44
+ }
45
+ ],
46
+ "autoRules": [],
47
+ "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
48
+ },
49
+ "lastRefreshMs": 1795780800000,
50
+ "expected": "ok"
51
+ },
52
+ {
53
+ "name": "stale-25h",
54
+ "bundle": {
55
+ "version": 14,
56
+ "keyId": "aithorized-policy-2026",
57
+ "defaults": {
58
+ "unmatched": "OBSERVE",
59
+ "ttlSeconds": 300
60
+ },
61
+ "rules": [
62
+ {
63
+ "id": "stripe-refund-large",
64
+ "match": {
65
+ "tool": "stripe.refund",
66
+ "args": {
67
+ "amount": {
68
+ "gt": 10000
69
+ }
70
+ }
71
+ },
72
+ "effect": "REQUIRE_APPROVAL",
73
+ "riskLevel": "HIGH"
74
+ }
75
+ ],
76
+ "autoRules": [],
77
+ "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
78
+ },
79
+ "lastRefreshMs": 1795690800000,
80
+ "expected": "stale"
81
+ },
82
+ {
83
+ "name": "fresh-boundary-23h",
84
+ "bundle": {
85
+ "version": 14,
86
+ "keyId": "aithorized-policy-2026",
87
+ "defaults": {
88
+ "unmatched": "OBSERVE",
89
+ "ttlSeconds": 300
90
+ },
91
+ "rules": [
92
+ {
93
+ "id": "stripe-refund-large",
94
+ "match": {
95
+ "tool": "stripe.refund",
96
+ "args": {
97
+ "amount": {
98
+ "gt": 10000
99
+ }
100
+ }
101
+ },
102
+ "effect": "REQUIRE_APPROVAL",
103
+ "riskLevel": "HIGH"
104
+ }
105
+ ],
106
+ "autoRules": [],
107
+ "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
108
+ },
109
+ "lastRefreshMs": 1795698000000,
110
+ "expected": "ok"
111
+ },
112
+ {
113
+ "name": "tampered-rule",
114
+ "bundle": {
115
+ "version": 14,
116
+ "keyId": "aithorized-policy-2026",
117
+ "defaults": {
118
+ "unmatched": "OBSERVE",
119
+ "ttlSeconds": 300
120
+ },
121
+ "rules": [
122
+ {
123
+ "id": "stripe-refund-large",
124
+ "match": {
125
+ "tool": "stripe.refund",
126
+ "args": {
127
+ "amount": {
128
+ "gt": 10000
129
+ }
130
+ }
131
+ },
132
+ "effect": "REQUIRE_APPROVAL",
133
+ "riskLevel": "LOW"
134
+ }
135
+ ],
136
+ "autoRules": [],
137
+ "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
138
+ },
139
+ "lastRefreshMs": 1795780800000,
140
+ "expected": "invalid"
141
+ },
142
+ {
143
+ "name": "wrong-key-id",
144
+ "bundle": {
145
+ "version": 14,
146
+ "keyId": "other-policy-key",
147
+ "defaults": {
148
+ "unmatched": "OBSERVE",
149
+ "ttlSeconds": 300
150
+ },
151
+ "rules": [
152
+ {
153
+ "id": "stripe-refund-large",
154
+ "match": {
155
+ "tool": "stripe.refund",
156
+ "args": {
157
+ "amount": {
158
+ "gt": 10000
159
+ }
160
+ }
161
+ },
162
+ "effect": "REQUIRE_APPROVAL",
163
+ "riskLevel": "HIGH"
164
+ }
165
+ ],
166
+ "autoRules": [],
167
+ "signature": "akO1o8shtnj0ZW6pSlDQXRp4zTqundN6FcLbFs1ly4iHTCfg5opHho2282bdyAAjGKZcGOaLN4NA_8JXmEi6Bg"
168
+ },
169
+ "lastRefreshMs": 1795780800000,
170
+ "expected": "invalid"
171
+ }
172
+ ]
173
+ }