@vorionsys/basis 1.0.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/.env.example +22 -0
- package/AMOY-MIGRATION.md +188 -0
- package/DEPLOY-AMOY.md +368 -0
- package/DEPLOY-NOW.md +216 -0
- package/DEPLOYMENT.md +239 -0
- package/GET-WALLET.md +286 -0
- package/QUICK-WALLET-SETUP.md +268 -0
- package/README.md +195 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +236 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +204 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +328 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +113 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +97 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +114 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +444 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +296 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +45 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +521 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +476 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +352 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +341 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +37 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +65 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
- package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +1 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +4 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.json +1430 -0
- package/build_errors.txt +0 -0
- package/build_output.txt +0 -0
- package/cache/solidity-files-cache.json +885 -0
- package/contracts/AgentCard.sol +478 -0
- package/contracts/deploy/01-deploy-agentcard.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/kya/accountability.d.ts.map +1 -0
- package/dist/kya/accountability.js +100 -0
- package/dist/kya/authorization.d.ts.map +1 -0
- package/dist/kya/authorization.js +258 -0
- package/dist/kya/behavior.d.ts.map +1 -0
- package/dist/kya/behavior.js +142 -0
- package/dist/kya/identity.d.ts.map +1 -0
- package/dist/kya/identity.js +187 -0
- package/dist/kya/index.d.ts.map +1 -0
- package/dist/kya/index.js +99 -0
- package/dist/kya/types.d.ts.map +1 -0
- package/dist/kya/types.js +5 -0
- package/dist/trust-1000-agents.test.d.ts.map +1 -0
- package/dist/trust-1000-agents.test.js +608 -0
- package/dist/trust-capabilities.d.ts.map +1 -0
- package/dist/trust-capabilities.js +478 -0
- package/dist/trust-factors.d.ts.map +1 -0
- package/dist/trust-factors.js +588 -0
- package/dist/trust-factors.test.d.ts.map +1 -0
- package/dist/trust-factors.test.js +179 -0
- package/dist/validation-gate.d.ts.map +1 -0
- package/dist/validation-gate.js +468 -0
- package/dist/validation-gate.test.d.ts.map +1 -0
- package/dist/validation-gate.test.js +419 -0
- package/hardhat.config.ts +55 -0
- package/package.json +57 -0
- package/scripts/certify-agent.ts +91 -0
- package/scripts/deploy-agentcard.ts +63 -0
- package/scripts/mint-agentcard.ts +87 -0
- package/specs/adversarial-sandbox-test-suite.md +1055 -0
- package/specs/kya-framework.md +910 -0
- package/specs/trust-factors-v2.md +437 -0
- package/src/index.ts +14 -0
- package/src/kya/accountability.ts +132 -0
- package/src/kya/authorization.ts +325 -0
- package/src/kya/behavior.ts +169 -0
- package/src/kya/identity.ts +224 -0
- package/src/kya/index.ts +125 -0
- package/src/kya/types.ts +242 -0
- package/src/trust-1000-agents.test.ts +745 -0
- package/src/trust-capabilities.ts +517 -0
- package/src/trust-factors.test.ts +241 -0
- package/src/trust-factors.ts +666 -0
- package/src/validation-gate.test.ts +531 -0
- package/src/validation-gate.ts +665 -0
- package/test-kya-simple.ts +258 -0
- package/test-kya.ts +245 -0
- package/tsconfig.json +14 -0
- package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +324 -0
- package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +292 -0
- package/typechain-types/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +11 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +470 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +489 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +443 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/@openzeppelin/index.ts +5 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/contracts/AgentCard.ts +1415 -0
- package/typechain-types/contracts/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +250 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +218 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +455 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +535 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +490 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +366 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +355 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +90 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +118 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/index.ts +4 -0
- package/typechain-types/factories/contracts/AgentCard__factory.ts +1480 -0
- package/typechain-types/factories/contracts/index.ts +4 -0
- package/typechain-types/factories/index.ts +5 -0
- package/typechain-types/index.ts +44 -0
- package/vitest.config.ts +8 -0
package/src/kya/index.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA (Know Your Agent) Framework SDK
|
|
3
|
+
*
|
|
4
|
+
* TypeScript SDK for KYA framework integration
|
|
5
|
+
* Part of BASIS (Blockchain Agent Standard for Identity and Security)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './identity.js';
|
|
9
|
+
export * from './authorization.js';
|
|
10
|
+
export * from './accountability.js';
|
|
11
|
+
export * from './behavior.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
|
|
14
|
+
import { IdentityVerifier } from './identity.js';
|
|
15
|
+
import { AuthorizationManager } from './authorization.js';
|
|
16
|
+
import { AccountabilityChain } from './accountability.js';
|
|
17
|
+
import { BehaviorMonitor } from './behavior.js';
|
|
18
|
+
import { KYAConfig, AnomalyAlert } from './types.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Main KYA Framework SDK
|
|
22
|
+
*/
|
|
23
|
+
export class KYA {
|
|
24
|
+
public identity: IdentityVerifier;
|
|
25
|
+
public authorization: AuthorizationManager;
|
|
26
|
+
public accountability: AccountabilityChain;
|
|
27
|
+
public behavior: BehaviorMonitor;
|
|
28
|
+
|
|
29
|
+
constructor(config: KYAConfig) {
|
|
30
|
+
this.identity = new IdentityVerifier(config.didResolver);
|
|
31
|
+
this.authorization = new AuthorizationManager(config.policyEngine);
|
|
32
|
+
this.accountability = new AccountabilityChain(config.database);
|
|
33
|
+
this.behavior = new BehaviorMonitor(config.database);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Complete agent verification flow
|
|
38
|
+
* 1. Verify identity (DID + signature)
|
|
39
|
+
* 2. Check authorization (capabilities + policies)
|
|
40
|
+
* 3. Log to accountability chain
|
|
41
|
+
* 4. Monitor behavior for anomalies
|
|
42
|
+
*/
|
|
43
|
+
async verifyAgent(params: {
|
|
44
|
+
agentDID: string;
|
|
45
|
+
action: string;
|
|
46
|
+
resource: string;
|
|
47
|
+
proof: {
|
|
48
|
+
challenge: string;
|
|
49
|
+
signature: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
};
|
|
52
|
+
}): Promise<{
|
|
53
|
+
allowed: boolean;
|
|
54
|
+
reason: string;
|
|
55
|
+
trustScore: number;
|
|
56
|
+
anomalies: string[];
|
|
57
|
+
}> {
|
|
58
|
+
// 1. Identity verification
|
|
59
|
+
const identityValid = await this.identity.verify({
|
|
60
|
+
did: params.agentDID,
|
|
61
|
+
challenge: params.proof.challenge,
|
|
62
|
+
signature: params.proof.signature,
|
|
63
|
+
timestamp: params.proof.timestamp,
|
|
64
|
+
publicKey: '', // Will be resolved from DID
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!identityValid) {
|
|
68
|
+
return {
|
|
69
|
+
allowed: false,
|
|
70
|
+
reason: 'Identity verification failed',
|
|
71
|
+
trustScore: 0,
|
|
72
|
+
anomalies: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 2. Authorization check
|
|
77
|
+
const authDecision = await this.authorization.authorize({
|
|
78
|
+
agentDID: params.agentDID,
|
|
79
|
+
action: params.action,
|
|
80
|
+
resource: params.resource,
|
|
81
|
+
context: {
|
|
82
|
+
timestamp: Date.now(),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!authDecision.allowed) {
|
|
87
|
+
return {
|
|
88
|
+
allowed: false,
|
|
89
|
+
reason: authDecision.reason,
|
|
90
|
+
trustScore: 0,
|
|
91
|
+
anomalies: [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 3. Behavior monitoring (detect anomalies)
|
|
96
|
+
const anomalies = await this.behavior.detectAnomalies(params.agentDID);
|
|
97
|
+
|
|
98
|
+
// 4. Log to accountability chain
|
|
99
|
+
await this.accountability.append({
|
|
100
|
+
id: this.generateId(),
|
|
101
|
+
timestamp: Date.now(),
|
|
102
|
+
agentDID: params.agentDID,
|
|
103
|
+
action: params.action,
|
|
104
|
+
resource: params.resource,
|
|
105
|
+
outcome: 'success',
|
|
106
|
+
evidence: {
|
|
107
|
+
intentHash: '',
|
|
108
|
+
authorizationDecision: authDecision,
|
|
109
|
+
},
|
|
110
|
+
signature: params.proof.signature,
|
|
111
|
+
chainLink: { prevHash: null },
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
allowed: true,
|
|
116
|
+
reason: 'Verified and authorized',
|
|
117
|
+
trustScore: await this.behavior.getTrustScore(params.agentDID),
|
|
118
|
+
anomalies: anomalies.map((a: AnomalyAlert) => a.type),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private generateId(): string {
|
|
123
|
+
return `kya_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/kya/types.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA Framework Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Configuration
|
|
7
|
+
// ============================================================================
|
|
8
|
+
|
|
9
|
+
export interface KYAConfig {
|
|
10
|
+
didResolver: DIDResolverConfig;
|
|
11
|
+
policyEngine: PolicyEngineConfig;
|
|
12
|
+
database: DatabaseConfig;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DIDResolverConfig {
|
|
16
|
+
networks: string[]; // e.g., ['vorion', 'ethereum', 'polygon']
|
|
17
|
+
resolverUrl?: string;
|
|
18
|
+
cacheEnabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PolicyEngineConfig {
|
|
22
|
+
policyBundlesPath: string;
|
|
23
|
+
defaultJurisdiction: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DatabaseConfig {
|
|
27
|
+
type: 'sqlite' | 'postgres';
|
|
28
|
+
connectionString: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Identity
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
export interface DIDDocument {
|
|
36
|
+
'@context': string[];
|
|
37
|
+
id: string;
|
|
38
|
+
controller: string;
|
|
39
|
+
verificationMethod: VerificationMethod[];
|
|
40
|
+
authentication: string[];
|
|
41
|
+
assertionMethod: string[];
|
|
42
|
+
service?: ServiceEndpoint[];
|
|
43
|
+
kya?: KYAMetadata;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface VerificationMethod {
|
|
47
|
+
id: string;
|
|
48
|
+
type: string;
|
|
49
|
+
controller: string;
|
|
50
|
+
publicKeyMultibase: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ServiceEndpoint {
|
|
54
|
+
id: string;
|
|
55
|
+
type: string;
|
|
56
|
+
serviceEndpoint: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface KYAMetadata {
|
|
60
|
+
trustScore: number;
|
|
61
|
+
tier: 'T0' | 'T1' | 'T2' | 'T3' | 'T4' | 'T5';
|
|
62
|
+
certified: boolean;
|
|
63
|
+
certifier?: string;
|
|
64
|
+
certificationDate?: string;
|
|
65
|
+
capabilities: string[];
|
|
66
|
+
restrictions: string[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface IdentityProof {
|
|
70
|
+
did: string;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
challenge: string;
|
|
73
|
+
signature: string;
|
|
74
|
+
publicKey: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Authorization
|
|
79
|
+
// ============================================================================
|
|
80
|
+
|
|
81
|
+
export interface AuthorizationRequest {
|
|
82
|
+
agentDID: string;
|
|
83
|
+
action: string;
|
|
84
|
+
resource: string;
|
|
85
|
+
context: {
|
|
86
|
+
timestamp: number;
|
|
87
|
+
sourceIP?: string;
|
|
88
|
+
trustScore?: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface AuthorizationDecision {
|
|
93
|
+
allowed: boolean;
|
|
94
|
+
reason: string;
|
|
95
|
+
conditions?: Record<string, unknown>;
|
|
96
|
+
trustImpact?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface CapabilityToken {
|
|
100
|
+
id: string;
|
|
101
|
+
issuer: string;
|
|
102
|
+
subject: string;
|
|
103
|
+
capabilities: KYACapability[];
|
|
104
|
+
notBefore: string;
|
|
105
|
+
notAfter: string;
|
|
106
|
+
signature: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface KYACapability {
|
|
110
|
+
action: string;
|
|
111
|
+
resource: string;
|
|
112
|
+
conditions?: Record<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface PolicyBundle {
|
|
116
|
+
id: string;
|
|
117
|
+
version: string;
|
|
118
|
+
jurisdiction: 'US' | 'EU' | 'CA' | 'SG' | 'Global';
|
|
119
|
+
industry?: 'finance' | 'healthcare' | 'government' | 'enterprise';
|
|
120
|
+
constraints: Constraint[];
|
|
121
|
+
obligations: Obligation[];
|
|
122
|
+
permissions: Permission[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface Constraint {
|
|
126
|
+
id: string;
|
|
127
|
+
description: string;
|
|
128
|
+
rule: string; // CEL expression or JSON Logic
|
|
129
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
130
|
+
enforcement: 'block' | 'warn' | 'log';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface Obligation {
|
|
134
|
+
id: string;
|
|
135
|
+
description: string;
|
|
136
|
+
rule: string;
|
|
137
|
+
action: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface Permission {
|
|
141
|
+
id: string;
|
|
142
|
+
description: string;
|
|
143
|
+
action: string;
|
|
144
|
+
resource: string;
|
|
145
|
+
minTrustScore: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Accountability
|
|
150
|
+
// ============================================================================
|
|
151
|
+
|
|
152
|
+
export interface AccountabilityRecord {
|
|
153
|
+
id: string;
|
|
154
|
+
timestamp: number;
|
|
155
|
+
agentDID: string;
|
|
156
|
+
action: string;
|
|
157
|
+
resource: string;
|
|
158
|
+
outcome: 'success' | 'failure' | 'denied';
|
|
159
|
+
evidence: {
|
|
160
|
+
intentHash: string;
|
|
161
|
+
authorizationDecision: AuthorizationDecision;
|
|
162
|
+
executionResult?: unknown;
|
|
163
|
+
};
|
|
164
|
+
signature: string;
|
|
165
|
+
witnessSignature?: string;
|
|
166
|
+
chainLink: {
|
|
167
|
+
prevHash: string | null;
|
|
168
|
+
merkleRoot?: string;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface AccountabilityVerification {
|
|
173
|
+
valid: boolean;
|
|
174
|
+
totalRecords: number;
|
|
175
|
+
brokenLinks: number;
|
|
176
|
+
issues?: string[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Behavior Monitoring
|
|
181
|
+
// ============================================================================
|
|
182
|
+
|
|
183
|
+
export interface BehaviorProfile {
|
|
184
|
+
agentDID: string;
|
|
185
|
+
baseline: {
|
|
186
|
+
actionsPerHour: { mean: number; stddev: number };
|
|
187
|
+
successRate: { mean: number; stddev: number };
|
|
188
|
+
topActions: Array<{ action: string; frequency: number }>;
|
|
189
|
+
topResources: Array<{ resource: string; frequency: number }>;
|
|
190
|
+
};
|
|
191
|
+
recentWindow: {
|
|
192
|
+
actionsInLastHour: number;
|
|
193
|
+
successRateLastHour: number;
|
|
194
|
+
newActionsInLastHour: string[];
|
|
195
|
+
newResourcesInLastHour: string[];
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface AnomalyAlert {
|
|
200
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
201
|
+
type: string;
|
|
202
|
+
description: string;
|
|
203
|
+
evidence: unknown;
|
|
204
|
+
recommendedAction: 'log' | 'warn' | 'throttle' | 'suspend';
|
|
205
|
+
trustImpact: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ============================================================================
|
|
209
|
+
// Trust Scoring
|
|
210
|
+
// ============================================================================
|
|
211
|
+
|
|
212
|
+
export interface TrustScoreComponents {
|
|
213
|
+
runtimeFactors: {
|
|
214
|
+
impact: number; // 0-1 (blast radius)
|
|
215
|
+
confidence: number; // 0-1 (parsing certainty)
|
|
216
|
+
precedent: number; // 0-1 (history match)
|
|
217
|
+
context: number; // 0-1 (environmental safety)
|
|
218
|
+
};
|
|
219
|
+
cumulativeTrust: {
|
|
220
|
+
CT: number; // Cumulative earned
|
|
221
|
+
BT: number; // Burned (negative)
|
|
222
|
+
GT: number; // Granted (certifications)
|
|
223
|
+
XT: number; // Exceptional (peer-awarded)
|
|
224
|
+
AC: number; // Agent class base
|
|
225
|
+
};
|
|
226
|
+
developmentLineage?: {
|
|
227
|
+
governanceCoverage: number; // 0-1
|
|
228
|
+
testCoverage: number; // 0-1
|
|
229
|
+
reviewDepth: number; // 0-1
|
|
230
|
+
patternCompliance: number; // 0-1
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface TrustScoreUpdate {
|
|
235
|
+
agentDID: string;
|
|
236
|
+
oldScore: number;
|
|
237
|
+
newScore: number;
|
|
238
|
+
oldTier: string;
|
|
239
|
+
newTier: string;
|
|
240
|
+
reason: string;
|
|
241
|
+
timestamp: number;
|
|
242
|
+
}
|