@kya-os/mcp-i-core 1.3.12 → 1.3.14
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/dist/config/remote-config.js +9 -12
- package/dist/runtime/base.js +11 -0
- package/dist/services/access-control.service.js +5 -0
- package/dist/services/tool-protection.service.js +17 -8
- package/package.json +2 -2
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-test$colon$coverage.log +0 -4586
- package/.turbo/turbo-test.log +0 -3169
- package/COMPLIANCE_IMPROVEMENT_REPORT.md +0 -483
- package/Composer 3.md +0 -615
- package/GPT-5.md +0 -1169
- package/OPUS-plan.md +0 -352
- package/PHASE_3_AND_4.1_SUMMARY.md +0 -585
- package/PHASE_3_SUMMARY.md +0 -317
- package/PHASE_4.1.3_SUMMARY.md +0 -428
- package/PHASE_4.1_COMPLETE.md +0 -525
- package/PHASE_4_USER_DID_IDENTITY_LINKING_PLAN.md +0 -1240
- package/SCHEMA_COMPLIANCE_REPORT.md +0 -275
- package/TEST_PLAN.md +0 -571
- package/coverage/coverage-final.json +0 -60
- package/dist/cache/oauth-config-cache.d.ts.map +0 -1
- package/dist/cache/oauth-config-cache.js.map +0 -1
- package/dist/cache/tool-protection-cache.d.ts.map +0 -1
- package/dist/cache/tool-protection-cache.js.map +0 -1
- package/dist/compliance/index.d.ts.map +0 -1
- package/dist/compliance/index.js.map +0 -1
- package/dist/compliance/schema-registry.d.ts.map +0 -1
- package/dist/compliance/schema-registry.js.map +0 -1
- package/dist/compliance/schema-verifier.d.ts.map +0 -1
- package/dist/compliance/schema-verifier.js.map +0 -1
- package/dist/config/remote-config.d.ts.map +0 -1
- package/dist/config/remote-config.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/delegation/audience-validator.d.ts.map +0 -1
- package/dist/delegation/audience-validator.js.map +0 -1
- package/dist/delegation/bitstring.d.ts.map +0 -1
- package/dist/delegation/bitstring.js.map +0 -1
- package/dist/delegation/cascading-revocation.d.ts.map +0 -1
- package/dist/delegation/cascading-revocation.js.map +0 -1
- package/dist/delegation/delegation-graph.d.ts.map +0 -1
- package/dist/delegation/delegation-graph.js.map +0 -1
- package/dist/delegation/did-key-resolver.d.ts.map +0 -1
- package/dist/delegation/did-key-resolver.js.map +0 -1
- package/dist/delegation/index.d.ts.map +0 -1
- package/dist/delegation/index.js.map +0 -1
- package/dist/delegation/statuslist-manager.d.ts.map +0 -1
- package/dist/delegation/statuslist-manager.js.map +0 -1
- package/dist/delegation/storage/index.d.ts.map +0 -1
- package/dist/delegation/storage/index.js.map +0 -1
- package/dist/delegation/storage/memory-graph-storage.d.ts.map +0 -1
- package/dist/delegation/storage/memory-graph-storage.js.map +0 -1
- package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +0 -1
- package/dist/delegation/storage/memory-statuslist-storage.js.map +0 -1
- package/dist/delegation/utils.d.ts.map +0 -1
- package/dist/delegation/utils.js.map +0 -1
- package/dist/delegation/vc-issuer.d.ts.map +0 -1
- package/dist/delegation/vc-issuer.js.map +0 -1
- package/dist/delegation/vc-verifier.d.ts.map +0 -1
- package/dist/delegation/vc-verifier.js.map +0 -1
- package/dist/identity/idp-token-resolver.d.ts.map +0 -1
- package/dist/identity/idp-token-resolver.js.map +0 -1
- package/dist/identity/idp-token-storage.interface.d.ts.map +0 -1
- package/dist/identity/idp-token-storage.interface.js.map +0 -1
- package/dist/identity/user-did-manager.d.ts.map +0 -1
- package/dist/identity/user-did-manager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/base.js.map +0 -1
- package/dist/providers/memory.d.ts.map +0 -1
- package/dist/providers/memory.js.map +0 -1
- package/dist/runtime/audit-logger.d.ts.map +0 -1
- package/dist/runtime/audit-logger.js.map +0 -1
- package/dist/runtime/base.d.ts.map +0 -1
- package/dist/runtime/base.js.map +0 -1
- package/dist/services/access-control.service.d.ts.map +0 -1
- package/dist/services/access-control.service.js.map +0 -1
- package/dist/services/authorization/authorization-registry.d.ts.map +0 -1
- package/dist/services/authorization/authorization-registry.js.map +0 -1
- package/dist/services/authorization/types.d.ts.map +0 -1
- package/dist/services/authorization/types.js.map +0 -1
- package/dist/services/batch-delegation.service.d.ts.map +0 -1
- package/dist/services/batch-delegation.service.js.map +0 -1
- package/dist/services/crypto.service.d.ts.map +0 -1
- package/dist/services/crypto.service.js.map +0 -1
- package/dist/services/errors.d.ts.map +0 -1
- package/dist/services/errors.js.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/services/oauth-config.service.d.ts.map +0 -1
- package/dist/services/oauth-config.service.js.map +0 -1
- package/dist/services/oauth-provider-registry.d.ts.map +0 -1
- package/dist/services/oauth-provider-registry.js.map +0 -1
- package/dist/services/oauth-service.d.ts.map +0 -1
- package/dist/services/oauth-service.js.map +0 -1
- package/dist/services/oauth-token-retrieval.service.d.ts.map +0 -1
- package/dist/services/oauth-token-retrieval.service.js.map +0 -1
- package/dist/services/proof-verifier.d.ts.map +0 -1
- package/dist/services/proof-verifier.js.map +0 -1
- package/dist/services/provider-resolver.d.ts.map +0 -1
- package/dist/services/provider-resolver.js.map +0 -1
- package/dist/services/provider-validator.d.ts.map +0 -1
- package/dist/services/provider-validator.js.map +0 -1
- package/dist/services/session-registration.service.d.ts.map +0 -1
- package/dist/services/session-registration.service.js.map +0 -1
- package/dist/services/storage.service.d.ts.map +0 -1
- package/dist/services/storage.service.js.map +0 -1
- package/dist/services/tool-context-builder.d.ts.map +0 -1
- package/dist/services/tool-context-builder.js.map +0 -1
- package/dist/services/tool-protection.service.d.ts.map +0 -1
- package/dist/services/tool-protection.service.js.map +0 -1
- package/dist/types/oauth-required-error.d.ts.map +0 -1
- package/dist/types/oauth-required-error.js.map +0 -1
- package/dist/types/tool-protection.d.ts.map +0 -1
- package/dist/types/tool-protection.js.map +0 -1
- package/dist/utils/base58.d.ts.map +0 -1
- package/dist/utils/base58.js.map +0 -1
- package/dist/utils/base64.d.ts.map +0 -1
- package/dist/utils/base64.js.map +0 -1
- package/dist/utils/cors.d.ts.map +0 -1
- package/dist/utils/cors.js.map +0 -1
- package/dist/utils/did-helpers.d.ts.map +0 -1
- package/dist/utils/did-helpers.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/storage-keys.d.ts.map +0 -1
- package/dist/utils/storage-keys.js.map +0 -1
- package/docs/API_REFERENCE.md +0 -1362
- package/docs/COMPLIANCE_MATRIX.md +0 -691
- package/docs/STATUSLIST2021_GUIDE.md +0 -696
- package/docs/W3C_VC_DELEGATION_GUIDE.md +0 -710
- package/src/__tests__/cache/tool-protection-cache.test.ts +0 -640
- package/src/__tests__/config/provider-runtime-config.test.ts +0 -309
- package/src/__tests__/delegation-e2e.test.ts +0 -690
- package/src/__tests__/identity/user-did-manager.test.ts +0 -232
- package/src/__tests__/index.test.ts +0 -56
- package/src/__tests__/integration/full-flow.test.ts +0 -789
- package/src/__tests__/integration.test.ts +0 -281
- package/src/__tests__/providers/base.test.ts +0 -173
- package/src/__tests__/providers/memory.test.ts +0 -319
- package/src/__tests__/regression/phase2-regression.test.ts +0 -429
- package/src/__tests__/runtime/audit-logger.test.ts +0 -154
- package/src/__tests__/runtime/base-extensions.test.ts +0 -595
- package/src/__tests__/runtime/base.test.ts +0 -869
- package/src/__tests__/runtime/delegation-flow.test.ts +0 -164
- package/src/__tests__/runtime/proof-client-did.test.ts +0 -376
- package/src/__tests__/runtime/route-interception.test.ts +0 -686
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +0 -908
- package/src/__tests__/services/agentshield-integration.test.ts +0 -791
- package/src/__tests__/services/cache-busting.test.ts +0 -125
- package/src/__tests__/services/oauth-service-pkce.test.ts +0 -556
- package/src/__tests__/services/provider-resolver-edge-cases.test.ts +0 -591
- package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -485
- package/src/__tests__/services/tool-protection-oauth-provider.test.ts +0 -480
- package/src/__tests__/services/tool-protection.service.test.ts +0 -1373
- package/src/__tests__/utils/mock-providers.ts +0 -340
- package/src/cache/oauth-config-cache.d.ts +0 -69
- package/src/cache/oauth-config-cache.d.ts.map +0 -1
- package/src/cache/oauth-config-cache.js.map +0 -1
- package/src/cache/oauth-config-cache.ts +0 -123
- package/src/cache/tool-protection-cache.ts +0 -171
- package/src/compliance/EXAMPLE.md +0 -412
- package/src/compliance/__tests__/schema-verifier.test.ts +0 -797
- package/src/compliance/index.ts +0 -8
- package/src/compliance/schema-registry.ts +0 -460
- package/src/compliance/schema-verifier.ts +0 -708
- package/src/config/__tests__/merged-config.spec.ts +0 -445
- package/src/config/__tests__/remote-config.spec.ts +0 -268
- package/src/config/remote-config.ts +0 -264
- package/src/config.ts +0 -312
- package/src/delegation/__tests__/audience-validator.test.ts +0 -112
- package/src/delegation/__tests__/bitstring.test.ts +0 -346
- package/src/delegation/__tests__/cascading-revocation.test.ts +0 -628
- package/src/delegation/__tests__/delegation-graph.test.ts +0 -584
- package/src/delegation/__tests__/did-key-resolver.test.ts +0 -265
- package/src/delegation/__tests__/utils.test.ts +0 -152
- package/src/delegation/__tests__/vc-issuer.test.ts +0 -442
- package/src/delegation/__tests__/vc-verifier.test.ts +0 -922
- package/src/delegation/audience-validator.ts +0 -52
- package/src/delegation/bitstring.ts +0 -278
- package/src/delegation/cascading-revocation.ts +0 -370
- package/src/delegation/delegation-graph.ts +0 -299
- package/src/delegation/did-key-resolver.ts +0 -179
- package/src/delegation/index.ts +0 -14
- package/src/delegation/statuslist-manager.ts +0 -353
- package/src/delegation/storage/__tests__/memory-graph-storage.test.ts +0 -366
- package/src/delegation/storage/__tests__/memory-statuslist-storage.test.ts +0 -228
- package/src/delegation/storage/index.ts +0 -9
- package/src/delegation/storage/memory-graph-storage.ts +0 -178
- package/src/delegation/storage/memory-statuslist-storage.ts +0 -77
- package/src/delegation/utils.ts +0 -221
- package/src/delegation/vc-issuer.ts +0 -232
- package/src/delegation/vc-verifier.ts +0 -568
- package/src/identity/idp-token-resolver.ts +0 -181
- package/src/identity/idp-token-storage.interface.ts +0 -94
- package/src/identity/user-did-manager.ts +0 -526
- package/src/index.ts +0 -310
- package/src/providers/base.d.ts +0 -91
- package/src/providers/base.d.ts.map +0 -1
- package/src/providers/base.js.map +0 -1
- package/src/providers/base.ts +0 -96
- package/src/providers/memory.ts +0 -142
- package/src/runtime/audit-logger.ts +0 -39
- package/src/runtime/base.ts +0 -1392
- package/src/services/__tests__/access-control.integration.test.ts +0 -443
- package/src/services/__tests__/access-control.proof-response-validation.test.ts +0 -578
- package/src/services/__tests__/access-control.service.test.ts +0 -970
- package/src/services/__tests__/batch-delegation.service.test.ts +0 -351
- package/src/services/__tests__/crypto.service.test.ts +0 -531
- package/src/services/__tests__/oauth-provider-registry.test.ts +0 -142
- package/src/services/__tests__/proof-verifier.integration.test.ts +0 -485
- package/src/services/__tests__/proof-verifier.test.ts +0 -489
- package/src/services/__tests__/provider-resolution.integration.test.ts +0 -202
- package/src/services/__tests__/provider-resolver.test.ts +0 -213
- package/src/services/__tests__/storage.service.test.ts +0 -358
- package/src/services/access-control.service.ts +0 -990
- package/src/services/authorization/authorization-registry.ts +0 -66
- package/src/services/authorization/types.ts +0 -71
- package/src/services/batch-delegation.service.ts +0 -137
- package/src/services/crypto.service.ts +0 -302
- package/src/services/errors.ts +0 -76
- package/src/services/index.ts +0 -18
- package/src/services/oauth-config.service.d.ts +0 -53
- package/src/services/oauth-config.service.d.ts.map +0 -1
- package/src/services/oauth-config.service.js.map +0 -1
- package/src/services/oauth-config.service.ts +0 -192
- package/src/services/oauth-provider-registry.d.ts +0 -57
- package/src/services/oauth-provider-registry.d.ts.map +0 -1
- package/src/services/oauth-provider-registry.js.map +0 -1
- package/src/services/oauth-provider-registry.ts +0 -141
- package/src/services/oauth-service.ts +0 -544
- package/src/services/oauth-token-retrieval.service.ts +0 -245
- package/src/services/proof-verifier.ts +0 -478
- package/src/services/provider-resolver.d.ts +0 -48
- package/src/services/provider-resolver.d.ts.map +0 -1
- package/src/services/provider-resolver.js.map +0 -1
- package/src/services/provider-resolver.ts +0 -146
- package/src/services/provider-validator.ts +0 -170
- package/src/services/session-registration.service.ts +0 -251
- package/src/services/storage.service.ts +0 -566
- package/src/services/tool-context-builder.ts +0 -237
- package/src/services/tool-protection.service.ts +0 -1070
- package/src/types/oauth-required-error.ts +0 -63
- package/src/types/tool-protection.ts +0 -155
- package/src/utils/__tests__/did-helpers.test.ts +0 -156
- package/src/utils/base58.ts +0 -109
- package/src/utils/base64.ts +0 -148
- package/src/utils/cors.ts +0 -83
- package/src/utils/did-helpers.ts +0 -210
- package/src/utils/index.ts +0 -8
- package/src/utils/storage-keys.ts +0 -278
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -56
package/src/index.ts
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @kya-os/mcp-i-core
|
|
3
|
-
*
|
|
4
|
-
* Core provider-based architecture for MCP-I framework.
|
|
5
|
-
* Platform-agnostic runtime that can be extended for any environment.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Base providers
|
|
9
|
-
export {
|
|
10
|
-
CryptoProvider,
|
|
11
|
-
ClockProvider,
|
|
12
|
-
FetchProvider,
|
|
13
|
-
StorageProvider,
|
|
14
|
-
NonceCacheProvider,
|
|
15
|
-
IdentityProvider,
|
|
16
|
-
type AgentIdentity,
|
|
17
|
-
} from "./providers/base";
|
|
18
|
-
|
|
19
|
-
// Memory providers
|
|
20
|
-
export {
|
|
21
|
-
MemoryStorageProvider,
|
|
22
|
-
MemoryNonceCacheProvider,
|
|
23
|
-
MemoryIdentityProvider,
|
|
24
|
-
} from "./providers/memory";
|
|
25
|
-
|
|
26
|
-
// Runtime
|
|
27
|
-
export { MCPIRuntimeBase } from "./runtime/base";
|
|
28
|
-
export type { RuntimeWithAccessControl } from "./runtime/base";
|
|
29
|
-
|
|
30
|
-
// Audit Logger Interface
|
|
31
|
-
export type { IAuditLogger } from "./runtime/audit-logger";
|
|
32
|
-
|
|
33
|
-
// Utilities
|
|
34
|
-
export * from "./utils";
|
|
35
|
-
// Tool Protection
|
|
36
|
-
export { ToolProtectionService } from "./services/tool-protection.service";
|
|
37
|
-
|
|
38
|
-
// Crypto Service
|
|
39
|
-
export { CryptoService } from "./services/crypto.service";
|
|
40
|
-
|
|
41
|
-
export type { Ed25519JWK, ParsedJWS } from "./services/crypto.service";
|
|
42
|
-
|
|
43
|
-
// Proof Verifier Service
|
|
44
|
-
export { ProofVerifier } from "./services/proof-verifier";
|
|
45
|
-
|
|
46
|
-
export type {
|
|
47
|
-
ProofVerificationResult,
|
|
48
|
-
ProofVerifierConfig,
|
|
49
|
-
} from "./services/proof-verifier";
|
|
50
|
-
|
|
51
|
-
// Access Control API Service (stub for Phase 3)
|
|
52
|
-
export { AccessControlApiService } from "./services/access-control.service";
|
|
53
|
-
|
|
54
|
-
export type {
|
|
55
|
-
AccessControlApiServiceConfig,
|
|
56
|
-
AccessControlApiServiceMetrics,
|
|
57
|
-
} from "./services/access-control.service";
|
|
58
|
-
|
|
59
|
-
// Session Registration Service
|
|
60
|
-
export {
|
|
61
|
-
SessionRegistrationService,
|
|
62
|
-
createSessionRegistrationService,
|
|
63
|
-
} from "./services/session-registration.service";
|
|
64
|
-
|
|
65
|
-
export type {
|
|
66
|
-
SessionRegistrationServiceConfig,
|
|
67
|
-
SessionRegistrationResult,
|
|
68
|
-
} from "./services/session-registration.service";
|
|
69
|
-
|
|
70
|
-
// OAuth Config Service (Phase 1)
|
|
71
|
-
export { OAuthConfigService } from "./services/oauth-config.service";
|
|
72
|
-
|
|
73
|
-
export type { OAuthConfigServiceConfig } from "./services/oauth-config.service";
|
|
74
|
-
|
|
75
|
-
// OAuth Service (Phase 1)
|
|
76
|
-
export { OAuthService } from "./services/oauth-service";
|
|
77
|
-
|
|
78
|
-
export type { OAuthServiceConfig } from "./services/oauth-service";
|
|
79
|
-
|
|
80
|
-
// Tool Context Builder (Phase 1)
|
|
81
|
-
export { ToolContextBuilder } from "./services/tool-context-builder";
|
|
82
|
-
|
|
83
|
-
export type { ToolContextBuilderConfig } from "./services/tool-context-builder";
|
|
84
|
-
|
|
85
|
-
// OAuth Provider Registry (Phase 2)
|
|
86
|
-
export { OAuthProviderRegistry } from "./services/oauth-provider-registry";
|
|
87
|
-
|
|
88
|
-
// Provider Resolver (Phase 2)
|
|
89
|
-
export { ProviderResolver } from "./services/provider-resolver";
|
|
90
|
-
|
|
91
|
-
// Provider Validator (Phase 3)
|
|
92
|
-
export { ProviderValidator, ProviderValidationError } from "./services/provider-validator";
|
|
93
|
-
|
|
94
|
-
// OAuth Token Retrieval Service (Phase 3)
|
|
95
|
-
export { OAuthTokenRetrievalService } from "./services/oauth-token-retrieval.service";
|
|
96
|
-
export type { OAuthTokenRetrievalServiceConfig } from "./services/oauth-token-retrieval.service";
|
|
97
|
-
|
|
98
|
-
// Batch Delegation Service (Phase 2)
|
|
99
|
-
export { BatchDelegationService } from "./services/batch-delegation.service";
|
|
100
|
-
export type { ToolGroup } from "./services/batch-delegation.service";
|
|
101
|
-
|
|
102
|
-
// OAuth Config Cache
|
|
103
|
-
export {
|
|
104
|
-
InMemoryOAuthConfigCache,
|
|
105
|
-
NoOpOAuthConfigCache,
|
|
106
|
-
} from "./cache/oauth-config-cache";
|
|
107
|
-
|
|
108
|
-
export type { OAuthConfigCache } from "./cache/oauth-config-cache";
|
|
109
|
-
|
|
110
|
-
// Storage Service Factory
|
|
111
|
-
export {
|
|
112
|
-
createStorageProviders,
|
|
113
|
-
StorageKeyHelpers,
|
|
114
|
-
migrateLegacyKeys,
|
|
115
|
-
} from "./services/storage.service";
|
|
116
|
-
|
|
117
|
-
export type {
|
|
118
|
-
StorageServiceConfig,
|
|
119
|
-
StorageProviders,
|
|
120
|
-
} from "./services/storage.service";
|
|
121
|
-
|
|
122
|
-
// Proof Verification Errors
|
|
123
|
-
export {
|
|
124
|
-
ProofVerificationError,
|
|
125
|
-
PROOF_VERIFICATION_ERROR_CODES,
|
|
126
|
-
createProofVerificationError,
|
|
127
|
-
} from "./services/errors";
|
|
128
|
-
|
|
129
|
-
export type { ProofVerificationErrorCode } from "./services/errors";
|
|
130
|
-
|
|
131
|
-
export {
|
|
132
|
-
ToolProtectionCache,
|
|
133
|
-
InMemoryToolProtectionCache,
|
|
134
|
-
NoOpToolProtectionCache,
|
|
135
|
-
} from "./cache/tool-protection-cache";
|
|
136
|
-
|
|
137
|
-
export type {
|
|
138
|
-
ToolProtection,
|
|
139
|
-
ToolProtectionConfig,
|
|
140
|
-
ToolProtectionServiceConfig,
|
|
141
|
-
} from "./types/tool-protection";
|
|
142
|
-
|
|
143
|
-
export { DelegationRequiredError } from "./types/tool-protection";
|
|
144
|
-
export { OAuthRequiredError } from "./types/oauth-required-error";
|
|
145
|
-
export type { OAuthRequiredErrorOptions } from "./types/oauth-required-error";
|
|
146
|
-
|
|
147
|
-
// Delegation (W3C VC-based)
|
|
148
|
-
export {
|
|
149
|
-
DelegationCredentialIssuer,
|
|
150
|
-
createDelegationIssuer,
|
|
151
|
-
type IssueDelegationOptions,
|
|
152
|
-
type VCSigningFunction,
|
|
153
|
-
type IdentityProvider as DelegationIdentityProvider,
|
|
154
|
-
} from "./delegation/vc-issuer";
|
|
155
|
-
|
|
156
|
-
export {
|
|
157
|
-
DelegationCredentialVerifier,
|
|
158
|
-
createDelegationVerifier,
|
|
159
|
-
type DelegationVCVerificationResult,
|
|
160
|
-
type VerifyDelegationVCOptions,
|
|
161
|
-
type DIDResolver,
|
|
162
|
-
type DIDDocument,
|
|
163
|
-
type VerificationMethod,
|
|
164
|
-
type StatusListResolver,
|
|
165
|
-
type SignatureVerificationFunction,
|
|
166
|
-
} from "./delegation/vc-verifier";
|
|
167
|
-
|
|
168
|
-
// StatusList2021
|
|
169
|
-
export {
|
|
170
|
-
StatusList2021Manager,
|
|
171
|
-
createStatusListManager,
|
|
172
|
-
type StatusListStorageProvider,
|
|
173
|
-
type StatusListIdentityProvider,
|
|
174
|
-
} from "./delegation/statuslist-manager";
|
|
175
|
-
|
|
176
|
-
export {
|
|
177
|
-
BitstringManager,
|
|
178
|
-
isIndexSet,
|
|
179
|
-
type CompressionFunction,
|
|
180
|
-
type DecompressionFunction,
|
|
181
|
-
} from "./delegation/bitstring";
|
|
182
|
-
|
|
183
|
-
// Delegation Graph & Cascading Revocation
|
|
184
|
-
export {
|
|
185
|
-
DelegationGraphManager,
|
|
186
|
-
createDelegationGraph,
|
|
187
|
-
type DelegationNode,
|
|
188
|
-
type DelegationGraphStorageProvider,
|
|
189
|
-
} from "./delegation/delegation-graph";
|
|
190
|
-
|
|
191
|
-
export {
|
|
192
|
-
CascadingRevocationManager,
|
|
193
|
-
createCascadingRevocationManager,
|
|
194
|
-
type RevocationEvent,
|
|
195
|
-
type RevocationHook,
|
|
196
|
-
type CascadingRevocationOptions,
|
|
197
|
-
} from "./delegation/cascading-revocation";
|
|
198
|
-
|
|
199
|
-
// Storage Implementations (for testing and examples)
|
|
200
|
-
export { MemoryStatusListStorage } from "./delegation/storage/memory-statuslist-storage";
|
|
201
|
-
|
|
202
|
-
export { MemoryDelegationGraphStorage } from "./delegation/storage/memory-graph-storage";
|
|
203
|
-
|
|
204
|
-
// DID:key Resolver (Phase 3 VC Verification)
|
|
205
|
-
export {
|
|
206
|
-
createDidKeyResolver,
|
|
207
|
-
isEd25519DidKey,
|
|
208
|
-
extractPublicKeyFromDidKey,
|
|
209
|
-
publicKeyToJwk,
|
|
210
|
-
resolveDidKeySync,
|
|
211
|
-
} from "./delegation/did-key-resolver";
|
|
212
|
-
|
|
213
|
-
// Base58 Utilities (for did:key encoding/decoding)
|
|
214
|
-
export {
|
|
215
|
-
base58Encode,
|
|
216
|
-
base58Decode,
|
|
217
|
-
isValidBase58,
|
|
218
|
-
} from "./utils/base58";
|
|
219
|
-
|
|
220
|
-
// Compliance Verification (with JSON Schema draft-07 support)
|
|
221
|
-
export {
|
|
222
|
-
SchemaVerifier,
|
|
223
|
-
createSchemaVerifier,
|
|
224
|
-
type SchemaMetadata,
|
|
225
|
-
type FieldComplianceResult,
|
|
226
|
-
type SchemaComplianceReport,
|
|
227
|
-
type FullComplianceReport,
|
|
228
|
-
} from "./compliance/schema-verifier";
|
|
229
|
-
|
|
230
|
-
export {
|
|
231
|
-
SCHEMA_REGISTRY,
|
|
232
|
-
getAllSchemas,
|
|
233
|
-
getSchemasByCategory,
|
|
234
|
-
getSchemaById,
|
|
235
|
-
getCriticalSchemas,
|
|
236
|
-
getSchemaStats,
|
|
237
|
-
} from "./compliance/schema-registry";
|
|
238
|
-
|
|
239
|
-
export {
|
|
240
|
-
canonicalizeJSON,
|
|
241
|
-
createUnsignedVCJWT,
|
|
242
|
-
completeVCJWT,
|
|
243
|
-
parseVCJWT,
|
|
244
|
-
type VCJWTHeader,
|
|
245
|
-
type VCJWTPayload,
|
|
246
|
-
type EncodeVCAsJWTOptions,
|
|
247
|
-
} from "./delegation/utils";
|
|
248
|
-
|
|
249
|
-
// Base64 utilities for VC JWT encoding
|
|
250
|
-
export {
|
|
251
|
-
base64urlEncodeFromBytes,
|
|
252
|
-
base64urlEncodeFromString,
|
|
253
|
-
base64urlDecodeToBytes,
|
|
254
|
-
base64urlDecodeToString,
|
|
255
|
-
bytesToBase64,
|
|
256
|
-
} from "./utils/base64";
|
|
257
|
-
|
|
258
|
-
// Re-export commonly used types from contracts
|
|
259
|
-
// Note: @kya-os/contracts exports are at the root level
|
|
260
|
-
import type {
|
|
261
|
-
HandshakeRequest,
|
|
262
|
-
SessionContext,
|
|
263
|
-
NonceCache,
|
|
264
|
-
NonceCacheEntry,
|
|
265
|
-
NonceCacheConfig,
|
|
266
|
-
ProofMeta,
|
|
267
|
-
DetachedProof,
|
|
268
|
-
CanonicalHashes,
|
|
269
|
-
AuditRecord,
|
|
270
|
-
} from "@kya-os/contracts";
|
|
271
|
-
|
|
272
|
-
export type {
|
|
273
|
-
HandshakeRequest,
|
|
274
|
-
SessionContext,
|
|
275
|
-
NonceCache,
|
|
276
|
-
NonceCacheEntry,
|
|
277
|
-
NonceCacheConfig,
|
|
278
|
-
ProofMeta,
|
|
279
|
-
DetachedProof,
|
|
280
|
-
CanonicalHashes,
|
|
281
|
-
AuditRecord,
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// Configuration types and utilities
|
|
285
|
-
export * from "./config";
|
|
286
|
-
|
|
287
|
-
// Remote configuration fetching
|
|
288
|
-
export {
|
|
289
|
-
fetchRemoteConfig,
|
|
290
|
-
type RemoteConfigCache,
|
|
291
|
-
type RemoteConfigOptions,
|
|
292
|
-
} from "./config/remote-config";
|
|
293
|
-
|
|
294
|
-
// User DID Manager (Phase 4)
|
|
295
|
-
export { UserDidManager } from "./identity/user-did-manager";
|
|
296
|
-
export type {
|
|
297
|
-
UserDidStorage,
|
|
298
|
-
UserDidManagerConfig,
|
|
299
|
-
UserKeyPair,
|
|
300
|
-
OAuthIdentity,
|
|
301
|
-
} from "./identity/user-did-manager";
|
|
302
|
-
|
|
303
|
-
// IDP Token Resolver (Phase 1 - MH-7, updated for CRED-003)
|
|
304
|
-
export { IdpTokenResolver } from "./identity/idp-token-resolver";
|
|
305
|
-
export type { IdpTokenResolverConfig } from "./identity/idp-token-resolver";
|
|
306
|
-
export type {
|
|
307
|
-
IIdpTokenStorage,
|
|
308
|
-
TokenUsageMetadata,
|
|
309
|
-
IdpTokensWithMetadata,
|
|
310
|
-
} from "./identity/idp-token-storage.interface";
|
package/src/providers/base.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Provider Classes
|
|
3
|
-
*
|
|
4
|
-
* Abstract classes that define the provider interfaces for
|
|
5
|
-
* platform-specific implementations.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Cryptographic operations provider
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class CryptoProvider {
|
|
11
|
-
abstract sign(data: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
12
|
-
abstract verify(data: Uint8Array, signature: Uint8Array, publicKey: string): Promise<boolean>;
|
|
13
|
-
abstract generateKeyPair(): Promise<{
|
|
14
|
-
privateKey: string;
|
|
15
|
-
publicKey: string;
|
|
16
|
-
}>;
|
|
17
|
-
abstract hash(data: Uint8Array): Promise<Uint8Array>;
|
|
18
|
-
abstract randomBytes(length: number): Promise<Uint8Array>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Clock/timing operations provider
|
|
22
|
-
*/
|
|
23
|
-
export declare abstract class ClockProvider {
|
|
24
|
-
abstract now(): number;
|
|
25
|
-
abstract isWithinSkew(timestamp: number, skewSeconds: number): boolean;
|
|
26
|
-
abstract hasExpired(expiresAt: number): boolean;
|
|
27
|
-
abstract calculateExpiry(ttlSeconds: number): number;
|
|
28
|
-
abstract format(timestamp: number): string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Network fetch operations provider
|
|
32
|
-
*/
|
|
33
|
-
export declare abstract class FetchProvider {
|
|
34
|
-
abstract resolveDID(did: string): Promise<any>;
|
|
35
|
-
abstract fetchStatusList(url: string): Promise<any>;
|
|
36
|
-
abstract fetchDelegationChain(id: string): Promise<any[]>;
|
|
37
|
-
abstract fetch(url: string, options?: any): Promise<Response>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Storage operations provider
|
|
41
|
-
*/
|
|
42
|
-
export declare abstract class StorageProvider {
|
|
43
|
-
abstract get(key: string): Promise<string | null>;
|
|
44
|
-
abstract set(key: string, value: string): Promise<void>;
|
|
45
|
-
abstract delete(key: string): Promise<void>;
|
|
46
|
-
abstract exists(key: string): Promise<boolean>;
|
|
47
|
-
abstract list(prefix?: string): Promise<string[]>;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Nonce cache provider
|
|
51
|
-
* Handles replay prevention
|
|
52
|
-
*
|
|
53
|
-
* Nonces should be scoped per agent to prevent cross-agent replay attacks.
|
|
54
|
-
* When agentDid is provided, implementations should use agent-scoped keys.
|
|
55
|
-
*/
|
|
56
|
-
export declare abstract class NonceCacheProvider {
|
|
57
|
-
/**
|
|
58
|
-
* Check if a nonce has been used
|
|
59
|
-
* @param nonce - The nonce to check
|
|
60
|
-
* @param agentDid - Optional agent DID for scoping (prevents cross-agent replay attacks)
|
|
61
|
-
*/
|
|
62
|
-
abstract has(nonce: string, agentDid?: string): Promise<boolean>;
|
|
63
|
-
/**
|
|
64
|
-
* Add a nonce to the cache
|
|
65
|
-
* @param nonce - The nonce to cache
|
|
66
|
-
* @param ttlSeconds - Time to live in seconds (callers now pass TTL, not absolute timestamp)
|
|
67
|
-
* @param agentDid - Optional agent DID for scoping (prevents cross-agent replay attacks)
|
|
68
|
-
*/
|
|
69
|
-
abstract add(nonce: string, ttlSeconds: number, agentDid?: string): Promise<void>;
|
|
70
|
-
abstract cleanup(): Promise<void>;
|
|
71
|
-
abstract destroy(): Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Identity provider for managing agent identities
|
|
75
|
-
*/
|
|
76
|
-
export interface AgentIdentity {
|
|
77
|
-
did: string;
|
|
78
|
-
kid: string;
|
|
79
|
-
privateKey: string;
|
|
80
|
-
publicKey: string;
|
|
81
|
-
createdAt: string;
|
|
82
|
-
type: 'development' | 'production';
|
|
83
|
-
metadata?: Record<string, any>;
|
|
84
|
-
}
|
|
85
|
-
export declare abstract class IdentityProvider {
|
|
86
|
-
abstract getIdentity(): Promise<AgentIdentity>;
|
|
87
|
-
abstract saveIdentity(identity: AgentIdentity): Promise<void>;
|
|
88
|
-
abstract rotateKeys(): Promise<AgentIdentity>;
|
|
89
|
-
abstract deleteIdentity(): Promise<void>;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["base.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,OAAgB,cAAc;CAMnC;AAED;;GAEG;AACH,MAAM,OAAgB,aAAa;CAMlC;AAED;;GAEG;AACH,MAAM,OAAgB,aAAa;CAKlC;AAED;;GAEG;AACH,MAAM,OAAgB,eAAe;CAMpC;AAED;;;;;;GAMG;AACH,MAAM,OAAgB,kBAAkB;CAkBvC;AAeD,MAAM,OAAgB,gBAAgB;CAKrC"}
|
package/src/providers/base.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Provider Classes
|
|
3
|
-
*
|
|
4
|
-
* Abstract classes that define the provider interfaces for
|
|
5
|
-
* platform-specific implementations.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Cryptographic operations provider
|
|
10
|
-
*/
|
|
11
|
-
export abstract class CryptoProvider {
|
|
12
|
-
abstract sign(data: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
13
|
-
abstract verify(data: Uint8Array, signature: Uint8Array, publicKey: string): Promise<boolean>;
|
|
14
|
-
abstract generateKeyPair(): Promise<{ privateKey: string; publicKey: string }>;
|
|
15
|
-
abstract hash(data: Uint8Array): Promise<Uint8Array>;
|
|
16
|
-
abstract randomBytes(length: number): Promise<Uint8Array>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Clock/timing operations provider
|
|
21
|
-
*/
|
|
22
|
-
export abstract class ClockProvider {
|
|
23
|
-
abstract now(): number;
|
|
24
|
-
abstract isWithinSkew(timestamp: number, skewSeconds: number): boolean;
|
|
25
|
-
abstract hasExpired(expiresAt: number): boolean;
|
|
26
|
-
abstract calculateExpiry(ttlSeconds: number): number;
|
|
27
|
-
abstract format(timestamp: number): string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Network fetch operations provider
|
|
32
|
-
*/
|
|
33
|
-
export abstract class FetchProvider {
|
|
34
|
-
abstract resolveDID(did: string): Promise<any>;
|
|
35
|
-
abstract fetchStatusList(url: string): Promise<any>;
|
|
36
|
-
abstract fetchDelegationChain(id: string): Promise<any[]>;
|
|
37
|
-
abstract fetch(url: string, options?: any): Promise<Response>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Storage operations provider
|
|
42
|
-
*/
|
|
43
|
-
export abstract class StorageProvider {
|
|
44
|
-
abstract get(key: string): Promise<string | null>;
|
|
45
|
-
abstract set(key: string, value: string): Promise<void>;
|
|
46
|
-
abstract delete(key: string): Promise<void>;
|
|
47
|
-
abstract exists(key: string): Promise<boolean>;
|
|
48
|
-
abstract list(prefix?: string): Promise<string[]>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Nonce cache provider
|
|
53
|
-
* Handles replay prevention
|
|
54
|
-
*
|
|
55
|
-
* Nonces should be scoped per agent to prevent cross-agent replay attacks.
|
|
56
|
-
* When agentDid is provided, implementations should use agent-scoped keys.
|
|
57
|
-
*/
|
|
58
|
-
export abstract class NonceCacheProvider {
|
|
59
|
-
/**
|
|
60
|
-
* Check if a nonce has been used
|
|
61
|
-
* @param nonce - The nonce to check
|
|
62
|
-
* @param agentDid - Optional agent DID for scoping (prevents cross-agent replay attacks)
|
|
63
|
-
*/
|
|
64
|
-
abstract has(nonce: string, agentDid?: string): Promise<boolean>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Add a nonce to the cache
|
|
68
|
-
* @param nonce - The nonce to cache
|
|
69
|
-
* @param ttlSeconds - Time to live in seconds (callers now pass TTL, not absolute timestamp)
|
|
70
|
-
* @param agentDid - Optional agent DID for scoping (prevents cross-agent replay attacks)
|
|
71
|
-
*/
|
|
72
|
-
abstract add(nonce: string, ttlSeconds: number, agentDid?: string): Promise<void>;
|
|
73
|
-
|
|
74
|
-
abstract cleanup(): Promise<void>;
|
|
75
|
-
abstract destroy(): Promise<void>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Identity provider for managing agent identities
|
|
80
|
-
*/
|
|
81
|
-
export interface AgentIdentity {
|
|
82
|
-
did: string;
|
|
83
|
-
kid: string;
|
|
84
|
-
privateKey: string;
|
|
85
|
-
publicKey: string;
|
|
86
|
-
createdAt: string;
|
|
87
|
-
type: 'development' | 'production';
|
|
88
|
-
metadata?: Record<string, any>;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export abstract class IdentityProvider {
|
|
92
|
-
abstract getIdentity(): Promise<AgentIdentity>;
|
|
93
|
-
abstract saveIdentity(identity: AgentIdentity): Promise<void>;
|
|
94
|
-
abstract rotateKeys(): Promise<AgentIdentity>;
|
|
95
|
-
abstract deleteIdentity(): Promise<void>;
|
|
96
|
-
}
|
package/src/providers/memory.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory-based provider implementations
|
|
3
|
-
*
|
|
4
|
-
* Simple in-memory implementations for development and testing.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
StorageProvider,
|
|
9
|
-
NonceCacheProvider,
|
|
10
|
-
IdentityProvider,
|
|
11
|
-
AgentIdentity
|
|
12
|
-
} from './base';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* In-memory storage provider
|
|
16
|
-
*/
|
|
17
|
-
export class MemoryStorageProvider extends StorageProvider {
|
|
18
|
-
private store: Map<string, string> = new Map();
|
|
19
|
-
|
|
20
|
-
async get(key: string): Promise<string | null> {
|
|
21
|
-
return this.store.get(key) ?? null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async set(key: string, value: string): Promise<void> {
|
|
25
|
-
this.store.set(key, value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async delete(key: string): Promise<void> {
|
|
29
|
-
this.store.delete(key);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async exists(key: string): Promise<boolean> {
|
|
33
|
-
return this.store.has(key);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async list(prefix?: string): Promise<string[]> {
|
|
37
|
-
const keys = Array.from(this.store.keys());
|
|
38
|
-
if (prefix) {
|
|
39
|
-
return keys.filter(k => k.startsWith(prefix));
|
|
40
|
-
}
|
|
41
|
-
return keys;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* In-memory nonce cache provider
|
|
47
|
-
*/
|
|
48
|
-
export class MemoryNonceCacheProvider extends NonceCacheProvider {
|
|
49
|
-
private nonces: Map<string, number> = new Map();
|
|
50
|
-
|
|
51
|
-
async has(nonce: string, agentDid?: string): Promise<boolean> {
|
|
52
|
-
const key = agentDid ? `nonce:${agentDid}:${nonce}` : `nonce:${nonce}`;
|
|
53
|
-
const expiry = this.nonces.get(key);
|
|
54
|
-
if (!expiry) return false;
|
|
55
|
-
|
|
56
|
-
if (Date.now() > expiry) {
|
|
57
|
-
this.nonces.delete(key);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async add(nonce: string, ttlSeconds: number, agentDid?: string): Promise<void> {
|
|
65
|
-
const key = agentDid ? `nonce:${agentDid}:${nonce}` : `nonce:${nonce}`;
|
|
66
|
-
// Convert TTL seconds to absolute expiration timestamp for storage
|
|
67
|
-
const expiresAt = Date.now() + (ttlSeconds * 1000);
|
|
68
|
-
this.nonces.set(key, expiresAt);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async cleanup(): Promise<void> {
|
|
72
|
-
const now = Date.now();
|
|
73
|
-
for (const [nonce, expiry] of this.nonces) {
|
|
74
|
-
if (now > expiry) {
|
|
75
|
-
this.nonces.delete(nonce);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async destroy(): Promise<void> {
|
|
81
|
-
this.nonces.clear();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* In-memory identity provider
|
|
87
|
-
*/
|
|
88
|
-
export class MemoryIdentityProvider extends IdentityProvider {
|
|
89
|
-
private identity?: AgentIdentity;
|
|
90
|
-
private cryptoProvider: any;
|
|
91
|
-
|
|
92
|
-
constructor(cryptoProvider?: any) {
|
|
93
|
-
super();
|
|
94
|
-
this.cryptoProvider = cryptoProvider;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async getIdentity(): Promise<AgentIdentity> {
|
|
98
|
-
if (!this.identity) {
|
|
99
|
-
this.identity = await this.generateIdentity();
|
|
100
|
-
}
|
|
101
|
-
return this.identity;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async saveIdentity(identity: AgentIdentity): Promise<void> {
|
|
105
|
-
this.identity = identity;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async rotateKeys(): Promise<AgentIdentity> {
|
|
109
|
-
this.identity = await this.generateIdentity();
|
|
110
|
-
return this.identity;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async deleteIdentity(): Promise<void> {
|
|
114
|
-
this.identity = undefined;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private async generateIdentity(): Promise<AgentIdentity> {
|
|
118
|
-
if (!this.cryptoProvider) {
|
|
119
|
-
throw new Error('Crypto provider required for identity generation');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const keyPair = await this.cryptoProvider.generateKeyPair();
|
|
123
|
-
const did = this.generateDIDFromPublicKey(keyPair.publicKey);
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
did,
|
|
127
|
-
kid: `${did}#key-1`,
|
|
128
|
-
privateKey: keyPair.privateKey,
|
|
129
|
-
publicKey: keyPair.publicKey,
|
|
130
|
-
createdAt: new Date().toISOString(),
|
|
131
|
-
type: 'development'
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private generateDIDFromPublicKey(publicKey: string): string {
|
|
136
|
-
// Simplified DID generation
|
|
137
|
-
const keyHash = Buffer.from(publicKey, 'base64')
|
|
138
|
-
.toString('base64url')
|
|
139
|
-
.substring(0, 32);
|
|
140
|
-
return `did:key:z${keyHash}`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Audit Logger Interface
|
|
3
|
-
*
|
|
4
|
-
* Platform-agnostic interface for audit logging in the MCP-I framework.
|
|
5
|
-
* Implementations should be provided by platform-specific packages.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { AuditContext, AuditEventContext } from "@kya-os/contracts/audit";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Interface for audit logging implementations
|
|
12
|
-
*
|
|
13
|
-
* This interface is platform-agnostic and can be implemented by:
|
|
14
|
-
* - Node.js implementations (using Node.js crypto)
|
|
15
|
-
* - Cloudflare Workers implementations (using Web Crypto API)
|
|
16
|
-
* - Other platform-specific implementations
|
|
17
|
-
*/
|
|
18
|
-
export interface IAuditLogger {
|
|
19
|
-
/**
|
|
20
|
-
* Log an audit record (with session deduplication)
|
|
21
|
-
*
|
|
22
|
-
* This method logs audit records using the frozen audit.v1 format.
|
|
23
|
-
* Only the first call per session is logged (deduplication).
|
|
24
|
-
*
|
|
25
|
-
* @param context - Audit context with identity, session, hashes, and verification status
|
|
26
|
-
*/
|
|
27
|
-
logAuditRecord(context: AuditContext): Promise<void>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Log an event (without session deduplication)
|
|
31
|
-
*
|
|
32
|
-
* This method logs events using the frozen audit.v1 format.
|
|
33
|
-
* Unlike logAuditRecord(), this always logs the event, allowing
|
|
34
|
-
* multiple events per session (e.g., consent events).
|
|
35
|
-
*
|
|
36
|
-
* @param context - Event context with eventType, identity, session, and optional eventData
|
|
37
|
-
*/
|
|
38
|
-
logEvent(context: AuditEventContext): Promise<void>;
|
|
39
|
-
}
|