@kya-os/checkpoint-shared 1.5.2 → 1.7.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 +98 -1
- package/dist/beacon-types/index.d.mts +12 -1
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +12 -1
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +18 -1
- package/dist/beacon-types/index.mjs +18 -2
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/{browser-posture-D4j2a5gi.d.ts → browser-posture-B8YiPa5c.d.ts} +6 -6
- package/dist/{browser-posture-D4j2a5gi.d.ts.map → browser-posture-B8YiPa5c.d.ts.map} +1 -1
- package/dist/{browser-posture-DVoHMHjY.d.mts → browser-posture-BLhw-MON.d.mts} +6 -6
- package/dist/{browser-posture-DVoHMHjY.d.mts.map → browser-posture-BLhw-MON.d.mts.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 +2 -2
- package/dist/browser-posture-proof.d.mts.map +1 -1
- package/dist/browser-posture-proof.d.ts +2 -2
- package/dist/browser-posture-proof.d.ts.map +1 -1
- package/dist/browser-posture-proof.js +43 -2
- package/dist/browser-posture-proof.mjs +43 -2
- 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 +3 -3
- package/dist/browser-posture.mjs +3 -3
- package/dist/browser-posture.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 +86 -51
- package/dist/canonical-signer/index.mjs +86 -51
- 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-DFamiNoz.d.mts +34 -0
- package/dist/client-ip-DFamiNoz.d.mts.map +1 -0
- package/dist/client-ip-DFamiNoz.d.ts +34 -0
- package/dist/client-ip-DFamiNoz.d.ts.map +1 -0
- package/dist/client-ip.d.mts +2 -0
- package/dist/client-ip.d.ts +2 -0
- package/dist/client-ip.js +7 -0
- package/dist/client-ip.mjs +3 -0
- package/dist/errors/index.d.mts +17 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +17 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +75 -3
- package/dist/errors/index.mjs +75 -3
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{external-Ct8j_hto.d.ts → external-B7WI9FyQ.d.mts} +2 -2
- package/dist/{external-Ct8j_hto.d.mts.map → external-B7WI9FyQ.d.mts.map} +1 -1
- package/dist/{external-Ct8j_hto.d.mts → external-B7WI9FyQ.d.ts} +2 -2
- package/dist/{external-Ct8j_hto.d.ts.map → external-B7WI9FyQ.d.ts.map} +1 -1
- package/dist/gateway-client-ip.d.mts +1 -1
- package/dist/gateway-client-ip.d.ts +1 -1
- package/dist/gateway-client-ip.js +1 -1
- package/dist/gateway-client-ip.mjs +1 -1
- package/dist/host-adapter/index.d.mts +2 -0
- package/dist/host-adapter/index.d.ts +2 -0
- package/dist/host-adapter/index.js +23 -0
- package/dist/host-adapter/index.mjs +3 -0
- package/dist/host-adapter-C-4IxmqM.mjs +540 -0
- package/dist/host-adapter-C-4IxmqM.mjs.map +1 -0
- package/dist/host-adapter-CwW9YB0U.js +694 -0
- package/dist/index-B7rTovHa.d.mts +707 -0
- package/dist/index-B7rTovHa.d.mts.map +1 -0
- package/dist/index-HaqfPtaL.d.ts +707 -0
- package/dist/index-HaqfPtaL.d.ts.map +1 -0
- package/dist/index.d.mts +742 -937
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +742 -937
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +758 -1193
- package/dist/index.mjs +659 -1148
- 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 +11 -0
- package/dist/kya-http.mjs +4 -0
- package/dist/mcpi/approval-grant/index.d.mts.map +1 -1
- package/dist/mcpi/approval-grant/index.d.ts.map +1 -1
- package/dist/mcpi/approval-grant/index.js +10 -1
- package/dist/mcpi/approval-grant/index.mjs +10 -1
- package/dist/mcpi/approval-grant/index.mjs.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.mts +3 -2
- package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.ts +3 -2
- package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
- package/dist/policy/enforcement.d.mts +2 -0
- package/dist/policy/enforcement.d.ts +2 -0
- package/dist/policy/enforcement.js +15 -0
- package/dist/policy/enforcement.mjs +3 -0
- package/dist/{posture-origins-Dl7i8j93.mjs → posture-origins-Ba83O0cD.mjs} +3 -3
- package/dist/posture-origins-Ba83O0cD.mjs.map +1 -0
- package/dist/{posture-origins-CEm83u4D.js → posture-origins-CdVOdiMT.js} +7 -1
- package/dist/{project-verification-key-CgSVX9_m.mjs → project-verification-key-66N4edKn.mjs} +2 -2
- package/dist/{project-verification-key-CgSVX9_m.mjs.map → project-verification-key-66N4edKn.mjs.map} +1 -1
- package/dist/{project-verification-key-C3L5rd8a.js → project-verification-key-BccT12tQ.js} +1 -1
- package/dist/registered-sid-D3g-gZQF.d.mts +11 -0
- package/dist/registered-sid-D3g-gZQF.d.mts.map +1 -0
- package/dist/registered-sid-D3g-gZQF.d.ts +11 -0
- package/dist/registered-sid-D3g-gZQF.d.ts.map +1 -0
- package/dist/registered-sid-eLCNZvIF.js +170 -0
- package/dist/registered-sid-hUl-bvM5.mjs +142 -0
- package/dist/registered-sid-hUl-bvM5.mjs.map +1 -0
- package/dist/{schemas-DxY-dk9y.mjs → schemas-7qodsG-Z.mjs} +49 -2
- package/dist/schemas-7qodsG-Z.mjs.map +1 -0
- package/dist/{schemas-BmjNLAE7.js → schemas-YhagYDx_.js} +59 -0
- package/dist/step-up-BjP--hG-.d.mts +114 -0
- package/dist/step-up-BjP--hG-.d.mts.map +1 -0
- package/dist/step-up-BjP--hG-.d.ts +114 -0
- package/dist/step-up-BjP--hG-.d.ts.map +1 -0
- package/dist/step-up-C2d8C20x.js +1697 -0
- package/dist/step-up-COlmWJN8.mjs +1513 -0
- package/dist/step-up-COlmWJN8.mjs.map +1 -0
- package/fixtures/cli-registration.v2.json +115 -0
- package/fixtures/detection/reason-codes.json +1 -1
- package/fixtures/kya-http/README.md +34 -26
- package/fixtures/kya-http/protected-resource-metadata.full.json +14 -5
- package/fixtures/kya-http/protected-resource-metadata.invalid-issuer.json +51 -0
- package/fixtures/kya-http/protected-resource-metadata.no-issuer.json +32 -0
- package/fixtures/reviewer-grant-revocation.v1.json +285 -0
- package/package.json +26 -4
- package/dist/posture-origins-Dl7i8j93.mjs.map +0 -1
- package/dist/schemas-DxY-dk9y.mjs.map +0 -1
- package/fixtures/kya-http/protected-resource-metadata.global.json +0 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ZodOptional, E as ZodObject, L as output, T as ZodNumber, V as $strip, _ as ZodGUID, g as ZodEnum, j as ZodString, l as ZodArray, m as ZodDefault, t as external_d_exports, u as ZodBoolean, w as ZodNullable, x as ZodLiteral } from "./external-B7WI9FyQ.js";
|
|
2
2
|
import { JWK, JWK as JWK$1 } from "jose";
|
|
3
3
|
//#region src/browser-posture-cookie.d.ts
|
|
4
4
|
declare function postureCookieName(projectId: string): string;
|
|
@@ -14,8 +14,8 @@ declare const BrowserPostureSchema: ZodObject<{
|
|
|
14
14
|
session_id: ZodGUID;
|
|
15
15
|
binding: ZodString;
|
|
16
16
|
verdict: ZodEnum<{
|
|
17
|
-
human: "human";
|
|
18
17
|
"agent-driven": "agent-driven";
|
|
18
|
+
human: "human";
|
|
19
19
|
insufficient: "insufficient";
|
|
20
20
|
}>;
|
|
21
21
|
score: ZodNullable<ZodNumber>;
|
|
@@ -46,8 +46,8 @@ declare const BrowserPostureReportSchema: ZodObject<{
|
|
|
46
46
|
projectId: ZodString;
|
|
47
47
|
sessionId: ZodGUID;
|
|
48
48
|
verdict: ZodEnum<{
|
|
49
|
-
human: "human";
|
|
50
49
|
"agent-driven": "agent-driven";
|
|
50
|
+
human: "human";
|
|
51
51
|
insufficient: "insufficient";
|
|
52
52
|
}>;
|
|
53
53
|
score: ZodNullable<ZodNumber>;
|
|
@@ -84,8 +84,8 @@ declare const BrowserPostureReportIngestSchema: ZodObject<{
|
|
|
84
84
|
projectId: ZodString;
|
|
85
85
|
sessionId: ZodGUID;
|
|
86
86
|
verdict: ZodEnum<{
|
|
87
|
-
human: "human";
|
|
88
87
|
"agent-driven": "agent-driven";
|
|
88
|
+
human: "human";
|
|
89
89
|
insufficient: "insufficient";
|
|
90
90
|
}>;
|
|
91
91
|
scorerVersion: ZodNumber;
|
|
@@ -98,7 +98,7 @@ declare const BrowserPostureReportIngestSchema: ZodObject<{
|
|
|
98
98
|
declare function browserPostureReport(posture: BrowserPosture): {
|
|
99
99
|
projectId: string;
|
|
100
100
|
sessionId: string;
|
|
101
|
-
verdict: "
|
|
101
|
+
verdict: "agent-driven" | "human" | "insufficient";
|
|
102
102
|
score: number | null;
|
|
103
103
|
scorerVersion: number;
|
|
104
104
|
reasons: string[];
|
|
@@ -166,4 +166,4 @@ declare function postureRequiredScopes(config: BrowserPostureConfig, path: strin
|
|
|
166
166
|
declare function validateBrowserPostureConfig(config: BrowserPostureConfig, projectId: string | undefined): void;
|
|
167
167
|
//#endregion
|
|
168
168
|
export { POSTURE_VERIFICATION_STATUSES as A, verifyBrowserPosture as C, BrowserPostureRejectionReason as D, BrowserPostureOutcomeSchema as E, POSTURE_TTL_SECONDS as F, postureCookieName as I, browserPostureReport as M, BrowserPosture as N, BrowserPostureReportIngestSchema as O, BrowserPostureSchema as P, validateBrowserPostureConfig as S, BrowserPostureOutcome as T, postureRequiredScopes as _, POSTURE_SESSION_HEADER as a, readPostureCookie as b, PostureVerification as c, inspectBrowserPosture as d, postureFromCookies as f, postureRequestFromHeaders as g, postureOutcomeReport as h, POSTURE_ISSUER as i, PostureVerificationStatus as j, BrowserPostureReportSchema as k, UNSIGNED_BROWSER_AGENT as l, postureOutcomeFromRequest as m, JWK$1 as n, POSTURE_TYPE as o, postureFromRequest as p, POSTURE_HEADER as r, PostureRequest as s, BrowserPostureConfig as t, behavioralConfidence as u, postureSessionBinding as v, BROWSER_POSTURE_REJECTION_REASONS as w, signBrowserPosture as x, postureUpgrade as y };
|
|
169
|
-
//# sourceMappingURL=browser-posture-
|
|
169
|
+
//# sourceMappingURL=browser-posture-B8YiPa5c.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-
|
|
1
|
+
{"version":3,"file":"browser-posture-B8YiPa5c.d.ts","names":[],"sources":["../src/browser-posture-cookie.ts","../src/beacon-types/index.ts","../src/browser-posture-schema.ts","../src/browser-posture-report.ts","../src/browser-posture.ts"],"mappings":";;;iBAgBgB,kBAAkB;;;cC4jDrB;;;cC1kDA,sBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C/B;KAGU,iBAAiB,cAAe;;;cC7C/B;KACD,oCAAoC;cAGnC,4BAA0B;;;;;;;;;;;;;;GAWrC;cAEW;KAaD,wCAAwC;cAEvC,6BAA2B;;;;;;;;;;;;;;;;;;;GAQpC;KACQ,wBAAwB,cAAe;cA2BtC,kCAAgC;;;;;;;;;;;;;;GAE3C;iBAEc,qBAAqB,SAAS;;;;;;;;;;;;;cClDjC;;;;;cAKA,uBAAwB;UAG3B;EACR;EACA;EACA;EACA;EACA;EACA;;iBAGc,eAAe,SAAS,iBAAiB;cAyC5C;cAGA;UAEI;EAEf,WAAW;EACX;EAEA;EACA;EACA;EAEA,kBAAkB;IAAQ;IAAc;;;iBAI1B,kBACd,mCACA;iBAcoB,sBAAsB,oBAAoB;iBAc1C,mBACpB,SAAS,gBACT,YAAY,KACZ,gBACC;KAqBS;EACN;EAAoB,SAAS;;EAC7B;;EACA;EAAoB,QAAQ;;cAOrB,uBAAwB,SAAS,wBAAsB;iBAM9C,sBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;iBA2EW,qBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;cAYE;cACA;UAGI;EACf;EAEA;EAEA;;iBAIc,0BACd,MAAM,iEACL;iBA6BmB,0BACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAcW,mBACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAIW,mBACpB,mCACA,QAAQ,sBACR,oBACC,QAAQ;iBAKK,sBACd,QAAQ,sBACR;iBAmBc,6BACd,QAAQ,sBACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ZodOptional, E as ZodObject, L as output, T as ZodNumber, V as $strip, _ as ZodGUID, g as ZodEnum, j as ZodString, l as ZodArray, m as ZodDefault, t as external_d_exports, u as ZodBoolean, w as ZodNullable, x as ZodLiteral } from "./external-B7WI9FyQ.mjs";
|
|
2
2
|
import { JWK, JWK as JWK$1 } from "jose";
|
|
3
3
|
//#region src/browser-posture-cookie.d.ts
|
|
4
4
|
declare function postureCookieName(projectId: string): string;
|
|
@@ -14,8 +14,8 @@ declare const BrowserPostureSchema: ZodObject<{
|
|
|
14
14
|
session_id: ZodGUID;
|
|
15
15
|
binding: ZodString;
|
|
16
16
|
verdict: ZodEnum<{
|
|
17
|
-
human: "human";
|
|
18
17
|
"agent-driven": "agent-driven";
|
|
18
|
+
human: "human";
|
|
19
19
|
insufficient: "insufficient";
|
|
20
20
|
}>;
|
|
21
21
|
score: ZodNullable<ZodNumber>;
|
|
@@ -46,8 +46,8 @@ declare const BrowserPostureReportSchema: ZodObject<{
|
|
|
46
46
|
projectId: ZodString;
|
|
47
47
|
sessionId: ZodGUID;
|
|
48
48
|
verdict: ZodEnum<{
|
|
49
|
-
human: "human";
|
|
50
49
|
"agent-driven": "agent-driven";
|
|
50
|
+
human: "human";
|
|
51
51
|
insufficient: "insufficient";
|
|
52
52
|
}>;
|
|
53
53
|
score: ZodNullable<ZodNumber>;
|
|
@@ -84,8 +84,8 @@ declare const BrowserPostureReportIngestSchema: ZodObject<{
|
|
|
84
84
|
projectId: ZodString;
|
|
85
85
|
sessionId: ZodGUID;
|
|
86
86
|
verdict: ZodEnum<{
|
|
87
|
-
human: "human";
|
|
88
87
|
"agent-driven": "agent-driven";
|
|
88
|
+
human: "human";
|
|
89
89
|
insufficient: "insufficient";
|
|
90
90
|
}>;
|
|
91
91
|
scorerVersion: ZodNumber;
|
|
@@ -98,7 +98,7 @@ declare const BrowserPostureReportIngestSchema: ZodObject<{
|
|
|
98
98
|
declare function browserPostureReport(posture: BrowserPosture): {
|
|
99
99
|
projectId: string;
|
|
100
100
|
sessionId: string;
|
|
101
|
-
verdict: "
|
|
101
|
+
verdict: "agent-driven" | "human" | "insufficient";
|
|
102
102
|
score: number | null;
|
|
103
103
|
scorerVersion: number;
|
|
104
104
|
reasons: string[];
|
|
@@ -166,4 +166,4 @@ declare function postureRequiredScopes(config: BrowserPostureConfig, path: strin
|
|
|
166
166
|
declare function validateBrowserPostureConfig(config: BrowserPostureConfig, projectId: string | undefined): void;
|
|
167
167
|
//#endregion
|
|
168
168
|
export { POSTURE_VERIFICATION_STATUSES as A, verifyBrowserPosture as C, BrowserPostureRejectionReason as D, BrowserPostureOutcomeSchema as E, POSTURE_TTL_SECONDS as F, postureCookieName as I, browserPostureReport as M, BrowserPosture as N, BrowserPostureReportIngestSchema as O, BrowserPostureSchema as P, validateBrowserPostureConfig as S, BrowserPostureOutcome as T, postureRequiredScopes as _, POSTURE_SESSION_HEADER as a, readPostureCookie as b, PostureVerification as c, inspectBrowserPosture as d, postureFromCookies as f, postureRequestFromHeaders as g, postureOutcomeReport as h, POSTURE_ISSUER as i, PostureVerificationStatus as j, BrowserPostureReportSchema as k, UNSIGNED_BROWSER_AGENT as l, postureOutcomeFromRequest as m, JWK$1 as n, POSTURE_TYPE as o, postureFromRequest as p, POSTURE_HEADER as r, PostureRequest as s, BrowserPostureConfig as t, behavioralConfidence as u, postureSessionBinding as v, BROWSER_POSTURE_REJECTION_REASONS as w, signBrowserPosture as x, postureUpgrade as y };
|
|
169
|
-
//# sourceMappingURL=browser-posture-
|
|
169
|
+
//# sourceMappingURL=browser-posture-BLhw-MON.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-
|
|
1
|
+
{"version":3,"file":"browser-posture-BLhw-MON.d.mts","names":[],"sources":["../src/browser-posture-cookie.ts","../src/beacon-types/index.ts","../src/browser-posture-schema.ts","../src/browser-posture-report.ts","../src/browser-posture.ts"],"mappings":";;;iBAgBgB,kBAAkB;;;cC4jDrB;;;cC1kDA,sBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C/B;KAGU,iBAAiB,cAAe;;;cC7C/B;KACD,oCAAoC;cAGnC,4BAA0B;;;;;;;;;;;;;;GAWrC;cAEW;KAaD,wCAAwC;cAEvC,6BAA2B;;;;;;;;;;;;;;;;;;;GAQpC;KACQ,wBAAwB,cAAe;cA2BtC,kCAAgC;;;;;;;;;;;;;;GAE3C;iBAEc,qBAAqB,SAAS;;;;;;;;;;;;;cClDjC;;;;;cAKA,uBAAwB;UAG3B;EACR;EACA;EACA;EACA;EACA;EACA;;iBAGc,eAAe,SAAS,iBAAiB;cAyC5C;cAGA;UAEI;EAEf,WAAW;EACX;EAEA;EACA;EACA;EAEA,kBAAkB;IAAQ;IAAc;;;iBAI1B,kBACd,mCACA;iBAcoB,sBAAsB,oBAAoB;iBAc1C,mBACpB,SAAS,gBACT,YAAY,KACZ,gBACC;KAqBS;EACN;EAAoB,SAAS;;EAC7B;;EACA;EAAoB,QAAQ;;cAOrB,uBAAwB,SAAS,wBAAsB;iBAM9C,sBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;iBA2EW,qBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;cAYE;cACA;UAGI;EACf;EAEA;EAEA;;iBAIc,0BACd,MAAM,iEACL;iBA6BmB,0BACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAcW,mBACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAIW,mBACpB,mCACA,QAAQ,sBACR,oBACC,QAAQ;iBAKK,sBACd,QAAQ,sBACR;iBAmBc,6BACd,QAAQ,sBACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=/^[0-9a-f]{8}-[0-9a-f]{4}-[
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(t){if(!e.test(t)||t!==t.toLowerCase())throw Error(`Invalid posture project id`);return`__Host-checkpoint_posture_${t}`}exports.postureCookieName=t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=/^[0-9a-f]{8}-[0-9a-f]{4}-[
|
|
1
|
+
const e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(t){if(!e.test(t)||t!==t.toLowerCase())throw Error(`Invalid posture project id`);return`__Host-checkpoint_posture_${t}`}export{t as postureCookieName};
|
|
2
2
|
//# sourceMappingURL=browser-posture-cookie.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-cookie.mjs","names":[],"sources":["../src/constants/patterns.ts","../src/browser-posture-cookie.ts"],"sourcesContent":["/**\n * Regular Expression Patterns\n *\n * Common regex patterns used for validation and detection\n */\n\n/**\n * Validation Patterns\n */\n// Hoisted out of the object literal below so bundle-size-critical leaves can\n// import JUST this one pattern. `VALIDATION_PATTERNS` re-exports it, so there\n// is still exactly one definition and no drift.\n//\n// Why it matters: rolldown (via tsdown) does not do property-level DCE on a\n// const object literal the way esbuild did. `browser-posture-cookie.ts` uses\n// only `.UUID`, but importing the whole object dragged every pattern —\n// ULID, SLUG, IPV4, IPV6 — into that leaf, taking it from 272 to 2,870 bytes.\n// The beacon inlines that leaf (`noExternal`), which pushed its gzipped\n// bundle from 29,337 to 30,123 against a 29,696-byte CI budget.\n//\n// UUID pattern: accepts versions 0-5 (0 is nil UUID, 1-5 are standard versions)\n// Variants: 0 (nil), 8-9-a-b (standard variants)\nexport const UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport const VALIDATION_PATTERNS = {\n // Identifiers\n UUID: UUID_PATTERN,\n ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n SLUG: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n\n // Network\n 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]?)$/,\n 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}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,\n IP: /^(?:(?: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]?)$|^(([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}|:))$/,\n // eslint-disable-next-line no-useless-escape\n // CIDR pattern: uses IPV4 pattern and restricts mask to 0-32\n CIDR: /^(?:(?: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]?)\\/(?:[0-9]|[12][0-9]|3[0-2])$/,\n // eslint-disable-next-line no-useless-escape\n DOMAIN: /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i,\n HOSTNAME:\n /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/,\n // eslint-disable-next-line no-useless-escape\n URL: /^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/,\n\n // Contact\n // Email pattern: stricter validation (rejects consecutive dots, requires TLD)\n // Local part: alphanumeric start/end, dots allowed but not consecutive\n EMAIL:\n /^[a-zA-Z0-9](?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]|\\.(?!\\.))*[a-zA-Z0-9]?@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,\n PHONE: /^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$/,\n\n // Security\n // JWT pattern: requires 3 parts (header.payload.signature) - signature cannot be empty\n JWT: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+$/,\n // eslint-disable-next-line no-useless-escape\n BASE64: /^[A-Za-z0-9+\\/]*={0,2}$/,\n HEX: /^[0-9a-fA-F]+$/,\n MD5: /^[a-f0-9]{32}$/i,\n SHA1: /^[a-f0-9]{40}$/i,\n SHA256: /^[a-f0-9]{64}$/i,\n\n // Versions\n SEMVER:\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/,\n\n // Files\n FILENAME: /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\\.[a-zA-Z0-9_-]+$/,\n PATH: /^(\\/[^/ ]*)+\\/?$/,\n\n // Keys\n API_KEY: /^[A-Za-z0-9_-]{32,}$/,\n SECRET_KEY: /^[A-Za-z0-9_-]{64,}$/,\n PIXEL_ID: /^px_[A-Za-z0-9]{16}$/,\n} as const;\n\n/**\n * User Agent Patterns for Agent Detection\n */\nexport const USER_AGENT_PATTERNS = {\n // AI Agents\n OPENAI: /(?:GPTBot|ChatGPT-User|OpenAI)/i,\n ANTHROPIC: /(?:Claude-Web|Claude-User|anthropic-ai|claude-web|claude-user|ClaudeBot)/i,\n PERPLEXITY: /(?:PerplexityBot|Perplexica)/i,\n GOOGLE_AI: /(?:Bard|Google-InspectionTool)/i,\n MICROSOFT_AI: /(?:BingPreview\\/.*ChatGPT|Copilot)/i,\n\n // Search Bots\n GOOGLEBOT: /Googlebot/i,\n BINGBOT: /(?:bingbot|BingPreview|msnbot)/i,\n DUCKDUCKBOT: /DuckDuckBot/i,\n BAIDUBOT: /Baiduspider/i,\n YANDEXBOT: /YandexBot/i,\n\n // Social Media Bots\n FACEBOOK: /(?:facebookexternalhit|facebookcatalog)/i,\n TWITTER: /(?:Twitterbot|TwitterImageProxy)/i,\n LINKEDIN: /LinkedInBot/i,\n WHATSAPP: /WhatsApp/i,\n TELEGRAM: /TelegramBot/i,\n DISCORD: /Discordbot/i,\n SLACK: /Slackbot/i,\n\n // Crawlers and Scrapers\n GENERIC_BOT: /(?:bot|crawler|spider|scraper|agent)/i,\n SCRAPY: /Scrapy/i,\n PUPPETEER: /(?:HeadlessChrome|Puppeteer)/i,\n PLAYWRIGHT: /Playwright/i,\n SELENIUM: /(?:selenium|webdriver)/i,\n\n // Development Tools\n POSTMAN: /PostmanRuntime/i,\n INSOMNIA: /insomnia/i,\n CURL: /curl/i,\n WGET: /Wget/i,\n HTTPIE: /HTTPie/i,\n\n // Monitoring Services\n UPTIMEROBOT: /UptimeRobot/i,\n PINGDOM: /Pingdom/i,\n NEWRELIC: /NewRelicPinger/i,\n DATADOG: /Datadog/i,\n} as const;\n\n/**\n * Header Patterns for Agent Detection\n */\nexport const HEADER_PATTERNS = {\n // AI-specific headers\n AI_HEADERS: /^(?:X-(?:OpenAI|Anthropic|AI|Bot|Agent|LLM))/i,\n\n // Automation headers\n AUTOMATION_HEADERS: /^(?:X-(?:Automated|Robot|Crawler|Scraper))/i,\n\n // Missing standard headers\n MISSING_ACCEPT: /^$/,\n MISSING_ACCEPT_LANGUAGE: /^$/,\n MISSING_ACCEPT_ENCODING: /^$/,\n\n // Suspicious patterns\n GENERIC_ACCEPT: /^\\*\\/\\*$/,\n NO_COOKIES: /^$/,\n\n // Known proxy headers\n PROXY_HEADERS: /^(?:X-Forwarded-|X-Real-IP|X-Originating-IP|Via|Forwarded)/i,\n\n // Cloud provider headers\n CLOUD_HEADERS: /^(?:X-(?:AWS|Azure|GCP|Cloudflare))/i,\n} as const;\n\n/**\n * Browser Patterns\n */\nexport const BROWSER_PATTERNS = {\n CHROME: /Chrome\\/([0-9.]+)/,\n FIREFOX: /Firefox\\/([0-9.]+)/,\n SAFARI: /Version\\/([0-9.]+).*Safari/,\n EDGE: /Edg\\/([0-9.]+)/,\n OPERA: /OPR\\/([0-9.]+)/,\n IE: /MSIE ([0-9.]+)/,\n} as const;\n\n/**\n * Operating System Patterns\n */\nexport const OS_PATTERNS = {\n WINDOWS: /Windows NT ([0-9.]+)/,\n MACOS: /Mac OS X ([0-9_]+)/,\n LINUX: /Linux/,\n ANDROID: /Android ([0-9.]+)/,\n IOS: /OS ([0-9_]+) like Mac OS X/,\n} as const;\n\n/**\n * Mobile Device Patterns\n */\nexport const MOBILE_PATTERNS = {\n MOBILE: /(?:Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini)/i,\n TABLET: /(?:iPad|Android.*Tablet|Tablet.*Android|Kindle|Silk)/i,\n DESKTOP: /(?:Windows NT|Mac OS X|Linux|CrOS)/i,\n} as const;\n\n/**\n * Suspicious Behavior Patterns\n */\nexport const SUSPICIOUS_PATTERNS = {\n // Rapid requests\n RAPID_REQUESTS: /^[0-9]{1,3}$/,\n\n // Sequential access\n SEQUENTIAL_URLS: /\\?(?:page|offset|id)=[0-9]+/,\n\n // Data extraction\n API_ENDPOINTS: /\\/api\\/|\\.json$|\\.xml$/i,\n\n // Form submission without interaction\n DIRECT_POST: /^POST$/,\n\n // Known attack patterns\n SQL_INJECTION:\n /(?:union|select|insert|update|delete|drop|create|alter|exec|script|javascript|onerror|onload|eval|src=)/i,\n XSS_ATTEMPT: /(?:<script|javascript:|onerror=|onclick=|<iframe|<embed|<object)/i,\n PATH_TRAVERSAL: /(?:\\.\\.\\/|\\.\\.\\\\|%2e%2e%2f|%252e%252e%252f)/i,\n\n // Encoding attempts\n URL_ENCODED: /%[0-9a-f]{2}/i,\n BASE64_DATA: /data:[^;]+;base64,/i,\n} as const;\n\n/**\n * Maximum input length for pattern matching. UAs, header values, and\n * detection payloads are bounded in practice (<4KB even for the most\n * verbose Chrome/Firefox UAs). Caps worst-case complexity for any\n * polynomial-shaped pattern an external caller might supply to\n * `testPattern` / `extractMatch`; CodeQL flagged the unbounded path\n * (js/polynomial-redos) on PR #2576.\n */\nconst MAX_PATTERN_INPUT_LENGTH = 4096;\n\n/**\n * Helper function to test a pattern. Returns `false` on inputs longer\n * than {@link MAX_PATTERN_INPUT_LENGTH} — an abuse signal we'd rather\n * reject than process.\n */\nexport function testPattern(pattern: RegExp, value: string): boolean {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;\n return pattern.test(value);\n}\n\n/**\n * Helper function to extract match from pattern. Returns `null` on\n * over-long inputs (same ReDoS defense as `testPattern`).\n */\nexport function extractMatch(pattern: RegExp, value: string): string | null {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;\n const match = value.match(pattern);\n return match ? match[1] || match[0] : null;\n}\n\n/**\n * Helper function to test multiple patterns\n */\nexport function testPatterns(patterns: RegExp[], value: string): boolean {\n return patterns.some((pattern) => testPattern(pattern, value));\n}\n\n/**\n * Helper function to find matching pattern\n */\nexport function findMatchingPattern(\n patterns: Record<string, RegExp>,\n value: string\n): string | null {\n for (const [name, pattern] of Object.entries(patterns)) {\n if (testPattern(pattern, value)) {\n return name;\n }\n }\n return null;\n}\n","// Imports the single hoisted pattern, not the whole `VALIDATION_PATTERNS`\n// object — same definition, but it keeps this leaf actually dependency-free\n// under rolldown, which does not property-shake object literals.\nimport { UUID_PATTERN } from './constants/patterns';\n\n/**\n * The browser-posture cookie name. Kept in its own dependency-free leaf so the\n * beacon (bundle-size budgeted, no `jose`) derives the name from the SAME\n * function every SDK reader uses via `./browser-posture`; two independent\n * derivations of this name is exactly the drift that dropped the cookie.\n *\n * The lowercase UUID only: the issuer signs `project_id` as the database's\n * lowercase project UUID and cookie names compare case-sensitively, so a\n * friendly id, or the same UUID in upper case, can never name a cookie a\n * reader will look for.\n */\nexport function postureCookieName(projectId: string): string {\n if (!UUID_PATTERN.test(projectId) || projectId !== projectId.toLowerCase())\n throw new Error('Invalid posture project id');\n return `__Host-checkpoint_posture_${projectId}`;\n}\n"],"mappings":"AAsBA,MAAa,EACX,8ECPF,SAAgB,EAAkB,EAA2B,CAC3D,GAAI,CAAC,EAAa,KAAK,CAAS,GAAK,IAAc,EAAU,YAAY,EACvE,MAAU,MAAM,4BAA4B,EAC9C,MAAO,6BAA6B,GACtC"}
|
|
1
|
+
{"version":3,"file":"browser-posture-cookie.mjs","names":[],"sources":["../src/constants/patterns.ts","../src/browser-posture-cookie.ts"],"sourcesContent":["/**\n * Regular Expression Patterns\n *\n * Common regex patterns used for validation and detection\n */\n\n/**\n * Validation Patterns\n */\n// Hoisted out of the object literal below so bundle-size-critical leaves can\n// import JUST this one pattern. `VALIDATION_PATTERNS` re-exports it, so there\n// is still exactly one definition and no drift.\n//\n// Why it matters: rolldown (via tsdown) does not do property-level DCE on a\n// const object literal the way esbuild did. `browser-posture-cookie.ts` uses\n// only `.UUID`, but importing the whole object dragged every pattern —\n// ULID, SLUG, IPV4, IPV6 — into that leaf, taking it from 272 to 2,870 bytes.\nexport const UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport const VALIDATION_PATTERNS = {\n // Identifiers\n UUID: UUID_PATTERN,\n ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n SLUG: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n\n // Network\n 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]?)$/,\n 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}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,\n IP: /^(?:(?: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]?)$|^(([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}|:))$/,\n // eslint-disable-next-line no-useless-escape\n // CIDR pattern: uses IPV4 pattern and restricts mask to 0-32\n CIDR: /^(?:(?: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]?)\\/(?:[0-9]|[12][0-9]|3[0-2])$/,\n // eslint-disable-next-line no-useless-escape\n DOMAIN: /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i,\n HOSTNAME:\n /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/,\n // eslint-disable-next-line no-useless-escape\n URL: /^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/,\n\n // Contact\n // Email pattern: stricter validation (rejects consecutive dots, requires TLD)\n // Local part: alphanumeric start/end, dots allowed but not consecutive\n EMAIL:\n /^[a-zA-Z0-9](?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]|\\.(?!\\.))*[a-zA-Z0-9]?@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,\n PHONE: /^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$/,\n\n // Security\n // JWT pattern: requires 3 parts (header.payload.signature) - signature cannot be empty\n JWT: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+$/,\n // eslint-disable-next-line no-useless-escape\n BASE64: /^[A-Za-z0-9+\\/]*={0,2}$/,\n HEX: /^[0-9a-fA-F]+$/,\n MD5: /^[a-f0-9]{32}$/i,\n SHA1: /^[a-f0-9]{40}$/i,\n SHA256: /^[a-f0-9]{64}$/i,\n\n // Versions\n SEMVER:\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/,\n\n // Files\n FILENAME: /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\\.[a-zA-Z0-9_-]+$/,\n PATH: /^(\\/[^/ ]*)+\\/?$/,\n\n // Keys\n API_KEY: /^[A-Za-z0-9_-]{32,}$/,\n SECRET_KEY: /^[A-Za-z0-9_-]{64,}$/,\n PIXEL_ID: /^px_[A-Za-z0-9]{16}$/,\n} as const;\n\n/**\n * User Agent Patterns for Agent Detection\n */\nexport const USER_AGENT_PATTERNS = {\n // AI Agents\n OPENAI: /(?:GPTBot|ChatGPT-User|OpenAI)/i,\n ANTHROPIC: /(?:Claude-Web|Claude-User|anthropic-ai|claude-web|claude-user|ClaudeBot)/i,\n PERPLEXITY: /(?:PerplexityBot|Perplexica)/i,\n GOOGLE_AI: /(?:Bard|Google-InspectionTool)/i,\n MICROSOFT_AI: /(?:BingPreview\\/.*ChatGPT|Copilot)/i,\n\n // Search Bots\n GOOGLEBOT: /Googlebot/i,\n BINGBOT: /(?:bingbot|BingPreview|msnbot)/i,\n DUCKDUCKBOT: /DuckDuckBot/i,\n BAIDUBOT: /Baiduspider/i,\n YANDEXBOT: /YandexBot/i,\n\n // Social Media Bots\n FACEBOOK: /(?:facebookexternalhit|facebookcatalog)/i,\n TWITTER: /(?:Twitterbot|TwitterImageProxy)/i,\n LINKEDIN: /LinkedInBot/i,\n WHATSAPP: /WhatsApp/i,\n TELEGRAM: /TelegramBot/i,\n DISCORD: /Discordbot/i,\n SLACK: /Slackbot/i,\n\n // Crawlers and Scrapers\n GENERIC_BOT: /(?:bot|crawler|spider|scraper|agent)/i,\n SCRAPY: /Scrapy/i,\n PUPPETEER: /(?:HeadlessChrome|Puppeteer)/i,\n PLAYWRIGHT: /Playwright/i,\n SELENIUM: /(?:selenium|webdriver)/i,\n\n // Development Tools\n POSTMAN: /PostmanRuntime/i,\n INSOMNIA: /insomnia/i,\n CURL: /curl/i,\n WGET: /Wget/i,\n HTTPIE: /HTTPie/i,\n\n // Monitoring Services\n UPTIMEROBOT: /UptimeRobot/i,\n PINGDOM: /Pingdom/i,\n NEWRELIC: /NewRelicPinger/i,\n DATADOG: /Datadog/i,\n} as const;\n\n/**\n * Header Patterns for Agent Detection\n */\nexport const HEADER_PATTERNS = {\n // AI-specific headers\n AI_HEADERS: /^(?:X-(?:OpenAI|Anthropic|AI|Bot|Agent|LLM))/i,\n\n // Automation headers\n AUTOMATION_HEADERS: /^(?:X-(?:Automated|Robot|Crawler|Scraper))/i,\n\n // Missing standard headers\n MISSING_ACCEPT: /^$/,\n MISSING_ACCEPT_LANGUAGE: /^$/,\n MISSING_ACCEPT_ENCODING: /^$/,\n\n // Suspicious patterns\n GENERIC_ACCEPT: /^\\*\\/\\*$/,\n NO_COOKIES: /^$/,\n\n // Known proxy headers\n PROXY_HEADERS: /^(?:X-Forwarded-|X-Real-IP|X-Originating-IP|Via|Forwarded)/i,\n\n // Cloud provider headers\n CLOUD_HEADERS: /^(?:X-(?:AWS|Azure|GCP|Cloudflare))/i,\n} as const;\n\n/**\n * Browser Patterns\n */\nexport const BROWSER_PATTERNS = {\n CHROME: /Chrome\\/([0-9.]+)/,\n FIREFOX: /Firefox\\/([0-9.]+)/,\n SAFARI: /Version\\/([0-9.]+).*Safari/,\n EDGE: /Edg\\/([0-9.]+)/,\n OPERA: /OPR\\/([0-9.]+)/,\n IE: /MSIE ([0-9.]+)/,\n} as const;\n\n/**\n * Operating System Patterns\n */\nexport const OS_PATTERNS = {\n WINDOWS: /Windows NT ([0-9.]+)/,\n MACOS: /Mac OS X ([0-9_]+)/,\n LINUX: /Linux/,\n ANDROID: /Android ([0-9.]+)/,\n IOS: /OS ([0-9_]+) like Mac OS X/,\n} as const;\n\n/**\n * Mobile Device Patterns\n */\nexport const MOBILE_PATTERNS = {\n MOBILE: /(?:Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini)/i,\n TABLET: /(?:iPad|Android.*Tablet|Tablet.*Android|Kindle|Silk)/i,\n DESKTOP: /(?:Windows NT|Mac OS X|Linux|CrOS)/i,\n} as const;\n\n/**\n * Suspicious Behavior Patterns\n */\nexport const SUSPICIOUS_PATTERNS = {\n // Rapid requests\n RAPID_REQUESTS: /^[0-9]{1,3}$/,\n\n // Sequential access\n SEQUENTIAL_URLS: /\\?(?:page|offset|id)=[0-9]+/,\n\n // Data extraction\n API_ENDPOINTS: /\\/api\\/|\\.json$|\\.xml$/i,\n\n // Form submission without interaction\n DIRECT_POST: /^POST$/,\n\n // Known attack patterns\n SQL_INJECTION:\n /(?:union|select|insert|update|delete|drop|create|alter|exec|script|javascript|onerror|onload|eval|src=)/i,\n XSS_ATTEMPT: /(?:<script|javascript:|onerror=|onclick=|<iframe|<embed|<object)/i,\n PATH_TRAVERSAL: /(?:\\.\\.\\/|\\.\\.\\\\|%2e%2e%2f|%252e%252e%252f)/i,\n\n // Encoding attempts\n URL_ENCODED: /%[0-9a-f]{2}/i,\n BASE64_DATA: /data:[^;]+;base64,/i,\n} as const;\n\n/**\n * Maximum input length for pattern matching. UAs, header values, and\n * detection payloads are bounded in practice (<4KB even for the most\n * verbose Chrome/Firefox UAs). Caps worst-case complexity for any\n * polynomial-shaped pattern an external caller might supply to\n * `testPattern` / `extractMatch`; CodeQL flagged the unbounded path\n * (js/polynomial-redos) on PR #2576.\n */\nconst MAX_PATTERN_INPUT_LENGTH = 4096;\n\n/**\n * Helper function to test a pattern. Returns `false` on inputs longer\n * than {@link MAX_PATTERN_INPUT_LENGTH} — an abuse signal we'd rather\n * reject than process.\n */\nexport function testPattern(pattern: RegExp, value: string): boolean {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;\n return pattern.test(value);\n}\n\n/**\n * Helper function to extract match from pattern. Returns `null` on\n * over-long inputs (same ReDoS defense as `testPattern`).\n */\nexport function extractMatch(pattern: RegExp, value: string): string | null {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;\n const match = value.match(pattern);\n return match ? match[1] || match[0] : null;\n}\n\n/**\n * Helper function to test multiple patterns\n */\nexport function testPatterns(patterns: RegExp[], value: string): boolean {\n return patterns.some((pattern) => testPattern(pattern, value));\n}\n\n/**\n * Helper function to find matching pattern\n */\nexport function findMatchingPattern(\n patterns: Record<string, RegExp>,\n value: string\n): string | null {\n for (const [name, pattern] of Object.entries(patterns)) {\n if (testPattern(pattern, value)) {\n return name;\n }\n }\n return null;\n}\n","// Imports the single hoisted pattern, not the whole `VALIDATION_PATTERNS`\n// object — same definition, but it keeps this leaf actually dependency-free\n// under rolldown, which does not property-shake object literals.\nimport { UUID_PATTERN } from './constants/patterns';\n\n/**\n * The browser-posture cookie name. Kept in its own dependency-free leaf so the\n * beacon (bundle-size budgeted, no `jose`) derives the name from the SAME\n * function every SDK reader uses via `./browser-posture`; two independent\n * derivations of this name is exactly the drift that dropped the cookie.\n *\n * The lowercase UUID only: the issuer signs `project_id` as the database's\n * lowercase project UUID and cookie names compare case-sensitively, so a\n * friendly id, or the same UUID in upper case, can never name a cookie a\n * reader will look for.\n */\nexport function postureCookieName(projectId: string): string {\n if (!UUID_PATTERN.test(projectId) || projectId !== projectId.toLowerCase())\n throw new Error('Invalid posture project id');\n return `__Host-checkpoint_posture_${projectId}`;\n}\n"],"mappings":"AAiBA,MAAa,EACX,6ECFF,SAAgB,EAAkB,EAA2B,CAC3D,GAAI,CAAC,EAAa,KAAK,CAAS,GAAK,IAAc,EAAU,YAAY,EACvE,MAAU,MAAM,4BAA4B,EAC9C,MAAO,6BAA6B,GACtC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { N as BrowserPosture } from "./browser-posture-
|
|
1
|
+
import { E as ZodObject, L as output, T as ZodNumber, V as $strip, j as ZodString, t as external_d_exports } from "./external-B7WI9FyQ.mjs";
|
|
2
|
+
import { N as BrowserPosture } from "./browser-posture-BLhw-MON.mjs";
|
|
3
3
|
//#region src/browser-posture-proof.d.ts
|
|
4
4
|
export declare const POSTURE_PROOF_TYPE = "dpop+jwt";
|
|
5
5
|
export declare const DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS = 60;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-proof.d.mts","names":[],"sources":["../src/browser-posture-proof.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"browser-posture-proof.d.mts","names":[],"sources":["../src/browser-posture-proof.ts"],"mappings":";;;qBAaa;qBAKA;qBAEA,2BAAyB;;;;;GAKpC;YACU,sBAAsB,cAAe;wBAgB3B,0BACpB,8BACA,SAAS,gBACT;EAAW;EAAgB;GAC3B,cACA,yBACC,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { N as BrowserPosture } from "./browser-posture-
|
|
1
|
+
import { E as ZodObject, L as output, T as ZodNumber, V as $strip, j as ZodString, t as external_d_exports } from "./external-B7WI9FyQ.js";
|
|
2
|
+
import { N as BrowserPosture } from "./browser-posture-B8YiPa5c.js";
|
|
3
3
|
//#region src/browser-posture-proof.d.ts
|
|
4
4
|
export declare const POSTURE_PROOF_TYPE = "dpop+jwt";
|
|
5
5
|
export declare const DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS = 60;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-proof.d.ts","names":[],"sources":["../src/browser-posture-proof.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"browser-posture-proof.d.ts","names":[],"sources":["../src/browser-posture-proof.ts"],"mappings":";;;qBAaa;qBAKA;qBAEA,2BAAyB;;;;;GAKpC;YACU,sBAAsB,cAAe;wBAgB3B,0BACpB,8BACA,SAAS,gBACT;EAAW;EAAgB;GAC3B,cACA,yBACC,QAAQ"}
|
|
@@ -1,7 +1,48 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_schemas = require('./schemas-
|
|
2
|
+
const require_schemas = require('./schemas-YhagYDx_.js');
|
|
3
3
|
let jose = require("jose");
|
|
4
4
|
|
|
5
|
+
//#region src/utils/base64url.ts
|
|
6
|
+
/**
|
|
7
|
+
* Base64url (RFC 4648 § 5) built on `atob` and `btoa` rather than Node's
|
|
8
|
+
* buffer API, so it runs on every runtime the SDKs support, Cloudflare Workers
|
|
9
|
+
* without `nodejs_compat` included.
|
|
10
|
+
*/
|
|
11
|
+
const BASE64URL_UNPADDED = /^[A-Za-z0-9_-]*$/;
|
|
12
|
+
const PADDING = 61;
|
|
13
|
+
/**
|
|
14
|
+
* `text` without its trailing `=` padding. A backward scan, not
|
|
15
|
+
* `replace(/=+$/, '')`: that regex retries from every `=` in a long run that
|
|
16
|
+
* does not reach the end, which is quadratic on hostile input.
|
|
17
|
+
*/
|
|
18
|
+
function withoutPadding(text) {
|
|
19
|
+
let end = text.length;
|
|
20
|
+
while (end > 0 && text.charCodeAt(end - 1) === PADDING) end -= 1;
|
|
21
|
+
return text.slice(0, end);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Decode base64url, with or without `=` padding.
|
|
25
|
+
*
|
|
26
|
+
* Strict where Node's buffer decoder is lenient: a character outside the
|
|
27
|
+
* alphabet, or a length no encoder produces (one character past a multiple of
|
|
28
|
+
* four), throws a `TypeError` instead of being skipped or truncated. This
|
|
29
|
+
* matches the engine's decoder.
|
|
30
|
+
*/
|
|
31
|
+
function base64UrlToBytes(text) {
|
|
32
|
+
const unpadded = withoutPadding(text);
|
|
33
|
+
if (!BASE64URL_UNPADDED.test(unpadded) || unpadded.length % 4 === 1) throw new TypeError("not valid base64url (RFC 4648 § 5)");
|
|
34
|
+
const base64 = unpadded.replace(/-/g, "+").replace(/_/g, "/");
|
|
35
|
+
const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
|
|
36
|
+
const bytes = new Uint8Array(binary.length);
|
|
37
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
38
|
+
return bytes;
|
|
39
|
+
}
|
|
40
|
+
/** Decode base64url to a string as UTF-8, replacing invalid sequences with U+FFFD. */
|
|
41
|
+
function base64UrlToString(text) {
|
|
42
|
+
return new TextDecoder().decode(base64UrlToBytes(text));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
5
46
|
//#region src/browser-posture-proof.ts
|
|
6
47
|
/**
|
|
7
48
|
* RFC 9449 DPoP-shaped proof verification (P37): binds a browser-posture
|
|
@@ -40,7 +81,7 @@ const BrowserPostureProofSchema = require_schemas.object({
|
|
|
40
81
|
async function verifyBrowserPostureProof(proofJws, posture, request, now = Math.floor(Date.now() / 1e3), maxAgeSeconds = 60) {
|
|
41
82
|
if (!proofJws || proofJws.length > 2e3 || !posture.cnf) return void 0;
|
|
42
83
|
try {
|
|
43
|
-
const decoded = JSON.parse(
|
|
84
|
+
const decoded = JSON.parse(base64UrlToString(proofJws.split(".")[0]));
|
|
44
85
|
if (decoded.typ !== "dpop+jwt" || decoded.alg !== "ES256" || !decoded.jwk || decoded.jwk.kty !== "EC" || decoded.jwk.crv !== "P-256" || decoded.jwk.d) return void 0;
|
|
45
86
|
if (await (0, jose.calculateJwkThumbprint)(decoded.jwk, "sha256") !== posture.cnf.jkt) return void 0;
|
|
46
87
|
const key = await (0, jose.importJWK)(decoded.jwk, "ES256");
|
|
@@ -1,6 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as string, v as number, y as object } from "./schemas-7qodsG-Z.mjs";
|
|
2
2
|
import { calculateJwkThumbprint, importJWK, jwtVerify } from "jose";
|
|
3
3
|
|
|
4
|
+
//#region src/utils/base64url.ts
|
|
5
|
+
/**
|
|
6
|
+
* Base64url (RFC 4648 § 5) built on `atob` and `btoa` rather than Node's
|
|
7
|
+
* buffer API, so it runs on every runtime the SDKs support, Cloudflare Workers
|
|
8
|
+
* without `nodejs_compat` included.
|
|
9
|
+
*/
|
|
10
|
+
const BASE64URL_UNPADDED = /^[A-Za-z0-9_-]*$/;
|
|
11
|
+
const PADDING = 61;
|
|
12
|
+
/**
|
|
13
|
+
* `text` without its trailing `=` padding. A backward scan, not
|
|
14
|
+
* `replace(/=+$/, '')`: that regex retries from every `=` in a long run that
|
|
15
|
+
* does not reach the end, which is quadratic on hostile input.
|
|
16
|
+
*/
|
|
17
|
+
function withoutPadding(text) {
|
|
18
|
+
let end = text.length;
|
|
19
|
+
while (end > 0 && text.charCodeAt(end - 1) === PADDING) end -= 1;
|
|
20
|
+
return text.slice(0, end);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decode base64url, with or without `=` padding.
|
|
24
|
+
*
|
|
25
|
+
* Strict where Node's buffer decoder is lenient: a character outside the
|
|
26
|
+
* alphabet, or a length no encoder produces (one character past a multiple of
|
|
27
|
+
* four), throws a `TypeError` instead of being skipped or truncated. This
|
|
28
|
+
* matches the engine's decoder.
|
|
29
|
+
*/
|
|
30
|
+
function base64UrlToBytes(text) {
|
|
31
|
+
const unpadded = withoutPadding(text);
|
|
32
|
+
if (!BASE64URL_UNPADDED.test(unpadded) || unpadded.length % 4 === 1) throw new TypeError("not valid base64url (RFC 4648 § 5)");
|
|
33
|
+
const base64 = unpadded.replace(/-/g, "+").replace(/_/g, "/");
|
|
34
|
+
const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
|
|
35
|
+
const bytes = new Uint8Array(binary.length);
|
|
36
|
+
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
37
|
+
return bytes;
|
|
38
|
+
}
|
|
39
|
+
/** Decode base64url to a string as UTF-8, replacing invalid sequences with U+FFFD. */
|
|
40
|
+
function base64UrlToString(text) {
|
|
41
|
+
return new TextDecoder().decode(base64UrlToBytes(text));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
4
45
|
//#region src/browser-posture-proof.ts
|
|
5
46
|
/**
|
|
6
47
|
* RFC 9449 DPoP-shaped proof verification (P37): binds a browser-posture
|
|
@@ -39,7 +80,7 @@ const BrowserPostureProofSchema = object({
|
|
|
39
80
|
async function verifyBrowserPostureProof(proofJws, posture, request, now = Math.floor(Date.now() / 1e3), maxAgeSeconds = 60) {
|
|
40
81
|
if (!proofJws || proofJws.length > 2e3 || !posture.cnf) return void 0;
|
|
41
82
|
try {
|
|
42
|
-
const decoded = JSON.parse(
|
|
83
|
+
const decoded = JSON.parse(base64UrlToString(proofJws.split(".")[0]));
|
|
43
84
|
if (decoded.typ !== "dpop+jwt" || decoded.alg !== "ES256" || !decoded.jwk || decoded.jwk.kty !== "EC" || decoded.jwk.crv !== "P-256" || decoded.jwk.d) return void 0;
|
|
44
85
|
if (await calculateJwkThumbprint(decoded.jwk, "sha256") !== posture.cnf.jkt) return void 0;
|
|
45
86
|
const key = await importJWK(decoded.jwk, "ES256");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-proof.mjs","names":["z.object","z.string","z.number"],"sources":["../src/browser-posture-proof.ts"],"sourcesContent":["import { calculateJwkThumbprint, importJWK, jwtVerify, type JWK } from 'jose';\nimport { z } from 'zod';\nimport type { BrowserPosture } from './browser-posture';\n\n/**\n * RFC 9449 DPoP-shaped proof verification (P37): binds a browser-posture\n * token to a non-extractable key the page holds, so the posture token's\n * TTL stops being the whole replay window. The literal RFC 9449 `typ`\n * value, not a project-specific string like the posture token's own\n * `checkpoint-posture+jwt` - adopting the registered value buys real\n * interoperability with any existing DPoP-aware tooling for no cost.\n */\nexport const POSTURE_PROOF_TYPE = 'dpop+jwt';\n/** Half the posture TTL: a per-request, single-use artifact needs a much\n * tighter freshness window than a session-scoped token. A caller-supplied\n * parameter, not a private constant - this must never repeat\n * `POSTURE_TTL_SECONDS`'s own hardcoding mistake. */\nexport const DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS = 60;\n\nexport const BrowserPostureProofSchema = z.object({\n jti: z.string().min(1).max(255),\n htm: z.string().min(1).max(16),\n htu: z.string().url(),\n iat: z.number().int().nonnegative(),\n});\nexport type BrowserPostureProof = z.infer<typeof BrowserPostureProofSchema>;\n\n/**\n * Verifies a DPoP-shaped proof (RFC 9449) against an ALREADY-VERIFIED\n * `BrowserPosture` (call `verifyBrowserPosture` first). Checks, in order:\n * the proof's own header shape (`typ`, `alg`, embedded `jwk`); that the\n * embedded key's RFC 7638 thumbprint matches `posture.cnf.jkt`; the\n * proof's ES256 signature against that same embedded key; `htm`/`htu`\n * against the real request; `iat` freshness. Returns `undefined` on ANY\n * failure, including when `posture.cnf` is absent (no binding to check\n * against), never throws.\n *\n * Does NOT check `jti` replay: that needs a store this library does not\n * own. The caller checks the returned proof's `jti` against their own\n * replay store as the final step before trusting the request.\n */\nexport async function verifyBrowserPostureProof(\n proofJws: string | undefined,\n posture: BrowserPosture,\n request: { method: string; url: string },\n now = Math.floor(Date.now() / 1000),\n maxAgeSeconds = DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS\n): Promise<BrowserPostureProof | undefined> {\n if (!proofJws || proofJws.length > 2000 || !posture.cnf) return undefined;\n try {\n // `proofJws` is already a non-empty, length-bounded string (checked\n // above), so `split('.')[0]` always yields a string, never `undefined`\n // - no `?? ''` fallback to dead-code around.\n const decoded = JSON.parse(
|
|
1
|
+
{"version":3,"file":"browser-posture-proof.mjs","names":["z.object","z.string","z.number"],"sources":["../src/utils/base64url.ts","../src/browser-posture-proof.ts"],"sourcesContent":["/**\n * Base64url (RFC 4648 § 5) built on `atob` and `btoa` rather than Node's\n * buffer API, so it runs on every runtime the SDKs support, Cloudflare Workers\n * without `nodejs_compat` included.\n */\n\nconst BASE64URL_UNPADDED = /^[A-Za-z0-9_-]*$/;\nconst PADDING = 61; // '='\n\n/**\n * `text` without its trailing `=` padding. A backward scan, not\n * `replace(/=+$/, '')`: that regex retries from every `=` in a long run that\n * does not reach the end, which is quadratic on hostile input.\n */\nfunction withoutPadding(text: string): string {\n let end = text.length;\n while (end > 0 && text.charCodeAt(end - 1) === PADDING) end -= 1;\n return text.slice(0, end);\n}\n\n/**\n * Decode base64url, with or without `=` padding.\n *\n * Strict where Node's buffer decoder is lenient: a character outside the\n * alphabet, or a length no encoder produces (one character past a multiple of\n * four), throws a `TypeError` instead of being skipped or truncated. This\n * matches the engine's decoder.\n */\nexport function base64UrlToBytes(text: string): Uint8Array {\n const unpadded = withoutPadding(text);\n if (!BASE64URL_UNPADDED.test(unpadded) || unpadded.length % 4 === 1) {\n throw new TypeError('not valid base64url (RFC 4648 § 5)');\n }\n const base64 = unpadded.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(base64 + '='.repeat((4 - (base64.length % 4)) % 4));\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return bytes;\n}\n\n/** Decode base64url to a string as UTF-8, replacing invalid sequences with U+FFFD. */\nexport function base64UrlToString(text: string): string {\n return new TextDecoder().decode(base64UrlToBytes(text));\n}\n\n/** Encode bytes as base64url without padding. */\nexport function bytesToBase64Url(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return withoutPadding(btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_'));\n}\n","import { calculateJwkThumbprint, importJWK, jwtVerify, type JWK } from 'jose';\nimport { z } from 'zod';\nimport type { BrowserPosture } from './browser-posture';\nimport { base64UrlToString } from './utils/base64url';\n\n/**\n * RFC 9449 DPoP-shaped proof verification (P37): binds a browser-posture\n * token to a non-extractable key the page holds, so the posture token's\n * TTL stops being the whole replay window. The literal RFC 9449 `typ`\n * value, not a project-specific string like the posture token's own\n * `checkpoint-posture+jwt` - adopting the registered value buys real\n * interoperability with any existing DPoP-aware tooling for no cost.\n */\nexport const POSTURE_PROOF_TYPE = 'dpop+jwt';\n/** Half the posture TTL: a per-request, single-use artifact needs a much\n * tighter freshness window than a session-scoped token. A caller-supplied\n * parameter, not a private constant - this must never repeat\n * `POSTURE_TTL_SECONDS`'s own hardcoding mistake. */\nexport const DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS = 60;\n\nexport const BrowserPostureProofSchema = z.object({\n jti: z.string().min(1).max(255),\n htm: z.string().min(1).max(16),\n htu: z.string().url(),\n iat: z.number().int().nonnegative(),\n});\nexport type BrowserPostureProof = z.infer<typeof BrowserPostureProofSchema>;\n\n/**\n * Verifies a DPoP-shaped proof (RFC 9449) against an ALREADY-VERIFIED\n * `BrowserPosture` (call `verifyBrowserPosture` first). Checks, in order:\n * the proof's own header shape (`typ`, `alg`, embedded `jwk`); that the\n * embedded key's RFC 7638 thumbprint matches `posture.cnf.jkt`; the\n * proof's ES256 signature against that same embedded key; `htm`/`htu`\n * against the real request; `iat` freshness. Returns `undefined` on ANY\n * failure, including when `posture.cnf` is absent (no binding to check\n * against), never throws.\n *\n * Does NOT check `jti` replay: that needs a store this library does not\n * own. The caller checks the returned proof's `jti` against their own\n * replay store as the final step before trusting the request.\n */\nexport async function verifyBrowserPostureProof(\n proofJws: string | undefined,\n posture: BrowserPosture,\n request: { method: string; url: string },\n now = Math.floor(Date.now() / 1000),\n maxAgeSeconds = DEFAULT_POSTURE_PROOF_MAX_AGE_SECONDS\n): Promise<BrowserPostureProof | undefined> {\n if (!proofJws || proofJws.length > 2000 || !posture.cnf) return undefined;\n try {\n // `proofJws` is already a non-empty, length-bounded string (checked\n // above), so `split('.')[0]` always yields a string, never `undefined`\n // - no `?? ''` fallback to dead-code around.\n const decoded = JSON.parse(base64UrlToString(proofJws.split('.')[0])) as {\n typ?: string;\n alg?: string;\n jwk?: JWK;\n };\n if (\n decoded.typ !== POSTURE_PROOF_TYPE ||\n decoded.alg !== 'ES256' ||\n !decoded.jwk ||\n decoded.jwk.kty !== 'EC' ||\n decoded.jwk.crv !== 'P-256' ||\n decoded.jwk.d\n )\n return undefined;\n const thumbprint = await calculateJwkThumbprint(decoded.jwk, 'sha256');\n if (thumbprint !== posture.cnf.jkt) return undefined;\n const key = await importJWK(decoded.jwk, 'ES256');\n const { payload } = await jwtVerify(proofJws, key, {\n algorithms: ['ES256'],\n typ: POSTURE_PROOF_TYPE,\n currentDate: new Date(now * 1000),\n });\n const parsed = BrowserPostureProofSchema.safeParse(payload);\n if (!parsed.success) return undefined;\n const claims = parsed.data;\n if (\n claims.htm.toUpperCase() !== request.method.toUpperCase() ||\n claims.htu !== request.url ||\n Math.abs(now - claims.iat) > maxAgeSeconds\n )\n return undefined;\n return claims;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;AAMA,MAAM,qBAAqB;AAC3B,MAAM,UAAU;;;;;;AAOhB,SAAS,eAAe,MAAsB;CAC5C,IAAI,MAAM,KAAK;CACf,OAAO,MAAM,KAAK,KAAK,WAAW,MAAM,CAAC,MAAM,SAAS,OAAO;CAC/D,OAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;;;;;;;;;AAUA,SAAgB,iBAAiB,MAA0B;CACzD,MAAM,WAAW,eAAe,IAAI;CACpC,IAAI,CAAC,mBAAmB,KAAK,QAAQ,KAAK,SAAS,SAAS,MAAM,GAChE,MAAM,IAAI,UAAU,oCAAoC;CAE1D,MAAM,SAAS,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG;CAC5D,MAAM,SAAS,KAAK,SAAS,IAAI,QAAQ,IAAK,OAAO,SAAS,KAAM,CAAC,CAAC;CACtE,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;CAC1C,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS,GAClD,MAAM,SAAS,OAAO,WAAW,KAAK;CAExC,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,iBAAiB,IAAI,CAAC;AACxD;;;;;;;;;;;;AChCA,MAAa,qBAAqB;;;;;AAKlC,MAAa,wCAAwC;AAErD,MAAa,4BAA4BA,OAAS;CAChD,KAAKC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC9B,KAAKA,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CAC7B,KAAKA,OAAS,CAAC,CAAC,IAAI;CACpB,KAAKC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;AACpC,CAAC;;;;;;;;;;;;;;;AAiBD,eAAsB,0BACpB,UACA,SACA,SACA,MAAM,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,GAClC,oBAC0C;CAC1C,IAAI,CAAC,YAAY,SAAS,SAAS,OAAQ,CAAC,QAAQ,KAAK,OAAO;CAChE,IAAI;EAIF,MAAM,UAAU,KAAK,MAAM,kBAAkB,SAAS,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;EAKpE,IACE,QAAQ,sBACR,QAAQ,QAAQ,WAChB,CAAC,QAAQ,OACT,QAAQ,IAAI,QAAQ,QACpB,QAAQ,IAAI,QAAQ,WACpB,QAAQ,IAAI,GAEZ,OAAO;EAET,IAAI,MADqB,uBAAuB,QAAQ,KAAK,QAAQ,MAClD,QAAQ,IAAI,KAAK,OAAO;EAC3C,MAAM,MAAM,MAAM,UAAU,QAAQ,KAAK,OAAO;EAChD,MAAM,EAAE,YAAY,MAAM,UAAU,UAAU,KAAK;GACjD,YAAY,CAAC,OAAO;GACpB,KAAK;GACL,6BAAa,IAAI,KAAK,MAAM,GAAI;EAClC,CAAC;EACD,MAAM,SAAS,0BAA0B,UAAU,OAAO;EAC1D,IAAI,CAAC,OAAO,SAAS,OAAO;EAC5B,MAAM,SAAS,OAAO;EACtB,IACE,OAAO,IAAI,YAAY,MAAM,QAAQ,OAAO,YAAY,KACxD,OAAO,QAAQ,QAAQ,OACvB,KAAK,IAAI,MAAM,OAAO,GAAG,IAAI,eAE7B,OAAO;EACT,OAAO;CACT,QAAQ;EACN;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as POSTURE_VERIFICATION_STATUSES, C as verifyBrowserPosture, D as BrowserPostureRejectionReason, E as BrowserPostureOutcomeSchema, F as POSTURE_TTL_SECONDS, I as postureCookieName, M as browserPostureReport, N as BrowserPosture, O as BrowserPostureReportIngestSchema, P as BrowserPostureSchema, S as validateBrowserPostureConfig, T as BrowserPostureOutcome, _ as postureRequiredScopes, a as POSTURE_SESSION_HEADER, b as readPostureCookie, c as PostureVerification, d as inspectBrowserPosture, f as postureFromCookies, g as postureRequestFromHeaders, h as postureOutcomeReport, i as POSTURE_ISSUER, j as PostureVerificationStatus, k as BrowserPostureReportSchema, l as UNSIGNED_BROWSER_AGENT, m as postureOutcomeFromRequest, n as JWK, o as POSTURE_TYPE, p as postureFromRequest, r as POSTURE_HEADER, s as PostureRequest, t as BrowserPostureConfig, u as behavioralConfidence, v as postureSessionBinding, w as BROWSER_POSTURE_REJECTION_REASONS, x as signBrowserPosture, y as postureUpgrade } from "./browser-posture-
|
|
1
|
+
import { A as POSTURE_VERIFICATION_STATUSES, C as verifyBrowserPosture, D as BrowserPostureRejectionReason, E as BrowserPostureOutcomeSchema, F as POSTURE_TTL_SECONDS, I as postureCookieName, M as browserPostureReport, N as BrowserPosture, O as BrowserPostureReportIngestSchema, P as BrowserPostureSchema, S as validateBrowserPostureConfig, T as BrowserPostureOutcome, _ as postureRequiredScopes, a as POSTURE_SESSION_HEADER, b as readPostureCookie, c as PostureVerification, d as inspectBrowserPosture, f as postureFromCookies, g as postureRequestFromHeaders, h as postureOutcomeReport, i as POSTURE_ISSUER, j as PostureVerificationStatus, k as BrowserPostureReportSchema, l as UNSIGNED_BROWSER_AGENT, m as postureOutcomeFromRequest, n as JWK, o as POSTURE_TYPE, p as postureFromRequest, r as POSTURE_HEADER, s as PostureRequest, t as BrowserPostureConfig, u as behavioralConfidence, v as postureSessionBinding, w as BROWSER_POSTURE_REJECTION_REASONS, x as signBrowserPosture, y as postureUpgrade } from "./browser-posture-BLhw-MON.mjs";
|
|
2
2
|
export { BROWSER_POSTURE_REJECTION_REASONS, type BrowserPosture, BrowserPostureConfig, type BrowserPostureOutcome, BrowserPostureOutcomeSchema, type BrowserPostureRejectionReason, BrowserPostureReportIngestSchema, BrowserPostureReportSchema, BrowserPostureSchema, type JWK, POSTURE_HEADER, POSTURE_ISSUER, POSTURE_SESSION_HEADER, POSTURE_TTL_SECONDS, POSTURE_TYPE, POSTURE_VERIFICATION_STATUSES, PostureRequest, PostureVerification, type PostureVerificationStatus, UNSIGNED_BROWSER_AGENT, behavioralConfidence, browserPostureReport, inspectBrowserPosture, postureCookieName, postureFromCookies, postureFromRequest, postureOutcomeFromRequest, postureOutcomeReport, postureRequestFromHeaders, postureRequiredScopes, postureSessionBinding, postureUpgrade, readPostureCookie, signBrowserPosture, validateBrowserPostureConfig, verifyBrowserPosture };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as POSTURE_VERIFICATION_STATUSES, C as verifyBrowserPosture, D as BrowserPostureRejectionReason, E as BrowserPostureOutcomeSchema, F as POSTURE_TTL_SECONDS, I as postureCookieName, M as browserPostureReport, N as BrowserPosture, O as BrowserPostureReportIngestSchema, P as BrowserPostureSchema, S as validateBrowserPostureConfig, T as BrowserPostureOutcome, _ as postureRequiredScopes, a as POSTURE_SESSION_HEADER, b as readPostureCookie, c as PostureVerification, d as inspectBrowserPosture, f as postureFromCookies, g as postureRequestFromHeaders, h as postureOutcomeReport, i as POSTURE_ISSUER, j as PostureVerificationStatus, k as BrowserPostureReportSchema, l as UNSIGNED_BROWSER_AGENT, m as postureOutcomeFromRequest, n as JWK, o as POSTURE_TYPE, p as postureFromRequest, r as POSTURE_HEADER, s as PostureRequest, t as BrowserPostureConfig, u as behavioralConfidence, v as postureSessionBinding, w as BROWSER_POSTURE_REJECTION_REASONS, x as signBrowserPosture, y as postureUpgrade } from "./browser-posture-
|
|
1
|
+
import { A as POSTURE_VERIFICATION_STATUSES, C as verifyBrowserPosture, D as BrowserPostureRejectionReason, E as BrowserPostureOutcomeSchema, F as POSTURE_TTL_SECONDS, I as postureCookieName, M as browserPostureReport, N as BrowserPosture, O as BrowserPostureReportIngestSchema, P as BrowserPostureSchema, S as validateBrowserPostureConfig, T as BrowserPostureOutcome, _ as postureRequiredScopes, a as POSTURE_SESSION_HEADER, b as readPostureCookie, c as PostureVerification, d as inspectBrowserPosture, f as postureFromCookies, g as postureRequestFromHeaders, h as postureOutcomeReport, i as POSTURE_ISSUER, j as PostureVerificationStatus, k as BrowserPostureReportSchema, l as UNSIGNED_BROWSER_AGENT, m as postureOutcomeFromRequest, n as JWK, o as POSTURE_TYPE, p as postureFromRequest, r as POSTURE_HEADER, s as PostureRequest, t as BrowserPostureConfig, u as behavioralConfidence, v as postureSessionBinding, w as BROWSER_POSTURE_REJECTION_REASONS, x as signBrowserPosture, y as postureUpgrade } from "./browser-posture-B8YiPa5c.js";
|
|
2
2
|
export { BROWSER_POSTURE_REJECTION_REASONS, type BrowserPosture, BrowserPostureConfig, type BrowserPostureOutcome, BrowserPostureOutcomeSchema, type BrowserPostureRejectionReason, BrowserPostureReportIngestSchema, BrowserPostureReportSchema, BrowserPostureSchema, type JWK, POSTURE_HEADER, POSTURE_ISSUER, POSTURE_SESSION_HEADER, POSTURE_TTL_SECONDS, POSTURE_TYPE, POSTURE_VERIFICATION_STATUSES, PostureRequest, PostureVerification, type PostureVerificationStatus, UNSIGNED_BROWSER_AGENT, behavioralConfidence, browserPostureReport, inspectBrowserPosture, postureCookieName, postureFromCookies, postureFromRequest, postureOutcomeFromRequest, postureOutcomeReport, postureRequestFromHeaders, postureRequiredScopes, postureSessionBinding, postureUpgrade, readPostureCookie, signBrowserPosture, validateBrowserPostureConfig, verifyBrowserPosture };
|
package/dist/browser-posture.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_schemas = require('./schemas-
|
|
3
|
-
const require_posture_origins = require('./posture-origins-
|
|
4
|
-
const require_project_verification_key = require('./project-verification-key-
|
|
2
|
+
const require_schemas = require('./schemas-YhagYDx_.js');
|
|
3
|
+
const require_posture_origins = require('./posture-origins-CdVOdiMT.js');
|
|
4
|
+
const require_project_verification_key = require('./project-verification-key-BccT12tQ.js');
|
|
5
5
|
let jose = require("jose");
|
|
6
6
|
|
|
7
7
|
//#region src/browser-posture-cookie.ts
|
package/dist/browser-posture.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { d as
|
|
3
|
-
import { t as projectVerificationKey } from "./project-verification-key-
|
|
1
|
+
import { C as string, T as unknown, c as array, g as literal, i as _enum, l as boolean, p as guid, v as number, x as record, y as object } from "./schemas-7qodsG-Z.mjs";
|
|
2
|
+
import { d as UUID_PATTERN, f as VALIDATION_PATTERNS, n as matchAllowedOrigin, r as parseOriginPattern } from "./posture-origins-Ba83O0cD.mjs";
|
|
3
|
+
import { t as projectVerificationKey } from "./project-verification-key-66N4edKn.mjs";
|
|
4
4
|
import { SignJWT, compactVerify, decodeProtectedHeader, importJWK } from "jose";
|
|
5
5
|
|
|
6
6
|
//#region src/browser-posture-cookie.ts
|