@kya-os/checkpoint-shared 1.6.0 → 1.8.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/CHANGELOG.md +122 -9
- package/README.md +24 -7
- package/dist/beacon-nonce/index.d.mts +1 -0
- package/dist/beacon-nonce/index.d.mts.map +1 -1
- package/dist/beacon-nonce/index.d.ts +1 -0
- package/dist/beacon-nonce/index.d.ts.map +1 -1
- package/dist/beacon-nonce/index.js +9 -3
- package/dist/beacon-nonce/index.mjs +9 -4
- package/dist/beacon-nonce/index.mjs.map +1 -1
- package/dist/beacon-types/index.d.mts +23 -1
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +23 -1
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +49 -4
- package/dist/beacon-types/index.mjs +47 -4
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/{browser-posture-BuChqmH5.d.mts → browser-posture-5fPrsxx7.d.mts} +2 -2
- package/dist/{browser-posture-BuChqmH5.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
- package/dist/{browser-posture-DIaVLuW3.d.ts → browser-posture-CCR1kh5e.d.ts} +2 -2
- package/dist/{browser-posture-DIaVLuW3.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
- package/dist/browser-posture-cookie.js +1 -1
- package/dist/browser-posture-cookie.mjs +1 -1
- package/dist/browser-posture-cookie.mjs.map +1 -1
- package/dist/browser-posture-proof.d.mts +16 -2
- package/dist/browser-posture-proof.d.mts.map +1 -1
- package/dist/browser-posture-proof.d.ts +16 -2
- package/dist/browser-posture-proof.d.ts.map +1 -1
- package/dist/browser-posture-proof.js +114 -17
- package/dist/browser-posture-proof.mjs +112 -17
- package/dist/browser-posture-proof.mjs.map +1 -1
- package/dist/browser-posture.d.mts +1 -1
- package/dist/browser-posture.d.ts +1 -1
- package/dist/browser-posture.js +6 -5
- package/dist/browser-posture.mjs +4 -3
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/browser.d.mts +25 -4
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +25 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/canonical-signer/index.d.mts.map +1 -1
- package/dist/canonical-signer/index.d.ts.map +1 -1
- package/dist/canonical-signer/index.js +116 -79
- package/dist/canonical-signer/index.mjs +117 -52
- package/dist/canonical-signer/index.mjs.map +1 -1
- package/dist/clearance.d.mts +1 -1
- package/dist/clearance.d.ts +1 -1
- package/dist/clearance.js +2 -2
- package/dist/clearance.mjs +2 -2
- package/dist/client-ip-B7w-uHfS.d.mts +55 -0
- package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
- package/dist/client-ip-B7w-uHfS.d.ts +55 -0
- package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
- package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
- package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
- package/dist/client-ip-DIJyr6px.mjs.map +1 -0
- package/dist/client-ip.d.mts +2 -0
- package/dist/client-ip.d.ts +2 -0
- package/dist/client-ip.js +8 -0
- package/dist/client-ip.mjs +3 -0
- package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
- package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
- package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
- package/dist/engine-enforcing-AYEcgNsb.js +39 -0
- package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
- package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
- package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
- package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
- package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
- package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
- package/dist/engine-info.d.mts +2 -0
- package/dist/engine-info.d.ts +2 -0
- package/dist/engine-info.js +4 -0
- package/dist/engine-info.mjs +3 -0
- package/dist/errors/index.d.mts +5 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +23 -4
- package/dist/errors/index.mjs +23 -4
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
- package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
- package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
- package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
- package/dist/fetcher-CivUCbhL.d.ts +44 -0
- package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
- package/dist/fetcher-cXQsbm6s.d.mts +44 -0
- package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
- package/dist/gateway-client-ip.d.mts +1 -1
- package/dist/gateway-client-ip.d.ts +1 -1
- package/dist/gateway-client-ip.js +2 -2
- package/dist/gateway-client-ip.mjs +2 -2
- package/dist/host-adapter/index.d.mts +2 -0
- package/dist/host-adapter/index.d.ts +2 -0
- package/dist/host-adapter/index.js +24 -0
- package/dist/host-adapter/index.mjs +3 -0
- package/dist/host-adapter-0F8EpbD6.js +753 -0
- package/dist/host-adapter-DHyISsIf.mjs +593 -0
- package/dist/host-adapter-DHyISsIf.mjs.map +1 -0
- package/dist/index-B3cHxr3O.d.mts +156 -0
- package/dist/index-B3cHxr3O.d.mts.map +1 -0
- package/dist/index-CXbOY7gB.d.ts +156 -0
- package/dist/index-CXbOY7gB.d.ts.map +1 -0
- package/dist/index.d.mts +6997 -12170
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +6997 -12170
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2510 -8893
- package/dist/index.mjs +2366 -8534
- package/dist/index.mjs.map +1 -1
- package/dist/kya-http-error-codes-7ewV5RuK.d.mts +29 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.mts.map +1 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.ts +29 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.ts.map +1 -0
- package/dist/kya-http-error-codes-C2JiWPsi.mjs +73 -0
- package/dist/kya-http-error-codes-C2JiWPsi.mjs.map +1 -0
- package/dist/kya-http-error-codes-UYb1zpGM.js +83 -0
- package/dist/kya-http.d.mts +3 -0
- package/dist/kya-http.d.ts +3 -0
- package/dist/kya-http.js +19 -0
- package/dist/kya-http.mjs +5 -0
- package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
- package/dist/mcpi/status-list/index.d.mts +72 -0
- package/dist/mcpi/status-list/index.d.mts.map +1 -0
- package/dist/mcpi/status-list/index.d.ts +72 -0
- package/dist/mcpi/status-list/index.d.ts.map +1 -0
- package/dist/mcpi/status-list/index.js +703 -0
- package/dist/mcpi/status-list/index.mjs +684 -0
- package/dist/mcpi/status-list/index.mjs.map +1 -0
- package/dist/patterns-B2r7M9wR.js +243 -0
- package/dist/patterns-B7dQoeE3.mjs +173 -0
- package/dist/patterns-B7dQoeE3.mjs.map +1 -0
- package/dist/patterns-Bp40cwh2.d.mts +110 -0
- package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
- package/dist/patterns-Bp40cwh2.d.ts +110 -0
- package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
- package/dist/patterns.d.mts +2 -0
- package/dist/patterns.d.ts +2 -0
- package/dist/patterns.js +15 -0
- package/dist/patterns.mjs +3 -0
- package/dist/policy/enforcement.d.mts +3 -0
- package/dist/policy/enforcement.d.ts +3 -0
- package/dist/policy/enforcement.js +21 -0
- package/dist/policy/enforcement.mjs +4 -0
- package/dist/policy/fetcher.d.mts +2 -0
- package/dist/policy/fetcher.d.ts +2 -0
- package/dist/policy/fetcher.js +240 -0
- package/dist/policy/fetcher.mjs +238 -0
- package/dist/policy/fetcher.mjs.map +1 -0
- package/dist/policy/schemas.d.mts +3 -0
- package/dist/policy/schemas.d.ts +3 -0
- package/dist/policy/schemas.js +27 -0
- package/dist/policy/schemas.mjs +4 -0
- package/dist/{posture-origins-Pn-ii-Pp.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
- package/dist/{posture-origins-LFkX80oF.js → posture-origins-DGyS4Vuk.mjs} +2 -267
- package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
- package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
- package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
- package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
- package/dist/provider-registry.d.mts +2 -0
- package/dist/provider-registry.d.ts +2 -0
- package/dist/provider-registry.js +51 -0
- package/dist/provider-registry.mjs +3 -0
- package/dist/reason-codes.d.mts +2 -0
- package/dist/reason-codes.d.ts +2 -0
- package/dist/reason-codes.js +8 -0
- package/dist/reason-codes.mjs +3 -0
- package/dist/registered-sid-26hNxp6t.mjs +151 -0
- package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
- package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
- package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
- package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
- package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
- package/dist/registered-sid-DVGTSH0L.js +185 -0
- package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
- package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
- package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
- package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
- package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
- package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
- package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
- package/dist/schemas-02CI7jgm.d.mts +535 -0
- package/dist/schemas-02CI7jgm.d.mts.map +1 -0
- package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
- package/dist/schemas-C_3C72SR.d.ts +535 -0
- package/dist/schemas-C_3C72SR.d.ts.map +1 -0
- package/dist/schemas-Cm4C4Z5G.js +703 -0
- package/dist/schemas-DPIT8usF.mjs +525 -0
- package/dist/schemas-DPIT8usF.mjs.map +1 -0
- package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
- package/dist/schemas-IHAhH3gV.mjs.map +1 -0
- package/dist/step-up-BK0oBi11.mjs +1563 -0
- package/dist/step-up-BK0oBi11.mjs.map +1 -0
- package/dist/step-up-Bp8RAQwv.js +1759 -0
- package/dist/step-up-Bz12gYKT.d.mts +130 -0
- package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
- package/dist/step-up-Bz12gYKT.d.ts +130 -0
- package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
- package/dist/test-fixtures/index.d.mts +4 -4
- package/dist/test-fixtures/index.d.mts.map +1 -1
- package/dist/test-fixtures/index.d.ts +4 -4
- package/dist/test-fixtures/index.d.ts.map +1 -1
- package/dist/test-fixtures/index.js +4 -4
- package/dist/test-fixtures/index.mjs +4 -4
- package/dist/test-fixtures/index.mjs.map +1 -1
- package/dist/verification-BAw9N8Pt.js +181 -0
- package/dist/verification-Cvvv86TT.mjs +123 -0
- package/dist/verification-Cvvv86TT.mjs.map +1 -0
- package/fixtures/client-ip-resolution.n01.json +101 -0
- package/fixtures/reviewer-grant-revocation.v1.json +53 -81
- package/package.json +59 -2
- package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
- package/dist/posture-origins-Pn-ii-Pp.mjs.map +0 -1
- package/dist/schemas-7qodsG-Z.mjs.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/utils/verification.d.ts
|
|
2
|
+
type VerificationMethod = 'signature' | 'pattern' | 'behavioral' | 'network' | 'mcp_i_handshake' | 'kyaos_handshake' | 'none' | 'error';
|
|
3
|
+
declare const KYA_OS_HANDSHAKE_METHODS: {
|
|
4
|
+
readonly CANONICAL: "kyaos_handshake";
|
|
5
|
+
readonly LEGACY: "mcp_i_handshake";
|
|
6
|
+
};
|
|
7
|
+
declare const KYA_OS_WIRE_METHODS: {
|
|
8
|
+
readonly CANONICAL: "kya-os";
|
|
9
|
+
readonly LEGACY: "mcp-i";
|
|
10
|
+
};
|
|
11
|
+
declare function isKyaOsHandshakeMethod(value: string | null | undefined): boolean;
|
|
12
|
+
declare function isKyaOsWireMethod(value: string | null | undefined): boolean;
|
|
13
|
+
declare function normalizeHandshakeMethod<T extends string | null | undefined>(value: T): T | typeof KYA_OS_HANDSHAKE_METHODS.CANONICAL;
|
|
14
|
+
declare function normalizeWireMethod<T extends string | null | undefined>(value: T): T | typeof KYA_OS_WIRE_METHODS.CANONICAL;
|
|
15
|
+
declare function getVerificationMethodDescription(method: VerificationMethod): string;
|
|
16
|
+
declare function getVerificationReliability(method: VerificationMethod): number;
|
|
17
|
+
declare function isHighConfidenceVerification(method: VerificationMethod): boolean;
|
|
18
|
+
declare function getVerificationRiskLevel(method: VerificationMethod, confidence: number): 'low' | 'medium' | 'high';
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/mcpi/delegation-headers.d.ts
|
|
21
|
+
declare const DELEGATION_PROOF_HEADERS: readonly ["kya-os-delegation-credential", "kya-delegation"];
|
|
22
|
+
declare function requestCarriesDelegationProof(headers: Headers | Record<string, unknown> | null | undefined): boolean;
|
|
23
|
+
declare function requestPresentedCredential(headers: Headers | Record<string, unknown> | null | undefined): boolean;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/mcpi/anonymous-principal.d.ts
|
|
26
|
+
declare const ANONYMOUS_PRINCIPAL_DID = "did:web:kya.vouched.id:principals:anonymous";
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/mcpi/registered-sid.d.ts
|
|
29
|
+
declare const REGISTERED_SID_MAX_LENGTH = 100;
|
|
30
|
+
declare const SID_ATTRIBUTABLE_RESULT: "verified";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { normalizeWireMethod as _, requestCarriesDelegationProof as a, KYA_OS_WIRE_METHODS as c, getVerificationReliability as d, getVerificationRiskLevel as f, normalizeHandshakeMethod as g, isKyaOsWireMethod as h, DELEGATION_PROOF_HEADERS as i, VerificationMethod as l, isKyaOsHandshakeMethod as m, SID_ATTRIBUTABLE_RESULT as n, requestPresentedCredential as o, isHighConfidenceVerification as p, ANONYMOUS_PRINCIPAL_DID as r, KYA_OS_HANDSHAKE_METHODS as s, REGISTERED_SID_MAX_LENGTH as t, getVerificationMethodDescription as u };
|
|
33
|
+
//# sourceMappingURL=registered-sid-D6KCaT1E.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registered-sid-D6KCaT1E.d.mts","names":[],"sources":["../src/utils/verification.ts","../src/mcpi/delegation-headers.ts","../src/mcpi/anonymous-principal.ts","../src/mcpi/registered-sid.ts"],"mappings":";KAIY;cA8BC;WAAA;WAAA;;cAOA;WAAA;WAAA;;iBAQG,uBAAuB;iBAKvB,kBAAkB;iBAsBlB,yBAAyB,qCACvC,OAAO,IACN,WAAW,yBAAyB;iBAavB,oBAAoB,qCAClC,OAAO,IACN,WAAW,oBAAoB;iBAOlB,iCAAiC,QAAQ;iBA2BzC,2BAA2B,QAAQ;iBAwBnC,6BAA6B,QAAQ;iBAQrC,yBACd,QAAQ,oBACR;;;cC9IW;iBAgBG,8BACd,SAAS,UAAU;iBA4FL,2BACd,SAAS,UAAU;;;cC5HR;;;cCUA;cAUA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/utils/verification.d.ts
|
|
2
|
+
type VerificationMethod = 'signature' | 'pattern' | 'behavioral' | 'network' | 'mcp_i_handshake' | 'kyaos_handshake' | 'none' | 'error';
|
|
3
|
+
declare const KYA_OS_HANDSHAKE_METHODS: {
|
|
4
|
+
readonly CANONICAL: "kyaos_handshake";
|
|
5
|
+
readonly LEGACY: "mcp_i_handshake";
|
|
6
|
+
};
|
|
7
|
+
declare const KYA_OS_WIRE_METHODS: {
|
|
8
|
+
readonly CANONICAL: "kya-os";
|
|
9
|
+
readonly LEGACY: "mcp-i";
|
|
10
|
+
};
|
|
11
|
+
declare function isKyaOsHandshakeMethod(value: string | null | undefined): boolean;
|
|
12
|
+
declare function isKyaOsWireMethod(value: string | null | undefined): boolean;
|
|
13
|
+
declare function normalizeHandshakeMethod<T extends string | null | undefined>(value: T): T | typeof KYA_OS_HANDSHAKE_METHODS.CANONICAL;
|
|
14
|
+
declare function normalizeWireMethod<T extends string | null | undefined>(value: T): T | typeof KYA_OS_WIRE_METHODS.CANONICAL;
|
|
15
|
+
declare function getVerificationMethodDescription(method: VerificationMethod): string;
|
|
16
|
+
declare function getVerificationReliability(method: VerificationMethod): number;
|
|
17
|
+
declare function isHighConfidenceVerification(method: VerificationMethod): boolean;
|
|
18
|
+
declare function getVerificationRiskLevel(method: VerificationMethod, confidence: number): 'low' | 'medium' | 'high';
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/mcpi/delegation-headers.d.ts
|
|
21
|
+
declare const DELEGATION_PROOF_HEADERS: readonly ["kya-os-delegation-credential", "kya-delegation"];
|
|
22
|
+
declare function requestCarriesDelegationProof(headers: Headers | Record<string, unknown> | null | undefined): boolean;
|
|
23
|
+
declare function requestPresentedCredential(headers: Headers | Record<string, unknown> | null | undefined): boolean;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/mcpi/anonymous-principal.d.ts
|
|
26
|
+
declare const ANONYMOUS_PRINCIPAL_DID = "did:web:kya.vouched.id:principals:anonymous";
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/mcpi/registered-sid.d.ts
|
|
29
|
+
declare const REGISTERED_SID_MAX_LENGTH = 100;
|
|
30
|
+
declare const SID_ATTRIBUTABLE_RESULT: "verified";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { normalizeWireMethod as _, requestCarriesDelegationProof as a, KYA_OS_WIRE_METHODS as c, getVerificationReliability as d, getVerificationRiskLevel as f, normalizeHandshakeMethod as g, isKyaOsWireMethod as h, DELEGATION_PROOF_HEADERS as i, VerificationMethod as l, isKyaOsHandshakeMethod as m, SID_ATTRIBUTABLE_RESULT as n, requestPresentedCredential as o, isHighConfidenceVerification as p, ANONYMOUS_PRINCIPAL_DID as r, KYA_OS_HANDSHAKE_METHODS as s, REGISTERED_SID_MAX_LENGTH as t, getVerificationMethodDescription as u };
|
|
33
|
+
//# sourceMappingURL=registered-sid-D6KCaT1E.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registered-sid-D6KCaT1E.d.ts","names":[],"sources":["../src/utils/verification.ts","../src/mcpi/delegation-headers.ts","../src/mcpi/anonymous-principal.ts","../src/mcpi/registered-sid.ts"],"mappings":";KAIY;cA8BC;WAAA;WAAA;;cAOA;WAAA;WAAA;;iBAQG,uBAAuB;iBAKvB,kBAAkB;iBAsBlB,yBAAyB,qCACvC,OAAO,IACN,WAAW,yBAAyB;iBAavB,oBAAoB,qCAClC,OAAO,IACN,WAAW,oBAAoB;iBAOlB,iCAAiC,QAAQ;iBA2BzC,2BAA2B,QAAQ;iBAwBnC,6BAA6B,QAAQ;iBAQrC,yBACd,QAAQ,oBACR;;;cC9IW;iBAgBG,8BACd,SAAS,UAAU;iBA4FL,2BACd,SAAS,UAAU;;;cC5HR;;;cCUA;cAUA"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
//#region src/mcpi/delegation-headers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Delegation-proof request detection (P2 / DR-1).
|
|
4
|
+
*
|
|
5
|
+
* The engine's L2 delegation-root pinning (`ContextSpec.trustedDelegationRoots`)
|
|
6
|
+
* is consulted for every credential the engine verifies: the delegation-proof
|
|
7
|
+
* headers below AND an `Authorization: Bearer` VC-JWT. Consumers gate root
|
|
8
|
+
* resolution on `requestPresentedCredential`, so the human / no-credential hot
|
|
9
|
+
* path stays a precise no-op.
|
|
10
|
+
*
|
|
11
|
+
* Keeping the header set here (rather than re-listing the literals at each site)
|
|
12
|
+
* is the whole point: a new delegation transport header is added in one place
|
|
13
|
+
* and every verifier surface agrees.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Lowercased delegation-proof header names. `kya-os-delegation-credential` is the
|
|
17
|
+
* canonical KYA-OS transport; `kya-delegation` is the legacy envelope form still
|
|
18
|
+
* accepted via `legacyEnvelopeFallback`.
|
|
19
|
+
*/
|
|
20
|
+
const DELEGATION_PROOF_HEADERS = ["kya-os-delegation-credential", "kya-delegation"];
|
|
21
|
+
/** A header value is "present" when it is a non-empty string (or non-empty list). */
|
|
22
|
+
function isPresent(value) {
|
|
23
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
24
|
+
return typeof value === "string" && value.length > 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Does the request carry a KYA-OS delegation-proof header?
|
|
28
|
+
*
|
|
29
|
+
* Accepts either a `Headers` instance (Next.js / fetch — case-insensitive
|
|
30
|
+
* lookup) or a plain header record (raw Node/Express headers, gateway worker's
|
|
31
|
+
* lowercased map). Record keys are matched case-insensitively, so callers do not
|
|
32
|
+
* need to pre-normalize. Returns `false` for `null`/`undefined`.
|
|
33
|
+
*/
|
|
34
|
+
function requestCarriesDelegationProof(headers) {
|
|
35
|
+
if (!headers) return false;
|
|
36
|
+
if (typeof headers.get === "function") {
|
|
37
|
+
const h = headers;
|
|
38
|
+
return DELEGATION_PROOF_HEADERS.some((name) => isPresent(h.get(name)));
|
|
39
|
+
}
|
|
40
|
+
const record = headers;
|
|
41
|
+
const lowerKeyed = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const key of Object.keys(record)) lowerKeyed.set(key.toLowerCase(), record[key]);
|
|
43
|
+
return DELEGATION_PROOF_HEADERS.some((name) => isPresent(lowerKeyed.get(name)));
|
|
44
|
+
}
|
|
45
|
+
const MAX_VC_JWT_PAYLOAD_CHARS = 16384;
|
|
46
|
+
function headerText(headers, name) {
|
|
47
|
+
if (typeof headers.get === "function") return headers.get(name) ?? void 0;
|
|
48
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
49
|
+
if (key.toLowerCase() !== name) continue;
|
|
50
|
+
if (Array.isArray(value)) return value.join(", ");
|
|
51
|
+
return typeof value === "string" ? value : void 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function isMemberDelimiter(c) {
|
|
55
|
+
return c === "=" || c === ";" || c === "," || c === " " || c === " ";
|
|
56
|
+
}
|
|
57
|
+
function hasKyaMember(value) {
|
|
58
|
+
let memberStart = true;
|
|
59
|
+
let quoted = false;
|
|
60
|
+
let escaped = false;
|
|
61
|
+
for (let i = 0; i < value.length; i++) {
|
|
62
|
+
const c = value[i];
|
|
63
|
+
if (quoted) {
|
|
64
|
+
if (escaped) escaped = false;
|
|
65
|
+
else if (c === "\\") escaped = true;
|
|
66
|
+
else if (c === "\"") quoted = false;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (memberStart) {
|
|
70
|
+
if (c === " " || c === " ") continue;
|
|
71
|
+
if (value.startsWith("kya", i) && (i + 3 === value.length || isMemberDelimiter(value[i + 3]))) return true;
|
|
72
|
+
memberStart = false;
|
|
73
|
+
}
|
|
74
|
+
if (c === "\"") quoted = true;
|
|
75
|
+
else if (c === ",") memberStart = true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
function decodeBase64UrlJson(segment) {
|
|
80
|
+
const padded = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
81
|
+
const binary = atob(padded + "=".repeat((4 - padded.length % 4) % 4));
|
|
82
|
+
const bytes = Uint8Array.from(binary, (ch) => ch.charCodeAt(0));
|
|
83
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
84
|
+
}
|
|
85
|
+
function isDelegationCredentialPayload(payload) {
|
|
86
|
+
if (typeof payload !== "object" || payload === null) return false;
|
|
87
|
+
if ("vc" in payload) return true;
|
|
88
|
+
const type = payload.type;
|
|
89
|
+
return Array.isArray(type) && type.includes("DelegationCredential");
|
|
90
|
+
}
|
|
91
|
+
function looksLikeVcJwt(token) {
|
|
92
|
+
const parts = token.split(".");
|
|
93
|
+
if (parts.length !== 3 || parts.some((part) => part.length === 0)) return false;
|
|
94
|
+
if (parts[1].length > MAX_VC_JWT_PAYLOAD_CHARS) return true;
|
|
95
|
+
try {
|
|
96
|
+
return isDelegationCredentialPayload(decodeBase64UrlJson(parts[1]));
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Same definition as the .NET / Java `IsCredentialPresented`. */
|
|
102
|
+
function requestPresentedCredential(headers) {
|
|
103
|
+
if (!headers) return false;
|
|
104
|
+
for (const name of ["signature-input", "signature"]) {
|
|
105
|
+
const value = headerText(headers, name);
|
|
106
|
+
if (value && hasKyaMember(value)) return true;
|
|
107
|
+
}
|
|
108
|
+
if (requestCarriesDelegationProof(headers)) return true;
|
|
109
|
+
const bearer = headerText(headers, "authorization")?.match(/^bearer\s+(\S+)/i);
|
|
110
|
+
return bearer !== null && bearer !== void 0 && looksLikeVcJwt(bearer[1]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/mcpi/anonymous-principal.ts
|
|
115
|
+
/**
|
|
116
|
+
* Canonical did:web for the anonymous-principal sentinel (see `./principal.ts`).
|
|
117
|
+
* Kept apart from the client DID derivation, which loads `@noble/hashes`, so
|
|
118
|
+
* request-path code can take it from the `./kya-http` lean entry.
|
|
119
|
+
*/
|
|
120
|
+
const ANONYMOUS_PRINCIPAL_DID = "did:web:kya.vouched.id:principals:anonymous";
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/mcpi/registered-sid.ts
|
|
124
|
+
/**
|
|
125
|
+
* The registered session anchor (`sid`) contract between a reporter and
|
|
126
|
+
* Checkpoint ingest. Kept apart from `reported-identity.ts`, which builds Zod
|
|
127
|
+
* schemas when it loads, so the runtime and the `./kya-http` entry can read
|
|
128
|
+
* these values without loading Zod.
|
|
129
|
+
*/
|
|
130
|
+
/**
|
|
131
|
+
* Max length of a registered session anchor (`sid`) accepted on the wire and
|
|
132
|
+
* enforced again at the customer route. The join partner
|
|
133
|
+
* `bouncer_sessions.id` is `varchar(100)`; `detections.registered_sid` stays
|
|
134
|
+
* `text` (converting a live column to `varchar` would take an ACCESS EXCLUSIVE
|
|
135
|
+
* rewrite of the hottest table), so this constant is the width contract
|
|
136
|
+
* instead of the column type.
|
|
137
|
+
*/
|
|
138
|
+
const REGISTERED_SID_MAX_LENGTH = 100;
|
|
139
|
+
/**
|
|
140
|
+
* The one delegation result that may attribute a `sid` to a session timeline.
|
|
141
|
+
* A rejected presentation carries no engine-emitted sid, and a sid on a
|
|
142
|
+
* `failed` / `not_presented` report is attacker-shaped, so ingest stamps
|
|
143
|
+
* `registered_sid` only for this result and nulls it otherwise (D4 / D15).
|
|
144
|
+
* One member on purpose: Section 13 of the plan records how an explicitly
|
|
145
|
+
* unverified-labeled `failed` could join it later.
|
|
146
|
+
*/
|
|
147
|
+
const SID_ATTRIBUTABLE_RESULT = "verified";
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
Object.defineProperty(exports, 'ANONYMOUS_PRINCIPAL_DID', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return ANONYMOUS_PRINCIPAL_DID;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, 'DELEGATION_PROOF_HEADERS', {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return DELEGATION_PROOF_HEADERS;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, 'REGISTERED_SID_MAX_LENGTH', {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return REGISTERED_SID_MAX_LENGTH;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, 'SID_ATTRIBUTABLE_RESULT', {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return SID_ATTRIBUTABLE_RESULT;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, 'requestCarriesDelegationProof', {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function () {
|
|
177
|
+
return requestCarriesDelegationProof;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, 'requestPresentedCredential', {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () {
|
|
183
|
+
return requestPresentedCredential;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/core/ruleset-hash.ts
|
|
2
|
+
/**
|
|
3
|
+
* The accepted shapes of `EngineInfo.rulesetHash`, the one definition the
|
|
4
|
+
* dashboard's ingest schema and the SDK detection reporter both test against.
|
|
5
|
+
* No Zod and no imports, so request-path code can load it through the
|
|
6
|
+
* `./engine-info` lean entry.
|
|
7
|
+
*
|
|
8
|
+
* 1. structured per-tier, what `kya-os-engine` emits
|
|
9
|
+
* (`api.rs` `build_engine_info`):
|
|
10
|
+
* `sha256:t1:<slot>:t2:<slot>:t3:<slot>:t4:<slot>`, each slot a 64-hex
|
|
11
|
+
* digest or the literal `unset` or `disabled`.
|
|
12
|
+
* 2. host-synthesized, what the runtime reports when the engine could not
|
|
13
|
+
* run (`hostSynthesizedEngineInfo` in checkpoint-wasm-runtime):
|
|
14
|
+
* `sha256:host-synthesized`.
|
|
15
|
+
* 3. flat `sha256:<64-hex>`, kept for back-compat and a future bundle digest.
|
|
16
|
+
*
|
|
17
|
+
* Anchored to the `sha256:` scheme, so bare hex or an injected value is
|
|
18
|
+
* rejected at the boundary.
|
|
19
|
+
*
|
|
20
|
+
* The engine owns the structured format. Its own test
|
|
21
|
+
* (`ruleset_hash_matches_structured_per_tier_format` in `api.rs`) and the
|
|
22
|
+
* runtime's smoke canary (`engine.smoke.test.ts`) pin the engine side; a
|
|
23
|
+
* change to the tiers changes this regex in the same PR.
|
|
24
|
+
*/
|
|
25
|
+
const TIER_SLOT = String.raw`(?:unset|disabled|[a-f0-9]{64})`;
|
|
26
|
+
const RULESET_HASH_REGEX = new RegExp(String.raw`^sha256:(?:[a-f0-9]{64}|host-synthesized|t1:${TIER_SLOT}:t2:${TIER_SLOT}:t3:${TIER_SLOT}:t4:${TIER_SLOT})$`);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
Object.defineProperty(exports, 'RULESET_HASH_REGEX', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return RULESET_HASH_REGEX;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleset-hash-IRN5eI9H.d.mts","names":[],"sources":["../src/core/ruleset-hash.ts"],"mappings":";cAyBa,oBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleset-hash-IRN5eI9H.d.ts","names":[],"sources":["../src/core/ruleset-hash.ts"],"mappings":";cAyBa,oBAAkB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/core/ruleset-hash.ts
|
|
2
|
+
/**
|
|
3
|
+
* The accepted shapes of `EngineInfo.rulesetHash`, the one definition the
|
|
4
|
+
* dashboard's ingest schema and the SDK detection reporter both test against.
|
|
5
|
+
* No Zod and no imports, so request-path code can load it through the
|
|
6
|
+
* `./engine-info` lean entry.
|
|
7
|
+
*
|
|
8
|
+
* 1. structured per-tier, what `kya-os-engine` emits
|
|
9
|
+
* (`api.rs` `build_engine_info`):
|
|
10
|
+
* `sha256:t1:<slot>:t2:<slot>:t3:<slot>:t4:<slot>`, each slot a 64-hex
|
|
11
|
+
* digest or the literal `unset` or `disabled`.
|
|
12
|
+
* 2. host-synthesized, what the runtime reports when the engine could not
|
|
13
|
+
* run (`hostSynthesizedEngineInfo` in checkpoint-wasm-runtime):
|
|
14
|
+
* `sha256:host-synthesized`.
|
|
15
|
+
* 3. flat `sha256:<64-hex>`, kept for back-compat and a future bundle digest.
|
|
16
|
+
*
|
|
17
|
+
* Anchored to the `sha256:` scheme, so bare hex or an injected value is
|
|
18
|
+
* rejected at the boundary.
|
|
19
|
+
*
|
|
20
|
+
* The engine owns the structured format. Its own test
|
|
21
|
+
* (`ruleset_hash_matches_structured_per_tier_format` in `api.rs`) and the
|
|
22
|
+
* runtime's smoke canary (`engine.smoke.test.ts`) pin the engine side; a
|
|
23
|
+
* change to the tiers changes this regex in the same PR.
|
|
24
|
+
*/
|
|
25
|
+
const TIER_SLOT = String.raw`(?:unset|disabled|[a-f0-9]{64})`;
|
|
26
|
+
const RULESET_HASH_REGEX = new RegExp(String.raw`^sha256:(?:[a-f0-9]{64}|host-synthesized|t1:${TIER_SLOT}:t2:${TIER_SLOT}:t3:${TIER_SLOT}:t4:${TIER_SLOT})$`);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { RULESET_HASH_REGEX as t };
|
|
30
|
+
//# sourceMappingURL=ruleset-hash-QQIaLuPi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleset-hash-QQIaLuPi.mjs","names":[],"sources":["../src/core/ruleset-hash.ts"],"sourcesContent":["/**\n * The accepted shapes of `EngineInfo.rulesetHash`, the one definition the\n * dashboard's ingest schema and the SDK detection reporter both test against.\n * No Zod and no imports, so request-path code can load it through the\n * `./engine-info` lean entry.\n *\n * 1. structured per-tier, what `kya-os-engine` emits\n * (`api.rs` `build_engine_info`):\n * `sha256:t1:<slot>:t2:<slot>:t3:<slot>:t4:<slot>`, each slot a 64-hex\n * digest or the literal `unset` or `disabled`.\n * 2. host-synthesized, what the runtime reports when the engine could not\n * run (`hostSynthesizedEngineInfo` in checkpoint-wasm-runtime):\n * `sha256:host-synthesized`.\n * 3. flat `sha256:<64-hex>`, kept for back-compat and a future bundle digest.\n *\n * Anchored to the `sha256:` scheme, so bare hex or an injected value is\n * rejected at the boundary.\n *\n * The engine owns the structured format. Its own test\n * (`ruleset_hash_matches_structured_per_tier_format` in `api.rs`) and the\n * runtime's smoke canary (`engine.smoke.test.ts`) pin the engine side; a\n * change to the tiers changes this regex in the same PR.\n */\nconst TIER_SLOT = String.raw`(?:unset|disabled|[a-f0-9]{64})`;\n\nexport const RULESET_HASH_REGEX = new RegExp(\n String.raw`^sha256:(?:[a-f0-9]{64}|host-synthesized|t1:${TIER_SLOT}:t2:${TIER_SLOT}:t3:${TIER_SLOT}:t4:${TIER_SLOT})$`\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,YAAY,OAAO,GAAG;AAE5B,MAAa,qBAAqB,IAAI,OACpC,OAAO,GAAG,+CAA+C,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,GACrH"}
|