@kya-os/mcp 1.16.2 → 1.18.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/AUDITABILITY.md +129 -8
- package/CHANGELOG.md +641 -0
- package/CONFORMANCE.md +12 -6
- package/README.md +67 -26
- package/SPEC.md +105 -18
- package/dist/audit/adapters/legacy-audit-log.d.ts +0 -1
- package/dist/audit/adapters/mcp.d.ts +0 -1
- package/dist/audit/adapters/mcp.js +35 -20
- package/dist/audit/adapters/mcp.js.map +1 -1
- package/dist/audit/adapters/references.d.ts +9 -0
- package/dist/audit/adapters/references.js +22 -0
- package/dist/audit/adapters/references.js.map +1 -0
- package/dist/audit/assurance.d.ts +0 -1
- package/dist/audit/checkpoint-coordinator.d.ts +0 -1
- package/dist/audit/checkpoint.d.ts +17 -1
- package/dist/audit/checkpoint.js +76 -21
- package/dist/audit/checkpoint.js.map +1 -1
- package/dist/audit/cli.d.ts +0 -1
- package/dist/audit/crypto.d.ts +0 -1
- package/dist/audit/crypto.js +12 -3
- package/dist/audit/crypto.js.map +1 -1
- package/dist/audit/errors.d.ts +0 -1
- package/dist/audit/evidence.d.ts +0 -1
- package/dist/audit/index.d.ts +0 -1
- package/dist/audit/integrity.d.ts +0 -1
- package/dist/audit/merkle.d.ts +0 -1
- package/dist/audit/mirror-service.d.ts +0 -1
- package/dist/audit/projection.d.ts +1 -1
- package/dist/audit/projection.js +23 -2
- package/dist/audit/projection.js.map +1 -1
- package/dist/audit/providers/anchor.d.ts +0 -1
- package/dist/audit/providers/evidence.d.ts +0 -1
- package/dist/audit/providers/journal.d.ts +0 -1
- package/dist/audit/providers/memory-journal.d.ts +0 -1
- package/dist/audit/providers/observer.d.ts +0 -1
- package/dist/audit/providers/outbox.d.ts +35 -6
- package/dist/audit/providers/outbox.js +46 -8
- package/dist/audit/providers/outbox.js.map +1 -1
- package/dist/audit/providers/recorder-client.d.ts +0 -1
- package/dist/audit/providers/source-state.d.ts +24 -2
- package/dist/audit/providers/source-state.js +65 -44
- package/dist/audit/providers/source-state.js.map +1 -1
- package/dist/audit/read-contract.d.ts +0 -1
- package/dist/audit/read-service.d.ts +2 -3
- package/dist/audit/read-service.js +17 -12
- package/dist/audit/read-service.js.map +1 -1
- package/dist/audit/recorder-service.d.ts +33 -5
- package/dist/audit/recorder-service.js +116 -20
- package/dist/audit/recorder-service.js.map +1 -1
- package/dist/audit/reference-recorder.d.ts +0 -1
- package/dist/audit/replay-bundle.d.ts +0 -1
- package/dist/audit/replay-bundle.js +143 -36
- package/dist/audit/replay-bundle.js.map +1 -1
- package/dist/audit/schemas.d.ts +0 -1
- package/dist/audit/service.d.ts +6 -3
- package/dist/audit/service.js +55 -24
- package/dist/audit/service.js.map +1 -1
- package/dist/audit/testing/index.d.ts +0 -1
- package/dist/audit/testing/provider-contracts.d.ts +1 -2
- package/dist/audit/testing/provider-contracts.js +32 -2
- package/dist/audit/testing/provider-contracts.js.map +1 -1
- package/dist/audit/types.d.ts +0 -1
- package/dist/audit/verifier.d.ts +57 -5
- package/dist/audit/verifier.js +240 -49
- package/dist/audit/verifier.js.map +1 -1
- package/dist/auth/handshake.d.ts +12 -1
- package/dist/auth/handshake.js +44 -11
- package/dist/auth/handshake.js.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/types.d.ts +0 -1
- package/dist/authz/accountability.d.ts +0 -1
- package/dist/authz/adapter.d.ts +0 -1
- package/dist/authz/examples/inmemory-oidc.d.ts +0 -1
- package/dist/authz/index.d.ts +0 -1
- package/dist/authz/oidc/authorize.d.ts +0 -1
- package/dist/authz/oidc/metadata.d.ts +0 -1
- package/dist/authz/oidc/oidc-adapter.d.ts +0 -1
- package/dist/authz/oidc/oidc-adapter.js +51 -3
- package/dist/authz/oidc/oidc-adapter.js.map +1 -1
- package/dist/authz/oidc/pending-flow-store.d.ts +6 -1
- package/dist/authz/oidc/pending-flow-store.js +22 -2
- package/dist/authz/oidc/pending-flow-store.js.map +1 -1
- package/dist/authz/oidc/pkce.d.ts +0 -1
- package/dist/authz/registry.d.ts +0 -1
- package/dist/authz/requirement.d.ts +0 -1
- package/dist/card/build.d.ts +0 -1
- package/dist/card/builder.d.ts +0 -1
- package/dist/card/cimd.d.ts +19 -5
- package/dist/card/cimd.js +52 -7
- package/dist/card/cimd.js.map +1 -1
- package/dist/card/delegation.d.ts +12 -4
- package/dist/card/delegation.js +38 -22
- package/dist/card/delegation.js.map +1 -1
- package/dist/card/emit.d.ts +0 -1
- package/dist/card/index.d.ts +0 -1
- package/dist/card/middleware.d.ts +0 -1
- package/dist/card/proof/build.d.ts +0 -1
- package/dist/card/proof/canonical.d.ts +0 -1
- package/dist/card/proof/canonical.js +6 -1
- package/dist/card/proof/canonical.js.map +1 -1
- package/dist/card/proof/http-sig.d.ts +0 -1
- package/dist/card/proof/index.d.ts +0 -1
- package/dist/card/proof/nonce-cache.d.ts +15 -14
- package/dist/card/proof/nonce-cache.js +22 -20
- package/dist/card/proof/nonce-cache.js.map +1 -1
- package/dist/card/proof/signer.d.ts +0 -1
- package/dist/card/proof/types.d.ts +10 -4
- package/dist/card/proof/types.js +2 -2
- package/dist/card/proof/verify.d.ts +0 -1
- package/dist/card/proof/verify.js +17 -3
- package/dist/card/proof/verify.js.map +1 -1
- package/dist/card/resolve.d.ts +0 -1
- package/dist/card/resolve.js +13 -8
- package/dist/card/resolve.js.map +1 -1
- package/dist/card/revocation.d.ts +0 -1
- package/dist/card/revocation.js +18 -6
- package/dist/card/revocation.js.map +1 -1
- package/dist/card/schema.d.ts +7 -6
- package/dist/card/schema.js +7 -3
- package/dist/card/schema.js.map +1 -1
- package/dist/card/verify.d.ts +0 -1
- package/dist/delegation/audience-validator.d.ts +0 -1
- package/dist/delegation/bitstring.d.ts +0 -1
- package/dist/delegation/cascading-revocation.d.ts +1 -2
- package/dist/delegation/cascading-revocation.js +34 -36
- package/dist/delegation/cascading-revocation.js.map +1 -1
- package/dist/delegation/chain-enforcement.d.ts +42 -5
- package/dist/delegation/chain-enforcement.js +127 -34
- package/dist/delegation/chain-enforcement.js.map +1 -1
- package/dist/delegation/delegation-graph.d.ts +30 -1
- package/dist/delegation/delegation-graph.js +33 -0
- package/dist/delegation/delegation-graph.js.map +1 -1
- package/dist/delegation/delegation-registration.d.ts +22 -0
- package/dist/delegation/delegation-registration.js +51 -0
- package/dist/delegation/delegation-registration.js.map +1 -0
- package/dist/delegation/delegation-status-entry.d.ts +22 -0
- package/dist/delegation/delegation-status-entry.js +42 -0
- package/dist/delegation/delegation-status-entry.js.map +1 -0
- package/dist/delegation/did-key-resolver.d.ts +0 -1
- package/dist/delegation/did-key-resolver.js +15 -4
- package/dist/delegation/did-key-resolver.js.map +1 -1
- package/dist/delegation/did-linkage.d.ts +0 -1
- package/dist/delegation/did-resolver-registry.d.ts +0 -1
- package/dist/delegation/did-web-resolver.d.ts +0 -1
- package/dist/delegation/did-web-resolver.js +40 -5
- package/dist/delegation/did-web-resolver.js.map +1 -1
- package/dist/delegation/holder-binding.d.ts +11 -11
- package/dist/delegation/holder-binding.js +8 -17
- package/dist/delegation/holder-binding.js.map +1 -1
- package/dist/delegation/index.d.ts +0 -1
- package/dist/delegation/outbound-headers.d.ts +0 -1
- package/dist/delegation/outbound-proof.d.ts +0 -1
- package/dist/delegation/scope-matcher.d.ts +25 -2
- package/dist/delegation/scope-matcher.js +75 -5
- package/dist/delegation/scope-matcher.js.map +1 -1
- package/dist/delegation/status-cache.d.ts +0 -1
- package/dist/delegation/statuslist-manager.d.ts +18 -2
- package/dist/delegation/statuslist-manager.js +40 -14
- package/dist/delegation/statuslist-manager.js.map +1 -1
- package/dist/delegation/storage/memory-graph-storage.d.ts +9 -3
- package/dist/delegation/storage/memory-graph-storage.js +28 -14
- package/dist/delegation/storage/memory-graph-storage.js.map +1 -1
- package/dist/delegation/storage/memory-statuslist-storage.d.ts +0 -1
- package/dist/delegation/utils.d.ts +5 -5
- package/dist/delegation/utils.js +4 -4
- package/dist/delegation/utils.js.map +1 -1
- package/dist/delegation/vc-issuer.d.ts +0 -1
- package/dist/delegation/vc-jwt-verify.d.ts +7 -2
- package/dist/delegation/vc-jwt-verify.js +55 -3
- package/dist/delegation/vc-jwt-verify.js.map +1 -1
- package/dist/delegation/vc-verification-checks.d.ts +0 -1
- package/dist/delegation/vc-verification-checks.js +9 -5
- package/dist/delegation/vc-verification-checks.js.map +1 -1
- package/dist/delegation/vc-verifier.d.ts +0 -1
- package/dist/delegation/vc-verifier.types.d.ts +0 -1
- package/dist/delegation/verification-method-key.d.ts +0 -1
- package/dist/delegation/verification-method-key.js +4 -3
- package/dist/delegation/verification-method-key.js.map +1 -1
- package/dist/errors.d.ts +0 -1
- package/dist/extension/declaration.d.ts +0 -1
- package/dist/extension/gate.d.ts +0 -1
- package/dist/extension/index.d.ts +0 -1
- package/dist/extension/settings.d.ts +0 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/cheqd/dlr.d.ts +0 -1
- package/dist/integrations/cheqd/dlr.js +6 -1
- package/dist/integrations/cheqd/dlr.js.map +1 -1
- package/dist/integrations/cheqd/index.d.ts +0 -1
- package/dist/integrations/cheqd/linkage.d.ts +0 -1
- package/dist/integrations/cheqd/registrar.d.ts +0 -1
- package/dist/integrations/cheqd/resolver.d.ts +0 -1
- package/dist/integrations/cheqd/statuslist-resolver.d.ts +0 -1
- package/dist/logging/index.d.ts +0 -1
- package/dist/logging/logger.d.ts +0 -1
- package/dist/middleware/index.d.ts +0 -1
- package/dist/middleware/kya-os-transport.d.ts +5 -3
- package/dist/middleware/kya-os-transport.js +58 -24
- package/dist/middleware/kya-os-transport.js.map +1 -1
- package/dist/middleware/with-kya-os-server.d.ts +30 -4
- package/dist/middleware/with-kya-os-server.js +19 -0
- package/dist/middleware/with-kya-os-server.js.map +1 -1
- package/dist/middleware/with-kya-os.config-types.d.ts +32 -4
- package/dist/middleware/with-kya-os.d.ts +0 -1
- package/dist/middleware/with-kya-os.delegation-gate.d.ts +2 -1
- package/dist/middleware/with-kya-os.delegation-gate.js +37 -9
- package/dist/middleware/with-kya-os.delegation-gate.js.map +1 -1
- package/dist/middleware/with-kya-os.delegation-verify.d.ts +1 -1
- package/dist/middleware/with-kya-os.delegation-verify.js +52 -9
- package/dist/middleware/with-kya-os.delegation-verify.js.map +1 -1
- package/dist/middleware/with-kya-os.deps.d.ts +0 -1
- package/dist/middleware/with-kya-os.grants.d.ts +13 -6
- package/dist/middleware/with-kya-os.grants.js +56 -18
- package/dist/middleware/with-kya-os.grants.js.map +1 -1
- package/dist/middleware/with-kya-os.helpers.d.ts +0 -1
- package/dist/middleware/with-kya-os.js +14 -4
- package/dist/middleware/with-kya-os.js.map +1 -1
- package/dist/middleware/with-kya-os.policy-gate.d.ts +0 -1
- package/dist/middleware/with-kya-os.policy-gate.js +18 -9
- package/dist/middleware/with-kya-os.policy-gate.js.map +1 -1
- package/dist/middleware/with-kya-os.protocol.d.ts +0 -1
- package/dist/middleware/with-kya-os.session.d.ts +28 -1
- package/dist/middleware/with-kya-os.session.js +146 -7
- package/dist/middleware/with-kya-os.session.js.map +1 -1
- package/dist/middleware/with-kya-os.types.d.ts +28 -5
- package/dist/policy/approval.d.ts +13 -2
- package/dist/policy/approval.js +15 -4
- package/dist/policy/approval.js.map +1 -1
- package/dist/policy/classifier.d.ts +0 -1
- package/dist/policy/default-engine.d.ts +5 -2
- package/dist/policy/default-engine.js +10 -2
- package/dist/policy/default-engine.js.map +1 -1
- package/dist/policy/engine.d.ts +0 -1
- package/dist/policy/index.d.ts +0 -1
- package/dist/policy/projection.d.ts +0 -1
- package/dist/policy/types.d.ts +0 -1
- package/dist/proof/covered-request.d.ts +46 -0
- package/dist/proof/covered-request.js +107 -0
- package/dist/proof/covered-request.js.map +1 -0
- package/dist/proof/errors.d.ts +3 -1
- package/dist/proof/errors.js +5 -0
- package/dist/proof/errors.js.map +1 -1
- package/dist/proof/generator.d.ts +51 -1
- package/dist/proof/generator.js +71 -13
- package/dist/proof/generator.js.map +1 -1
- package/dist/proof/index.d.ts +1 -2
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/verifier.d.ts +50 -12
- package/dist/proof/verifier.js +164 -84
- package/dist/proof/verifier.js.map +1 -1
- package/dist/providers/audit-log.d.ts +0 -1
- package/dist/providers/base.d.ts +19 -1
- package/dist/providers/base.js.map +1 -1
- package/dist/providers/grant-store.d.ts +8 -2
- package/dist/providers/grant-store.js +5 -5
- package/dist/providers/grant-store.js.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/memory.d.ts +19 -1
- package/dist/providers/memory.js +53 -7
- package/dist/providers/memory.js.map +1 -1
- package/dist/providers/node-crypto.d.ts +4 -1
- package/dist/providers/node-crypto.js +32 -9
- package/dist/providers/node-crypto.js.map +1 -1
- package/dist/providers/nonce-admission.d.ts +31 -0
- package/dist/providers/nonce-admission.js +47 -0
- package/dist/providers/nonce-admission.js.map +1 -0
- package/dist/providers/nonce-retention.d.ts +8 -0
- package/dist/providers/nonce-retention.js +15 -0
- package/dist/providers/nonce-retention.js.map +1 -0
- package/dist/providers/runtime-fetch.d.ts +0 -1
- package/dist/providers/system-clock.d.ts +0 -1
- package/dist/providers/web-crypto.d.ts +0 -1
- package/dist/providers/web-crypto.js +7 -1
- package/dist/providers/web-crypto.js.map +1 -1
- package/dist/session/index.d.ts +0 -1
- package/dist/session/manager.d.ts +13 -1
- package/dist/session/manager.js +25 -9
- package/dist/session/manager.js.map +1 -1
- package/dist/session/session-store.d.ts +0 -1
- package/dist/types/protocol.d.ts +11 -3
- package/dist/types/protocol.js +21 -14
- package/dist/types/protocol.js.map +1 -1
- package/dist/utils/base58.d.ts +16 -3
- package/dist/utils/base58.js +34 -12
- package/dist/utils/base58.js.map +1 -1
- package/dist/utils/base64.d.ts +0 -1
- package/dist/utils/canonical-json.d.ts +7 -1
- package/dist/utils/canonical-json.js +130 -60
- package/dist/utils/canonical-json.js.map +1 -1
- package/dist/utils/crypto-service.d.ts +0 -1
- package/dist/utils/crypto-service.js +22 -2
- package/dist/utils/crypto-service.js.map +1 -1
- package/dist/utils/did-helpers.d.ts +0 -1
- package/dist/utils/ed25519-constants.d.ts +0 -1
- package/dist/utils/ed25519-public-key.d.ts +27 -0
- package/dist/utils/ed25519-public-key.js +86 -0
- package/dist/utils/ed25519-public-key.js.map +1 -0
- package/dist/utils/guards.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/ip-classifier.d.ts +0 -1
- package/dist/utils/safe-fetch-transports.d.ts +0 -1
- package/dist/utils/safe-fetch-types.d.ts +0 -1
- package/dist/utils/safe-fetch.d.ts +0 -1
- package/dist/utils/statuslist-bits.d.ts +0 -1
- package/dist/utils/statuslist-purpose.d.ts +0 -1
- package/dist/utils/ttl-cache.d.ts +0 -1
- package/dist/utils/url.d.ts +0 -1
- package/package.json +24 -19
- package/schemas/card-delegation-credential.json +4 -1
- package/dist/audit/adapters/legacy-audit-log.d.ts.map +0 -1
- package/dist/audit/adapters/mcp.d.ts.map +0 -1
- package/dist/audit/assurance.d.ts.map +0 -1
- package/dist/audit/checkpoint-coordinator.d.ts.map +0 -1
- package/dist/audit/checkpoint.d.ts.map +0 -1
- package/dist/audit/cli.d.ts.map +0 -1
- package/dist/audit/crypto.d.ts.map +0 -1
- package/dist/audit/errors.d.ts.map +0 -1
- package/dist/audit/evidence.d.ts.map +0 -1
- package/dist/audit/index.d.ts.map +0 -1
- package/dist/audit/integrity.d.ts.map +0 -1
- package/dist/audit/merkle.d.ts.map +0 -1
- package/dist/audit/mirror-service.d.ts.map +0 -1
- package/dist/audit/projection.d.ts.map +0 -1
- package/dist/audit/providers/anchor.d.ts.map +0 -1
- package/dist/audit/providers/evidence.d.ts.map +0 -1
- package/dist/audit/providers/journal.d.ts.map +0 -1
- package/dist/audit/providers/memory-journal.d.ts.map +0 -1
- package/dist/audit/providers/observer.d.ts.map +0 -1
- package/dist/audit/providers/outbox.d.ts.map +0 -1
- package/dist/audit/providers/recorder-client.d.ts.map +0 -1
- package/dist/audit/providers/source-state.d.ts.map +0 -1
- package/dist/audit/read-contract.d.ts.map +0 -1
- package/dist/audit/read-service.d.ts.map +0 -1
- package/dist/audit/recorder-service.d.ts.map +0 -1
- package/dist/audit/reference-recorder.d.ts.map +0 -1
- package/dist/audit/replay-bundle.d.ts.map +0 -1
- package/dist/audit/schemas.d.ts.map +0 -1
- package/dist/audit/service.d.ts.map +0 -1
- package/dist/audit/testing/index.d.ts.map +0 -1
- package/dist/audit/testing/provider-contracts.d.ts.map +0 -1
- package/dist/audit/types.d.ts.map +0 -1
- package/dist/audit/verifier.d.ts.map +0 -1
- package/dist/auth/handshake.d.ts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/authz/accountability.d.ts.map +0 -1
- package/dist/authz/adapter.d.ts.map +0 -1
- package/dist/authz/examples/inmemory-oidc.d.ts.map +0 -1
- package/dist/authz/index.d.ts.map +0 -1
- package/dist/authz/oidc/authorize.d.ts.map +0 -1
- package/dist/authz/oidc/metadata.d.ts.map +0 -1
- package/dist/authz/oidc/oidc-adapter.d.ts.map +0 -1
- package/dist/authz/oidc/pending-flow-store.d.ts.map +0 -1
- package/dist/authz/oidc/pkce.d.ts.map +0 -1
- package/dist/authz/registry.d.ts.map +0 -1
- package/dist/authz/requirement.d.ts.map +0 -1
- package/dist/card/build.d.ts.map +0 -1
- package/dist/card/builder.d.ts.map +0 -1
- package/dist/card/cimd.d.ts.map +0 -1
- package/dist/card/delegation.d.ts.map +0 -1
- package/dist/card/emit.d.ts.map +0 -1
- package/dist/card/index.d.ts.map +0 -1
- package/dist/card/middleware.d.ts.map +0 -1
- package/dist/card/proof/build.d.ts.map +0 -1
- package/dist/card/proof/canonical.d.ts.map +0 -1
- package/dist/card/proof/http-sig.d.ts.map +0 -1
- package/dist/card/proof/index.d.ts.map +0 -1
- package/dist/card/proof/nonce-cache.d.ts.map +0 -1
- package/dist/card/proof/signer.d.ts.map +0 -1
- package/dist/card/proof/types.d.ts.map +0 -1
- package/dist/card/proof/verify.d.ts.map +0 -1
- package/dist/card/resolve.d.ts.map +0 -1
- package/dist/card/revocation.d.ts.map +0 -1
- package/dist/card/schema.d.ts.map +0 -1
- package/dist/card/verify.d.ts.map +0 -1
- package/dist/delegation/audience-validator.d.ts.map +0 -1
- package/dist/delegation/bitstring.d.ts.map +0 -1
- package/dist/delegation/cascading-revocation.d.ts.map +0 -1
- package/dist/delegation/chain-enforcement.d.ts.map +0 -1
- package/dist/delegation/delegation-graph.d.ts.map +0 -1
- package/dist/delegation/did-key-resolver.d.ts.map +0 -1
- package/dist/delegation/did-linkage.d.ts.map +0 -1
- package/dist/delegation/did-resolver-registry.d.ts.map +0 -1
- package/dist/delegation/did-web-resolver.d.ts.map +0 -1
- package/dist/delegation/holder-binding.d.ts.map +0 -1
- package/dist/delegation/index.d.ts.map +0 -1
- package/dist/delegation/outbound-headers.d.ts.map +0 -1
- package/dist/delegation/outbound-proof.d.ts.map +0 -1
- package/dist/delegation/scope-matcher.d.ts.map +0 -1
- package/dist/delegation/status-cache.d.ts.map +0 -1
- package/dist/delegation/statuslist-manager.d.ts.map +0 -1
- package/dist/delegation/storage/memory-graph-storage.d.ts.map +0 -1
- package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +0 -1
- package/dist/delegation/utils.d.ts.map +0 -1
- package/dist/delegation/vc-issuer.d.ts.map +0 -1
- package/dist/delegation/vc-jwt-verify.d.ts.map +0 -1
- package/dist/delegation/vc-verification-checks.d.ts.map +0 -1
- package/dist/delegation/vc-verifier.d.ts.map +0 -1
- package/dist/delegation/vc-verifier.types.d.ts.map +0 -1
- package/dist/delegation/verification-method-key.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/extension/declaration.d.ts.map +0 -1
- package/dist/extension/gate.d.ts.map +0 -1
- package/dist/extension/index.d.ts.map +0 -1
- package/dist/extension/settings.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/integrations/cheqd/dlr.d.ts.map +0 -1
- package/dist/integrations/cheqd/index.d.ts.map +0 -1
- package/dist/integrations/cheqd/linkage.d.ts.map +0 -1
- package/dist/integrations/cheqd/registrar.d.ts.map +0 -1
- package/dist/integrations/cheqd/resolver.d.ts.map +0 -1
- package/dist/integrations/cheqd/statuslist-resolver.d.ts.map +0 -1
- package/dist/logging/index.d.ts.map +0 -1
- package/dist/logging/logger.d.ts.map +0 -1
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/kya-os-transport.d.ts.map +0 -1
- package/dist/middleware/with-kya-os-server.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.config-types.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.delegation-gate.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.delegation-verify.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.deps.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.grants.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.helpers.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.policy-gate.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.protocol.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.session.d.ts.map +0 -1
- package/dist/middleware/with-kya-os.types.d.ts.map +0 -1
- package/dist/policy/approval.d.ts.map +0 -1
- package/dist/policy/classifier.d.ts.map +0 -1
- package/dist/policy/default-engine.d.ts.map +0 -1
- package/dist/policy/engine.d.ts.map +0 -1
- package/dist/policy/index.d.ts.map +0 -1
- package/dist/policy/projection.d.ts.map +0 -1
- package/dist/policy/types.d.ts.map +0 -1
- package/dist/proof/errors.d.ts.map +0 -1
- package/dist/proof/generator.d.ts.map +0 -1
- package/dist/proof/index.d.ts.map +0 -1
- package/dist/proof/verifier.d.ts.map +0 -1
- package/dist/providers/audit-log.d.ts.map +0 -1
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/grant-store.d.ts.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/memory.d.ts.map +0 -1
- package/dist/providers/node-crypto.d.ts.map +0 -1
- package/dist/providers/runtime-fetch.d.ts.map +0 -1
- package/dist/providers/system-clock.d.ts.map +0 -1
- package/dist/providers/web-crypto.d.ts.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/manager.d.ts.map +0 -1
- package/dist/session/session-store.d.ts.map +0 -1
- package/dist/types/protocol.d.ts.map +0 -1
- package/dist/utils/base58.d.ts.map +0 -1
- package/dist/utils/base64.d.ts.map +0 -1
- package/dist/utils/canonical-json.d.ts.map +0 -1
- package/dist/utils/crypto-service.d.ts.map +0 -1
- package/dist/utils/did-helpers.d.ts.map +0 -1
- package/dist/utils/ed25519-constants.d.ts.map +0 -1
- package/dist/utils/guards.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/ip-classifier.d.ts.map +0 -1
- package/dist/utils/safe-fetch-transports.d.ts.map +0 -1
- package/dist/utils/safe-fetch-types.d.ts.map +0 -1
- package/dist/utils/safe-fetch.d.ts.map +0 -1
- package/dist/utils/statuslist-bits.d.ts.map +0 -1
- package/dist/utils/statuslist-purpose.d.ts.map +0 -1
- package/dist/utils/ttl-cache.d.ts.map +0 -1
- package/dist/utils/url.d.ts.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request a proof's `requestHash` covers (SPEC §7.3), and the shapes of
|
|
3
|
+
* one tool call a verifier accepts it for.
|
|
4
|
+
*
|
|
5
|
+
* SPEC §7.3 covers the JSON-RPC request the client actually sends, so anyone
|
|
6
|
+
* holding the wire message can recompute the hash: the `tools/call` message's
|
|
7
|
+
* `{ method, params }` with the members that cannot be signed taken out.
|
|
8
|
+
* `params._meta` is intermediary-mutable transport metadata, and the
|
|
9
|
+
* `_kyaos`-prefixed control arguments carry the credentials that authorize the
|
|
10
|
+
* call (a delegation, the holder-binding proof, approval grants); two of those
|
|
11
|
+
* are themselves bound to this hash, so covering them would make the hash
|
|
12
|
+
* depend on its own output.
|
|
13
|
+
*
|
|
14
|
+
* Producers in 1.x still hash the legacy shape `{ method: <tool name>, params:
|
|
15
|
+
* <arguments> }`, so verifiers already deployed keep accepting their proofs.
|
|
16
|
+
* Verifiers accept a hash of either shape of the same call (see
|
|
17
|
+
* {@link alternateRequestShapes}); producers switch to the §7.3 shape in 2.0.0.
|
|
18
|
+
*/
|
|
19
|
+
/** JSON-RPC method of an MCP tool invocation. */
|
|
20
|
+
const TOOLS_CALL_METHOD = 'tools/call';
|
|
21
|
+
/**
|
|
22
|
+
* The control-arg key prefix. Args beginning with this are protocol envelope
|
|
23
|
+
* (`_kyaos_delegation`, `_kyaos_proof`, `_kyaos_approvals`), not the caller's
|
|
24
|
+
* tool intent.
|
|
25
|
+
*/
|
|
26
|
+
const KYAOS_CONTROL_PREFIX = '_kyaos';
|
|
27
|
+
/**
|
|
28
|
+
* Whether an argument key is reserved KYA-OS protocol envelope (`_kyaos*`:
|
|
29
|
+
* `_kyaos_delegation`, `_kyaos_proof`, `_kyaos_approvals`, …) rather than caller
|
|
30
|
+
* tool intent. The SINGLE predicate behind both the request hash and the
|
|
31
|
+
* middleware's handler-arg stripping, so the set excluded from the bound hash
|
|
32
|
+
* and the set withheld from the handler cannot drift — a proof binds exactly the
|
|
33
|
+
* call the handler runs.
|
|
34
|
+
*/
|
|
35
|
+
export function isKyaOsControlArg(key) {
|
|
36
|
+
return key.startsWith(KYAOS_CONTROL_PREFIX);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The other shapes of the call `request` describes, whose `requestHash` a
|
|
40
|
+
* verifier accepts as well as the hash of `request` itself. A caller may hold
|
|
41
|
+
* the call in either shape: the legacy shape `{ method: <tool name>, params:
|
|
42
|
+
* <arguments> }` that 1.x producers sign, or the `tools/call` request as sent.
|
|
43
|
+
* From either, this yields the SPEC §7.3 covered request and the legacy shape
|
|
44
|
+
* with the arguments as given and with the control args removed: 1.x
|
|
45
|
+
* producers differ in whether control args stay in the legacy shape (the
|
|
46
|
+
* holder-binding request, the step-up hash and wrapped handlers drop them, a
|
|
47
|
+
* proof added at the transport keeps them).
|
|
48
|
+
*
|
|
49
|
+
* Every shape describes the same tool name and business arguments, so
|
|
50
|
+
* accepting any of them binds the same call. The legacy shape keeps its known
|
|
51
|
+
* ambiguities for the 1.x line: a tool named after a JSON-RPC method hashes
|
|
52
|
+
* like that method's request, and `params` members other than the arguments
|
|
53
|
+
* are not covered.
|
|
54
|
+
*/
|
|
55
|
+
export function alternateRequestShapes(request) {
|
|
56
|
+
const call = asToolCall(request);
|
|
57
|
+
if (call === undefined)
|
|
58
|
+
return [];
|
|
59
|
+
const legacy = (args) => ({
|
|
60
|
+
method: call.name,
|
|
61
|
+
params: args,
|
|
62
|
+
});
|
|
63
|
+
return [
|
|
64
|
+
coveredToolCall(call),
|
|
65
|
+
legacy(call.args),
|
|
66
|
+
legacy(withoutKeys(call.args, isKyaOsControlArg)),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Read a tool call's name and arguments from either shape. A `tools/call`
|
|
71
|
+
* whose params carry a string `name` is the wire shape; any other request is
|
|
72
|
+
* read as the legacy shape, its method being the tool name. Arguments that are
|
|
73
|
+
* not an object describe no tool call, so they yield no alternate shapes. An
|
|
74
|
+
* absent `arguments` is read as `{}`: MCP clients may omit it for a call
|
|
75
|
+
* without arguments, and a server cannot tell the two apart.
|
|
76
|
+
*/
|
|
77
|
+
function asToolCall(request) {
|
|
78
|
+
const { method, params } = request;
|
|
79
|
+
if (method === TOOLS_CALL_METHOD && isJsonObject(params) && typeof params['name'] === 'string') {
|
|
80
|
+
const args = params['arguments'] ?? {};
|
|
81
|
+
return isJsonObject(args) ? { name: params['name'], args, params } : undefined;
|
|
82
|
+
}
|
|
83
|
+
const args = params ?? {};
|
|
84
|
+
return isJsonObject(args)
|
|
85
|
+
? { name: method, args, params: { name: method, arguments: args } }
|
|
86
|
+
: undefined;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The SPEC §7.3 covered request for a tool call: its `tools/call` params
|
|
90
|
+
* without the top-level `_meta` member, and its arguments without the control
|
|
91
|
+
* args. Every other params member stays covered, and nothing nested deeper is
|
|
92
|
+
* touched, so signer and verifier derive the same request.
|
|
93
|
+
*/
|
|
94
|
+
function coveredToolCall(call) {
|
|
95
|
+
const params = withoutKeys(call.params, (key) => key === '_meta');
|
|
96
|
+
params['arguments'] = withoutKeys(call.args, isKyaOsControlArg);
|
|
97
|
+
return { method: TOOLS_CALL_METHOD, params };
|
|
98
|
+
}
|
|
99
|
+
function isJsonObject(value) {
|
|
100
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
101
|
+
}
|
|
102
|
+
// Object.fromEntries defines own properties, so a received `__proto__` member
|
|
103
|
+
// stays a member instead of becoming the copy's prototype.
|
|
104
|
+
function withoutKeys(value, drop) {
|
|
105
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => !drop(key)));
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=covered-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"covered-request.js","sourceRoot":"","sources":["../../src/proof/covered-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,iDAAiD;AACjD,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAEvC;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,GAAG,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC9C,CAAC;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACl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CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAChE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,8EAA8E;AAC9E,2DAA2D;AAC3D,SAAS,WAAW,CAClB,KAA8B,EAC9B,IAA8B;IAE9B,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
package/dist/proof/errors.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export declare const PROOF_VERIFICATION_ERROR_CODES: {
|
|
|
14
14
|
readonly TIMESTAMP_SKEW_EXCEEDED: "TIMESTAMP_SKEW_EXCEEDED";
|
|
15
15
|
readonly TIMESTAMP_INVALID: "TIMESTAMP_INVALID";
|
|
16
16
|
readonly CONTENT_BINDING_MISMATCH: "CONTENT_BINDING_MISMATCH";
|
|
17
|
+
readonly KID_DID_MISMATCH: "KID_DID_MISMATCH";
|
|
18
|
+
readonly DID_MISMATCH: "DID_MISMATCH";
|
|
19
|
+
readonly AUDIENCE_MISMATCH: "AUDIENCE_MISMATCH";
|
|
17
20
|
readonly INVALID_JWS_SIGNATURE: "INVALID_JWS_SIGNATURE";
|
|
18
21
|
readonly INVALID_JWS_FORMAT: "INVALID_JWS_FORMAT";
|
|
19
22
|
readonly INVALID_JWS_HEADER: "INVALID_JWS_HEADER";
|
|
@@ -48,4 +51,3 @@ export declare class ProofVerificationError extends Error {
|
|
|
48
51
|
* Create a proof verification error
|
|
49
52
|
*/
|
|
50
53
|
export declare function createProofVerificationError(code: ProofVerificationErrorCode, message: string, details?: Record<string, unknown>): ProofVerificationError;
|
|
51
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/proof/errors.js
CHANGED
|
@@ -19,6 +19,11 @@ export const PROOF_VERIFICATION_ERROR_CODES = {
|
|
|
19
19
|
// the request/response the verifier actually received does not match the hash
|
|
20
20
|
// bound in the (authentic) proof — i.e. the content was substituted in transit.
|
|
21
21
|
CONTENT_BINDING_MISMATCH: "CONTENT_BINDING_MISMATCH",
|
|
22
|
+
// Signer binding: `kid` names a key of a DID other than the claimed `did`,
|
|
23
|
+
// or the proof's `did` / `audience` is not the one the caller expected.
|
|
24
|
+
KID_DID_MISMATCH: "KID_DID_MISMATCH",
|
|
25
|
+
DID_MISMATCH: "DID_MISMATCH",
|
|
26
|
+
AUDIENCE_MISMATCH: "AUDIENCE_MISMATCH",
|
|
22
27
|
// Signature errors
|
|
23
28
|
INVALID_JWS_SIGNATURE: "INVALID_JWS_SIGNATURE",
|
|
24
29
|
INVALID_JWS_FORMAT: "INVALID_JWS_FORMAT",
|
package/dist/proof/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/proof/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,yBAAyB;IACzB,uBAAuB,EAAE,yBAAyB;IAClD,sBAAsB,EAAE,wBAAwB;IAEhD,kBAAkB;IAClB,qBAAqB,EAAE,uBAAuB;IAC9C,uBAAuB,EAAE,yBAAyB;IAClD,iBAAiB,EAAE,mBAAmB;IACtC,8EAA8E;IAC9E,8EAA8E;IAC9E,gFAAgF;IAChF,wBAAwB,EAAE,0BAA0B;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/proof/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;A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SAAI,GAAJ,IAAI,CAA4B;QAEhC,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAAgC,EAChC,OAAe,EACf,OAAiC;IAEjC,OAAO,IAAI,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -57,6 +57,12 @@ export interface ProofAgentIdentity {
|
|
|
57
57
|
privateKey: string | CryptoKey;
|
|
58
58
|
publicKey: string;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* A request as a proof binds it: `method` and `params`. 1.x producers pass a
|
|
62
|
+
* tool call as `{ method: <tool name>, params: <arguments> }`; verifiers also
|
|
63
|
+
* take the `tools/call` request as sent (SPEC §7.3, see
|
|
64
|
+
* {@link acceptedRequestHashes}).
|
|
65
|
+
*/
|
|
60
66
|
export interface ToolRequest {
|
|
61
67
|
method: string;
|
|
62
68
|
params?: unknown;
|
|
@@ -118,6 +124,40 @@ export declare function computeCanonicalHashes(request: ToolRequest, response: T
|
|
|
118
124
|
requestHash: string;
|
|
119
125
|
responseHash?: string;
|
|
120
126
|
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Every `requestHash` a verifier accepts for `request`: the hash of `request`
|
|
129
|
+
* as given (the {@link computeCanonicalHashes} rule producers sign with), then
|
|
130
|
+
* the hashes of the same call's other shapes, so that a caller holding either
|
|
131
|
+
* the legacy `{ method: <tool name>, params: <arguments> }` shape or the
|
|
132
|
+
* `tools/call` request as sent can verify a proof minted over either (SPEC
|
|
133
|
+
* §7.3). Each candidate describes the same tool name and business arguments,
|
|
134
|
+
* so none admits a proof over a different call.
|
|
135
|
+
*/
|
|
136
|
+
export declare function acceptedRequestHashes(request: ToolRequest, hash: (bytes: Uint8Array) => Promise<string>): Promise<string[]>;
|
|
137
|
+
/** How received content fails to match the hashes a proof binds. */
|
|
138
|
+
export type ContentBindingMismatch = 'request' | 'response' | 'response-missing' | 'response-unexpected';
|
|
139
|
+
/**
|
|
140
|
+
* Compare the request (and response) a verifier actually received with the
|
|
141
|
+
* hashes a proof binds; `undefined` means they match. Shared by `ProofVerifier`
|
|
142
|
+
* and `ProofGenerator.verifyProof` so both apply one fail-closed rule.
|
|
143
|
+
*
|
|
144
|
+
* The request matches when `meta.requestHash` is any of
|
|
145
|
+
* {@link acceptedRequestHashes}; the hash of the request as given is tried
|
|
146
|
+
* first, and the other shapes only when it differs.
|
|
147
|
+
*
|
|
148
|
+
* `meta.responseHash` is the ONLY thing that binds the response body —
|
|
149
|
+
* including a needs_authorization challenge's `authorizationUrl` — so it is
|
|
150
|
+
* checked whenever the proof carries one. Gating the comparison on a response
|
|
151
|
+
* being supplied would pass a caller who supplies only the request while a
|
|
152
|
+
* swapped URL went unverified (the `requestHash` is identical for a genuine and
|
|
153
|
+
* a MITM'd challenge). So: a proof that binds a response must be given one, and
|
|
154
|
+
* a proof that binds none must not be. The response profile comes from the
|
|
155
|
+
* proof's own signature-covered `prf` claim, never from configuration.
|
|
156
|
+
*/
|
|
157
|
+
export declare function findContentBindingMismatch(meta: Pick<ProofMeta, 'requestHash' | 'responseHash' | 'prf'>, expected: {
|
|
158
|
+
request: ToolRequest;
|
|
159
|
+
response?: ToolResponse;
|
|
160
|
+
}, hash: (bytes: Uint8Array) => Promise<string>): Promise<ContentBindingMismatch | undefined>;
|
|
121
161
|
/**
|
|
122
162
|
* Build the exact JWS payload object a proof signs over, from its `ProofMeta`.
|
|
123
163
|
* SINGLE source of truth for the payload SHAPE — the signer
|
|
@@ -161,6 +201,17 @@ export declare class ProofGenerator {
|
|
|
161
201
|
private resolveSigningKey;
|
|
162
202
|
private generateJWS;
|
|
163
203
|
private formatPrivateKeyAsPEM;
|
|
204
|
+
/**
|
|
205
|
+
* Check that a proof was signed by this generator's identity over `request`
|
|
206
|
+
* and, when the proof binds one, `response`. Every `meta` member is checked
|
|
207
|
+
* through the signature: the JWS is verified against the payload rebuilt from
|
|
208
|
+
* `meta`, and a payload it embeds must be that one. A proof that binds a
|
|
209
|
+
* response fails without one, and a proof that binds none fails with one.
|
|
210
|
+
* `request` may be given in either shape (see {@link acceptedRequestHashes}).
|
|
211
|
+
*
|
|
212
|
+
* This checks the artifact only, with no freshness or replay state; verify
|
|
213
|
+
* proofs received over the wire with `ProofVerifier.verifyProof`.
|
|
214
|
+
*/
|
|
164
215
|
verifyProof(proof: DetachedProof, request: ToolRequest, response?: ToolResponse): Promise<boolean>;
|
|
165
216
|
private base64PublicKeyToJWK;
|
|
166
217
|
}
|
|
@@ -169,4 +220,3 @@ export declare function extractCanonicalData(request: ToolRequest, response: Too
|
|
|
169
220
|
request: unknown;
|
|
170
221
|
response: unknown;
|
|
171
222
|
};
|
|
172
|
-
//# sourceMappingURL=generator.d.ts.map
|
package/dist/proof/generator.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { CompactSign, importPKCS8 } from 'jose';
|
|
11
11
|
import { canonicalizeJson, canonicalizeJsonBytes } from '../utils/canonical-json.js';
|
|
12
|
-
import { RESPONSE_PROOF_PROFILE_BODY, RESPONSE_PROOF_PROFILE_ENVELOPE, } from '../types/protocol.js';
|
|
12
|
+
import { RESPONSE_PROOF_PROFILE_BODY, RESPONSE_PROOF_PROFILE_ENVELOPE, validateDetachedProof, } from '../types/protocol.js';
|
|
13
13
|
import { CryptoService } from '../utils/crypto-service.js';
|
|
14
|
+
import { alternateRequestShapes } from './covered-request.js';
|
|
14
15
|
import { base64ToBytes, base64urlEncodeFromBytes, bytesToBase64 } from '../utils/base64.js';
|
|
15
16
|
import { ED25519_PKCS8_DER_HEADER, ED25519_KEY_SIZE } from '../utils/ed25519-constants.js';
|
|
16
17
|
/**
|
|
@@ -108,6 +109,54 @@ function canonicalResponseBody(data, profile) {
|
|
|
108
109
|
}
|
|
109
110
|
return envelope;
|
|
110
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Every `requestHash` a verifier accepts for `request`: the hash of `request`
|
|
114
|
+
* as given (the {@link computeCanonicalHashes} rule producers sign with), then
|
|
115
|
+
* the hashes of the same call's other shapes, so that a caller holding either
|
|
116
|
+
* the legacy `{ method: <tool name>, params: <arguments> }` shape or the
|
|
117
|
+
* `tools/call` request as sent can verify a proof minted over either (SPEC
|
|
118
|
+
* §7.3). Each candidate describes the same tool name and business arguments,
|
|
119
|
+
* so none admits a proof over a different call.
|
|
120
|
+
*/
|
|
121
|
+
export async function acceptedRequestHashes(request, hash) {
|
|
122
|
+
const hashes = new Set();
|
|
123
|
+
for (const shape of [request, ...alternateRequestShapes(request)]) {
|
|
124
|
+
hashes.add((await computeCanonicalHashes(shape, undefined, hash)).requestHash);
|
|
125
|
+
}
|
|
126
|
+
return [...hashes];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Compare the request (and response) a verifier actually received with the
|
|
130
|
+
* hashes a proof binds; `undefined` means they match. Shared by `ProofVerifier`
|
|
131
|
+
* and `ProofGenerator.verifyProof` so both apply one fail-closed rule.
|
|
132
|
+
*
|
|
133
|
+
* The request matches when `meta.requestHash` is any of
|
|
134
|
+
* {@link acceptedRequestHashes}; the hash of the request as given is tried
|
|
135
|
+
* first, and the other shapes only when it differs.
|
|
136
|
+
*
|
|
137
|
+
* `meta.responseHash` is the ONLY thing that binds the response body —
|
|
138
|
+
* including a needs_authorization challenge's `authorizationUrl` — so it is
|
|
139
|
+
* checked whenever the proof carries one. Gating the comparison on a response
|
|
140
|
+
* being supplied would pass a caller who supplies only the request while a
|
|
141
|
+
* swapped URL went unverified (the `requestHash` is identical for a genuine and
|
|
142
|
+
* a MITM'd challenge). So: a proof that binds a response must be given one, and
|
|
143
|
+
* a proof that binds none must not be. The response profile comes from the
|
|
144
|
+
* proof's own signature-covered `prf` claim, never from configuration.
|
|
145
|
+
*/
|
|
146
|
+
export async function findContentBindingMismatch(meta, expected, hash) {
|
|
147
|
+
const { requestHash, responseHash } = await computeCanonicalHashes(expected.request, expected.response, hash, meta.prf ?? RESPONSE_PROOF_PROFILE_BODY);
|
|
148
|
+
if (meta.requestHash !== requestHash &&
|
|
149
|
+
!(await acceptedRequestHashes(expected.request, hash)).includes(meta.requestHash)) {
|
|
150
|
+
return 'request';
|
|
151
|
+
}
|
|
152
|
+
const bindsResponse = meta.responseHash !== undefined;
|
|
153
|
+
if (bindsResponse !== (expected.response !== undefined)) {
|
|
154
|
+
return bindsResponse ? 'response-missing' : 'response-unexpected';
|
|
155
|
+
}
|
|
156
|
+
if (bindsResponse && meta.responseHash !== responseHash)
|
|
157
|
+
return 'response';
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
111
160
|
/**
|
|
112
161
|
* Build the exact JWS payload object a proof signs over, from its `ProofMeta`.
|
|
113
162
|
* SINGLE source of truth for the payload SHAPE — the signer
|
|
@@ -252,24 +301,33 @@ export class ProofGenerator {
|
|
|
252
301
|
formattedKey +
|
|
253
302
|
'\n-----END PRIVATE KEY-----');
|
|
254
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Check that a proof was signed by this generator's identity over `request`
|
|
306
|
+
* and, when the proof binds one, `response`. Every `meta` member is checked
|
|
307
|
+
* through the signature: the JWS is verified against the payload rebuilt from
|
|
308
|
+
* `meta`, and a payload it embeds must be that one. A proof that binds a
|
|
309
|
+
* response fails without one, and a proof that binds none fails with one.
|
|
310
|
+
* `request` may be given in either shape (see {@link acceptedRequestHashes}).
|
|
311
|
+
*
|
|
312
|
+
* This checks the artifact only, with no freshness or replay state; verify
|
|
313
|
+
* proofs received over the wire with `ProofVerifier.verifyProof`.
|
|
314
|
+
*/
|
|
255
315
|
async verifyProof(proof, request, response) {
|
|
256
316
|
try {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (
|
|
317
|
+
if (!validateDetachedProof(proof).success)
|
|
318
|
+
return false;
|
|
319
|
+
const { meta } = proof;
|
|
320
|
+
// iss/sub cover meta.did; the protected header's kid is pinned below.
|
|
321
|
+
if (meta.did !== this.identity.did || meta.kid !== this.identity.kid) {
|
|
262
322
|
return false;
|
|
263
323
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
324
|
+
const mismatch = await findContentBindingMismatch(meta, { request, ...(response !== undefined ? { response } : {}) }, (bytes) => this.cryptoProvider.hash(bytes));
|
|
325
|
+
if (mismatch !== undefined)
|
|
326
|
+
return false;
|
|
270
327
|
const publicKeyJwk = this.base64PublicKeyToJWK(this.identity.publicKey);
|
|
271
328
|
const cryptoService = new CryptoService(this.cryptoProvider);
|
|
272
|
-
return cryptoService.verifyJWS(proof.jws, publicKeyJwk, {
|
|
329
|
+
return await cryptoService.verifyJWS(proof.jws, publicKeyJwk, {
|
|
330
|
+
detachedPayload: canonicalizeJson(buildProofJwsPayload(meta)),
|
|
273
331
|
expectedKid: this.identity.kid,
|
|
274
332
|
alg: 'EdDSA',
|
|
275
333
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/proof/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/proof/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,qBAAqB,GAKtB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AE,KAAK,EAAE,CAAC;IAC1B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,OAAoB,EACpB,QAAsB;IAKtB,OAAO;QACL,OAAO,EAAE;YACP,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD;QACD,QAAQ,EAAE,QAAQ,CAAC,IAAI;KACxB,CAAC;AACJ,CAAC"}
|
package/dist/proof/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { ProofGenerator, createProofResponse, extractCanonicalData, computeCanonicalHashes, buildProofJwsPayload, KYA_OS_PROOF_META_KEY, LEGACY_NAMESPACED_PROOF_META_KEY, LEGACY_PROOF_META_KEY, RESPONSE_PROOF_PROFILE_BODY, RESPONSE_PROOF_PROFILE_ENVELOPE, type ProofAgentIdentity, type ToolRequest, type ToolResponse, type ProofOptions, type ResponseProofProfile, } from './generator.js';
|
|
2
|
-
export { ProofVerifier, validateMetaStructure, extractProofFromMeta, DEFAULT_CLOCK_SKEW_SECONDS, MIN_CLOCK_SKEW_SECONDS, MAX_CLOCK_SKEW_SECONDS, type ProofVerifierConfig, type ProofVerificationResult, } from './verifier.js';
|
|
2
|
+
export { ProofVerifier, validateMetaStructure, extractProofFromMeta, DEFAULT_CLOCK_SKEW_SECONDS, MIN_CLOCK_SKEW_SECONDS, MAX_CLOCK_SKEW_SECONDS, type ProofVerifierConfig, type ProofVerificationOptions, type ProofVerificationResult, } from './verifier.js';
|
|
3
3
|
export { ProofVerificationError, PROOF_VERIFICATION_ERROR_CODES, createProofVerificationError, type ProofVerificationErrorCode, } from './errors.js';
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/proof/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proof/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,GAMhC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/proof/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,GAMhC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,GAIvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,GAE7B,MAAM,aAAa,CAAC"}
|
package/dist/proof/verifier.d.ts
CHANGED
|
@@ -19,13 +19,29 @@ export interface ProofVerificationResult {
|
|
|
19
19
|
errorCode?: ProofVerificationErrorCode;
|
|
20
20
|
details?: Record<string, unknown>;
|
|
21
21
|
}
|
|
22
|
+
/** Who a verified proof must come from and be addressed to. */
|
|
23
|
+
export interface ProofVerificationOptions {
|
|
24
|
+
/** `meta.did` must equal this: the signer the caller expects (e.g. the server it called). */
|
|
25
|
+
expectedDid?: string;
|
|
26
|
+
/** `meta.audience` must equal this, or be one of the array (DID rotation, multi-DID servers). */
|
|
27
|
+
expectedAudience?: string | string[];
|
|
28
|
+
}
|
|
22
29
|
export interface ProofVerifierConfig {
|
|
23
30
|
cryptoProvider: CryptoProvider;
|
|
24
31
|
clockProvider: ClockProvider;
|
|
25
32
|
nonceCacheProvider: NonceCacheProvider;
|
|
26
33
|
fetchProvider: FetchProvider;
|
|
27
34
|
timestampSkewSeconds?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Minimum retention in seconds; raised to cover the proof's accepted lifetime
|
|
37
|
+
* and supported skew updates. 0 keeps each nonce for that window only.
|
|
38
|
+
*/
|
|
28
39
|
nonceTtlSeconds?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Refuse nonce caches without an atomic `consume()` instead of falling back
|
|
42
|
+
* to `has()` then `add()`. The constructor throws for such a cache.
|
|
43
|
+
*/
|
|
44
|
+
requireAtomicNonce?: boolean;
|
|
29
45
|
}
|
|
30
46
|
/** Default timestamp skew for proof verification (seconds) */
|
|
31
47
|
export declare const DEFAULT_CLOCK_SKEW_SECONDS = 120;
|
|
@@ -40,6 +56,7 @@ export declare class ProofVerifier {
|
|
|
40
56
|
private fetch;
|
|
41
57
|
private timestampSkewSeconds;
|
|
42
58
|
private nonceTtlSeconds;
|
|
59
|
+
private requireAtomicNonce;
|
|
43
60
|
private cryptoProvider;
|
|
44
61
|
constructor(config: ProofVerifierConfig);
|
|
45
62
|
/**
|
|
@@ -79,13 +96,20 @@ export declare class ProofVerifier {
|
|
|
79
96
|
* `content` array); for an envelope-profile proof (`prf: "org.kya-os/response-proof.envelope"`)
|
|
80
97
|
* pass the ENTIRE received result object — the verifier removes the
|
|
81
98
|
* top-level `_meta` member itself, so passing the result as received (proof
|
|
82
|
-
* attachment included) is correct.
|
|
99
|
+
* attachment included) is correct. Pass the `request` either as the
|
|
100
|
+
* `tools/call` request you sent (`{method: "tools/call", params: {name,
|
|
101
|
+
* arguments}}`) or in the legacy `{method: <tool name>, params: <arguments>}`
|
|
102
|
+
* shape: a `requestHash` over either shape of that call is accepted (SPEC
|
|
103
|
+
* §7.3; 1.x producers sign the legacy shape).
|
|
104
|
+
* @param options - Optional signer binding: the `did` the proof must come
|
|
105
|
+
* from and the `audience` it must be addressed to. Independently of these,
|
|
106
|
+
* a `kid` naming a key of a DID other than `meta.did` always fails.
|
|
83
107
|
* @returns Verification result
|
|
84
108
|
*/
|
|
85
109
|
verifyProof(proof: DetachedProof, publicKeyJwk: Ed25519JWK, expected?: {
|
|
86
110
|
request: ToolRequest;
|
|
87
111
|
response?: ToolResponse;
|
|
88
|
-
}): Promise<ProofVerificationResult>;
|
|
112
|
+
}, options?: ProofVerificationOptions): Promise<ProofVerificationResult>;
|
|
89
113
|
/**
|
|
90
114
|
* Verify a retained proof as historical evidence.
|
|
91
115
|
*
|
|
@@ -99,7 +123,16 @@ export declare class ProofVerifier {
|
|
|
99
123
|
response?: ToolResponse;
|
|
100
124
|
}): Promise<ProofVerificationResult>;
|
|
101
125
|
/**
|
|
102
|
-
* Verify proof with detached payload (for CLI/verifier compatibility)
|
|
126
|
+
* Verify proof with detached payload (for CLI/verifier compatibility).
|
|
127
|
+
*
|
|
128
|
+
* The timestamp and replay checks read `proof.meta`, so the payload the
|
|
129
|
+
* signature is checked over must be the one rebuilt from that meta: a
|
|
130
|
+
* supplied payload that differs from it byte for byte is rejected. Otherwise
|
|
131
|
+
* an accepted proof could be replayed with a fresh `meta.nonce` and the old
|
|
132
|
+
* payload.
|
|
133
|
+
*
|
|
134
|
+
* @deprecated Use {@link verifyProof}. It rebuilds the payload from
|
|
135
|
+
* `proof.meta` itself, so supplying the payload adds nothing.
|
|
103
136
|
* @param proof - The proof to verify
|
|
104
137
|
* @param canonicalPayload - Canonical JSON payload (for detached JWS) as string or Uint8Array
|
|
105
138
|
* @param publicKeyJwk - Ed25519 public key in JWK format
|
|
@@ -107,10 +140,19 @@ export declare class ProofVerifier {
|
|
|
107
140
|
*/
|
|
108
141
|
verifyProofDetached(proof: DetachedProof, canonicalPayload: string | Uint8Array, publicKeyJwk: Ed25519JWK): Promise<ProofVerificationResult>;
|
|
109
142
|
/**
|
|
110
|
-
* Shared verification pipeline for proof
|
|
143
|
+
* Shared verification pipeline for a structurally valid proof.
|
|
111
144
|
* @private
|
|
112
145
|
*/
|
|
113
146
|
private runVerificationPipeline;
|
|
147
|
+
/**
|
|
148
|
+
* Bind the signing key to the principal. `kid` names the signing key; when
|
|
149
|
+
* it is an absolute DID URL its DID part must be `meta.did`, or a proof could
|
|
150
|
+
* claim a victim's DID while being signed by a key another DID publishes. A
|
|
151
|
+
* relative `kid` is resolved against `meta.did`. Then apply the caller's
|
|
152
|
+
* expected signer and audience, if given.
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
private validateSigner;
|
|
114
156
|
/**
|
|
115
157
|
* Recompute the canonical hashes of the request/response the verifier actually
|
|
116
158
|
* received (via the same hashing the signer used) and compare to the proof's
|
|
@@ -130,10 +172,11 @@ export declare class ProofVerifier {
|
|
|
130
172
|
*/
|
|
131
173
|
private validateProofStructure;
|
|
132
174
|
/**
|
|
133
|
-
*
|
|
175
|
+
* Admit the nonce once every other proof check has passed: atomically through
|
|
176
|
+
* the cache's consume(), or through the has()/add() fallback without it.
|
|
134
177
|
* @private
|
|
135
178
|
*/
|
|
136
|
-
private
|
|
179
|
+
private consumeNonce;
|
|
137
180
|
/**
|
|
138
181
|
* Validate timestamp skew
|
|
139
182
|
* @private
|
|
@@ -144,11 +187,6 @@ export declare class ProofVerifier {
|
|
|
144
187
|
* @private
|
|
145
188
|
*/
|
|
146
189
|
private verifySignature;
|
|
147
|
-
/**
|
|
148
|
-
* Add nonce to cache to prevent replay (scoped to agent DID)
|
|
149
|
-
* @private
|
|
150
|
-
*/
|
|
151
|
-
private addNonceToCache;
|
|
152
190
|
/**
|
|
153
191
|
* Fetch public key from DID document
|
|
154
192
|
* @param did - DID to resolve
|
|
@@ -168,6 +206,7 @@ export declare class ProofVerifier {
|
|
|
168
206
|
* @returns Canonical JSON string matching the original JWS payload structure
|
|
169
207
|
*/
|
|
170
208
|
buildCanonicalPayload(meta: DetachedProof["meta"]): string;
|
|
209
|
+
private encodeCanonicalPayload;
|
|
171
210
|
}
|
|
172
211
|
/**
|
|
173
212
|
* Whether `key` is an MCP-reserved / standard `_meta` key (SEP-414) that KYA-OS
|
|
@@ -223,4 +262,3 @@ export declare function extractProofFromMeta(meta: Record<string, unknown>, poli
|
|
|
223
262
|
reason: string;
|
|
224
263
|
errorCode: string;
|
|
225
264
|
};
|
|
226
|
-
//# sourceMappingURL=verifier.d.ts.map
|