@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
|
@@ -1,174 +1,3 @@
|
|
|
1
|
-
//#region src/constants/patterns.ts
|
|
2
|
-
/**
|
|
3
|
-
* Regular Expression Patterns
|
|
4
|
-
*
|
|
5
|
-
* Common regex patterns used for validation and detection
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Validation Patterns
|
|
9
|
-
*/
|
|
10
|
-
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
11
|
-
const VALIDATION_PATTERNS = {
|
|
12
|
-
UUID: UUID_PATTERN,
|
|
13
|
-
ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
14
|
-
SLUG: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
|
|
15
|
-
IPV4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
16
|
-
IPV6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4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|
|
35
|
-
PIXEL_ID: /^px_[A-Za-z0-9]{16}$/
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* User Agent Patterns for Agent Detection
|
|
39
|
-
*/
|
|
40
|
-
const USER_AGENT_PATTERNS = {
|
|
41
|
-
OPENAI: /(?:GPTBot|ChatGPT-User|OpenAI)/i,
|
|
42
|
-
ANTHROPIC: /(?:Claude-Web|Claude-User|anthropic-ai|claude-web|claude-user|ClaudeBot)/i,
|
|
43
|
-
PERPLEXITY: /(?:PerplexityBot|Perplexica)/i,
|
|
44
|
-
GOOGLE_AI: /(?:Bard|Google-InspectionTool)/i,
|
|
45
|
-
MICROSOFT_AI: /(?:BingPreview\/.*ChatGPT|Copilot)/i,
|
|
46
|
-
GOOGLEBOT: /Googlebot/i,
|
|
47
|
-
BINGBOT: /(?:bingbot|BingPreview|msnbot)/i,
|
|
48
|
-
DUCKDUCKBOT: /DuckDuckBot/i,
|
|
49
|
-
BAIDUBOT: /Baiduspider/i,
|
|
50
|
-
YANDEXBOT: /YandexBot/i,
|
|
51
|
-
FACEBOOK: /(?:facebookexternalhit|facebookcatalog)/i,
|
|
52
|
-
TWITTER: /(?:Twitterbot|TwitterImageProxy)/i,
|
|
53
|
-
LINKEDIN: /LinkedInBot/i,
|
|
54
|
-
WHATSAPP: /WhatsApp/i,
|
|
55
|
-
TELEGRAM: /TelegramBot/i,
|
|
56
|
-
DISCORD: /Discordbot/i,
|
|
57
|
-
SLACK: /Slackbot/i,
|
|
58
|
-
GENERIC_BOT: /(?:bot|crawler|spider|scraper|agent)/i,
|
|
59
|
-
SCRAPY: /Scrapy/i,
|
|
60
|
-
PUPPETEER: /(?:HeadlessChrome|Puppeteer)/i,
|
|
61
|
-
PLAYWRIGHT: /Playwright/i,
|
|
62
|
-
SELENIUM: /(?:selenium|webdriver)/i,
|
|
63
|
-
POSTMAN: /PostmanRuntime/i,
|
|
64
|
-
INSOMNIA: /insomnia/i,
|
|
65
|
-
CURL: /curl/i,
|
|
66
|
-
WGET: /Wget/i,
|
|
67
|
-
HTTPIE: /HTTPie/i,
|
|
68
|
-
UPTIMEROBOT: /UptimeRobot/i,
|
|
69
|
-
PINGDOM: /Pingdom/i,
|
|
70
|
-
NEWRELIC: /NewRelicPinger/i,
|
|
71
|
-
DATADOG: /Datadog/i
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Header Patterns for Agent Detection
|
|
75
|
-
*/
|
|
76
|
-
const HEADER_PATTERNS = {
|
|
77
|
-
AI_HEADERS: /^(?:X-(?:OpenAI|Anthropic|AI|Bot|Agent|LLM))/i,
|
|
78
|
-
AUTOMATION_HEADERS: /^(?:X-(?:Automated|Robot|Crawler|Scraper))/i,
|
|
79
|
-
MISSING_ACCEPT: /^$/,
|
|
80
|
-
MISSING_ACCEPT_LANGUAGE: /^$/,
|
|
81
|
-
MISSING_ACCEPT_ENCODING: /^$/,
|
|
82
|
-
GENERIC_ACCEPT: /^\*\/\*$/,
|
|
83
|
-
NO_COOKIES: /^$/,
|
|
84
|
-
PROXY_HEADERS: /^(?:X-Forwarded-|X-Real-IP|X-Originating-IP|Via|Forwarded)/i,
|
|
85
|
-
CLOUD_HEADERS: /^(?:X-(?:AWS|Azure|GCP|Cloudflare))/i
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Browser Patterns
|
|
89
|
-
*/
|
|
90
|
-
const BROWSER_PATTERNS = {
|
|
91
|
-
CHROME: /Chrome\/([0-9.]+)/,
|
|
92
|
-
FIREFOX: /Firefox\/([0-9.]+)/,
|
|
93
|
-
SAFARI: /Version\/([0-9.]+).*Safari/,
|
|
94
|
-
EDGE: /Edg\/([0-9.]+)/,
|
|
95
|
-
OPERA: /OPR\/([0-9.]+)/,
|
|
96
|
-
IE: /MSIE ([0-9.]+)/
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Operating System Patterns
|
|
100
|
-
*/
|
|
101
|
-
const OS_PATTERNS = {
|
|
102
|
-
WINDOWS: /Windows NT ([0-9.]+)/,
|
|
103
|
-
MACOS: /Mac OS X ([0-9_]+)/,
|
|
104
|
-
LINUX: /Linux/,
|
|
105
|
-
ANDROID: /Android ([0-9.]+)/,
|
|
106
|
-
IOS: /OS ([0-9_]+) like Mac OS X/
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Mobile Device Patterns
|
|
110
|
-
*/
|
|
111
|
-
const MOBILE_PATTERNS = {
|
|
112
|
-
MOBILE: /(?:Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini)/i,
|
|
113
|
-
TABLET: /(?:iPad|Android.*Tablet|Tablet.*Android|Kindle|Silk)/i,
|
|
114
|
-
DESKTOP: /(?:Windows NT|Mac OS X|Linux|CrOS)/i
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Suspicious Behavior Patterns
|
|
118
|
-
*/
|
|
119
|
-
const SUSPICIOUS_PATTERNS = {
|
|
120
|
-
RAPID_REQUESTS: /^[0-9]{1,3}$/,
|
|
121
|
-
SEQUENTIAL_URLS: /\?(?:page|offset|id)=[0-9]+/,
|
|
122
|
-
API_ENDPOINTS: /\/api\/|\.json$|\.xml$/i,
|
|
123
|
-
DIRECT_POST: /^POST$/,
|
|
124
|
-
SQL_INJECTION: /(?:union|select|insert|update|delete|drop|create|alter|exec|script|javascript|onerror|onload|eval|src=)/i,
|
|
125
|
-
XSS_ATTEMPT: /(?:<script|javascript:|onerror=|onclick=|<iframe|<embed|<object)/i,
|
|
126
|
-
PATH_TRAVERSAL: /(?:\.\.\/|\.\.\\|%2e%2e%2f|%252e%252e%252f)/i,
|
|
127
|
-
URL_ENCODED: /%[0-9a-f]{2}/i,
|
|
128
|
-
BASE64_DATA: /data:[^;]+;base64,/i
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Maximum input length for pattern matching. UAs, header values, and
|
|
132
|
-
* detection payloads are bounded in practice (<4KB even for the most
|
|
133
|
-
* verbose Chrome/Firefox UAs). Caps worst-case complexity for any
|
|
134
|
-
* polynomial-shaped pattern an external caller might supply to
|
|
135
|
-
* `testPattern` / `extractMatch`; CodeQL flagged the unbounded path
|
|
136
|
-
* (js/polynomial-redos) on PR #2576.
|
|
137
|
-
*/
|
|
138
|
-
const MAX_PATTERN_INPUT_LENGTH = 4096;
|
|
139
|
-
/**
|
|
140
|
-
* Helper function to test a pattern. Returns `false` on inputs longer
|
|
141
|
-
* than {@link MAX_PATTERN_INPUT_LENGTH} — an abuse signal we'd rather
|
|
142
|
-
* reject than process.
|
|
143
|
-
*/
|
|
144
|
-
function testPattern(pattern, value) {
|
|
145
|
-
if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;
|
|
146
|
-
return pattern.test(value);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Helper function to extract match from pattern. Returns `null` on
|
|
150
|
-
* over-long inputs (same ReDoS defense as `testPattern`).
|
|
151
|
-
*/
|
|
152
|
-
function extractMatch(pattern, value) {
|
|
153
|
-
if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;
|
|
154
|
-
const match = value.match(pattern);
|
|
155
|
-
return match ? match[1] || match[0] : null;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Helper function to test multiple patterns
|
|
159
|
-
*/
|
|
160
|
-
function testPatterns(patterns, value) {
|
|
161
|
-
return patterns.some((pattern) => testPattern(pattern, value));
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Helper function to find matching pattern
|
|
165
|
-
*/
|
|
166
|
-
function findMatchingPattern(patterns, value) {
|
|
167
|
-
for (const [name, pattern] of Object.entries(patterns)) if (testPattern(pattern, value)) return name;
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
1
|
//#region src/posture-origins/index.ts
|
|
173
2
|
/**
|
|
174
3
|
* Posture origins: which page origins a project's browser posture token may
|
|
@@ -529,99 +358,5 @@ function matchAllowedOrigin(pageOrigin, allowed) {
|
|
|
529
358
|
}
|
|
530
359
|
|
|
531
360
|
//#endregion
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
get: function () {
|
|
535
|
-
return BROWSER_PATTERNS;
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
Object.defineProperty(exports, 'HEADER_PATTERNS', {
|
|
539
|
-
enumerable: true,
|
|
540
|
-
get: function () {
|
|
541
|
-
return HEADER_PATTERNS;
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
Object.defineProperty(exports, 'MOBILE_PATTERNS', {
|
|
545
|
-
enumerable: true,
|
|
546
|
-
get: function () {
|
|
547
|
-
return MOBILE_PATTERNS;
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
Object.defineProperty(exports, 'OS_PATTERNS', {
|
|
551
|
-
enumerable: true,
|
|
552
|
-
get: function () {
|
|
553
|
-
return OS_PATTERNS;
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
Object.defineProperty(exports, 'SUSPICIOUS_PATTERNS', {
|
|
557
|
-
enumerable: true,
|
|
558
|
-
get: function () {
|
|
559
|
-
return SUSPICIOUS_PATTERNS;
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
Object.defineProperty(exports, 'USER_AGENT_PATTERNS', {
|
|
563
|
-
enumerable: true,
|
|
564
|
-
get: function () {
|
|
565
|
-
return USER_AGENT_PATTERNS;
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
Object.defineProperty(exports, 'UUID_PATTERN', {
|
|
569
|
-
enumerable: true,
|
|
570
|
-
get: function () {
|
|
571
|
-
return UUID_PATTERN;
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
Object.defineProperty(exports, 'VALIDATION_PATTERNS', {
|
|
575
|
-
enumerable: true,
|
|
576
|
-
get: function () {
|
|
577
|
-
return VALIDATION_PATTERNS;
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
Object.defineProperty(exports, 'extractMatch', {
|
|
581
|
-
enumerable: true,
|
|
582
|
-
get: function () {
|
|
583
|
-
return extractMatch;
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
Object.defineProperty(exports, 'findMatchingPattern', {
|
|
587
|
-
enumerable: true,
|
|
588
|
-
get: function () {
|
|
589
|
-
return findMatchingPattern;
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
Object.defineProperty(exports, 'isPublicSuffixLike', {
|
|
593
|
-
enumerable: true,
|
|
594
|
-
get: function () {
|
|
595
|
-
return isPublicSuffixLike;
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
Object.defineProperty(exports, 'matchAllowedOrigin', {
|
|
599
|
-
enumerable: true,
|
|
600
|
-
get: function () {
|
|
601
|
-
return matchAllowedOrigin;
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
Object.defineProperty(exports, 'parseOriginPattern', {
|
|
605
|
-
enumerable: true,
|
|
606
|
-
get: function () {
|
|
607
|
-
return parseOriginPattern;
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
Object.defineProperty(exports, 'testPattern', {
|
|
611
|
-
enumerable: true,
|
|
612
|
-
get: function () {
|
|
613
|
-
return testPattern;
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
Object.defineProperty(exports, 'testPatterns', {
|
|
617
|
-
enumerable: true,
|
|
618
|
-
get: function () {
|
|
619
|
-
return testPatterns;
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
Object.defineProperty(exports, 'validatePostureOrigins', {
|
|
623
|
-
enumerable: true,
|
|
624
|
-
get: function () {
|
|
625
|
-
return validatePostureOrigins;
|
|
626
|
-
}
|
|
627
|
-
});
|
|
361
|
+
export { validatePostureOrigins as i, matchAllowedOrigin as n, parseOriginPattern as r, isPublicSuffixLike as t };
|
|
362
|
+
//# sourceMappingURL=posture-origins-DGyS4Vuk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posture-origins-DGyS4Vuk.mjs","names":[],"sources":["../src/posture-origins/index.ts"],"sourcesContent":["/**\n * Posture origins: which page origins a project's browser posture token may\n * be issued for (and, at the edge gateway, accepted on).\n *\n * The primary origin is derived from `project.domain`. A project can add up\n * to {@link MAX_POSTURE_ORIGINS} more in `settings.postureOrigins`, for the\n * installs a single varchar cannot describe: a Shopify store whose shoppers\n * browse a custom domain while `project.domain` is the myshopify host, `www`\n * next to the apex, a staging host, several storefront domains.\n *\n * One resolver, used by every caller (the beacon issuer, the settings APIs,\n * the dashboard editor, the gateway verifier, the beacon-ingest Worker), so\n * what the dashboard accepts, what the issuer signs and what the gateway\n * verifies can never drift apart.\n *\n * Pure, dependency-free, Web-standard `URL` only: safe in Node, the browser\n * and Cloudflare Workers. `URL` also gives consistent IDN handling: a\n * Unicode host is converted to its punycode (`xn--`) form everywhere, which\n * is exactly how a browser serializes the `Origin` header.\n *\n * Pattern rules (the stored form is always normalized):\n * - `https://host[:port]`: an exact origin. HTTPS only, with no localhost\n * exception, because the posture signer (`signBrowserPosture`) refuses any\n * non-HTTPS audience anyway.\n * - A bare `host` is read as `https://host`. Paths, a trailing slash, query\n * and fragment are stripped; userinfo (`user@host`) is rejected.\n * - `https://*.example.com`: matches any origin ONE OR MORE labels below\n * `example.com` (`a.example.com`, `a.b.example.com`), same scheme and port.\n * It never matches the apex `example.com`; list that separately. The\n * wildcard is allowed only as the whole leftmost label.\n * - A wildcard over a public or multi-tenant suffix is rejected\n * (`*.com`, `*.co.uk`, `*.myshopify.com`, `*.vercel.app`, ...): it would\n * let any tenant of that platform mint posture for this project.\n *\n * @example\n * const allowed = resolveProjectAllowedOrigins({\n * domain: 'checkpoint-rebrand.myshopify.com',\n * settings: { postureOrigins: ['https://www.brand.com', 'https://*.brand.com'] },\n * });\n * matchAllowedOrigin('https://shop.brand.com', allowed); // 'https://shop.brand.com'\n * matchAllowedOrigin('https://brand.com', allowed); // undefined (apex not listed)\n */\n\nexport const MAX_POSTURE_ORIGINS = 20;\n/** Longest accepted entry: `https://` + a 253-char host + `:65535`, with headroom. */\nexport const MAX_POSTURE_ORIGIN_LENGTH = 300;\n\n/**\n * Multi-tenant hosting suffixes a customer does not control the siblings of.\n * A wildcard AT or anywhere BELOW one of these is refused, because platforms\n * nest tenant namespaces (`*.s3.us-east-1.amazonaws.com`, `*.a.run.app`,\n * `*.blob.core.windows.net`). An exact tenant host (`https://brand.myshopify.com`)\n * is still accepted.\n *\n * The public-suffix list is not a dependency of this package (it would ship\n * to the dashboard bundle and both Workers), so this is a curated list plus\n * the structural checks in {@link isPublicSuffixLike}. It is not complete:\n * adopting the PSL private section (e.g. `tldts`) is the full fix.\n */\nexport const MULTI_TENANT_SUFFIXES: ReadonlySet<string> = new Set([\n // Commerce and site builders\n 'myshopify.com',\n 'shopifypreview.com',\n 'myshopline.com',\n 'mybigcommerce.com',\n 'bigcartel.com',\n 'company.site',\n 'square.site',\n 'wixsite.com',\n 'wixstudio.io',\n 'squarespace.com',\n 'webflow.io',\n 'framer.app',\n 'framer.website',\n 'carrd.co',\n 'weebly.com',\n 'godaddysites.com',\n 'mystrikingly.com',\n 'hs-sites.com',\n 'hubspotpagebuilder.com',\n 'myportfolio.com',\n 'notion.site',\n 'ghost.io',\n 'substack.com',\n 'tumblr.com',\n 'blogspot.com',\n 'wordpress.com',\n 'wpengine.com',\n 'wpenginepowered.com',\n 'pantheonsite.io',\n 'kinsta.cloud',\n 'gitbook.io',\n 'bubbleapps.io',\n 'neocities.org',\n // App and AI builders\n 'lovable.app',\n 'lovable.dev',\n 'replit.app',\n 'replit.dev',\n 'repl.co',\n 'glitch.me',\n 'vusercontent.net',\n 'csb.app',\n 'codesandbox.io',\n 'stackblitz.io',\n 'webcontainer.io',\n 'streamlit.app',\n 'hf.space',\n 'gradio.live',\n 'pythonanywhere.com',\n // Hosting platforms\n 'vercel.app',\n 'now.sh',\n 'netlify.app',\n 'netlify.com',\n 'pages.dev',\n 'workers.dev',\n 'r2.dev',\n 'github.io',\n 'github.dev',\n 'gitlab.io',\n 'herokuapp.com',\n 'onrender.com',\n 'fly.dev',\n 'railway.app',\n 'koyeb.app',\n 'deno.dev',\n 'surge.sh',\n 'ondigitalocean.app',\n 'digitaloceanspaces.com',\n 'gitpod.io',\n // Cloud providers and CDNs\n 'amazonaws.com',\n 'amplifyapp.com',\n 'awsapprunner.com',\n 'elasticbeanstalk.com',\n 'cloudfront.net',\n 'azurewebsites.net',\n 'azurestaticapps.net',\n 'azurecontainerapps.io',\n 'azureedge.net',\n 'azurefd.net',\n 'azure-api.net',\n 'cloudapp.net',\n 'cloudapp.azure.com',\n 'windows.net',\n 'run.app',\n 'web.app',\n 'firebaseapp.com',\n 'firebasestorage.app',\n 'appspot.com',\n 'googleapis.com',\n 'googleusercontent.com',\n 'translate.goog',\n 'fastly.net',\n 'akamaized.net',\n 'akamaihd.net',\n 'edgekey.net',\n 'edgesuite.net',\n 'b-cdn.net',\n 'cloudflarestorage.com',\n 'supabase.co',\n // Tunnels\n 'ngrok.io',\n 'ngrok.app',\n 'ngrok.dev',\n 'ngrok-free.app',\n 'ngrok-free.dev',\n 'trycloudflare.com',\n 'loca.lt',\n]);\n\n/** Common second-level labels under a two-letter country TLD (`co.uk`, `com.au`, `ne.jp`). */\nconst CCTLD_SECOND_LEVEL_LABELS: ReadonlySet<string> = new Set([\n 'ac',\n 'biz',\n 'co',\n 'com',\n 'edu',\n 'gen',\n 'go',\n 'gob',\n 'gov',\n 'info',\n 'ltd',\n 'me',\n 'mil',\n 'ne',\n 'net',\n 'nic',\n 'or',\n 'org',\n 'plc',\n 'sch',\n]);\n\nconst WILDCARD_PROBE_LABEL = 'posture-origin-wildcard-probe';\n\nexport interface ParsedOriginPattern {\n /** The normalized stored form, e.g. `https://*.example.com` or `https://a.example.com:8443`. */\n pattern: string;\n wildcard: boolean;\n /** Lowercased, punycoded host WITHOUT the `*.` prefix. */\n host: string;\n /** Explicit port, or '' for the scheme default. */\n port: string;\n}\n\nexport type OriginPatternResult =\n | { ok: true; value: ParsedOriginPattern }\n | { ok: false; error: string };\n\n/**\n * True when a wildcard directly over `host` would cover sites the customer\n * does not control: a single label (`com`), a common ccTLD second level\n * (`co.uk`, `com.au`), or a known multi-tenant platform suffix or any host\n * below one (`myshopify.com`, `s3.us-east-1.amazonaws.com`). A heuristic,\n * not the full PSL.\n */\nexport function isPublicSuffixLike(host: string): boolean {\n const labels = host.split('.');\n if (labels.length < 2) return true;\n for (let index = 0; index < labels.length - 1; index++) {\n if (MULTI_TENANT_SUFFIXES.has(labels.slice(index).join('.'))) return true;\n }\n if (labels.length === 2) {\n const [second, top] = labels;\n if (top.length === 2 && CCTLD_SECOND_LEVEL_LABELS.has(second)) return true;\n }\n return false;\n}\n\nfunction isIpLiteral(host: string): boolean {\n return host.startsWith('[') || /^\\d+(\\.\\d+){3}$/.test(host);\n}\n\n/**\n * Validates and normalizes one allowlist entry. Returns a human-readable\n * error for the settings API's 400 and the dashboard editor.\n */\nexport function parseOriginPattern(input: string): OriginPatternResult {\n const trimmed = typeof input === 'string' ? input.trim() : '';\n if (!trimmed) return { ok: false, error: 'Enter an origin such as https://www.example.com' };\n if (trimmed.length > MAX_POSTURE_ORIGIN_LENGTH) {\n return { ok: false, error: `Must be at most ${MAX_POSTURE_ORIGIN_LENGTH} characters` };\n }\n const schemeMatch = /^([a-z][a-z0-9+.-]*):\\/\\//i.exec(trimmed);\n if (schemeMatch && schemeMatch[1].toLowerCase() !== 'https') {\n return { ok: false, error: 'Only https:// origins are supported' };\n }\n const rest = schemeMatch ? trimmed.slice(schemeMatch[0].length) : trimmed;\n const wildcard = rest.startsWith('*.');\n const withoutWildcard = wildcard ? rest.slice(2) : rest;\n if (withoutWildcard.includes('*')) {\n return {\n ok: false,\n error: 'A wildcard is only allowed as the whole first label, e.g. https://*.example.com',\n };\n }\n let url: URL;\n try {\n url = new URL(`https://${wildcard ? `${WILDCARD_PROBE_LABEL}.` : ''}${withoutWildcard}`);\n } catch {\n return { ok: false, error: 'Not a valid origin' };\n }\n if (url.username || url.password) {\n return { ok: false, error: 'Origins cannot contain a username or password' };\n }\n let host = url.hostname;\n if (wildcard) host = host.slice(WILDCARD_PROBE_LABEL.length + 1);\n if (!host || host.endsWith('.') || host.startsWith('.')) {\n return { ok: false, error: 'Not a valid host name' };\n }\n if (isIpLiteral(host)) {\n return { ok: false, error: 'Use a domain name, not an IP address' };\n }\n if (wildcard && isPublicSuffixLike(host)) {\n return {\n ok: false,\n error: `*.${host} would include sites you do not control; list your own hosts instead`,\n };\n }\n if (!host.includes('.')) {\n return { ok: false, error: 'Use a fully qualified domain, e.g. www.example.com' };\n }\n const port = url.port;\n // Port 0 is not a connectable port, so no page is ever served from it.\n if (port === '0') return { ok: false, error: 'Not a valid port' };\n const pattern = `https://${wildcard ? '*.' : ''}${host}${port ? `:${port}` : ''}`;\n return { ok: true, value: { pattern, wildcard, host, port } };\n}\n\nexport type PostureOriginsValidation =\n | { ok: true; origins: string[] }\n | { ok: false; errors: Array<{ index: number; message: string }> };\n\n/**\n * Validates a full allowlist from an API body or the editor: every entry\n * must parse, the list is capped, and duplicates (after normalization) are\n * removed while keeping first-seen order.\n */\nexport function validatePostureOrigins(input: unknown): PostureOriginsValidation {\n if (!Array.isArray(input)) {\n return { ok: false, errors: [{ index: -1, message: 'Expected a list of origins' }] };\n }\n if (input.length > MAX_POSTURE_ORIGINS) {\n return {\n ok: false,\n errors: [{ index: -1, message: `At most ${MAX_POSTURE_ORIGINS} additional origins` }],\n };\n }\n const errors: Array<{ index: number; message: string }> = [];\n const origins: string[] = [];\n input.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n errors.push({ index, message: 'Each origin must be a string' });\n return;\n }\n const parsed = parseOriginPattern(entry);\n if (!parsed.ok) {\n errors.push({ index, message: parsed.error });\n return;\n }\n if (!origins.includes(parsed.value.pattern)) origins.push(parsed.value.pattern);\n });\n return errors.length > 0 ? { ok: false, errors } : { ok: true, origins };\n}\n\n/**\n * The primary origin from `project.domain`: an exact HTTPS origin, or\n * undefined when the domain is unset or carries a path, query, fragment or\n * userinfo. A bare host is read as `https://host`.\n */\nexport function primaryPostureOrigin(domain: string | null | undefined): string | undefined {\n if (!domain) return undefined;\n try {\n const url = new URL(domain.includes('://') ? domain : `https://${domain}`);\n if (\n url.protocol !== 'https:' ||\n url.username ||\n url.password ||\n url.pathname !== '/' ||\n url.search ||\n url.hash\n )\n return undefined;\n return url.origin;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads `settings.postureOrigins` defensively: settings is a jsonb column,\n * so anything written before validation existed (or by hand) is re-parsed\n * and invalid entries are dropped rather than trusted.\n */\nexport function postureKeysUrl(base: string, projectId: string): string {\n return `${base}/api/v1/beacon/keys?projectId=${projectId}`;\n}\n\nexport function readPostureOriginsSetting(settings: unknown): string[] {\n if (!settings || typeof settings !== 'object') return [];\n const raw = (settings as { postureOrigins?: unknown }).postureOrigins;\n if (!Array.isArray(raw)) return [];\n const origins: string[] = [];\n for (const entry of raw.slice(0, MAX_POSTURE_ORIGINS)) {\n if (typeof entry !== 'string') continue;\n const parsed = parseOriginPattern(entry);\n if (parsed.ok && !origins.includes(parsed.value.pattern)) origins.push(parsed.value.pattern);\n }\n return origins;\n}\n\n/**\n * Every origin pattern a project's posture may be issued for: the primary\n * (from `project.domain`) first, then the additional allowlist. Empty when\n * neither exists, which the issuer reports as `domain-unset`.\n */\nexport function resolveProjectAllowedOrigins(project: {\n domain: string | null | undefined;\n settings?: unknown;\n}): string[] {\n const allowed: string[] = [];\n const primary = primaryPostureOrigin(project.domain);\n if (primary) allowed.push(primary);\n for (const pattern of readPostureOriginsSetting(project.settings)) {\n if (!allowed.includes(pattern)) allowed.push(pattern);\n }\n return allowed;\n}\n\n/**\n * Returns the page origin when it matches one of `allowed`, else undefined.\n * The page origin must already be in the browser's serialized form\n * (`https://host[:port]`, lowercase, no path); anything else, including the\n * opaque `null` origin, never matches. The value returned is the page origin\n * itself, never a pattern, so a signed audience is always a concrete origin.\n */\nexport function matchAllowedOrigin(\n pageOrigin: string | null | undefined,\n allowed: readonly string[]\n): string | undefined {\n if (!pageOrigin || allowed.length === 0) return undefined;\n let url: URL;\n try {\n url = new URL(pageOrigin);\n } catch {\n return undefined;\n }\n if (url.protocol !== 'https:' || url.origin !== pageOrigin) return undefined;\n const host = url.hostname;\n if (host.includes('*')) return undefined;\n for (const entry of allowed) {\n const parsed = parseOriginPattern(entry);\n if (!parsed.ok || parsed.value.port !== url.port) continue;\n const { wildcard, host: patternHost } = parsed.value;\n if (!wildcard) {\n if (host === patternHost) return pageOrigin;\n continue;\n }\n if (host.length > patternHost.length + 1 && host.endsWith(`.${patternHost}`)) {\n return pageOrigin;\n }\n }\n return undefined;\n}\n\n/**\n * The page origin for an ingest request: the browser-set `Origin` header,\n * or, ONLY when that header is absent, the origin of `Referer`. Both are\n * set by the browser and equally forgeable by a non-browser client, so the\n * fallback adds no trust; it recovers installs whose proxy or request mode\n * drops `Origin`. A present-but-opaque `Origin: null` is kept as is (and\n * never matches), so a sandboxed frame cannot fall back to its Referer.\n * Never read `X-Forwarded-Host`, `X-Forwarded-Origin` or any custom header\n * here: those are caller-controlled.\n */\nexport function pageOriginFromHeaders(\n origin: string | null | undefined,\n referer: string | null | undefined\n): string | null {\n // Present means present: an empty `Origin:` is kept (and never matches)\n // rather than falling back to Referer.\n if (origin !== null && origin !== undefined) return origin;\n if (!referer) return null;\n try {\n const url = new URL(referer);\n if (url.protocol !== 'https:' || url.username || url.password) return null;\n return url.origin;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,sBAAsB;;AAEnC,MAAa,4BAA4B;;;;;;;;;;;;;AAczC,MAAa,wCAA6C,IAAI,IAAI;CAEhE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;C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a,OAAO;GACjC;EACF;EACA,IAAI,KAAK,SAAS,YAAY,SAAS,KAAK,KAAK,SAAS,IAAI,aAAa,GACzE,OAAO;CAEX;AAEF"}
|
package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as string, _ as number, g as never, h as literal, v as object } from "./schemas-IHAhH3gV.mjs";
|
|
2
2
|
import { decodeProtectedHeader } from "jose";
|
|
3
3
|
|
|
4
4
|
//#region src/project-verification-key.ts
|
|
@@ -34,4 +34,4 @@ function projectVerificationKey(token, config, now) {
|
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
36
|
export { projectVerificationKey as t };
|
|
37
|
-
//# sourceMappingURL=project-verification-key-
|
|
37
|
+
//# sourceMappingURL=project-verification-key-CWXdu3-n.mjs.map
|
package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-verification-key-
|
|
1
|
+
{"version":3,"file":"project-verification-key-CWXdu3-n.mjs","names":["z.object","z.literal","z.string","z.never","z.number"],"sources":["../src/project-verification-key.ts"],"sourcesContent":["import { decodeProtectedHeader, type JWK } from 'jose';\nimport { z } from 'zod';\n\nconst publicKey = z.object({\n kty: z.literal('EC'),\n crv: z.literal('P-256'),\n kid: z.string().min(1),\n x: z.string().min(1),\n y: z.string().min(1),\n d: z.never().optional(),\n});\nconst overlap = z.object({\n pending: z.object({ publicKey }).optional(),\n previous: z.object({ publicKey, expiresAt: z.number().finite() }).optional(),\n});\n\n/** Select only from operator-configured project keys. Token headers never supply key material or URLs. */\nexport function projectVerificationKey(\n token: string,\n config: { publicKey: JWK; keyId: string },\n now: number\n): JWK | undefined {\n const { kid } = decodeProtectedHeader(token);\n if (typeof kid !== 'string' || !kid) return undefined;\n if (kid === config.keyId) {\n // Strip the rotation-metadata members (`pending`, `previous`) a staged\n // rotation leaves on the stored active key before handing it out as a\n // bare JWK. Node's jose tolerates unknown JWK members; workerd's\n // `importKey('jwk')` (the gateway Worker) may not, which would fail\n // every posture/clearance verification for the project until they're\n // gone. Same strip `getProjectPostureKeySet` already applies.\n const {\n pending: _pending,\n previous: _previous,\n ...rest\n } = config.publicKey as JWK & {\n pending?: unknown;\n previous?: unknown;\n };\n return rest;\n }\n const parsed = overlap.safeParse(config.publicKey);\n if (!parsed.success) return undefined;\n const { pending, previous } = parsed.data;\n const candidates = [\n pending?.publicKey,\n previous && previous.expiresAt > now * 1000 ? previous.publicKey : undefined,\n ].filter((key) => key?.kid === kid);\n return candidates.length === 1 ? candidates[0] : undefined;\n}\n"],"mappings":";;;;AAGA,MAAM,YAAYA,OAAS;CACzB,KAAKC,QAAU,IAAI;CACnB,KAAKA,QAAU,OAAO;CACtB,KAAKC,OAAS,CAAC,CAAC,IAAI,CAAC;CACrB,GAAGA,OAAS,CAAC,CAAC,IAAI,CAAC;CACnB,GAAGA,OAAS,CAAC,CAAC,IAAI,CAAC;CACnB,GAAGC,MAAQ,CAAC,CAAC,SAAS;AACxB,CAAC;AACD,MAAM,UAAUH,OAAS;CACvB,SAASA,OAAS,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS;CAC1C,UAAUA,OAAS;EAAE;EAAW,WAAWI,OAAS,CAAC,CAAC,OAAO;CAAE,CAAC,CAAC,CAAC,SAAS;AAC7E,CAAC;;AAGD,SAAgB,uBACd,OACA,QACA,KACiB;CACjB,MAAM,EAAE,QAAQ,sBAAsB,KAAK;CAC3C,IAAI,OAAO,QAAQ,YAAY,CAAC,KAAK,OAAO;CAC5C,IAAI,QAAQ,OAAO,OAAO;EAOxB,MAAM,EACJ,SAAS,UACT,UAAU,WACV,GAAG,SACD,OAAO;EAIX,OAAO;CACT;CACA,MAAM,SAAS,QAAQ,UAAU,OAAO,SAAS;CACjD,IAAI,CAAC,OAAO,SAAS,OAAO;CAC5B,MAAM,EAAE,SAAS,aAAa,OAAO;CACrC,MAAM,aAAa,CACjB,SAAS,WACT,YAAY,SAAS,YAAY,MAAM,MAAO,SAAS,YAAY,MACrE,CAAC,CAAC,QAAQ,QAAQ,KAAK,QAAQ,GAAG;CAClC,OAAO,WAAW,WAAW,IAAI,WAAW,KAAK;AACnD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderDefinitionSchema as ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition } from "@kya-os/provider-registry";
|
|
2
|
+
export { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderDefinitionSchema as ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition } from "@kya-os/provider-registry";
|
|
2
|
+
export { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _kya_os_provider_registry = require("@kya-os/provider-registry");
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, 'AUTH_MODES', {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () {
|
|
7
|
+
return _kya_os_provider_registry.AUTH_MODES;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, 'CredentialProviderConfigSchema', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _kya_os_provider_registry.CredentialProviderConfigSchema;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, 'OAuthProviderConfigSchema', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _kya_os_provider_registry.OAuthProviderConfigSchema;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, 'PROVIDER_AUTH_TYPES', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _kya_os_provider_registry.PROVIDER_AUTH_TYPES;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, 'ProviderConfigSchema', {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _kya_os_provider_registry.ProviderConfigSchema;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, 'ProviderRegistryDefinitionSchema', {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _kya_os_provider_registry.ProviderDefinitionSchema;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, 'validateProviderConfig', {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return _kya_os_provider_registry.validateProviderConfig;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, 'validateProviderDefinition', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return _kya_os_provider_registry.validateProviderDefinition;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderDefinitionSchema as ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition } from "@kya-os/provider-registry";
|
|
2
|
+
|
|
3
|
+
export { AUTH_MODES, CredentialProviderConfigSchema, OAuthProviderConfigSchema, PROVIDER_AUTH_TYPES, ProviderConfigSchema, ProviderRegistryDefinitionSchema, validateProviderConfig, validateProviderDefinition };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as mapDetectionToReasonCodes, i as formatReasonCodesHeader, n as MAX_REASON_CODES_ON_WIRE, o as DETECTION_REASON_CODES, r as ReasonCodeDetectionFacts, s as DetectionReasonCode, t as MAX_REASON_CODES_HEADER_BYTES } from "./detection-reason-mapping-CQexNvR7.mjs";
|
|
2
|
+
export { DETECTION_REASON_CODES, DetectionReasonCode, MAX_REASON_CODES_HEADER_BYTES, MAX_REASON_CODES_ON_WIRE, ReasonCodeDetectionFacts, formatReasonCodesHeader, mapDetectionToReasonCodes };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as mapDetectionToReasonCodes, i as formatReasonCodesHeader, n as MAX_REASON_CODES_ON_WIRE, o as DETECTION_REASON_CODES, r as ReasonCodeDetectionFacts, s as DetectionReasonCode, t as MAX_REASON_CODES_HEADER_BYTES } from "./detection-reason-mapping-CQexNvR7.js";
|
|
2
|
+
export { DETECTION_REASON_CODES, DetectionReasonCode, MAX_REASON_CODES_HEADER_BYTES, MAX_REASON_CODES_ON_WIRE, ReasonCodeDetectionFacts, formatReasonCodesHeader, mapDetectionToReasonCodes };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_detection_reason_mapping = require('./detection-reason-mapping-B9RSkOs8.js');
|
|
3
|
+
|
|
4
|
+
exports.DETECTION_REASON_CODES = require_detection_reason_mapping.DETECTION_REASON_CODES;
|
|
5
|
+
exports.MAX_REASON_CODES_HEADER_BYTES = require_detection_reason_mapping.MAX_REASON_CODES_HEADER_BYTES;
|
|
6
|
+
exports.MAX_REASON_CODES_ON_WIRE = require_detection_reason_mapping.MAX_REASON_CODES_ON_WIRE;
|
|
7
|
+
exports.formatReasonCodesHeader = require_detection_reason_mapping.formatReasonCodesHeader;
|
|
8
|
+
exports.mapDetectionToReasonCodes = require_detection_reason_mapping.mapDetectionToReasonCodes;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as DETECTION_REASON_CODES, i as mapDetectionToReasonCodes, n as MAX_REASON_CODES_ON_WIRE, r as formatReasonCodesHeader, t as MAX_REASON_CODES_HEADER_BYTES } from "./detection-reason-mapping-BGymWIPl.mjs";
|
|
2
|
+
|
|
3
|
+
export { DETECTION_REASON_CODES, MAX_REASON_CODES_HEADER_BYTES, MAX_REASON_CODES_ON_WIRE, formatReasonCodesHeader, mapDetectionToReasonCodes };
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
export { requestCarriesDelegationProof as a, DELEGATION_PROOF_HEADERS as i, SID_ATTRIBUTABLE_RESULT as n, requestPresentedCredential as o, ANONYMOUS_PRINCIPAL_DID as r, REGISTERED_SID_MAX_LENGTH as t };
|
|
151
|
+
//# sourceMappingURL=registered-sid-26hNxp6t.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registered-sid-26hNxp6t.mjs","names":[],"sources":["../src/mcpi/delegation-headers.ts","../src/mcpi/anonymous-principal.ts","../src/mcpi/registered-sid.ts"],"sourcesContent":["/**\n * Delegation-proof request detection (P2 / DR-1).\n *\n * The engine's L2 delegation-root pinning (`ContextSpec.trustedDelegationRoots`)\n * is consulted for every credential the engine verifies: the delegation-proof\n * headers below AND an `Authorization: Bearer` VC-JWT. Consumers gate root\n * resolution on `requestPresentedCredential`, so the human / no-credential hot\n * path stays a precise no-op.\n *\n * Keeping the header set here (rather than re-listing the literals at each site)\n * is the whole point: a new delegation transport header is added in one place\n * and every verifier surface agrees.\n */\n\n/**\n * Lowercased delegation-proof header names. `kya-os-delegation-credential` is the\n * canonical KYA-OS transport; `kya-delegation` is the legacy envelope form still\n * accepted via `legacyEnvelopeFallback`.\n */\nexport const DELEGATION_PROOF_HEADERS = ['kya-os-delegation-credential', 'kya-delegation'] as const;\n\n/** A header value is \"present\" when it is a non-empty string (or non-empty list). */\nfunction isPresent(value: unknown): boolean {\n if (Array.isArray(value)) return value.length > 0;\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * Does the request carry a KYA-OS delegation-proof header?\n *\n * Accepts either a `Headers` instance (Next.js / fetch — case-insensitive\n * lookup) or a plain header record (raw Node/Express headers, gateway worker's\n * lowercased map). Record keys are matched case-insensitively, so callers do not\n * need to pre-normalize. Returns `false` for `null`/`undefined`.\n */\nexport function requestCarriesDelegationProof(\n headers: Headers | Record<string, unknown> | null | undefined\n): boolean {\n if (!headers) return false;\n\n if (typeof (headers as Headers).get === 'function') {\n const h = headers as Headers;\n return DELEGATION_PROOF_HEADERS.some((name) => isPresent(h.get(name)));\n }\n\n const record = headers as Record<string, unknown>;\n const lowerKeyed = new Map<string, unknown>();\n for (const key of Object.keys(record)) {\n lowerKeyed.set(key.toLowerCase(), record[key]);\n }\n return DELEGATION_PROOF_HEADERS.some((name) => isPresent(lowerKeyed.get(name)));\n}\n\nconst MAX_VC_JWT_PAYLOAD_CHARS = 16 * 1024;\n\nfunction headerText(headers: Headers | Record<string, unknown>, name: string): string | undefined {\n if (typeof (headers as Headers).get === 'function') {\n return (headers as Headers).get(name) ?? undefined;\n }\n for (const [key, value] of Object.entries(headers as Record<string, unknown>)) {\n if (key.toLowerCase() !== name) continue;\n if (Array.isArray(value)) return value.join(', ');\n return typeof value === 'string' ? value : undefined;\n }\n return undefined;\n}\n\nfunction isMemberDelimiter(c: string): boolean {\n return c === '=' || c === ';' || c === ',' || c === ' ' || c === '\\t';\n}\n\n// Quote-aware member scan; the engine owns the authoritative parse.\nfunction hasKyaMember(value: string): boolean {\n let memberStart = true;\n let quoted = false;\n let escaped = false;\n for (let i = 0; i < value.length; i++) {\n const c = value[i];\n if (quoted) {\n if (escaped) escaped = false;\n else if (c === '\\\\') escaped = true;\n else if (c === '\"') quoted = false;\n continue;\n }\n if (memberStart) {\n if (c === ' ' || c === '\\t') continue;\n if (\n value.startsWith('kya', i) &&\n (i + 3 === value.length || isMemberDelimiter(value[i + 3]))\n ) {\n return true;\n }\n memberStart = false;\n }\n if (c === '\"') quoted = true;\n else if (c === ',') memberStart = true;\n }\n return false;\n}\n\nfunction decodeBase64UrlJson(segment: string): unknown {\n const padded = segment.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(padded + '='.repeat((4 - (padded.length % 4)) % 4));\n const bytes = Uint8Array.from(binary, (ch) => ch.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n\nfunction isDelegationCredentialPayload(payload: unknown): boolean {\n if (typeof payload !== 'object' || payload === null) return false;\n if ('vc' in payload) return true;\n const type = (payload as { type?: unknown }).type;\n return Array.isArray(type) && type.includes('DelegationCredential');\n}\n\n// Must equal the orchestrator's delegation routing (`vc` claim OR flat `type`\n// DelegationCredential); an oversized payload counts as presented.\nfunction looksLikeVcJwt(token: string): boolean {\n const parts = token.split('.');\n if (parts.length !== 3 || parts.some((part) => part.length === 0)) return false;\n if (parts[1].length > MAX_VC_JWT_PAYLOAD_CHARS) return true;\n try {\n return isDelegationCredentialPayload(decodeBase64UrlJson(parts[1]));\n } catch {\n return false;\n }\n}\n\n/** Same definition as the .NET / Java `IsCredentialPresented`. */\nexport function requestPresentedCredential(\n headers: Headers | Record<string, unknown> | null | undefined\n): boolean {\n if (!headers) return false;\n for (const name of ['signature-input', 'signature']) {\n const value = headerText(headers, name);\n if (value && hasKyaMember(value)) return true;\n }\n if (requestCarriesDelegationProof(headers)) return true;\n const authorization = headerText(headers, 'authorization');\n const bearer = authorization?.match(/^bearer\\s+(\\S+)/i);\n return bearer !== null && bearer !== undefined && looksLikeVcJwt(bearer[1]);\n}\n","/**\n * Canonical did:web for the anonymous-principal sentinel (see `./principal.ts`).\n * Kept apart from the client DID derivation, which loads `@noble/hashes`, so\n * request-path code can take it from the `./kya-http` lean entry.\n */\nexport const ANONYMOUS_PRINCIPAL_DID = 'did:web:kya.vouched.id:principals:anonymous';\n","/**\n * The registered session anchor (`sid`) contract between a reporter and\n * Checkpoint ingest. Kept apart from `reported-identity.ts`, which builds Zod\n * schemas when it loads, so the runtime and the `./kya-http` entry can read\n * these values without loading Zod.\n */\n\n/**\n * Max length of a registered session anchor (`sid`) accepted on the wire and\n * enforced again at the customer route. The join partner\n * `bouncer_sessions.id` is `varchar(100)`; `detections.registered_sid` stays\n * `text` (converting a live column to `varchar` would take an ACCESS EXCLUSIVE\n * rewrite of the hottest table), so this constant is the width contract\n * instead of the column type.\n */\nexport const REGISTERED_SID_MAX_LENGTH = 100;\n\n/**\n * The one delegation result that may attribute a `sid` to a session timeline.\n * A rejected presentation carries no engine-emitted sid, and a sid on a\n * `failed` / `not_presented` report is attacker-shaped, so ingest stamps\n * `registered_sid` only for this result and nulls it otherwise (D4 / D15).\n * One member on purpose: Section 13 of the plan records how an explicitly\n * unverified-labeled `failed` could join it later.\n */\nexport const SID_ATTRIBUTABLE_RESULT = 'verified' as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,2BAA2B,CAAC,gCAAgC,gBAAgB;;AAGzF,SAAS,UAAU,OAAyB;CAC1C,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,SAAS;CAChD,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;;;;;;;;;AAUA,SAAgB,8BACd,SACS;CACT,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI,OAAQ,QAAoB,QAAQ,YAAY;EAClD,MAAM,IAAI;EACV,OAAO,yBAAyB,MAAM,SAAS,UAAU,EAAE,IAAI,IAAI,CAAC,CAAC;CACvE;CAEA,MAAM,SAAS;CACf,MAAM,6BAAa,IAAI,IAAqB;CAC5C,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,WAAW,IAAI,IAAI,YAAY,GAAG,OAAO,IAAI;CAE/C,OAAO,yBAAyB,MAAM,SAAS,UAAU,WAAW,IAAI,IAAI,CAAC,CAAC;AAChF;AAEA,MAAM,2BAA2B;AAEjC,SAAS,WAAW,SAA4C,MAAkC;CAChG,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