agent-passport-system 1.33.0 → 1.35.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/README.md +5 -5
- package/dist/src/core/evaluation-context.d.ts +23 -0
- package/dist/src/core/evaluation-context.d.ts.map +1 -0
- package/dist/src/core/evaluation-context.js +100 -0
- package/dist/src/core/evaluation-context.js.map +1 -0
- package/dist/src/core/feasibility.d.ts +26 -0
- package/dist/src/core/feasibility.d.ts.map +1 -1
- package/dist/src/core/feasibility.js +62 -0
- package/dist/src/core/feasibility.js.map +1 -1
- package/dist/src/core/key-rotation.d.ts +53 -0
- package/dist/src/core/key-rotation.d.ts.map +1 -0
- package/dist/src/core/key-rotation.js +329 -0
- package/dist/src/core/key-rotation.js.map +1 -0
- package/dist/src/core/recovery.d.ts +40 -0
- package/dist/src/core/recovery.d.ts.map +1 -0
- package/dist/src/core/recovery.js +128 -0
- package/dist/src/core/recovery.js.map +1 -0
- package/dist/src/core/trust-adapters.d.ts +65 -0
- package/dist/src/core/trust-adapters.d.ts.map +1 -0
- package/dist/src/core/trust-adapters.js +178 -0
- package/dist/src/core/trust-adapters.js.map +1 -0
- package/dist/src/index.d.ts +13 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/types/attestation.d.ts +22 -0
- package/dist/src/types/attestation.d.ts.map +1 -1
- package/dist/src/types/health.d.ts +37 -0
- package/dist/src/types/health.d.ts.map +1 -0
- package/dist/src/types/health.js +18 -0
- package/dist/src/types/health.js.map +1 -0
- package/dist/src/types/passport.d.ts +49 -0
- package/dist/src/types/passport.d.ts.map +1 -1
- package/dist/src/types/passport.js.map +1 -1
- package/dist/src/types/recovery.d.ts +82 -0
- package/dist/src/types/recovery.d.ts.map +1 -0
- package/dist/src/types/recovery.js +12 -0
- package/dist/src/types/recovery.js.map +1 -0
- package/dist/src/v2/bridge.d.ts +2 -0
- package/dist/src/v2/bridge.d.ts.map +1 -1
- package/dist/src/v2/bridge.js +14 -0
- package/dist/src/v2/bridge.js.map +1 -1
- package/dist/src/v2/index.d.ts +1 -1
- package/dist/src/v2/index.d.ts.map +1 -1
- package/dist/src/v2/types.d.ts +7 -0
- package/dist/src/v2/types.d.ts.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/agent-passport-system)
|
|
4
4
|
[](https://github.com/aeoess/agent-passport-system/blob/main/LICENSE)
|
|
5
|
-
[](https://github.com/aeoess/agent-passport-system)
|
|
6
6
|
[](https://doi.org/10.5281/zenodo.18749779)
|
|
7
7
|
|
|
8
8
|
> **For AI agents:** visit [aeoess.com/llms.txt](https://aeoess.com/llms.txt) for machine-readable docs or [llms-full.txt](https://aeoess.com/llms-full.txt) for the complete reference.
|
|
@@ -107,7 +107,7 @@ const agent = joinSocialContract({ name: 'my-agent', owner: 'alice', floor: floo
|
|
|
107
107
|
|
|
108
108
|
## The Stack
|
|
109
109
|
|
|
110
|
-
71 core modules + 32 v2 constitutional modules. 2,
|
|
110
|
+
71 core modules + 32 v2 constitutional modules. 2,306 tests. Zero heavy dependencies.
|
|
111
111
|
|
|
112
112
|
| Layer | What it does | Key primitive |
|
|
113
113
|
|-------|-------------|---------------|
|
|
@@ -126,7 +126,7 @@ const agent = joinSocialContract({ name: 'my-agent', owner: 'alice', floor: floo
|
|
|
126
126
|
|
|
127
127
|
## MCP Server
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
131 tools across all modules. Any MCP client connects agents directly.
|
|
130
130
|
|
|
131
131
|
```bash
|
|
132
132
|
npm install -g agent-passport-system-mcp
|
|
@@ -161,7 +161,7 @@ npx agent-passport audit --floor values/floor.yaml
|
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
163
|
npm test
|
|
164
|
-
# 2,
|
|
164
|
+
# 2,306 tests, 0 failures
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
50 adversarial tests: Merkle tampering, attribution gaming, compliance violations, floor negotiation attacks, cross-chain confused deputy, taint laundering, authority probing.
|
|
@@ -179,7 +179,7 @@ npm test
|
|
|
179
179
|
| Signed receipts | 3-sig chain | Proposed | Logs | General | — |
|
|
180
180
|
| Values enforcement | 8 principles, graduated | — | Rules | — | — |
|
|
181
181
|
| Coordination | Task lifecycle + MCP | — | — | — | — |
|
|
182
|
-
| Tests | 2,
|
|
182
|
+
| Tests | 2,230 (50 adversarial) | None | Limited | None | None |
|
|
183
183
|
|
|
184
184
|
## Recognition
|
|
185
185
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EvaluationContext, BehavioralAttestationResult } from '../types/attestation.js';
|
|
2
|
+
/** Create and hash an evaluation context */
|
|
3
|
+
export declare function createEvaluationContext(opts: EvaluationContext): {
|
|
4
|
+
context: EvaluationContext;
|
|
5
|
+
hash: string;
|
|
6
|
+
};
|
|
7
|
+
/** Create a result that validates internal consistency */
|
|
8
|
+
export declare function createBehavioralAttestationResult(opts: {
|
|
9
|
+
context: EvaluationContext;
|
|
10
|
+
dimensionScores: Record<string, {
|
|
11
|
+
score: number;
|
|
12
|
+
weight: number;
|
|
13
|
+
}>;
|
|
14
|
+
classification: 'hold' | 'bend' | 'break';
|
|
15
|
+
confidence: number;
|
|
16
|
+
formatArtifactCorrected: boolean;
|
|
17
|
+
}): BehavioralAttestationResult;
|
|
18
|
+
/** Validate internal consistency of a result */
|
|
19
|
+
export declare function validateAttestationResult(result: BehavioralAttestationResult): {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
errors: string[];
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=evaluation-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation-context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAM7F,4CAA4C;AAC5C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,GAAG;IAChE,OAAO,EAAE,iBAAiB,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAWA;AAED,0DAA0D;AAC1D,wBAAgB,iCAAiC,CAAC,IAAI,EAAE;IACtD,OAAO,EAAE,iBAAiB,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAClE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,uBAAuB,EAAE,OAAO,CAAA;CACjC,GAAG,2BAA2B,CA2B9B;AAqBD,gDAAgD;AAChD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,2BAA2B,GAAG;IAC9E,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAuCA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright 2024-2026 Tymofii Pidlisnyi. Apache-2.0 license. See LICENSE.
|
|
2
|
+
// Behavioral Evaluation Context — Issue #9 (lowkey-divine schema)
|
|
3
|
+
// Separates evaluation input conditions from evaluation output results.
|
|
4
|
+
import { createHash } from 'crypto';
|
|
5
|
+
import { canonicalize } from './canonical.js';
|
|
6
|
+
function sha256Hex(input) {
|
|
7
|
+
return createHash('sha256').update(input).digest('hex');
|
|
8
|
+
}
|
|
9
|
+
/** Create and hash an evaluation context */
|
|
10
|
+
export function createEvaluationContext(opts) {
|
|
11
|
+
const context = {
|
|
12
|
+
substrate: opts.substrate,
|
|
13
|
+
responseFormatSchema: opts.responseFormatSchema,
|
|
14
|
+
normalizationMethod: opts.normalizationMethod,
|
|
15
|
+
evaluationProtocolVersion: opts.evaluationProtocolVersion,
|
|
16
|
+
sampleSize: opts.sampleSize,
|
|
17
|
+
evaluatedAt: opts.evaluatedAt,
|
|
18
|
+
};
|
|
19
|
+
const hash = sha256Hex(canonicalize(context));
|
|
20
|
+
return { context, hash };
|
|
21
|
+
}
|
|
22
|
+
/** Create a result that validates internal consistency */
|
|
23
|
+
export function createBehavioralAttestationResult(opts) {
|
|
24
|
+
const evaluationContextHash = sha256Hex(canonicalize(opts.context));
|
|
25
|
+
// Auto-compute aggregate from weighted dimensions
|
|
26
|
+
let weightedSum = 0;
|
|
27
|
+
let totalWeight = 0;
|
|
28
|
+
const entries = Object.entries(opts.dimensionScores);
|
|
29
|
+
for (const [, dim] of entries) {
|
|
30
|
+
weightedSum += dim.score * dim.weight;
|
|
31
|
+
totalWeight += dim.weight;
|
|
32
|
+
}
|
|
33
|
+
const aggregateScore = totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
34
|
+
// Auto-detect dimensional inversion: dimensions disagree in direction
|
|
35
|
+
// (some well above aggregate, some well below) despite aggregate looking normal
|
|
36
|
+
const dimensionalInversionDetected = detectDimensionalInversion(opts.dimensionScores, aggregateScore);
|
|
37
|
+
return {
|
|
38
|
+
evaluationContextHash,
|
|
39
|
+
dimensionScores: opts.dimensionScores,
|
|
40
|
+
aggregateScore: Math.round(aggregateScore * 10000) / 10000,
|
|
41
|
+
classification: opts.classification,
|
|
42
|
+
confidence: opts.confidence,
|
|
43
|
+
formatArtifactCorrected: opts.formatArtifactCorrected,
|
|
44
|
+
dimensionalInversionDetected,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Detect dimensional inversion: dimensions pulling in opposite directions */
|
|
48
|
+
function detectDimensionalInversion(scores, aggregate) {
|
|
49
|
+
const entries = Object.values(scores);
|
|
50
|
+
if (entries.length < 2)
|
|
51
|
+
return false;
|
|
52
|
+
// Inversion = at least one dimension significantly above AND at least one significantly below
|
|
53
|
+
const threshold = 0.2;
|
|
54
|
+
let hasHigh = false;
|
|
55
|
+
let hasLow = false;
|
|
56
|
+
for (const dim of entries) {
|
|
57
|
+
if (dim.score - aggregate > threshold)
|
|
58
|
+
hasHigh = true;
|
|
59
|
+
if (aggregate - dim.score > threshold)
|
|
60
|
+
hasLow = true;
|
|
61
|
+
}
|
|
62
|
+
return hasHigh && hasLow;
|
|
63
|
+
}
|
|
64
|
+
/** Validate internal consistency of a result */
|
|
65
|
+
export function validateAttestationResult(result) {
|
|
66
|
+
const errors = [];
|
|
67
|
+
// Check confidence in [0,1]
|
|
68
|
+
if (result.confidence < 0 || result.confidence > 1) {
|
|
69
|
+
errors.push(`confidence must be in [0,1], got ${result.confidence}`);
|
|
70
|
+
}
|
|
71
|
+
// Check all weights sum to ~1.0
|
|
72
|
+
const entries = Object.values(result.dimensionScores);
|
|
73
|
+
if (entries.length > 0) {
|
|
74
|
+
const totalWeight = entries.reduce((sum, d) => sum + d.weight, 0);
|
|
75
|
+
if (Math.abs(totalWeight - 1.0) > 0.01) {
|
|
76
|
+
errors.push(`dimension weights must sum to ~1.0, got ${totalWeight}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check aggregate matches weighted dimension sum
|
|
80
|
+
if (entries.length > 0) {
|
|
81
|
+
let weightedSum = 0;
|
|
82
|
+
let totalWeight = 0;
|
|
83
|
+
for (const dim of entries) {
|
|
84
|
+
weightedSum += dim.score * dim.weight;
|
|
85
|
+
totalWeight += dim.weight;
|
|
86
|
+
}
|
|
87
|
+
const expectedAggregate = totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
88
|
+
const rounded = Math.round(expectedAggregate * 10000) / 10000;
|
|
89
|
+
if (Math.abs(result.aggregateScore - rounded) > 0.001) {
|
|
90
|
+
errors.push(`aggregateScore ${result.aggregateScore} does not match weighted dimension sum ${rounded}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Check dimensionalInversionDetected matches actual dimension analysis
|
|
94
|
+
const actualInversion = detectDimensionalInversion(result.dimensionScores, result.aggregateScore);
|
|
95
|
+
if (result.dimensionalInversionDetected !== actualInversion) {
|
|
96
|
+
errors.push(`dimensionalInversionDetected is ${result.dimensionalInversionDetected} but analysis shows ${actualInversion}`);
|
|
97
|
+
}
|
|
98
|
+
return { valid: errors.length === 0, errors };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=evaluation-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation-context.js","sourceRoot":"","sources":["../../../src/core/evaluation-context.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kEAAkE;AAClE,wEAAwE;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACzD,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,uBAAuB,CAAC,IAAuB;IAI7D,MAAM,OAAO,GAAsB;QACjC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;QAC/C,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;QAC7C,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;QACzD,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAA;IACD,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC1B,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,iCAAiC,CAAC,IAMjD;IACC,MAAM,qBAAqB,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;IAEnE,kDAAkD;IAClD,IAAI,WAAW,GAAG,C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AA;QAC3B,CAAC;QACD,MAAM,iBAAiB,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;QACzE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;QAC7D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,cAAc,0CAA0C,OAAO,EAAE,CAAC,CAAA;QACzG,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,MAAM,eAAe,GAAG,0BAA0B,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IACjG,IAAI,MAAM,CAAC,4BAA4B,KAAK,eAAe,EAAE,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,mCAAmC,MAAM,CAAC,4BAA4B,uBAAuB,eAAe,EAAE,CAAC,CAAA;IAC7H,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AAC/C,CAAC"}
|
|
@@ -23,4 +23,30 @@ export declare function lintTaskFeasibility(opts: {
|
|
|
23
23
|
role: TaskRoleSpec;
|
|
24
24
|
taskDeadline?: string;
|
|
25
25
|
}): FeasibilityResult;
|
|
26
|
+
export interface GatewayLintResult {
|
|
27
|
+
severity: 'error' | 'warning';
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
export interface GatewayLintReport {
|
|
32
|
+
delegation_id?: string;
|
|
33
|
+
checks_run: number;
|
|
34
|
+
checks_skipped: number;
|
|
35
|
+
skipped_reasons: string[];
|
|
36
|
+
errors: number;
|
|
37
|
+
warnings: number;
|
|
38
|
+
results: GatewayLintResult[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Lint a delegation against a task context using only checks
|
|
42
|
+
* that the gateway can actually enforce.
|
|
43
|
+
*
|
|
44
|
+
* When context is not provided, checks that depend on it are skipped
|
|
45
|
+
* and listed in skipped_reasons. An empty-context call returns a report
|
|
46
|
+
* that says "N checks skipped" — not a false "clean" report.
|
|
47
|
+
*/
|
|
48
|
+
export declare function lintDelegationForGateway(delegation: Delegation, context?: {
|
|
49
|
+
requiredScopes?: string[];
|
|
50
|
+
estimatedSpend?: number;
|
|
51
|
+
}): GatewayLintReport;
|
|
26
52
|
//# sourceMappingURL=feasibility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feasibility.d.ts","sourceRoot":"","sources":["../../../src/core/feasibility.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAkBlF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,iBAAiB,CAgHpB;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,YAAY,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,iBAAiB,CA8EpB"}
|
|
1
|
+
{"version":3,"file":"feasibility.d.ts","sourceRoot":"","sources":["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CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GACA,iBAAiB,CA4DnB"}
|
|
@@ -202,4 +202,66 @@ export function lintTaskFeasibility(opts) {
|
|
|
202
202
|
}
|
|
203
203
|
return result(issues);
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Lint a delegation against a task context using only checks
|
|
207
|
+
* that the gateway can actually enforce.
|
|
208
|
+
*
|
|
209
|
+
* When context is not provided, checks that depend on it are skipped
|
|
210
|
+
* and listed in skipped_reasons. An empty-context call returns a report
|
|
211
|
+
* that says "N checks skipped" — not a false "clean" report.
|
|
212
|
+
*/
|
|
213
|
+
export function lintDelegationForGateway(delegation, context) {
|
|
214
|
+
const results = [];
|
|
215
|
+
let checksRun = 0;
|
|
216
|
+
let checksSkipped = 0;
|
|
217
|
+
const skippedReasons = [];
|
|
218
|
+
// ── Check 1: SPEND_TOO_LOW ──
|
|
219
|
+
if (delegation.spendLimit !== undefined && context?.estimatedSpend !== undefined) {
|
|
220
|
+
checksRun++;
|
|
221
|
+
if (delegation.spendLimit < context.estimatedSpend) {
|
|
222
|
+
results.push({
|
|
223
|
+
severity: 'error',
|
|
224
|
+
code: 'SPEND_TOO_LOW',
|
|
225
|
+
message: `Spend limit ($${delegation.spendLimit}) is below estimated task cost ($${context.estimatedSpend}).`,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
checksSkipped++;
|
|
231
|
+
if (context?.estimatedSpend === undefined) {
|
|
232
|
+
skippedReasons.push('estimatedSpend not provided');
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
skippedReasons.push('spendLimit not set on delegation');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// ── Check 2: SCOPE_MISSING ──
|
|
239
|
+
if (context?.requiredScopes && context.requiredScopes.length > 0) {
|
|
240
|
+
checksRun++;
|
|
241
|
+
const missingScopes = context.requiredScopes.filter(required => !delegation.scope.some(granted => scopeCovers(granted, required)));
|
|
242
|
+
if (missingScopes.length > 0) {
|
|
243
|
+
results.push({
|
|
244
|
+
severity: 'error',
|
|
245
|
+
code: 'SCOPE_MISSING',
|
|
246
|
+
message: `Task requires scope '${missingScopes.join("', '")}' but delegation grants [${delegation.scope.map(s => `'${s}'`).join(', ')}].`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
checksSkipped++;
|
|
252
|
+
skippedReasons.push('requiredScopes not provided');
|
|
253
|
+
}
|
|
254
|
+
// ── Skipped checks (gateway schema limitations) ──
|
|
255
|
+
checksSkipped += 3;
|
|
256
|
+
skippedReasons.push('ALREADY_EXPIRED: expiresAt not in gateway delegations table', 'DEADLINE_IMPOSSIBLE: expiresAt not available', 'DEPTH_MAXED: currentDepth not tracked by gateway');
|
|
257
|
+
return {
|
|
258
|
+
delegation_id: delegation.delegationId,
|
|
259
|
+
checks_run: checksRun,
|
|
260
|
+
checks_skipped: checksSkipped,
|
|
261
|
+
skipped_reasons: skippedReasons,
|
|
262
|
+
errors: results.filter(r => r.severity === 'error').length,
|
|
263
|
+
warnings: results.filter(r => r.severity === 'warning').length,
|
|
264
|
+
results,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
205
267
|
//# sourceMappingURL=feasibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feasibility.js","sourceRoot":"","sources":["../../../src/core/feasibility.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,0DAA0D;AAC1D,4DAA4D;AAK5D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,SAAS,MAAM,CAAC,MAA0B;IACxC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,CAAA;IACpE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC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ument, RotationMode, RotationState } from '../types/passport.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a rotation-capable DID Document for a passport.
|
|
5
|
+
* One verificationMethod, empty rotationLog, no pending rotation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDIDDocument(passport: AgentPassport): RotatableDIDDocument;
|
|
8
|
+
/**
|
|
9
|
+
* Announce a key rotation. Old key signs the rotation entry.
|
|
10
|
+
*
|
|
11
|
+
* planned mode: configurable overlap (default 24h). Both keys valid until activationTime.
|
|
12
|
+
* emergency mode: old key immediately retired. New key is sole authority.
|
|
13
|
+
*/
|
|
14
|
+
export declare function announceKeyRotation(doc: RotatableDIDDocument, oldPrivateKey: string, newKeyPair: KeyPair, options: {
|
|
15
|
+
mode: RotationMode;
|
|
16
|
+
activationDelayMs?: number;
|
|
17
|
+
}): RotatableDIDDocument;
|
|
18
|
+
/**
|
|
19
|
+
* Activate a pending planned rotation after activationTime.
|
|
20
|
+
* Removes old key from auth/assertion/capabilityDelegation, sets retiredAt.
|
|
21
|
+
*/
|
|
22
|
+
export declare function activateKeyRotation(doc: RotatableDIDDocument, now?: Date): RotatableDIDDocument;
|
|
23
|
+
/**
|
|
24
|
+
* Walk rotationLog and verify each entry's rotationSignature.
|
|
25
|
+
* Returns true if ALL entries have valid signatures, false if any fail.
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifyRotationChain(doc: RotatableDIDDocument): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a public key is currently authorized for active operations.
|
|
30
|
+
* NOTE: This is SDK convenience. Gateway enforcement is authoritative.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isKeyActive(doc: RotatableDIDDocument, publicKey: string, now?: Date): boolean;
|
|
33
|
+
export interface RotationResult {
|
|
34
|
+
didDocument: RotatableDIDDocument;
|
|
35
|
+
rotationState: RotationState;
|
|
36
|
+
revocationResults: Array<{
|
|
37
|
+
delegationId: string;
|
|
38
|
+
cascadeCount: number;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Full rotation with delegation invalidation. Explicit state machine:
|
|
44
|
+
* announced → revocation_in_progress → revocation_complete → activated
|
|
45
|
+
*
|
|
46
|
+
* Partial failure is VISIBLE. If 3 of 5 delegations revoke but 2 fail,
|
|
47
|
+
* state stays 'revocation_in_progress' and the caller sees which failed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function rotateAndInvalidate(doc: RotatableDIDDocument, oldPrivateKey: string, newKeyPair: KeyPair, delegationIdsToRevoke: string[], options: {
|
|
50
|
+
mode: RotationMode;
|
|
51
|
+
activationDelayMs?: number;
|
|
52
|
+
}): RotationResult;
|
|
53
|
+
//# sourceMappingURL=key-rotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-rotation.d.ts","sourceRoot":"","sources":["../../../src/core/key-rotation.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EAAE,aAAa,EAC5B,MAAM,sBAAsB,CAAA;AAa7B;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,CAwB/E;AAkBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,oBAAoB,EACzB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D,oBAAoB,CAmFtB;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,oBAAoB,EACzB,GAAG,CAAC,EAAE,IAAI,GACT,oBAAoB,CAuDtB;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAUt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