@kya-os/checkpoint-shared 1.3.0 → 1.3.1
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 +19 -0
- package/dist/beacon-types/index.d.mts +3 -1
- package/dist/beacon-types/index.d.ts +3 -1
- package/dist/beacon-types/index.js +15 -2
- package/dist/beacon-types/index.mjs +15 -2
- package/dist/browser-posture-report.d.mts +85 -0
- package/dist/browser-posture-report.d.ts +85 -0
- package/dist/browser-posture-report.js +1 -0
- package/dist/browser-posture-report.mjs +1 -0
- package/dist/browser-posture.d.mts +114 -0
- package/dist/browser-posture.d.ts +114 -0
- package/dist/browser-posture.js +4204 -0
- package/dist/browser-posture.mjs +4187 -0
- package/dist/browser.d.mts +30 -1
- package/dist/browser.d.ts +30 -1
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/errors/index.d.mts +104 -0
- package/dist/errors/index.d.ts +104 -0
- package/dist/errors/index.js +338 -0
- package/dist/errors/index.mjs +333 -0
- package/dist/gateway/index.d.mts +6 -1
- package/dist/gateway/index.d.ts +6 -1
- package/dist/gateway/index.js +4 -0
- package/dist/gateway/index.mjs +4 -1
- package/dist/index.d.mts +769 -146
- package/dist/index.d.ts +769 -146
- package/dist/index.js +926 -282
- package/dist/index.mjs +903 -283
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/index.js +95 -2
- package/dist/signals/index.mjs +95 -2
- package/fixtures/client-ip-resolution.json +103 -0
- package/fixtures/detection/reason-codes.json +35 -0
- package/fixtures/detection/signal-exposure-example.json +62 -0
- package/fixtures/kya-http/README.md +112 -0
- package/fixtures/kya-http/challenge-proof.canonical.json +25 -0
- package/fixtures/kya-http/challenge.approval-quorum.json +37 -0
- package/fixtures/kya-http/challenge.delegation.fetcher-200.json +55 -0
- package/fixtures/kya-http/challenge.delegation.full.json +81 -0
- package/fixtures/kya-http/challenge.delegation.minimal.json +57 -0
- package/fixtures/kya-http/error-codes.json +35 -0
- package/fixtures/kya-http/fetcher-200-predicate.vectors.json +72 -0
- package/fixtures/kya-http/negative.challenges.json +54 -0
- package/fixtures/kya-http/pickup.transcript.json +96 -0
- package/fixtures/kya-http/pickup.transcript.quorum.json +156 -0
- package/fixtures/kya-http/protected-resource-metadata.full.json +30 -0
- package/fixtures/kya-http/protected-resource-metadata.global.json +28 -0
- package/fixtures/kya-http/registration.request.json +33 -0
- package/fixtures/kya-http/registration.response.json +32 -0
- package/package.json +20 -2
package/dist/index.js
CHANGED
|
@@ -1550,9 +1550,9 @@ var ParseInputLazyPath = class {
|
|
|
1550
1550
|
return this._cachedPath;
|
|
1551
1551
|
}
|
|
1552
1552
|
};
|
|
1553
|
-
var handleResult = (ctx,
|
|
1554
|
-
if (isValid(
|
|
1555
|
-
return { success: true, data:
|
|
1553
|
+
var handleResult = (ctx, result2) => {
|
|
1554
|
+
if (isValid(result2)) {
|
|
1555
|
+
return { success: true, data: result2.value };
|
|
1556
1556
|
} else {
|
|
1557
1557
|
if (!ctx.common.issues.length) {
|
|
1558
1558
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -1623,21 +1623,21 @@ var ZodType = class {
|
|
|
1623
1623
|
};
|
|
1624
1624
|
}
|
|
1625
1625
|
_parseSync(input) {
|
|
1626
|
-
const
|
|
1627
|
-
if (isAsync(
|
|
1626
|
+
const result2 = this._parse(input);
|
|
1627
|
+
if (isAsync(result2)) {
|
|
1628
1628
|
throw new Error("Synchronous parse encountered promise.");
|
|
1629
1629
|
}
|
|
1630
|
-
return
|
|
1630
|
+
return result2;
|
|
1631
1631
|
}
|
|
1632
1632
|
_parseAsync(input) {
|
|
1633
|
-
const
|
|
1634
|
-
return Promise.resolve(
|
|
1633
|
+
const result2 = this._parse(input);
|
|
1634
|
+
return Promise.resolve(result2);
|
|
1635
1635
|
}
|
|
1636
1636
|
parse(data, params) {
|
|
1637
|
-
const
|
|
1638
|
-
if (
|
|
1639
|
-
return
|
|
1640
|
-
throw
|
|
1637
|
+
const result2 = this.safeParse(data, params);
|
|
1638
|
+
if (result2.success)
|
|
1639
|
+
return result2.data;
|
|
1640
|
+
throw result2.error;
|
|
1641
1641
|
}
|
|
1642
1642
|
safeParse(data, params) {
|
|
1643
1643
|
const ctx = {
|
|
@@ -1652,8 +1652,8 @@ var ZodType = class {
|
|
|
1652
1652
|
data,
|
|
1653
1653
|
parsedType: getParsedType(data)
|
|
1654
1654
|
};
|
|
1655
|
-
const
|
|
1656
|
-
return handleResult(ctx,
|
|
1655
|
+
const result2 = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
1656
|
+
return handleResult(ctx, result2);
|
|
1657
1657
|
}
|
|
1658
1658
|
"~validate"(data) {
|
|
1659
1659
|
const ctx = {
|
|
@@ -1669,9 +1669,9 @@ var ZodType = class {
|
|
|
1669
1669
|
};
|
|
1670
1670
|
if (!this["~standard"].async) {
|
|
1671
1671
|
try {
|
|
1672
|
-
const
|
|
1673
|
-
return isValid(
|
|
1674
|
-
value:
|
|
1672
|
+
const result2 = this._parseSync({ data, path: [], parent: ctx });
|
|
1673
|
+
return isValid(result2) ? {
|
|
1674
|
+
value: result2.value
|
|
1675
1675
|
} : {
|
|
1676
1676
|
issues: ctx.common.issues
|
|
1677
1677
|
};
|
|
@@ -1685,17 +1685,17 @@ var ZodType = class {
|
|
|
1685
1685
|
};
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
|
-
return this._parseAsync({ data, path: [], parent: ctx }).then((
|
|
1689
|
-
value:
|
|
1688
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result2) => isValid(result2) ? {
|
|
1689
|
+
value: result2.value
|
|
1690
1690
|
} : {
|
|
1691
1691
|
issues: ctx.common.issues
|
|
1692
1692
|
});
|
|
1693
1693
|
}
|
|
1694
1694
|
async parseAsync(data, params) {
|
|
1695
|
-
const
|
|
1696
|
-
if (
|
|
1697
|
-
return
|
|
1698
|
-
throw
|
|
1695
|
+
const result2 = await this.safeParseAsync(data, params);
|
|
1696
|
+
if (result2.success)
|
|
1697
|
+
return result2.data;
|
|
1698
|
+
throw result2.error;
|
|
1699
1699
|
}
|
|
1700
1700
|
async safeParseAsync(data, params) {
|
|
1701
1701
|
const ctx = {
|
|
@@ -1711,8 +1711,8 @@ var ZodType = class {
|
|
|
1711
1711
|
parsedType: getParsedType(data)
|
|
1712
1712
|
};
|
|
1713
1713
|
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
1714
|
-
const
|
|
1715
|
-
return handleResult(ctx,
|
|
1714
|
+
const result2 = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
1715
|
+
return handleResult(ctx, result2);
|
|
1716
1716
|
}
|
|
1717
1717
|
refine(check, message) {
|
|
1718
1718
|
const getIssueProperties = (val) => {
|
|
@@ -1725,13 +1725,13 @@ var ZodType = class {
|
|
|
1725
1725
|
}
|
|
1726
1726
|
};
|
|
1727
1727
|
return this._refinement((val, ctx) => {
|
|
1728
|
-
const
|
|
1728
|
+
const result2 = check(val);
|
|
1729
1729
|
const setError = () => ctx.addIssue({
|
|
1730
1730
|
code: ZodIssueCode.custom,
|
|
1731
1731
|
...getIssueProperties(val)
|
|
1732
1732
|
});
|
|
1733
|
-
if (typeof Promise !== "undefined" &&
|
|
1734
|
-
return
|
|
1733
|
+
if (typeof Promise !== "undefined" && result2 instanceof Promise) {
|
|
1734
|
+
return result2.then((data) => {
|
|
1735
1735
|
if (!data) {
|
|
1736
1736
|
setError();
|
|
1737
1737
|
return false;
|
|
@@ -1740,7 +1740,7 @@ var ZodType = class {
|
|
|
1740
1740
|
}
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
|
-
if (!
|
|
1743
|
+
if (!result2) {
|
|
1744
1744
|
setError();
|
|
1745
1745
|
return false;
|
|
1746
1746
|
} else {
|
|
@@ -3235,14 +3235,14 @@ var ZodArray = class _ZodArray extends ZodType {
|
|
|
3235
3235
|
if (ctx.common.async) {
|
|
3236
3236
|
return Promise.all([...ctx.data].map((item, i) => {
|
|
3237
3237
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
3238
|
-
})).then((
|
|
3239
|
-
return ParseStatus.mergeArray(status,
|
|
3238
|
+
})).then((result3) => {
|
|
3239
|
+
return ParseStatus.mergeArray(status, result3);
|
|
3240
3240
|
});
|
|
3241
3241
|
}
|
|
3242
|
-
const
|
|
3242
|
+
const result2 = [...ctx.data].map((item, i) => {
|
|
3243
3243
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
3244
3244
|
});
|
|
3245
|
-
return ParseStatus.mergeArray(status,
|
|
3245
|
+
return ParseStatus.mergeArray(status, result2);
|
|
3246
3246
|
}
|
|
3247
3247
|
get element() {
|
|
3248
3248
|
return this._def.type;
|
|
@@ -3647,18 +3647,18 @@ var ZodUnion = class extends ZodType {
|
|
|
3647
3647
|
const { ctx } = this._processInputParams(input);
|
|
3648
3648
|
const options = this._def.options;
|
|
3649
3649
|
function handleResults(results) {
|
|
3650
|
-
for (const
|
|
3651
|
-
if (
|
|
3652
|
-
return
|
|
3650
|
+
for (const result2 of results) {
|
|
3651
|
+
if (result2.result.status === "valid") {
|
|
3652
|
+
return result2.result;
|
|
3653
3653
|
}
|
|
3654
3654
|
}
|
|
3655
|
-
for (const
|
|
3656
|
-
if (
|
|
3657
|
-
ctx.common.issues.push(...
|
|
3658
|
-
return
|
|
3655
|
+
for (const result2 of results) {
|
|
3656
|
+
if (result2.result.status === "dirty") {
|
|
3657
|
+
ctx.common.issues.push(...result2.ctx.common.issues);
|
|
3658
|
+
return result2.result;
|
|
3659
3659
|
}
|
|
3660
3660
|
}
|
|
3661
|
-
const unionErrors = results.map((
|
|
3661
|
+
const unionErrors = results.map((result2) => new ZodError(result2.ctx.common.issues));
|
|
3662
3662
|
addIssueToContext(ctx, {
|
|
3663
3663
|
code: ZodIssueCode.invalid_union,
|
|
3664
3664
|
unionErrors
|
|
@@ -3696,15 +3696,15 @@ var ZodUnion = class extends ZodType {
|
|
|
3696
3696
|
},
|
|
3697
3697
|
parent: null
|
|
3698
3698
|
};
|
|
3699
|
-
const
|
|
3699
|
+
const result2 = option._parseSync({
|
|
3700
3700
|
data: ctx.data,
|
|
3701
3701
|
path: ctx.path,
|
|
3702
3702
|
parent: childCtx
|
|
3703
3703
|
});
|
|
3704
|
-
if (
|
|
3705
|
-
return
|
|
3706
|
-
} else if (
|
|
3707
|
-
dirty = { result, ctx: childCtx };
|
|
3704
|
+
if (result2.status === "valid") {
|
|
3705
|
+
return result2;
|
|
3706
|
+
} else if (result2.status === "dirty" && !dirty) {
|
|
3707
|
+
dirty = { result: result2, ctx: childCtx };
|
|
3708
3708
|
}
|
|
3709
3709
|
if (childCtx.common.issues.length) {
|
|
3710
3710
|
issues.push(childCtx.common.issues);
|
|
@@ -4249,9 +4249,9 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
4249
4249
|
error.addIssue(makeArgsIssue(args, e));
|
|
4250
4250
|
throw error;
|
|
4251
4251
|
});
|
|
4252
|
-
const
|
|
4253
|
-
const parsedReturns = await me._def.returns._def.type.parseAsync(
|
|
4254
|
-
error.addIssue(makeReturnsIssue(
|
|
4252
|
+
const result2 = await Reflect.apply(fn, this, parsedArgs);
|
|
4253
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result2, params).catch((e) => {
|
|
4254
|
+
error.addIssue(makeReturnsIssue(result2, e));
|
|
4255
4255
|
throw error;
|
|
4256
4256
|
});
|
|
4257
4257
|
return parsedReturns;
|
|
@@ -4263,10 +4263,10 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
4263
4263
|
if (!parsedArgs.success) {
|
|
4264
4264
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
4265
4265
|
}
|
|
4266
|
-
const
|
|
4267
|
-
const parsedReturns = me._def.returns.safeParse(
|
|
4266
|
+
const result2 = Reflect.apply(fn, this, parsedArgs.data);
|
|
4267
|
+
const parsedReturns = me._def.returns.safeParse(result2, params);
|
|
4268
4268
|
if (!parsedReturns.success) {
|
|
4269
|
-
throw new ZodError([makeReturnsIssue(
|
|
4269
|
+
throw new ZodError([makeReturnsIssue(result2, parsedReturns.error)]);
|
|
4270
4270
|
}
|
|
4271
4271
|
return parsedReturns.data;
|
|
4272
4272
|
});
|
|
@@ -4518,43 +4518,43 @@ var ZodEffects = class extends ZodType {
|
|
|
4518
4518
|
return Promise.resolve(processed).then(async (processed2) => {
|
|
4519
4519
|
if (status.value === "aborted")
|
|
4520
4520
|
return INVALID;
|
|
4521
|
-
const
|
|
4521
|
+
const result2 = await this._def.schema._parseAsync({
|
|
4522
4522
|
data: processed2,
|
|
4523
4523
|
path: ctx.path,
|
|
4524
4524
|
parent: ctx
|
|
4525
4525
|
});
|
|
4526
|
-
if (
|
|
4526
|
+
if (result2.status === "aborted")
|
|
4527
4527
|
return INVALID;
|
|
4528
|
-
if (
|
|
4529
|
-
return DIRTY(
|
|
4528
|
+
if (result2.status === "dirty")
|
|
4529
|
+
return DIRTY(result2.value);
|
|
4530
4530
|
if (status.value === "dirty")
|
|
4531
|
-
return DIRTY(
|
|
4532
|
-
return
|
|
4531
|
+
return DIRTY(result2.value);
|
|
4532
|
+
return result2;
|
|
4533
4533
|
});
|
|
4534
4534
|
} else {
|
|
4535
4535
|
if (status.value === "aborted")
|
|
4536
4536
|
return INVALID;
|
|
4537
|
-
const
|
|
4537
|
+
const result2 = this._def.schema._parseSync({
|
|
4538
4538
|
data: processed,
|
|
4539
4539
|
path: ctx.path,
|
|
4540
4540
|
parent: ctx
|
|
4541
4541
|
});
|
|
4542
|
-
if (
|
|
4542
|
+
if (result2.status === "aborted")
|
|
4543
4543
|
return INVALID;
|
|
4544
|
-
if (
|
|
4545
|
-
return DIRTY(
|
|
4544
|
+
if (result2.status === "dirty")
|
|
4545
|
+
return DIRTY(result2.value);
|
|
4546
4546
|
if (status.value === "dirty")
|
|
4547
|
-
return DIRTY(
|
|
4548
|
-
return
|
|
4547
|
+
return DIRTY(result2.value);
|
|
4548
|
+
return result2;
|
|
4549
4549
|
}
|
|
4550
4550
|
}
|
|
4551
4551
|
if (effect.type === "refinement") {
|
|
4552
4552
|
const executeRefinement = (acc) => {
|
|
4553
|
-
const
|
|
4553
|
+
const result2 = effect.refinement(acc, checkCtx);
|
|
4554
4554
|
if (ctx.common.async) {
|
|
4555
|
-
return Promise.resolve(
|
|
4555
|
+
return Promise.resolve(result2);
|
|
4556
4556
|
}
|
|
4557
|
-
if (
|
|
4557
|
+
if (result2 instanceof Promise) {
|
|
4558
4558
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4559
4559
|
}
|
|
4560
4560
|
return acc;
|
|
@@ -4592,18 +4592,18 @@ var ZodEffects = class extends ZodType {
|
|
|
4592
4592
|
});
|
|
4593
4593
|
if (!isValid(base))
|
|
4594
4594
|
return INVALID;
|
|
4595
|
-
const
|
|
4596
|
-
if (
|
|
4595
|
+
const result2 = effect.transform(base.value, checkCtx);
|
|
4596
|
+
if (result2 instanceof Promise) {
|
|
4597
4597
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
4598
4598
|
}
|
|
4599
|
-
return { status: status.value, value:
|
|
4599
|
+
return { status: status.value, value: result2 };
|
|
4600
4600
|
} else {
|
|
4601
4601
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
4602
4602
|
if (!isValid(base))
|
|
4603
4603
|
return INVALID;
|
|
4604
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((
|
|
4604
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result2) => ({
|
|
4605
4605
|
status: status.value,
|
|
4606
|
-
value:
|
|
4606
|
+
value: result2
|
|
4607
4607
|
}));
|
|
4608
4608
|
});
|
|
4609
4609
|
}
|
|
@@ -4700,18 +4700,18 @@ var ZodCatch = class extends ZodType {
|
|
|
4700
4700
|
issues: []
|
|
4701
4701
|
}
|
|
4702
4702
|
};
|
|
4703
|
-
const
|
|
4703
|
+
const result2 = this._def.innerType._parse({
|
|
4704
4704
|
data: newCtx.data,
|
|
4705
4705
|
path: newCtx.path,
|
|
4706
4706
|
parent: {
|
|
4707
4707
|
...newCtx
|
|
4708
4708
|
}
|
|
4709
4709
|
});
|
|
4710
|
-
if (isAsync(
|
|
4711
|
-
return
|
|
4710
|
+
if (isAsync(result2)) {
|
|
4711
|
+
return result2.then((result3) => {
|
|
4712
4712
|
return {
|
|
4713
4713
|
status: "valid",
|
|
4714
|
-
value:
|
|
4714
|
+
value: result3.status === "valid" ? result3.value : this._def.catchValue({
|
|
4715
4715
|
get error() {
|
|
4716
4716
|
return new ZodError(newCtx.common.issues);
|
|
4717
4717
|
},
|
|
@@ -4722,7 +4722,7 @@ var ZodCatch = class extends ZodType {
|
|
|
4722
4722
|
} else {
|
|
4723
4723
|
return {
|
|
4724
4724
|
status: "valid",
|
|
4725
|
-
value:
|
|
4725
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
4726
4726
|
get error() {
|
|
4727
4727
|
return new ZodError(newCtx.common.issues);
|
|
4728
4728
|
},
|
|
@@ -4836,14 +4836,14 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
4836
4836
|
};
|
|
4837
4837
|
var ZodReadonly = class extends ZodType {
|
|
4838
4838
|
_parse(input) {
|
|
4839
|
-
const
|
|
4839
|
+
const result2 = this._def.innerType._parse(input);
|
|
4840
4840
|
const freeze = (data) => {
|
|
4841
4841
|
if (isValid(data)) {
|
|
4842
4842
|
data.value = Object.freeze(data.value);
|
|
4843
4843
|
}
|
|
4844
4844
|
return data;
|
|
4845
4845
|
};
|
|
4846
|
-
return isAsync(
|
|
4846
|
+
return isAsync(result2) ? result2.then((data) => freeze(data)) : freeze(result2);
|
|
4847
4847
|
}
|
|
4848
4848
|
unwrap() {
|
|
4849
4849
|
return this._def.innerType;
|
|
@@ -5010,7 +5010,7 @@ var DetectionInputSchema = external_exports.object({
|
|
|
5010
5010
|
ip: external_exports.string().optional(),
|
|
5011
5011
|
ipAddress: external_exports.string().optional(),
|
|
5012
5012
|
// Alias for ip
|
|
5013
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
5013
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
5014
5014
|
url: external_exports.string().optional(),
|
|
5015
5015
|
method: external_exports.string().optional(),
|
|
5016
5016
|
body: external_exports.unknown().optional(),
|
|
@@ -5019,19 +5019,25 @@ var DetectionInputSchema = external_exports.object({
|
|
|
5019
5019
|
var RequestContextSchema = external_exports.object({
|
|
5020
5020
|
userAgent: external_exports.string().optional(),
|
|
5021
5021
|
ipAddress: external_exports.string().optional(),
|
|
5022
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
5022
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
5023
5023
|
url: external_exports.string().optional(),
|
|
5024
5024
|
method: external_exports.string().optional(),
|
|
5025
5025
|
body: external_exports.unknown().optional(),
|
|
5026
5026
|
timestamp: external_exports.date().default(() => /* @__PURE__ */ new Date())
|
|
5027
5027
|
});
|
|
5028
5028
|
var DetectionSignalSchema = external_exports.object({
|
|
5029
|
-
signalType: external_exports.enum(["signature", "pattern", "behavioral", "network", "fingerprint"])
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5029
|
+
signalType: external_exports.enum(["signature", "pattern", "behavioral", "network", "fingerprint"]).describe(
|
|
5030
|
+
"Evidence plane this signal was observed on: cryptographic signature, User-Agent/header pattern, behavioral interaction, network/IP, or transport fingerprint."
|
|
5031
|
+
),
|
|
5032
|
+
confidence: external_exports.number().min(0).max(100).describe("This signal's own confidence contribution on the 0-100 scale."),
|
|
5033
|
+
weight: external_exports.number().min(0).max(1).describe("This signal's relative weight (0-1) in the combined verdict."),
|
|
5034
|
+
source: external_exports.string().describe(
|
|
5035
|
+
"Machine-readable evidence source (e.g. 'user_agent_pattern', 'vendor_ip_feed', 'transport.ja4', 'mcp_i'). New signal families (e.g. request-velocity, platform bot-management corroboration) appear as new source values: additive, never a breaking change."
|
|
5036
|
+
),
|
|
5037
|
+
explanation: external_exports.string().describe("Human-readable explanation of what this signal observed. Prose, not a contract."),
|
|
5038
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
5039
|
+
"Optional source-specific structured details (e.g. the matched pattern, the vendor feed name)."
|
|
5040
|
+
)
|
|
5035
5041
|
});
|
|
5036
5042
|
var ReasoningStepSchema = external_exports.object({
|
|
5037
5043
|
signalType: external_exports.string(),
|
|
@@ -5073,6 +5079,7 @@ var DetectionReasoningSchema = external_exports.object({
|
|
|
5073
5079
|
primaryFactors: external_exports.array(external_exports.string()),
|
|
5074
5080
|
supportingEvidence: external_exports.array(external_exports.string()),
|
|
5075
5081
|
confidenceBreakdown: external_exports.record(
|
|
5082
|
+
external_exports.string(),
|
|
5076
5083
|
external_exports.object({
|
|
5077
5084
|
confidence: external_exports.number().min(0).max(100),
|
|
5078
5085
|
weight: external_exports.number().min(0).max(1),
|
|
@@ -5089,7 +5096,7 @@ var EngineInfoSchema = external_exports.object({
|
|
|
5089
5096
|
rulesetHash: external_exports.string(),
|
|
5090
5097
|
rulesetVersion: external_exports.string(),
|
|
5091
5098
|
buildSha: external_exports.string().optional(),
|
|
5092
|
-
extras: external_exports.record(external_exports.unknown()).optional()
|
|
5099
|
+
extras: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
5093
5100
|
});
|
|
5094
5101
|
var DetectionDetailSchema = external_exports.object({
|
|
5095
5102
|
// Core fields
|
|
@@ -5167,7 +5174,7 @@ var DetectionDetailSchema = external_exports.object({
|
|
|
5167
5174
|
recommendations: external_exports.array(external_exports.string()).optional()
|
|
5168
5175
|
}).optional(),
|
|
5169
5176
|
// Metadata
|
|
5170
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
5177
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
5171
5178
|
timestamp: external_exports.union([external_exports.date(), external_exports.number()]).default(() => /* @__PURE__ */ new Date()),
|
|
5172
5179
|
requestId: external_exports.string().optional(),
|
|
5173
5180
|
/** Engine self-identification — see EngineInfoSchema. Optional for
|
|
@@ -5328,7 +5335,7 @@ var AgentPatternSchema = external_exports.object({
|
|
|
5328
5335
|
type: AgentTypeSchema,
|
|
5329
5336
|
name: external_exports.string(),
|
|
5330
5337
|
patterns: external_exports.array(external_exports.string()),
|
|
5331
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
5338
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
5332
5339
|
ipRanges: external_exports.array(external_exports.string()).optional(),
|
|
5333
5340
|
confidence: external_exports.number().min(0).max(1).default(0.8),
|
|
5334
5341
|
category: external_exports.enum([
|
|
@@ -5507,6 +5514,232 @@ function reconstructConfidenceFromEvidence(evidence) {
|
|
|
5507
5514
|
return (1 - probabilityAbsent) * 100;
|
|
5508
5515
|
}
|
|
5509
5516
|
|
|
5517
|
+
// src/core/detection-reason-codes.ts
|
|
5518
|
+
var DETECTION_REASON_CODES = {
|
|
5519
|
+
// ── Cryptographic / verified attribution (strongest evidence, first) ────
|
|
5520
|
+
/** `verificationMethod === 'kya-http'` — a kya-http/RFC 9421 signature verified. */
|
|
5521
|
+
SIGNATURE_VERIFIED: "detection/signature-verified",
|
|
5522
|
+
/** `verificationMethod === 'kya-http-delegated'` — a verified delegation credential rode the request. */
|
|
5523
|
+
DELEGATION_VERIFIED: "detection/delegation-verified",
|
|
5524
|
+
/** `verificationMethod === 'mcp-i' | 'kya-os'` (the wire values; `isKyaOsWireMethod`) — the MCP-I/KYA-OS handshake verified. */
|
|
5525
|
+
MCP_I_VERIFIED: "detection/mcp-i-verified",
|
|
5526
|
+
/** `verificationMethod === 'did'` — the worker's DID-header scheme verified an Ed25519 signature against the agent's DID Document. */
|
|
5527
|
+
DID_SIGNATURE_VERIFIED: "detection/did-signature-verified",
|
|
5528
|
+
/** `verificationMethod === 'signature'` — the worker's RFC 9421 signature verifier (ChatGPT et al.) verified against the DB-refreshed key directory. */
|
|
5529
|
+
RFC9421_SIGNATURE_VERIFIED: "detection/rfc9421-signature-verified",
|
|
5530
|
+
/** `verificationMethod` starts with `tier1_` (e.g. `tier1_rfc9421`) — the engine's Tier-1 protocol attribution verified. */
|
|
5531
|
+
TIER1_ATTRIBUTION_VERIFIED: "detection/tier1-attribution-verified",
|
|
5532
|
+
/** `verificationMethod === 'error'` — a presented credential was demoted/rejected during verification; see the sibling `kyaErrorCode`. */
|
|
5533
|
+
VERIFICATION_ERROR: "detection/verification-error",
|
|
5534
|
+
// ── Structured evidence signals (one per distinct `signals[].source`) ───
|
|
5535
|
+
/** A `signals[]` entry with `source === 'user_agent_pattern'` — the User-Agent matched a known pattern. */
|
|
5536
|
+
UA_PATTERN_MATCH: "detection/ua-pattern-match",
|
|
5537
|
+
/** `source === 'header_heuristic'` — a header shape/combination heuristic matched. */
|
|
5538
|
+
HEADER_HEURISTIC: "detection/header-heuristic",
|
|
5539
|
+
/** `source === 'ip_heuristic'` — an IP-based heuristic matched. */
|
|
5540
|
+
IP_HEURISTIC: "detection/ip-heuristic",
|
|
5541
|
+
/** `source === 'vendor_ip_feed'` — the request IP matched a known vendor's published IP range. */
|
|
5542
|
+
VENDOR_IP_CORROBORATED: "detection/vendor-ip-corroborated",
|
|
5543
|
+
/** `source === 'transport.ja4'` — the TLS JA4 fingerprint matched a known client library. */
|
|
5544
|
+
JA4_FINGERPRINT_MATCH: "detection/ja4-fingerprint-match",
|
|
5545
|
+
/** `source === 'client.attributes'` — a pixel/beacon-reported client attribute contributed. */
|
|
5546
|
+
CLIENT_ATTRIBUTE_SIGNAL: "detection/client-attribute-signal",
|
|
5547
|
+
/** `source === 'behavioural.interaction'` — a behavioral/interaction signal contributed. */
|
|
5548
|
+
BEHAVIORAL_SIGNAL: "detection/behavioral-signal",
|
|
5549
|
+
/** `source === 'mcp_i'` — an MCP-I header was present (evidence short of a completed handshake). */
|
|
5550
|
+
MCP_I_SIGNAL: "detection/mcp-i-signal",
|
|
5551
|
+
/** `source === 'kya_http_binding'` — a kya-http binding was presented (evidence short of full verification). */
|
|
5552
|
+
KYA_HTTP_BINDING_SIGNAL: "detection/kya-http-binding-signal",
|
|
5553
|
+
/** `source === 'kya_delegation_bearer'` — a delegation bearer credential was presented. */
|
|
5554
|
+
KYA_DELEGATION_BEARER_SIGNAL: "detection/kya-delegation-bearer-signal",
|
|
5555
|
+
/** A `signals[]` entry whose `source` starts with `tier1_` — raw Tier-1 protocol evidence, short of (or alongside) full verification. */
|
|
5556
|
+
TIER1_ATTRIBUTION_SIGNAL: "detection/tier1-attribution-signal",
|
|
5557
|
+
// ── Classification flags ─────────────────────────────────────────────────
|
|
5558
|
+
/** `isAiCrawler === true` — classified as an AI training crawler (GPTBot, ClaudeBot, etc.), not an interactive agent. */
|
|
5559
|
+
AI_CRAWLER_FLAG: "detection/ai-crawler-flag",
|
|
5560
|
+
// ── Zero-evidence fallbacks — an assumed verdict deserves a code saying so
|
|
5561
|
+
// (in the spirit of #4800): these fire ONLY when nothing above matched,
|
|
5562
|
+
// so the mapping never returns an empty list. ───────────────────────────
|
|
5563
|
+
/** `detectionClass === 'human'` with no contributing signals and no verification — the baseline "nothing matched" human path. */
|
|
5564
|
+
ZERO_EVIDENCE_HUMAN: "detection/zero-evidence-human",
|
|
5565
|
+
/** `detectionClass === 'incomplete_data' | 'unknown'` (or absent) — the engine could not classify confidently. */
|
|
5566
|
+
INCOMPLETE_DATA_OVERRIDE: "detection/incomplete-data-override",
|
|
5567
|
+
/** A non-human, non-incomplete-data class (`ai_agent` / `bot` / `automation`) reached with zero contributing signals and no verification — classified on prior/heuristic grounds alone. */
|
|
5568
|
+
CLASSIFIED_WITHOUT_SIGNAL_EVIDENCE: "detection/classified-without-signal-evidence"
|
|
5569
|
+
};
|
|
5570
|
+
|
|
5571
|
+
// src/utils/verification.ts
|
|
5572
|
+
var KYA_OS_HANDSHAKE_METHODS = {
|
|
5573
|
+
/** New canonical engine value. Not emitted yet — accepted on read. */
|
|
5574
|
+
CANONICAL: "kyaos_handshake",
|
|
5575
|
+
/** @deprecated Legacy engine value. Still emitted by the Rust engine. */
|
|
5576
|
+
LEGACY: "mcp_i_handshake"
|
|
5577
|
+
};
|
|
5578
|
+
var KYA_OS_WIRE_METHODS = {
|
|
5579
|
+
/** New canonical wire value. Not emitted yet — accepted on read. */
|
|
5580
|
+
CANONICAL: "kya-os",
|
|
5581
|
+
/** @deprecated Legacy wire value. Still emitted by the gateway worker. */
|
|
5582
|
+
LEGACY: "mcp-i"
|
|
5583
|
+
};
|
|
5584
|
+
function isKyaOsHandshakeMethod(value) {
|
|
5585
|
+
return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;
|
|
5586
|
+
}
|
|
5587
|
+
function isKyaOsWireMethod(value) {
|
|
5588
|
+
return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;
|
|
5589
|
+
}
|
|
5590
|
+
function normalizeHandshakeMethod(value) {
|
|
5591
|
+
return isKyaOsHandshakeMethod(value) ? KYA_OS_HANDSHAKE_METHODS.CANONICAL : value;
|
|
5592
|
+
}
|
|
5593
|
+
function normalizeWireMethod(value) {
|
|
5594
|
+
return isKyaOsWireMethod(value) ? KYA_OS_WIRE_METHODS.CANONICAL : value;
|
|
5595
|
+
}
|
|
5596
|
+
function getVerificationMethodDescription(method) {
|
|
5597
|
+
switch (normalizeHandshakeMethod(method)) {
|
|
5598
|
+
case "signature":
|
|
5599
|
+
return "HTTP Signature Verification";
|
|
5600
|
+
case "pattern":
|
|
5601
|
+
return "User-Agent Pattern Matching";
|
|
5602
|
+
case "behavioral":
|
|
5603
|
+
return "Behavioral Analysis";
|
|
5604
|
+
case "network":
|
|
5605
|
+
return "Network-based Detection";
|
|
5606
|
+
case KYA_OS_HANDSHAKE_METHODS.CANONICAL:
|
|
5607
|
+
return "MCP Handshake Detection";
|
|
5608
|
+
case "error":
|
|
5609
|
+
return "Detection Error";
|
|
5610
|
+
case "none":
|
|
5611
|
+
default:
|
|
5612
|
+
return "No Verification";
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
function getVerificationReliability(method) {
|
|
5616
|
+
switch (normalizeHandshakeMethod(method)) {
|
|
5617
|
+
case "signature":
|
|
5618
|
+
return 1;
|
|
5619
|
+
// Highest reliability
|
|
5620
|
+
case KYA_OS_HANDSHAKE_METHODS.CANONICAL:
|
|
5621
|
+
return 0.95;
|
|
5622
|
+
case "behavioral":
|
|
5623
|
+
return 0.8;
|
|
5624
|
+
case "network":
|
|
5625
|
+
return 0.6;
|
|
5626
|
+
case "pattern":
|
|
5627
|
+
return 0.5;
|
|
5628
|
+
case "none":
|
|
5629
|
+
return 0.3;
|
|
5630
|
+
case "error":
|
|
5631
|
+
default:
|
|
5632
|
+
return 0.1;
|
|
5633
|
+
}
|
|
5634
|
+
}
|
|
5635
|
+
function isHighConfidenceVerification(method) {
|
|
5636
|
+
return method === "signature" || isKyaOsHandshakeMethod(method);
|
|
5637
|
+
}
|
|
5638
|
+
function getVerificationRiskLevel(method, confidence) {
|
|
5639
|
+
if (method === "signature") {
|
|
5640
|
+
return "low";
|
|
5641
|
+
}
|
|
5642
|
+
if (isKyaOsHandshakeMethod(method)) {
|
|
5643
|
+
return "low";
|
|
5644
|
+
}
|
|
5645
|
+
if (confidence >= 0.9) {
|
|
5646
|
+
return method === "behavioral" ? "medium" : "high";
|
|
5647
|
+
}
|
|
5648
|
+
if (confidence >= 0.7) {
|
|
5649
|
+
return "medium";
|
|
5650
|
+
}
|
|
5651
|
+
return "high";
|
|
5652
|
+
}
|
|
5653
|
+
|
|
5654
|
+
// src/core/detection-reason-mapping.ts
|
|
5655
|
+
var VERIFICATION_METHOD_CODES = {
|
|
5656
|
+
"kya-http-delegated": DETECTION_REASON_CODES.DELEGATION_VERIFIED,
|
|
5657
|
+
"kya-http": DETECTION_REASON_CODES.SIGNATURE_VERIFIED,
|
|
5658
|
+
did: DETECTION_REASON_CODES.DID_SIGNATURE_VERIFIED,
|
|
5659
|
+
signature: DETECTION_REASON_CODES.RFC9421_SIGNATURE_VERIFIED,
|
|
5660
|
+
error: DETECTION_REASON_CODES.VERIFICATION_ERROR
|
|
5661
|
+
};
|
|
5662
|
+
var SIGNAL_SOURCE_CODES = {
|
|
5663
|
+
mcp_i: DETECTION_REASON_CODES.MCP_I_SIGNAL,
|
|
5664
|
+
kya_http_binding: DETECTION_REASON_CODES.KYA_HTTP_BINDING_SIGNAL,
|
|
5665
|
+
kya_delegation_bearer: DETECTION_REASON_CODES.KYA_DELEGATION_BEARER_SIGNAL,
|
|
5666
|
+
user_agent_pattern: DETECTION_REASON_CODES.UA_PATTERN_MATCH,
|
|
5667
|
+
header_heuristic: DETECTION_REASON_CODES.HEADER_HEURISTIC,
|
|
5668
|
+
ip_heuristic: DETECTION_REASON_CODES.IP_HEURISTIC,
|
|
5669
|
+
vendor_ip_feed: DETECTION_REASON_CODES.VENDOR_IP_CORROBORATED,
|
|
5670
|
+
"transport.ja4": DETECTION_REASON_CODES.JA4_FINGERPRINT_MATCH,
|
|
5671
|
+
"client.attributes": DETECTION_REASON_CODES.CLIENT_ATTRIBUTE_SIGNAL,
|
|
5672
|
+
"behavioural.interaction": DETECTION_REASON_CODES.BEHAVIORAL_SIGNAL
|
|
5673
|
+
};
|
|
5674
|
+
function mapDetectionToReasonCodes(detail) {
|
|
5675
|
+
const codes = [];
|
|
5676
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5677
|
+
const push = (code) => {
|
|
5678
|
+
if (code && !seen.has(code)) {
|
|
5679
|
+
seen.add(code);
|
|
5680
|
+
codes.push(code);
|
|
5681
|
+
}
|
|
5682
|
+
};
|
|
5683
|
+
const verificationMethod = detail.verificationMethod;
|
|
5684
|
+
if (verificationMethod) {
|
|
5685
|
+
if (verificationMethod.startsWith("tier1_")) {
|
|
5686
|
+
push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_VERIFIED);
|
|
5687
|
+
} else if (
|
|
5688
|
+
// Dual-accept BOTH value spaces for the KYA-OS handshake: the gateway
|
|
5689
|
+
// worker normalizes to the WIRE values (`mcp-i`/`kya-os`) before
|
|
5690
|
+
// calling in, while the enforce route's engine-refined detail carries
|
|
5691
|
+
// the ENGINE values (`mcp_i_handshake`/`kyaos_handshake`). Routing
|
|
5692
|
+
// both through the shared predicates keeps the alias pairs in exactly
|
|
5693
|
+
// one place and closes the exact single-value-space gap Bugbot
|
|
5694
|
+
// caught on PR #4874.
|
|
5695
|
+
isKyaOsWireMethod(verificationMethod) || isKyaOsHandshakeMethod(verificationMethod)
|
|
5696
|
+
) {
|
|
5697
|
+
push(DETECTION_REASON_CODES.MCP_I_VERIFIED);
|
|
5698
|
+
} else {
|
|
5699
|
+
push(VERIFICATION_METHOD_CODES[verificationMethod]);
|
|
5700
|
+
}
|
|
5701
|
+
}
|
|
5702
|
+
const presentSources = /* @__PURE__ */ new Set();
|
|
5703
|
+
let hasTier1Signal = false;
|
|
5704
|
+
for (const signal of detail.signals ?? []) {
|
|
5705
|
+
presentSources.add(signal.source);
|
|
5706
|
+
if (signal.source.startsWith("tier1_")) hasTier1Signal = true;
|
|
5707
|
+
}
|
|
5708
|
+
for (const source of Object.keys(SIGNAL_SOURCE_CODES)) {
|
|
5709
|
+
if (presentSources.has(source)) push(SIGNAL_SOURCE_CODES[source]);
|
|
5710
|
+
}
|
|
5711
|
+
if (hasTier1Signal) {
|
|
5712
|
+
push(DETECTION_REASON_CODES.TIER1_ATTRIBUTION_SIGNAL);
|
|
5713
|
+
}
|
|
5714
|
+
if (detail.isAiCrawler) {
|
|
5715
|
+
push(DETECTION_REASON_CODES.AI_CRAWLER_FLAG);
|
|
5716
|
+
}
|
|
5717
|
+
if (codes.length === 0) {
|
|
5718
|
+
if (detail.detectionClass === "human") {
|
|
5719
|
+
push(DETECTION_REASON_CODES.ZERO_EVIDENCE_HUMAN);
|
|
5720
|
+
} else if (detail.detectionClass === "incomplete_data" || detail.detectionClass === "unknown" || !detail.detectionClass) {
|
|
5721
|
+
push(DETECTION_REASON_CODES.INCOMPLETE_DATA_OVERRIDE);
|
|
5722
|
+
} else {
|
|
5723
|
+
push(DETECTION_REASON_CODES.CLASSIFIED_WITHOUT_SIGNAL_EVIDENCE);
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5726
|
+
return codes;
|
|
5727
|
+
}
|
|
5728
|
+
var MAX_REASON_CODES_ON_WIRE = 5;
|
|
5729
|
+
var MAX_REASON_CODES_HEADER_BYTES = 256;
|
|
5730
|
+
var HEADER_BYTES_ENCODER = new TextEncoder();
|
|
5731
|
+
function formatReasonCodesHeader(codes) {
|
|
5732
|
+
const capped = codes.slice(0, MAX_REASON_CODES_ON_WIRE);
|
|
5733
|
+
while (capped.length > 0) {
|
|
5734
|
+
const joined = capped.join(",");
|
|
5735
|
+
if (HEADER_BYTES_ENCODER.encode(joined).byteLength <= MAX_REASON_CODES_HEADER_BYTES) {
|
|
5736
|
+
return joined;
|
|
5737
|
+
}
|
|
5738
|
+
capped.pop();
|
|
5739
|
+
}
|
|
5740
|
+
return "";
|
|
5741
|
+
}
|
|
5742
|
+
|
|
5510
5743
|
// src/config/shield.ts
|
|
5511
5744
|
var CacheConfigSchema = external_exports.object({
|
|
5512
5745
|
enabled: external_exports.boolean().default(true),
|
|
@@ -5559,7 +5792,7 @@ var AgentShieldConfigSchema = external_exports.object({
|
|
|
5559
5792
|
wasm: WasmConfigSchema.optional(),
|
|
5560
5793
|
// Custom rules and patterns
|
|
5561
5794
|
customRules: external_exports.array(external_exports.string()).optional(),
|
|
5562
|
-
customPatterns: external_exports.record(external_exports.string()).optional(),
|
|
5795
|
+
customPatterns: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
5563
5796
|
// Allowlists and blocklists
|
|
5564
5797
|
allowedAgents: external_exports.array(external_exports.string()).optional(),
|
|
5565
5798
|
blockedAgents: external_exports.array(external_exports.string()).optional(),
|
|
@@ -5596,7 +5829,7 @@ var ResponseActionSchema = external_exports.object({
|
|
|
5596
5829
|
statusCode: external_exports.number().default(403),
|
|
5597
5830
|
message: external_exports.string().default("Access denied"),
|
|
5598
5831
|
redirect: external_exports.string().optional(),
|
|
5599
|
-
addHeaders: external_exports.record(external_exports.string()).optional(),
|
|
5832
|
+
addHeaders: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
5600
5833
|
customResponse: external_exports.any().optional()
|
|
5601
5834
|
});
|
|
5602
5835
|
var EventConfigSchema = external_exports.object({
|
|
@@ -5629,7 +5862,7 @@ var MiddlewareSessionDataSchema = external_exports.object({
|
|
|
5629
5862
|
firstSeen: external_exports.number(),
|
|
5630
5863
|
lastSeen: external_exports.number(),
|
|
5631
5864
|
requestCount: external_exports.number(),
|
|
5632
|
-
metadata: external_exports.record(external_exports.any()).optional()
|
|
5865
|
+
metadata: external_exports.record(external_exports.string(), external_exports.any()).optional()
|
|
5633
5866
|
});
|
|
5634
5867
|
var MiddlewareConfigSchema = external_exports.object({
|
|
5635
5868
|
action: MiddlewareActionSchema.default("log"),
|
|
@@ -6735,7 +6968,11 @@ var VALIDATION_ERRORS = {
|
|
|
6735
6968
|
INVALID_URL: "VALIDATION_INVALID_URL",
|
|
6736
6969
|
INVALID_UUID: "VALIDATION_INVALID_UUID",
|
|
6737
6970
|
INVALID_IP_ADDRESS: "VALIDATION_INVALID_IP_ADDRESS",
|
|
6738
|
-
INVALID_USER_AGENT: "VALIDATION_INVALID_USER_AGENT"
|
|
6971
|
+
INVALID_USER_AGENT: "VALIDATION_INVALID_USER_AGENT",
|
|
6972
|
+
BAD_REQUEST: "VALIDATION_BAD_REQUEST",
|
|
6973
|
+
INVALID_START_DATE: "VALIDATION_INVALID_START_DATE",
|
|
6974
|
+
INVALID_END_DATE: "VALIDATION_INVALID_END_DATE",
|
|
6975
|
+
INVALID_DATE_RANGE: "VALIDATION_INVALID_DATE_RANGE"
|
|
6739
6976
|
};
|
|
6740
6977
|
var DETECTION_ERRORS = {
|
|
6741
6978
|
DETECTION_FAILED: "DETECTION_FAILED",
|
|
@@ -6760,7 +6997,8 @@ var PERMISSION_ERRORS = {
|
|
|
6760
6997
|
RESOURCE_ACCESS_DENIED: "PERMISSION_ACCESS_DENIED",
|
|
6761
6998
|
OPERATION_NOT_ALLOWED: "PERMISSION_OPERATION_NOT_ALLOWED",
|
|
6762
6999
|
PROJECT_ACCESS_DENIED: "PERMISSION_PROJECT_ACCESS_DENIED",
|
|
6763
|
-
PIXEL_ACCESS_DENIED: "PERMISSION_PIXEL_ACCESS_DENIED"
|
|
7000
|
+
PIXEL_ACCESS_DENIED: "PERMISSION_PIXEL_ACCESS_DENIED",
|
|
7001
|
+
FORBIDDEN: "PERMISSION_FORBIDDEN"
|
|
6764
7002
|
};
|
|
6765
7003
|
var NETWORK_ERRORS = {
|
|
6766
7004
|
CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED",
|
|
@@ -6777,7 +7015,8 @@ var INTERNAL_ERRORS = {
|
|
|
6777
7015
|
CONFIGURATION_ERROR: "INTERNAL_CONFIGURATION_ERROR",
|
|
6778
7016
|
INITIALIZATION_ERROR: "INTERNAL_INITIALIZATION_ERROR",
|
|
6779
7017
|
PROCESSING_ERROR: "INTERNAL_PROCESSING_ERROR",
|
|
6780
|
-
UNKNOWN_ERROR: "INTERNAL_UNKNOWN_ERROR"
|
|
7018
|
+
UNKNOWN_ERROR: "INTERNAL_UNKNOWN_ERROR",
|
|
7019
|
+
SERVICE_UNAVAILABLE_TRANSIENT: "SERVICE_UNAVAILABLE_TRANSIENT"
|
|
6781
7020
|
};
|
|
6782
7021
|
var SESSION_ERRORS = {
|
|
6783
7022
|
SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
|
|
@@ -6795,7 +7034,10 @@ var PIXEL_ERRORS = {
|
|
|
6795
7034
|
PIXEL_DOMAIN_NOT_ALLOWED: "PIXEL_DOMAIN_NOT_ALLOWED",
|
|
6796
7035
|
PIXEL_PATH_SKIPPED: "PIXEL_PATH_SKIPPED",
|
|
6797
7036
|
PIXEL_EVENT_INVALID: "PIXEL_EVENT_INVALID",
|
|
6798
|
-
PIXEL_BATCH_TOO_LARGE: "PIXEL_BATCH_TOO_LARGE"
|
|
7037
|
+
PIXEL_BATCH_TOO_LARGE: "PIXEL_BATCH_TOO_LARGE",
|
|
7038
|
+
MISSING_PIXEL_ID: "MISSING_PIXEL_ID",
|
|
7039
|
+
INVALID_EDGE_SIGNATURE: "INVALID_EDGE_SIGNATURE",
|
|
7040
|
+
DETECTION_STORAGE_FAILED: "DETECTION_STORAGE_FAILED"
|
|
6799
7041
|
};
|
|
6800
7042
|
var API_ERRORS = {
|
|
6801
7043
|
ENDPOINT_NOT_FOUND: "API_ENDPOINT_NOT_FOUND",
|
|
@@ -6805,6 +7047,27 @@ var API_ERRORS = {
|
|
|
6805
7047
|
RESPONSE_TOO_LARGE: "API_RESPONSE_TOO_LARGE",
|
|
6806
7048
|
REQUEST_TOO_LARGE: "API_REQUEST_TOO_LARGE"
|
|
6807
7049
|
};
|
|
7050
|
+
var BILLING_ERRORS = {
|
|
7051
|
+
LIMIT_EXCEEDED: "LIMIT_EXCEEDED",
|
|
7052
|
+
BILLING_SUSPENDED: "BILLING_SUSPENDED",
|
|
7053
|
+
BILLING_GRACE_PERIOD: "BILLING_GRACE_PERIOD"
|
|
7054
|
+
};
|
|
7055
|
+
var RESOURCE_ERRORS = {
|
|
7056
|
+
CONFLICT: "CONFLICT",
|
|
7057
|
+
PROJECT_NOT_FOUND: "PROJECT_NOT_FOUND",
|
|
7058
|
+
REVIEW_REQUIRED: "REVIEW_REQUIRED"
|
|
7059
|
+
};
|
|
7060
|
+
var POLICY_ERRORS = {
|
|
7061
|
+
POLICY_FETCH_FAILED: "POLICY_FETCH_FAILED"
|
|
7062
|
+
};
|
|
7063
|
+
var BARE_ERRORS = {
|
|
7064
|
+
BARE_VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
7065
|
+
BARE_INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
7066
|
+
};
|
|
7067
|
+
var LOWERCASE_ERRORS = {
|
|
7068
|
+
LOWERCASE_INVALID_JSON: "invalid_json",
|
|
7069
|
+
LOWERCASE_VALIDATION_ERROR: "validation_error"
|
|
7070
|
+
};
|
|
6808
7071
|
var ERROR_CODES = {
|
|
6809
7072
|
...AUTH_ERRORS,
|
|
6810
7073
|
...VALIDATION_ERRORS,
|
|
@@ -6815,7 +7078,12 @@ var ERROR_CODES = {
|
|
|
6815
7078
|
...INTERNAL_ERRORS,
|
|
6816
7079
|
...SESSION_ERRORS,
|
|
6817
7080
|
...PIXEL_ERRORS,
|
|
6818
|
-
...API_ERRORS
|
|
7081
|
+
...API_ERRORS,
|
|
7082
|
+
...BILLING_ERRORS,
|
|
7083
|
+
...RESOURCE_ERRORS,
|
|
7084
|
+
...POLICY_ERRORS,
|
|
7085
|
+
...BARE_ERRORS,
|
|
7086
|
+
...LOWERCASE_ERRORS
|
|
6819
7087
|
};
|
|
6820
7088
|
var ERROR_MESSAGES = {
|
|
6821
7089
|
// Authentication
|
|
@@ -6839,6 +7107,10 @@ var ERROR_MESSAGES = {
|
|
|
6839
7107
|
[VALIDATION_ERRORS.INVALID_UUID]: "Invalid UUID format",
|
|
6840
7108
|
[VALIDATION_ERRORS.INVALID_IP_ADDRESS]: "Invalid IP address format",
|
|
6841
7109
|
[VALIDATION_ERRORS.INVALID_USER_AGENT]: "Invalid or missing user agent",
|
|
7110
|
+
[VALIDATION_ERRORS.BAD_REQUEST]: "Bad request",
|
|
7111
|
+
[VALIDATION_ERRORS.INVALID_START_DATE]: "Invalid request data",
|
|
7112
|
+
[VALIDATION_ERRORS.INVALID_END_DATE]: "Invalid request data",
|
|
7113
|
+
[VALIDATION_ERRORS.INVALID_DATE_RANGE]: "Invalid request data",
|
|
6842
7114
|
// Detection
|
|
6843
7115
|
[DETECTION_ERRORS.DETECTION_FAILED]: "Agent detection failed",
|
|
6844
7116
|
[DETECTION_ERRORS.INSUFFICIENT_DATA]: "Insufficient data for detection",
|
|
@@ -6861,6 +7133,7 @@ var ERROR_MESSAGES = {
|
|
|
6861
7133
|
[PERMISSION_ERRORS.OPERATION_NOT_ALLOWED]: "Operation not allowed",
|
|
6862
7134
|
[PERMISSION_ERRORS.PROJECT_ACCESS_DENIED]: "Project access denied",
|
|
6863
7135
|
[PERMISSION_ERRORS.PIXEL_ACCESS_DENIED]: "Pixel access denied",
|
|
7136
|
+
[PERMISSION_ERRORS.FORBIDDEN]: "Access denied",
|
|
6864
7137
|
// Network
|
|
6865
7138
|
[NETWORK_ERRORS.CONNECTION_FAILED]: "Connection failed",
|
|
6866
7139
|
[NETWORK_ERRORS.TIMEOUT]: "Request timeout",
|
|
@@ -6876,6 +7149,7 @@ var ERROR_MESSAGES = {
|
|
|
6876
7149
|
[INTERNAL_ERRORS.INITIALIZATION_ERROR]: "Initialization error",
|
|
6877
7150
|
[INTERNAL_ERRORS.PROCESSING_ERROR]: "Processing error",
|
|
6878
7151
|
[INTERNAL_ERRORS.UNKNOWN_ERROR]: "An unknown error occurred",
|
|
7152
|
+
[INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: "A dependency is temporarily unavailable. Retry shortly.",
|
|
6879
7153
|
// Session
|
|
6880
7154
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
|
|
6881
7155
|
[SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
|
|
@@ -6892,20 +7166,49 @@ var ERROR_MESSAGES = {
|
|
|
6892
7166
|
[PIXEL_ERRORS.PIXEL_PATH_SKIPPED]: "Path is configured to be skipped",
|
|
6893
7167
|
[PIXEL_ERRORS.PIXEL_EVENT_INVALID]: "Invalid pixel event",
|
|
6894
7168
|
[PIXEL_ERRORS.PIXEL_BATCH_TOO_LARGE]: "Event batch exceeds maximum size",
|
|
7169
|
+
[PIXEL_ERRORS.MISSING_PIXEL_ID]: "Project ID is required",
|
|
7170
|
+
[PIXEL_ERRORS.INVALID_EDGE_SIGNATURE]: "Invalid request signature",
|
|
7171
|
+
[PIXEL_ERRORS.DETECTION_STORAGE_FAILED]: "Failed to store detection data",
|
|
6895
7172
|
// API
|
|
6896
7173
|
[API_ERRORS.ENDPOINT_NOT_FOUND]: "API endpoint not found",
|
|
6897
7174
|
[API_ERRORS.METHOD_NOT_ALLOWED]: "HTTP method not allowed",
|
|
6898
7175
|
[API_ERRORS.VERSION_NOT_SUPPORTED]: "API version not supported",
|
|
6899
7176
|
[API_ERRORS.CONTENT_TYPE_NOT_SUPPORTED]: "Content type not supported",
|
|
6900
7177
|
[API_ERRORS.RESPONSE_TOO_LARGE]: "Response exceeds maximum size",
|
|
6901
|
-
[API_ERRORS.REQUEST_TOO_LARGE]: "Request exceeds maximum size"
|
|
7178
|
+
[API_ERRORS.REQUEST_TOO_LARGE]: "Request exceeds maximum size",
|
|
7179
|
+
// Billing
|
|
7180
|
+
[BILLING_ERRORS.LIMIT_EXCEEDED]: "Billing limit exceeded",
|
|
7181
|
+
[BILLING_ERRORS.BILLING_SUSPENDED]: "Account billing suspended",
|
|
7182
|
+
[BILLING_ERRORS.BILLING_GRACE_PERIOD]: "Account in billing grace period",
|
|
7183
|
+
// Resources
|
|
7184
|
+
[RESOURCE_ERRORS.CONFLICT]: "Resource conflict",
|
|
7185
|
+
[RESOURCE_ERRORS.PROJECT_NOT_FOUND]: "Project not found",
|
|
7186
|
+
[RESOURCE_ERRORS.REVIEW_REQUIRED]: "Deploy requires explicit confirmation of the consequential writes it will perform.",
|
|
7187
|
+
// Policy
|
|
7188
|
+
[POLICY_ERRORS.POLICY_FETCH_FAILED]: "Failed to fetch policy",
|
|
7189
|
+
// Bare (un-prefixed, shared across pixel/openclaw/deploy/shopify/bouncer)
|
|
7190
|
+
[BARE_ERRORS.BARE_VALIDATION_ERROR]: "Invalid request data",
|
|
7191
|
+
[BARE_ERRORS.BARE_INTERNAL_ERROR]: "Internal server error",
|
|
7192
|
+
// Lowercase (kya-os events wire format)
|
|
7193
|
+
[LOWERCASE_ERRORS.LOWERCASE_INVALID_JSON]: "Request body must be valid JSON",
|
|
7194
|
+
[LOWERCASE_ERRORS.LOWERCASE_VALIDATION_ERROR]: "Invalid request body"
|
|
6902
7195
|
};
|
|
6903
7196
|
var ERROR_STATUS_CODES = {
|
|
7197
|
+
// 200 OK (billing grace period is a soft warning, not a failure)
|
|
7198
|
+
[BILLING_ERRORS.BILLING_GRACE_PERIOD]: 200,
|
|
6904
7199
|
// 400 Bad Request
|
|
6905
7200
|
[VALIDATION_ERRORS.INVALID_REQUEST]: 400,
|
|
6906
7201
|
[VALIDATION_ERRORS.MISSING_REQUIRED_FIELD]: 400,
|
|
6907
7202
|
[VALIDATION_ERRORS.INVALID_FIELD_TYPE]: 400,
|
|
6908
7203
|
[VALIDATION_ERRORS.INVALID_FIELD_VALUE]: 400,
|
|
7204
|
+
[VALIDATION_ERRORS.BAD_REQUEST]: 400,
|
|
7205
|
+
[VALIDATION_ERRORS.INVALID_START_DATE]: 400,
|
|
7206
|
+
[VALIDATION_ERRORS.INVALID_END_DATE]: 400,
|
|
7207
|
+
[VALIDATION_ERRORS.INVALID_DATE_RANGE]: 400,
|
|
7208
|
+
[PIXEL_ERRORS.MISSING_PIXEL_ID]: 400,
|
|
7209
|
+
[BARE_ERRORS.BARE_VALIDATION_ERROR]: 400,
|
|
7210
|
+
[LOWERCASE_ERRORS.LOWERCASE_INVALID_JSON]: 400,
|
|
7211
|
+
[LOWERCASE_ERRORS.LOWERCASE_VALIDATION_ERROR]: 400,
|
|
6909
7212
|
// 401 Unauthorized
|
|
6910
7213
|
[AUTH_ERRORS.INVALID_API_KEY]: 401,
|
|
6911
7214
|
[AUTH_ERRORS.EXPIRED_API_KEY]: 401,
|
|
@@ -6913,10 +7216,15 @@ var ERROR_STATUS_CODES = {
|
|
|
6913
7216
|
[AUTH_ERRORS.EXPIRED_TOKEN]: 401,
|
|
6914
7217
|
[AUTH_ERRORS.MISSING_CREDENTIALS]: 401,
|
|
6915
7218
|
[AUTH_ERRORS.UNAUTHORIZED]: 401,
|
|
7219
|
+
// 402 Payment Required
|
|
7220
|
+
[BILLING_ERRORS.LIMIT_EXCEEDED]: 402,
|
|
7221
|
+
[BILLING_ERRORS.BILLING_SUSPENDED]: 402,
|
|
6916
7222
|
// 403 Forbidden
|
|
6917
7223
|
[PERMISSION_ERRORS.INSUFFICIENT_PERMISSIONS]: 403,
|
|
6918
7224
|
[PERMISSION_ERRORS.RESOURCE_ACCESS_DENIED]: 403,
|
|
6919
7225
|
[PERMISSION_ERRORS.OPERATION_NOT_ALLOWED]: 403,
|
|
7226
|
+
[PERMISSION_ERRORS.FORBIDDEN]: 403,
|
|
7227
|
+
[PIXEL_ERRORS.INVALID_EDGE_SIGNATURE]: 403,
|
|
6920
7228
|
// 404 Not Found
|
|
6921
7229
|
[PERMISSION_ERRORS.RESOURCE_NOT_FOUND]: 404,
|
|
6922
7230
|
[API_ERRORS.ENDPOINT_NOT_FOUND]: 404,
|
|
@@ -6924,11 +7232,20 @@ var ERROR_STATUS_CODES = {
|
|
|
6924
7232
|
[SESSION_ERRORS.SESSION_NOT_FOUND]: 404,
|
|
6925
7233
|
// 405 Method Not Allowed
|
|
6926
7234
|
[API_ERRORS.METHOD_NOT_ALLOWED]: 405,
|
|
7235
|
+
// 409 Conflict
|
|
7236
|
+
[RESOURCE_ERRORS.CONFLICT]: 409,
|
|
7237
|
+
// NOTE: RESOURCE_ERRORS.PROJECT_NOT_FOUND deliberately has no entry here.
|
|
7238
|
+
// The pixel API emits it with 400, while enforce and the policy
|
|
7239
|
+
// middleware emit it with 404. There is no single correct status, so it
|
|
7240
|
+
// stays unpinned and callers set their own status per surface. Locked by
|
|
7241
|
+
// a test in __tests__/errors.test.ts.
|
|
6927
7242
|
// 413 Payload Too Large
|
|
6928
7243
|
[API_ERRORS.REQUEST_TOO_LARGE]: 413,
|
|
6929
7244
|
[PIXEL_ERRORS.PIXEL_BATCH_TOO_LARGE]: 413,
|
|
6930
7245
|
// 415 Unsupported Media Type
|
|
6931
7246
|
[API_ERRORS.CONTENT_TYPE_NOT_SUPPORTED]: 415,
|
|
7247
|
+
// 422 Unprocessable Entity
|
|
7248
|
+
[RESOURCE_ERRORS.REVIEW_REQUIRED]: 422,
|
|
6932
7249
|
// 429 Too Many Requests
|
|
6933
7250
|
[RATE_LIMIT_ERRORS.RATE_LIMIT_EXCEEDED]: 429,
|
|
6934
7251
|
[RATE_LIMIT_ERRORS.BURST_LIMIT_EXCEEDED]: 429,
|
|
@@ -6937,10 +7254,14 @@ var ERROR_STATUS_CODES = {
|
|
|
6937
7254
|
[INTERNAL_ERRORS.INTERNAL_SERVER_ERROR]: 500,
|
|
6938
7255
|
[INTERNAL_ERRORS.DATABASE_ERROR]: 500,
|
|
6939
7256
|
[INTERNAL_ERRORS.PROCESSING_ERROR]: 500,
|
|
7257
|
+
[PIXEL_ERRORS.DETECTION_STORAGE_FAILED]: 500,
|
|
7258
|
+
[POLICY_ERRORS.POLICY_FETCH_FAILED]: 500,
|
|
7259
|
+
[BARE_ERRORS.BARE_INTERNAL_ERROR]: 500,
|
|
6940
7260
|
// 502 Bad Gateway
|
|
6941
7261
|
[NETWORK_ERRORS.UPSTREAM_ERROR]: 502,
|
|
6942
7262
|
// 503 Service Unavailable
|
|
6943
7263
|
[INTERNAL_ERRORS.INITIALIZATION_ERROR]: 503,
|
|
7264
|
+
[INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: 503,
|
|
6944
7265
|
// 504 Gateway Timeout
|
|
6945
7266
|
[NETWORK_ERRORS.TIMEOUT]: 504
|
|
6946
7267
|
};
|
|
@@ -7515,7 +7836,7 @@ var DetectionRequestSchema = external_exports.object({
|
|
|
7515
7836
|
userAgent: external_exports.string(),
|
|
7516
7837
|
// Optional fields
|
|
7517
7838
|
ipAddress: external_exports.string().optional(),
|
|
7518
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
7839
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
7519
7840
|
url: external_exports.string().optional(),
|
|
7520
7841
|
method: external_exports.string().optional(),
|
|
7521
7842
|
// Behavioral data
|
|
@@ -7611,6 +7932,7 @@ var HealthResponseSchema = external_exports.object({
|
|
|
7611
7932
|
version: external_exports.string(),
|
|
7612
7933
|
uptime: external_exports.number().min(0),
|
|
7613
7934
|
checks: external_exports.record(
|
|
7935
|
+
external_exports.string(),
|
|
7614
7936
|
external_exports.object({
|
|
7615
7937
|
status: external_exports.enum(["pass", "fail"]),
|
|
7616
7938
|
message: external_exports.string().optional()
|
|
@@ -7691,13 +8013,13 @@ var PixelEventSchema = external_exports.object({
|
|
|
7691
8013
|
// Request Information
|
|
7692
8014
|
userAgent: external_exports.string(),
|
|
7693
8015
|
ipAddress: external_exports.string().optional(),
|
|
7694
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
8016
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
7695
8017
|
// Detection Results
|
|
7696
8018
|
detection: DetectionResultSchema.optional(),
|
|
7697
8019
|
// Behavioral Data
|
|
7698
8020
|
behavioral: BehavioralSignalsSchema.optional(),
|
|
7699
8021
|
// Custom Data
|
|
7700
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
8022
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
7701
8023
|
customEventName: external_exports.string().optional()
|
|
7702
8024
|
});
|
|
7703
8025
|
var BatchPixelEventRequestSchema = external_exports.object({
|
|
@@ -7766,6 +8088,40 @@ var ClientDetectionSchema = external_exports.object({
|
|
|
7766
8088
|
scrollEvents: external_exports.number().optional(),
|
|
7767
8089
|
clickEvents: external_exports.number().optional(),
|
|
7768
8090
|
touchEvents: external_exports.number().optional(),
|
|
8091
|
+
// Input events dispatched with isTrusted:false (synthetic script/extension
|
|
8092
|
+
// input, never real hardware). Provenance signal for content-script agent
|
|
8093
|
+
// drivers — see human-promotion-audit.untrustedInputShare.
|
|
8094
|
+
untrustedEvents: external_exports.number().optional(),
|
|
8095
|
+
// Timing physics, counters only (checkpoint-detector.js). Bucket edges sit
|
|
8096
|
+
// below the floor a hand showed on the lab gauntlet; the server derives
|
|
8097
|
+
// shares and means (lib/detection/timing-physics.ts). No timestamps,
|
|
8098
|
+
// coordinates, or key identity ever ride here. `timingVersion` names the
|
|
8099
|
+
// detector's guard set (IME, modifier, multi-touch skips) so rows from
|
|
8100
|
+
// different sets can be told apart at calibration.
|
|
8101
|
+
timingVersion: external_exports.number().optional(),
|
|
8102
|
+
keyDwellCount: external_exports.number().optional(),
|
|
8103
|
+
keyDwellUnder5: external_exports.number().optional(),
|
|
8104
|
+
keyDwellSumMs: external_exports.number().optional(),
|
|
8105
|
+
keyGapCount: external_exports.number().optional(),
|
|
8106
|
+
keyGapUnder5: external_exports.number().optional(),
|
|
8107
|
+
pressCount: external_exports.number().optional(),
|
|
8108
|
+
pressAdjacencyCount: external_exports.number().int().nonnegative().optional(),
|
|
8109
|
+
pressAdjacentUnder5: external_exports.number().int().nonnegative().optional(),
|
|
8110
|
+
pressUnder10: external_exports.number().optional(),
|
|
8111
|
+
pressSumMs: external_exports.number().optional(),
|
|
8112
|
+
mouseClicks: external_exports.number().optional(),
|
|
8113
|
+
zeroTrailClicks: external_exports.number().optional(),
|
|
8114
|
+
// Path kinematics, counters only (checkpoint-detector.js), for the driver
|
|
8115
|
+
// that manufactures a hand's timing: coalesced samples per pointermove,
|
|
8116
|
+
// and whether consecutive steps repeat their length or their heading.
|
|
8117
|
+
// Mouse pointer only; no coordinate rides here. `kinematicsVersion` names
|
|
8118
|
+
// the rule set (tolerances, pointer filter) the way `timingVersion` does.
|
|
8119
|
+
kinematicsVersion: external_exports.number().optional(),
|
|
8120
|
+
pointerMoves: external_exports.number().optional(),
|
|
8121
|
+
coalescedMoves: external_exports.number().optional(),
|
|
8122
|
+
stepPairs: external_exports.number().optional(),
|
|
8123
|
+
equalSteps: external_exports.number().optional(),
|
|
8124
|
+
straightSteps: external_exports.number().optional(),
|
|
7769
8125
|
hasInteraction: external_exports.boolean().optional(),
|
|
7770
8126
|
// Connection info
|
|
7771
8127
|
connection: external_exports.object({
|
|
@@ -7802,7 +8158,7 @@ var PixelTrackingRequestSchema = external_exports.object({
|
|
|
7802
8158
|
// profile onto the newly-identified one (properties are never merged across
|
|
7803
8159
|
// profiles automatically). Mirrors the analytics-SDK `identify(previousId)` arg.
|
|
7804
8160
|
previousId: external_exports.string().optional(),
|
|
7805
|
-
userTraits: external_exports.record(external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
8161
|
+
userTraits: external_exports.record(external_exports.string(), external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
7806
8162
|
message: "User traits too large (max 10KB)"
|
|
7807
8163
|
}).refine((traits) => !traits || Object.keys(traits).length < 50, {
|
|
7808
8164
|
message: "Too many user trait properties (max 50)"
|
|
@@ -7832,7 +8188,7 @@ var PixelTrackingRequestSchema = external_exports.object({
|
|
|
7832
8188
|
// Detection data
|
|
7833
8189
|
userAgent: external_exports.string(),
|
|
7834
8190
|
// Browser user agent
|
|
7835
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
8191
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
7836
8192
|
// Any additional headers
|
|
7837
8193
|
// Client info
|
|
7838
8194
|
screenResolution: external_exports.string().optional(),
|
|
@@ -7973,7 +8329,7 @@ var PixelVerificationStatusSchema = external_exports.object({
|
|
|
7973
8329
|
});
|
|
7974
8330
|
var PixelUserIdentificationSchema = external_exports.object({
|
|
7975
8331
|
userId: external_exports.string(),
|
|
7976
|
-
traits: external_exports.record(external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
8332
|
+
traits: external_exports.record(external_exports.string(), external_exports.unknown()).optional().refine((traits) => !traits || JSON.stringify(traits).length < 1e4, {
|
|
7977
8333
|
message: "User traits too large (max 10KB)"
|
|
7978
8334
|
}).refine((traits) => !traits || Object.keys(traits).length < 50, {
|
|
7979
8335
|
message: "Too many user trait properties (max 50)"
|
|
@@ -8005,7 +8361,7 @@ var EventTrackingRequestSchema = external_exports.object({
|
|
|
8005
8361
|
referrer: external_exports.string().url().optional(),
|
|
8006
8362
|
method: external_exports.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional(),
|
|
8007
8363
|
// Headers for additional context
|
|
8008
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
8364
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
8009
8365
|
// Behavioral tracking data
|
|
8010
8366
|
behavioralData: BehavioralDataSchema.optional(),
|
|
8011
8367
|
// Client-side browser fingerprint (headless/automation tells, interaction).
|
|
@@ -8021,7 +8377,7 @@ var EventTrackingRequestSchema = external_exports.object({
|
|
|
8021
8377
|
screenResolution: external_exports.string().optional(),
|
|
8022
8378
|
viewport: external_exports.string().optional(),
|
|
8023
8379
|
// Custom metadata
|
|
8024
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
8380
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
8025
8381
|
});
|
|
8026
8382
|
var EventTrackingResponseSchema = external_exports.object({
|
|
8027
8383
|
success: external_exports.boolean(),
|
|
@@ -8107,7 +8463,7 @@ var EventStorageRecordSchema = external_exports.object({
|
|
|
8107
8463
|
scrollDepth: external_exports.number().optional(),
|
|
8108
8464
|
clickCount: external_exports.number().optional(),
|
|
8109
8465
|
// Metadata
|
|
8110
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
8466
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
8111
8467
|
// Timestamps
|
|
8112
8468
|
createdAt: external_exports.date(),
|
|
8113
8469
|
processedAt: external_exports.date()
|
|
@@ -8146,7 +8502,7 @@ var SignatureVerificationRequestSchema = external_exports.object({
|
|
|
8146
8502
|
// Algorithm hint
|
|
8147
8503
|
algorithm: SignatureAlgorithmSchema.optional(),
|
|
8148
8504
|
// Additional headers for context
|
|
8149
|
-
headers: external_exports.record(external_exports.string()).optional()
|
|
8505
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
8150
8506
|
});
|
|
8151
8507
|
var SignatureVerificationResponseSchema = external_exports.object({
|
|
8152
8508
|
success: external_exports.boolean(),
|
|
@@ -8544,7 +8900,7 @@ var PixelConfigurationSchema = external_exports.object({
|
|
|
8544
8900
|
flushInterval: external_exports.number().min(100).max(6e4).default(5e3),
|
|
8545
8901
|
enableBehavioralTracking: external_exports.boolean().default(true),
|
|
8546
8902
|
enableSessionReplay: external_exports.boolean().default(false),
|
|
8547
|
-
customHeaders: external_exports.record(external_exports.string()).default({})
|
|
8903
|
+
customHeaders: external_exports.record(external_exports.string(), external_exports.string()).default({})
|
|
8548
8904
|
});
|
|
8549
8905
|
var PixelSchema = external_exports.object({
|
|
8550
8906
|
id: external_exports.string().uuid(),
|
|
@@ -8595,7 +8951,7 @@ var DetectionLogSchema = external_exports.object({
|
|
|
8595
8951
|
agentType: external_exports.string().optional(),
|
|
8596
8952
|
userAgent: external_exports.string().optional(),
|
|
8597
8953
|
ipAddress: external_exports.string().ip().optional(),
|
|
8598
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
8954
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
8599
8955
|
sessionId: external_exports.string().optional(),
|
|
8600
8956
|
createdAt: external_exports.date()
|
|
8601
8957
|
});
|
|
@@ -8988,7 +9344,7 @@ var BouncerConfigSchema = external_exports.object({
|
|
|
8988
9344
|
// Consent page configuration
|
|
8989
9345
|
consentConfig: ConsentConfigSchema.optional(),
|
|
8990
9346
|
// Tool discovery
|
|
8991
|
-
discoveredTools: external_exports.record(external_exports.unknown()).default({}),
|
|
9347
|
+
discoveredTools: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
|
|
8992
9348
|
mcpServerUrl: httpUrlSchema().nullable().optional(),
|
|
8993
9349
|
mcpWorkerUrl: httpUrlSchema().nullable().optional(),
|
|
8994
9350
|
// Organization settings
|
|
@@ -9049,14 +9405,14 @@ var DelegationSchema = external_exports.object({
|
|
|
9049
9405
|
userIdentifier: external_exports.string().max(500).nullable().optional(),
|
|
9050
9406
|
// Human-readable (email)
|
|
9051
9407
|
scopes: external_exports.array(external_exports.string()),
|
|
9052
|
-
constraints: external_exports.record(external_exports.unknown()).nullable().optional(),
|
|
9408
|
+
constraints: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional(),
|
|
9053
9409
|
status: DelegationStatusSchema.default("active"),
|
|
9054
9410
|
issuedAt: external_exports.string().datetime(),
|
|
9055
9411
|
expiresAt: external_exports.string().datetime().nullable().optional(),
|
|
9056
9412
|
revokedAt: external_exports.string().datetime().nullable().optional(),
|
|
9057
9413
|
revocationReason: external_exports.string().max(500).nullable().optional(),
|
|
9058
9414
|
credentialJwt: external_exports.string().nullable().optional(),
|
|
9059
|
-
metadata: external_exports.record(external_exports.unknown()).default({}),
|
|
9415
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
|
|
9060
9416
|
createdAt: external_exports.string().datetime(),
|
|
9061
9417
|
updatedAt: external_exports.string().datetime()
|
|
9062
9418
|
});
|
|
@@ -9069,15 +9425,15 @@ var BouncerProofSchema = external_exports.object({
|
|
|
9069
9425
|
agentDid: external_exports.string().max(500),
|
|
9070
9426
|
userIdentifier: external_exports.string().max(500).nullable().optional(),
|
|
9071
9427
|
toolName: external_exports.string().max(255),
|
|
9072
|
-
toolArgs: external_exports.record(external_exports.unknown()).nullable().optional(),
|
|
9073
|
-
toolResult: external_exports.record(external_exports.unknown()).nullable().optional(),
|
|
9428
|
+
toolArgs: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional(),
|
|
9429
|
+
toolResult: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional(),
|
|
9074
9430
|
scopes: external_exports.array(external_exports.string()).nullable().optional(),
|
|
9075
9431
|
signature: external_exports.string(),
|
|
9076
9432
|
publicKey: external_exports.string(),
|
|
9077
9433
|
timestamp: external_exports.number().int(),
|
|
9078
9434
|
// Unix timestamp
|
|
9079
9435
|
nonce: external_exports.string().max(100),
|
|
9080
|
-
crispDelta: external_exports.record(external_exports.unknown()).nullable().optional(),
|
|
9436
|
+
crispDelta: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional(),
|
|
9081
9437
|
outcome: BouncerOutcomeSchema.default("success"),
|
|
9082
9438
|
errorMessage: external_exports.string().nullable().optional(),
|
|
9083
9439
|
createdAt: external_exports.string().datetime()
|
|
@@ -9221,7 +9577,7 @@ external_exports.object({
|
|
|
9221
9577
|
function toProviderRegistryFormat(provider) {
|
|
9222
9578
|
const { type, authorizationUrl, tokenUrl, userInfoUrl, ...rest } = provider;
|
|
9223
9579
|
const authType = type;
|
|
9224
|
-
const
|
|
9580
|
+
const result2 = {
|
|
9225
9581
|
id: rest.id,
|
|
9226
9582
|
authType,
|
|
9227
9583
|
displayName: rest.displayName,
|
|
@@ -9229,7 +9585,7 @@ function toProviderRegistryFormat(provider) {
|
|
|
9229
9585
|
metadata: rest.metadata
|
|
9230
9586
|
};
|
|
9231
9587
|
if (authType === "oauth2" && (authorizationUrl || tokenUrl)) {
|
|
9232
|
-
|
|
9588
|
+
result2.oauthConfig = {
|
|
9233
9589
|
authorizationEndpoint: authorizationUrl || "",
|
|
9234
9590
|
tokenEndpoint: tokenUrl || "",
|
|
9235
9591
|
userInfoEndpoint: userInfoUrl,
|
|
@@ -9238,7 +9594,7 @@ function toProviderRegistryFormat(provider) {
|
|
|
9238
9594
|
defaultScopes: rest.defaultScopes || rest.scopes
|
|
9239
9595
|
};
|
|
9240
9596
|
}
|
|
9241
|
-
return
|
|
9597
|
+
return result2;
|
|
9242
9598
|
}
|
|
9243
9599
|
function isSupportedAuthType(authType) {
|
|
9244
9600
|
return authType === "oauth2" || authType === "password";
|
|
@@ -9375,7 +9731,7 @@ function validateOrganizationName(name) {
|
|
|
9375
9731
|
return { valid: true };
|
|
9376
9732
|
} catch (error) {
|
|
9377
9733
|
if (error instanceof external_exports.ZodError) {
|
|
9378
|
-
return { valid: false, error: error.
|
|
9734
|
+
return { valid: false, error: error.issues[0]?.message || "Invalid organization name" };
|
|
9379
9735
|
}
|
|
9380
9736
|
return { valid: false, error: "Invalid organization name" };
|
|
9381
9737
|
}
|
|
@@ -9523,7 +9879,8 @@ var MarketplaceSourceSchema = external_exports.enum([
|
|
|
9523
9879
|
"shopify",
|
|
9524
9880
|
"netlify",
|
|
9525
9881
|
"railway",
|
|
9526
|
-
"shopware"
|
|
9882
|
+
"shopware",
|
|
9883
|
+
"mixer"
|
|
9527
9884
|
]);
|
|
9528
9885
|
var ProvisioningModeSchema = external_exports.enum(["observe", "enforce"]);
|
|
9529
9886
|
var ProvisionKeyRequestSchema = external_exports.object({
|
|
@@ -9569,7 +9926,7 @@ var ProvisionKeyRequestSchema = external_exports.object({
|
|
|
9569
9926
|
*/
|
|
9570
9927
|
organizationId: external_exports.string().uuid().optional(),
|
|
9571
9928
|
/** Optional non-secret provider context (teamId, userId, resource name). */
|
|
9572
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
9929
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
9573
9930
|
});
|
|
9574
9931
|
var ProvisionKeyResponseSchema = external_exports.object({
|
|
9575
9932
|
/**
|
|
@@ -9864,6 +10221,26 @@ var PublicApiHeadersSchema = external_exports.object({
|
|
|
9864
10221
|
"x-request-id": external_exports.string().optional()
|
|
9865
10222
|
});
|
|
9866
10223
|
|
|
10224
|
+
// src/api/signal-exposure.ts
|
|
10225
|
+
var REASON_CODE_VALUES = Object.values(DETECTION_REASON_CODES);
|
|
10226
|
+
var DetectionReasonCodeSchema = external_exports.enum(REASON_CODE_VALUES).describe(
|
|
10227
|
+
"A machine-readable detection/* reason code from the DETECTION_REASON_CODES registry (see docs/architecture/detection-reason-codes.generated.md)."
|
|
10228
|
+
);
|
|
10229
|
+
var DetectionSignalExposureSchema = external_exports.object({
|
|
10230
|
+
signals: external_exports.array(DetectionSignalSchema).describe(
|
|
10231
|
+
"The engine's full per-signal evidence breakdown, verbatim (not the condensed single-entry summary). Empty when the engine did not run (skipDetection) or faulted. THE extension point: future signal families arrive as new entries/sources here, additively."
|
|
10232
|
+
),
|
|
10233
|
+
reasonCodes: external_exports.array(DetectionReasonCodeSchema).min(1).describe(
|
|
10234
|
+
"Ordered detection/* reason codes, most-significant-evidence first, derived by the same mapDetectionToReasonCodes projection that feeds the gateway KYA-Reason-Codes header. Never empty: an assumed verdict carries a zero-evidence fallback code."
|
|
10235
|
+
),
|
|
10236
|
+
confidenceLevel: ConfidenceLevelSchema.optional().describe(
|
|
10237
|
+
"The engine's banded confidence level (low | medium | high | very_high). Omitted when the engine did not produce one (engine fault, skipDetection, or a demoted forged-credential verdict)."
|
|
10238
|
+
),
|
|
10239
|
+
isAiCrawler: external_exports.boolean().optional().describe(
|
|
10240
|
+
"True when the engine classified the client as an AI training crawler (GPTBot, ClaudeBot, \u2026) rather than an interactive agent. Omitted when the engine did not run."
|
|
10241
|
+
)
|
|
10242
|
+
});
|
|
10243
|
+
|
|
9867
10244
|
// src/api/fingerprint.ts
|
|
9868
10245
|
var ClientDetectionSchema2 = external_exports.object({
|
|
9869
10246
|
// Core detection
|
|
@@ -9943,15 +10320,15 @@ var FingerprintAnalysisSchema = external_exports.object({
|
|
|
9943
10320
|
});
|
|
9944
10321
|
var FingerprintDetectRequestSchema = external_exports.object({
|
|
9945
10322
|
clientDetection: ClientDetectionSchema2,
|
|
9946
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
10323
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
9947
10324
|
});
|
|
9948
10325
|
var FingerprintResponseSchema = external_exports.object({
|
|
9949
10326
|
timestamp: external_exports.string(),
|
|
9950
10327
|
method: external_exports.string(),
|
|
9951
10328
|
url: external_exports.string(),
|
|
9952
10329
|
path: external_exports.string(),
|
|
9953
|
-
queryParams: external_exports.record(external_exports.string()),
|
|
9954
|
-
headers: external_exports.record(external_exports.string()),
|
|
10330
|
+
queryParams: external_exports.record(external_exports.string(), external_exports.string()),
|
|
10331
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()),
|
|
9955
10332
|
headerCount: external_exports.number(),
|
|
9956
10333
|
ip: external_exports.string(),
|
|
9957
10334
|
httpVersion: external_exports.string(),
|
|
@@ -9991,7 +10368,7 @@ var EnhancedFingerprintResponseSchema = external_exports.object({
|
|
|
9991
10368
|
http: external_exports.object({
|
|
9992
10369
|
method: external_exports.string(),
|
|
9993
10370
|
url: external_exports.string(),
|
|
9994
|
-
headers: external_exports.record(external_exports.string()),
|
|
10371
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()),
|
|
9995
10372
|
headerCount: external_exports.number(),
|
|
9996
10373
|
ip: external_exports.string(),
|
|
9997
10374
|
userAgent: external_exports.string()
|
|
@@ -10031,7 +10408,7 @@ var FingerprintRecordSchema = external_exports.object({
|
|
|
10031
10408
|
ip: external_exports.string(),
|
|
10032
10409
|
// Headers
|
|
10033
10410
|
userAgent: external_exports.string().nullable(),
|
|
10034
|
-
headers: external_exports.record(external_exports.string()),
|
|
10411
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()),
|
|
10035
10412
|
// Detection results
|
|
10036
10413
|
isBot: external_exports.boolean(),
|
|
10037
10414
|
botType: external_exports.string().nullable(),
|
|
@@ -10044,7 +10421,7 @@ var FingerprintRecordSchema = external_exports.object({
|
|
|
10044
10421
|
// Metadata
|
|
10045
10422
|
sessionId: external_exports.string().nullable(),
|
|
10046
10423
|
projectId: external_exports.string().nullable(),
|
|
10047
|
-
metadata: external_exports.record(external_exports.unknown()).nullable()
|
|
10424
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable()
|
|
10048
10425
|
});
|
|
10049
10426
|
var BotPatternSchema2 = external_exports.object({
|
|
10050
10427
|
name: external_exports.string(),
|
|
@@ -10605,7 +10982,7 @@ var DeploymentMetadataSchema = external_exports.object({
|
|
|
10605
10982
|
privateKey: external_exports.string()
|
|
10606
10983
|
}).optional(),
|
|
10607
10984
|
/** Validated source-specific secrets forwarded to GitHub/Cloudflare. */
|
|
10608
|
-
additionalSecrets: external_exports.record(external_exports.string()).optional(),
|
|
10985
|
+
additionalSecrets: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
10609
10986
|
/** Semantic source type used for descriptions and registry metadata. */
|
|
10610
10987
|
agentType: external_exports.string().optional(),
|
|
10611
10988
|
createdAt: external_exports.number(),
|
|
@@ -10749,8 +11126,8 @@ function isValidWasmRequestMetadata(value) {
|
|
|
10749
11126
|
return WasmRequestMetadataSchema.safeParse(value).success;
|
|
10750
11127
|
}
|
|
10751
11128
|
function parseAgentName(value) {
|
|
10752
|
-
const
|
|
10753
|
-
return
|
|
11129
|
+
const result2 = AgentTypeSchema.safeParse(value);
|
|
11130
|
+
return result2.success ? result2.data : "unknown";
|
|
10754
11131
|
}
|
|
10755
11132
|
function normalizeAgentName(value) {
|
|
10756
11133
|
const normalized = value.toLowerCase().trim();
|
|
@@ -10828,13 +11205,13 @@ var SessionDataSchema = external_exports.object({
|
|
|
10828
11205
|
// Request Context
|
|
10829
11206
|
userAgent: external_exports.string().optional(),
|
|
10830
11207
|
ipAddress: external_exports.string().optional(),
|
|
10831
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
11208
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
10832
11209
|
// Behavioral Data
|
|
10833
11210
|
behavioral: BehavioralSignalsSchema.optional(),
|
|
10834
11211
|
pageViews: external_exports.number().int().min(0).default(0),
|
|
10835
11212
|
interactions: external_exports.number().int().min(0).default(0),
|
|
10836
11213
|
// Custom Metadata
|
|
10837
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
11214
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
10838
11215
|
});
|
|
10839
11216
|
var SessionCreateRequestSchema = external_exports.object({
|
|
10840
11217
|
userId: external_exports.string().optional(),
|
|
@@ -10842,10 +11219,10 @@ var SessionCreateRequestSchema = external_exports.object({
|
|
|
10842
11219
|
projectId: external_exports.string().optional(),
|
|
10843
11220
|
userAgent: external_exports.string().optional(),
|
|
10844
11221
|
ipAddress: external_exports.string().optional(),
|
|
10845
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
11222
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
10846
11223
|
ttl: external_exports.number().min(60).default(3600),
|
|
10847
11224
|
// Time to live in seconds
|
|
10848
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
11225
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
10849
11226
|
});
|
|
10850
11227
|
var SessionUpdateRequestSchema = external_exports.object({
|
|
10851
11228
|
sessionId: external_exports.string(),
|
|
@@ -10853,7 +11230,7 @@ var SessionUpdateRequestSchema = external_exports.object({
|
|
|
10853
11230
|
state: SessionStateSchema.optional(),
|
|
10854
11231
|
detectionResult: DetectionResultSchema.optional(),
|
|
10855
11232
|
behavioral: BehavioralSignalsSchema.optional(),
|
|
10856
|
-
metadata: external_exports.record(external_exports.unknown()).optional(),
|
|
11233
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
10857
11234
|
lastActivityAt: external_exports.date().optional()
|
|
10858
11235
|
}),
|
|
10859
11236
|
extendTtl: external_exports.boolean().default(true)
|
|
@@ -10872,7 +11249,7 @@ var SessionQueryOptionsSchema = external_exports.object({
|
|
|
10872
11249
|
var SessionConfigSchema = external_exports.object({
|
|
10873
11250
|
// Storage
|
|
10874
11251
|
storage: SessionStorageTypeSchema.default("memory"),
|
|
10875
|
-
storageOptions: external_exports.record(external_exports.unknown()).optional(),
|
|
11252
|
+
storageOptions: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
10876
11253
|
// Timing
|
|
10877
11254
|
ttl: external_exports.number().min(60).default(3600),
|
|
10878
11255
|
// Default 1 hour
|
|
@@ -10919,7 +11296,7 @@ var SessionEventSchema = external_exports.object({
|
|
|
10919
11296
|
type: SessionEventTypeSchema,
|
|
10920
11297
|
sessionId: external_exports.string(),
|
|
10921
11298
|
timestamp: external_exports.date(),
|
|
10922
|
-
data: external_exports.record(external_exports.unknown()).optional()
|
|
11299
|
+
data: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
10923
11300
|
});
|
|
10924
11301
|
var SessionTokenPayloadSchema = external_exports.object({
|
|
10925
11302
|
sessionId: external_exports.string(),
|
|
@@ -10929,7 +11306,7 @@ var SessionTokenPayloadSchema = external_exports.object({
|
|
|
10929
11306
|
// Issued at
|
|
10930
11307
|
exp: external_exports.number(),
|
|
10931
11308
|
// Expires at
|
|
10932
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
11309
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
10933
11310
|
});
|
|
10934
11311
|
|
|
10935
11312
|
// src/types/transport.ts
|
|
@@ -11123,7 +11500,7 @@ var WorkerErrorSchema = external_exports.object({
|
|
|
11123
11500
|
code: external_exports.string().optional(),
|
|
11124
11501
|
stack: external_exports.string().optional(),
|
|
11125
11502
|
timestamp: external_exports.number(),
|
|
11126
|
-
context: external_exports.record(external_exports.any()).optional(),
|
|
11503
|
+
context: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
11127
11504
|
recoverable: external_exports.boolean().default(true),
|
|
11128
11505
|
retryAfter: external_exports.number().optional()
|
|
11129
11506
|
});
|
|
@@ -11203,7 +11580,7 @@ var ProtocolVersionSchema = external_exports.literal("1.0.0");
|
|
|
11203
11580
|
// src/types/database.ts
|
|
11204
11581
|
var BulkOperationParamsSchema = external_exports.object({
|
|
11205
11582
|
operation: external_exports.enum(["create", "update", "delete", "upsert"]),
|
|
11206
|
-
data: external_exports.array(external_exports.record(external_exports.unknown())),
|
|
11583
|
+
data: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())),
|
|
11207
11584
|
options: external_exports.object({
|
|
11208
11585
|
skipValidation: external_exports.boolean().optional(),
|
|
11209
11586
|
returnResults: external_exports.boolean().optional(),
|
|
@@ -11219,7 +11596,7 @@ var BulkOperationResultSchema = external_exports.object({
|
|
|
11219
11596
|
external_exports.object({
|
|
11220
11597
|
index: external_exports.number(),
|
|
11221
11598
|
error: external_exports.string(),
|
|
11222
|
-
data: external_exports.record(external_exports.unknown()).optional()
|
|
11599
|
+
data: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
11223
11600
|
})
|
|
11224
11601
|
).default([])
|
|
11225
11602
|
});
|
|
@@ -11305,7 +11682,7 @@ var DetectionMetadataSchema = external_exports.object({
|
|
|
11305
11682
|
touchEvents: external_exports.number().optional()
|
|
11306
11683
|
}).optional(),
|
|
11307
11684
|
// Custom fields
|
|
11308
|
-
custom: external_exports.record(external_exports.unknown()).optional()
|
|
11685
|
+
custom: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
11309
11686
|
});
|
|
11310
11687
|
var AnalyticsExportParamsSchema = external_exports.object({
|
|
11311
11688
|
format: external_exports.enum(["csv", "json", "xlsx"]).default("json"),
|
|
@@ -11356,7 +11733,7 @@ var AnalyticsDataPointSchema = external_exports.object({
|
|
|
11356
11733
|
timestamp: external_exports.date(),
|
|
11357
11734
|
value: external_exports.number(),
|
|
11358
11735
|
label: external_exports.string().optional(),
|
|
11359
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
11736
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
11360
11737
|
});
|
|
11361
11738
|
var AnalyticsSummarySchema = external_exports.object({
|
|
11362
11739
|
total: external_exports.number(),
|
|
@@ -11420,7 +11797,7 @@ var DatabaseDetectionMetadataSchema = external_exports.object({
|
|
|
11420
11797
|
// Request context
|
|
11421
11798
|
userAgent: external_exports.string().optional(),
|
|
11422
11799
|
ipAddress: external_exports.string().optional(),
|
|
11423
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
11800
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
11424
11801
|
// Browser fingerprint data
|
|
11425
11802
|
clientDetection: external_exports.object({
|
|
11426
11803
|
headless: external_exports.boolean().optional(),
|
|
@@ -11535,7 +11912,7 @@ var CollectedDataSchema = external_exports.object({
|
|
|
11535
11912
|
timestamp: external_exports.date()
|
|
11536
11913
|
}),
|
|
11537
11914
|
// HEADERS (noscript, middleware, express, edge)
|
|
11538
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
11915
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
11539
11916
|
// CLIENT-SIDE (pixel, beacon only)
|
|
11540
11917
|
clientSide: external_exports.object({
|
|
11541
11918
|
canvas: external_exports.object({
|
|
@@ -11608,7 +11985,7 @@ var CollectedDataSchema = external_exports.object({
|
|
|
11608
11985
|
httpVersion: external_exports.string(),
|
|
11609
11986
|
protocol: external_exports.string(),
|
|
11610
11987
|
requestSize: external_exports.number().optional(),
|
|
11611
|
-
cookies: external_exports.record(external_exports.string()).optional(),
|
|
11988
|
+
cookies: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
11612
11989
|
sessionData: external_exports.any().optional(),
|
|
11613
11990
|
geoLocation: external_exports.object({
|
|
11614
11991
|
country: external_exports.string(),
|
|
@@ -11816,7 +12193,7 @@ external_exports.object({
|
|
|
11816
12193
|
integrationType: IntegrationTypeSchema,
|
|
11817
12194
|
userAgent: external_exports.string(),
|
|
11818
12195
|
ipAddress: external_exports.string(),
|
|
11819
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
12196
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
11820
12197
|
// Fingerprint hashes
|
|
11821
12198
|
canvasHash: external_exports.string().optional(),
|
|
11822
12199
|
webglHash: external_exports.string().optional(),
|
|
@@ -11964,6 +12341,68 @@ var AgentCategorySchema = external_exports.enum([
|
|
|
11964
12341
|
"unknown"
|
|
11965
12342
|
// Unclassified agents
|
|
11966
12343
|
]);
|
|
12344
|
+
var AGENT_CATEGORY_META = {
|
|
12345
|
+
ai_assistant: {
|
|
12346
|
+
label: "AI assistant",
|
|
12347
|
+
inline: "AI assistant",
|
|
12348
|
+
definition: "An AI assistant acting for a person in real time (ChatGPT, Claude, Perplexity)."
|
|
12349
|
+
},
|
|
12350
|
+
search_engine: {
|
|
12351
|
+
label: "Search engine",
|
|
12352
|
+
inline: "search engine",
|
|
12353
|
+
definition: "An indexing crawler that makes your pages findable (Googlebot, Bingbot)."
|
|
12354
|
+
},
|
|
12355
|
+
social_media: {
|
|
12356
|
+
label: "Social media",
|
|
12357
|
+
inline: "social media",
|
|
12358
|
+
definition: "A crawler building link previews for a social platform."
|
|
12359
|
+
},
|
|
12360
|
+
monitoring: {
|
|
12361
|
+
label: "Monitoring",
|
|
12362
|
+
inline: "monitoring",
|
|
12363
|
+
definition: "An uptime or health checker polling your endpoints."
|
|
12364
|
+
},
|
|
12365
|
+
scraper: {
|
|
12366
|
+
label: "Scraper",
|
|
12367
|
+
inline: "scraper",
|
|
12368
|
+
definition: "Bulk content extraction, including AI training crawlers such as GPTBot and ClaudeBot."
|
|
12369
|
+
},
|
|
12370
|
+
automation: {
|
|
12371
|
+
label: "Automation",
|
|
12372
|
+
inline: "automation",
|
|
12373
|
+
definition: "A headless browser or scripted driver (Puppeteer, Playwright, Selenium)."
|
|
12374
|
+
},
|
|
12375
|
+
security: {
|
|
12376
|
+
label: "Security",
|
|
12377
|
+
inline: "security",
|
|
12378
|
+
definition: "A vulnerability scanner or security research crawler."
|
|
12379
|
+
},
|
|
12380
|
+
analytics: {
|
|
12381
|
+
label: "Analytics",
|
|
12382
|
+
inline: "analytics",
|
|
12383
|
+
definition: "An SEO or analytics tool sampling your pages."
|
|
12384
|
+
},
|
|
12385
|
+
unknown: {
|
|
12386
|
+
label: "Other",
|
|
12387
|
+
inline: "other",
|
|
12388
|
+
definition: "Detected and classified traffic that has not been attributed to a named vendor, usually because it matched only a generic bot signature. Not a detection failure, and worth sampling periodically: a new agent lands here before anyone writes a signature for it."
|
|
12389
|
+
}
|
|
12390
|
+
};
|
|
12391
|
+
function formatUnrecognizedValue(value) {
|
|
12392
|
+
return value.replace(/_/g, " ");
|
|
12393
|
+
}
|
|
12394
|
+
var LEGACY_CATEGORY_SENTINELS = /* @__PURE__ */ new Set(["__uncategorized__", "__unidentified__"]);
|
|
12395
|
+
function formatAgentCategory(value) {
|
|
12396
|
+
if (!value || LEGACY_CATEGORY_SENTINELS.has(value)) return AGENT_CATEGORY_META.unknown.label;
|
|
12397
|
+
const meta = AGENT_CATEGORY_META[value];
|
|
12398
|
+
return meta ? meta.label : formatUnrecognizedValue(value);
|
|
12399
|
+
}
|
|
12400
|
+
function formatAgentCategoryInline(value) {
|
|
12401
|
+
if (!value || LEGACY_CATEGORY_SENTINELS.has(value)) return AGENT_CATEGORY_META.unknown.inline;
|
|
12402
|
+
const meta = AGENT_CATEGORY_META[value];
|
|
12403
|
+
return meta ? meta.inline : formatUnrecognizedValue(value);
|
|
12404
|
+
}
|
|
12405
|
+
var UNNAMED_AGENT_LABEL = "Unnamed agent";
|
|
11967
12406
|
var AgentTypeDefinitionSchema = external_exports.object({
|
|
11968
12407
|
id: external_exports.string().uuid(),
|
|
11969
12408
|
name: external_exports.string(),
|
|
@@ -11992,14 +12431,14 @@ var AgentClassificationResultSchema = external_exports.object({
|
|
|
11992
12431
|
isLegitimate: external_exports.boolean(),
|
|
11993
12432
|
signatureVerified: external_exports.boolean().optional(),
|
|
11994
12433
|
matchedPatterns: external_exports.array(external_exports.string()),
|
|
11995
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
12434
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
11996
12435
|
});
|
|
11997
12436
|
var AgentClassificationRequestSchema = external_exports.object({
|
|
11998
12437
|
userAgent: external_exports.string().optional(),
|
|
11999
|
-
headers: external_exports.record(external_exports.string()).optional(),
|
|
12438
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
12000
12439
|
ipAddress: external_exports.string().optional(),
|
|
12001
12440
|
sessionId: external_exports.string().optional(),
|
|
12002
|
-
metadata: external_exports.record(external_exports.unknown()).optional()
|
|
12441
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
12003
12442
|
});
|
|
12004
12443
|
var AgentStatisticsSchema = external_exports.object({
|
|
12005
12444
|
agentTypeId: external_exports.string().uuid(),
|
|
@@ -12204,7 +12643,13 @@ var EXCLUSION_BUCKETS = [
|
|
|
12204
12643
|
"shopify_review",
|
|
12205
12644
|
"cohort"
|
|
12206
12645
|
];
|
|
12207
|
-
var ADMIN_OVERVIEW_SECTIONS = [
|
|
12646
|
+
var ADMIN_OVERVIEW_SECTIONS = [
|
|
12647
|
+
"ladder",
|
|
12648
|
+
"installations",
|
|
12649
|
+
"traffic",
|
|
12650
|
+
"lists",
|
|
12651
|
+
"hiAi"
|
|
12652
|
+
];
|
|
12208
12653
|
var ADMIN_OVERVIEW_CACHE_STATUSES = ["hit", "stale", "miss", "bypass"];
|
|
12209
12654
|
var SERVICE_TRAFFIC_KEYS = [...INSTALLATION_KINDS, "mixed", "none"];
|
|
12210
12655
|
|
|
@@ -12375,89 +12820,6 @@ function createValidationErrorResponse(message, details, meta) {
|
|
|
12375
12820
|
};
|
|
12376
12821
|
}
|
|
12377
12822
|
|
|
12378
|
-
// src/utils/verification.ts
|
|
12379
|
-
var KYA_OS_HANDSHAKE_METHODS = {
|
|
12380
|
-
/** New canonical engine value. Not emitted yet — accepted on read. */
|
|
12381
|
-
CANONICAL: "kyaos_handshake",
|
|
12382
|
-
/** @deprecated Legacy engine value. Still emitted by the Rust engine. */
|
|
12383
|
-
LEGACY: "mcp_i_handshake"
|
|
12384
|
-
};
|
|
12385
|
-
var KYA_OS_WIRE_METHODS = {
|
|
12386
|
-
/** New canonical wire value. Not emitted yet — accepted on read. */
|
|
12387
|
-
CANONICAL: "kya-os",
|
|
12388
|
-
/** @deprecated Legacy wire value. Still emitted by the gateway worker. */
|
|
12389
|
-
LEGACY: "mcp-i"
|
|
12390
|
-
};
|
|
12391
|
-
function isKyaOsHandshakeMethod(value) {
|
|
12392
|
-
return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;
|
|
12393
|
-
}
|
|
12394
|
-
function isKyaOsWireMethod(value) {
|
|
12395
|
-
return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;
|
|
12396
|
-
}
|
|
12397
|
-
function normalizeHandshakeMethod(value) {
|
|
12398
|
-
return isKyaOsHandshakeMethod(value) ? KYA_OS_HANDSHAKE_METHODS.CANONICAL : value;
|
|
12399
|
-
}
|
|
12400
|
-
function normalizeWireMethod(value) {
|
|
12401
|
-
return isKyaOsWireMethod(value) ? KYA_OS_WIRE_METHODS.CANONICAL : value;
|
|
12402
|
-
}
|
|
12403
|
-
function getVerificationMethodDescription(method) {
|
|
12404
|
-
switch (normalizeHandshakeMethod(method)) {
|
|
12405
|
-
case "signature":
|
|
12406
|
-
return "HTTP Signature Verification";
|
|
12407
|
-
case "pattern":
|
|
12408
|
-
return "User-Agent Pattern Matching";
|
|
12409
|
-
case "behavioral":
|
|
12410
|
-
return "Behavioral Analysis";
|
|
12411
|
-
case "network":
|
|
12412
|
-
return "Network-based Detection";
|
|
12413
|
-
case KYA_OS_HANDSHAKE_METHODS.CANONICAL:
|
|
12414
|
-
return "MCP Handshake Detection";
|
|
12415
|
-
case "error":
|
|
12416
|
-
return "Detection Error";
|
|
12417
|
-
case "none":
|
|
12418
|
-
default:
|
|
12419
|
-
return "No Verification";
|
|
12420
|
-
}
|
|
12421
|
-
}
|
|
12422
|
-
function getVerificationReliability(method) {
|
|
12423
|
-
switch (normalizeHandshakeMethod(method)) {
|
|
12424
|
-
case "signature":
|
|
12425
|
-
return 1;
|
|
12426
|
-
// Highest reliability
|
|
12427
|
-
case KYA_OS_HANDSHAKE_METHODS.CANONICAL:
|
|
12428
|
-
return 0.95;
|
|
12429
|
-
case "behavioral":
|
|
12430
|
-
return 0.8;
|
|
12431
|
-
case "network":
|
|
12432
|
-
return 0.6;
|
|
12433
|
-
case "pattern":
|
|
12434
|
-
return 0.5;
|
|
12435
|
-
case "none":
|
|
12436
|
-
return 0.3;
|
|
12437
|
-
case "error":
|
|
12438
|
-
default:
|
|
12439
|
-
return 0.1;
|
|
12440
|
-
}
|
|
12441
|
-
}
|
|
12442
|
-
function isHighConfidenceVerification(method) {
|
|
12443
|
-
return method === "signature" || isKyaOsHandshakeMethod(method);
|
|
12444
|
-
}
|
|
12445
|
-
function getVerificationRiskLevel(method, confidence) {
|
|
12446
|
-
if (method === "signature") {
|
|
12447
|
-
return "low";
|
|
12448
|
-
}
|
|
12449
|
-
if (isKyaOsHandshakeMethod(method)) {
|
|
12450
|
-
return "low";
|
|
12451
|
-
}
|
|
12452
|
-
if (confidence >= 0.9) {
|
|
12453
|
-
return method === "behavioral" ? "medium" : "high";
|
|
12454
|
-
}
|
|
12455
|
-
if (confidence >= 0.7) {
|
|
12456
|
-
return "medium";
|
|
12457
|
-
}
|
|
12458
|
-
return "high";
|
|
12459
|
-
}
|
|
12460
|
-
|
|
12461
12823
|
// src/utils/detection-class.ts
|
|
12462
12824
|
function detectionClassToEnum(detectionClass) {
|
|
12463
12825
|
switch (detectionClass.type) {
|
|
@@ -12528,17 +12890,264 @@ function isClaudeProductLabel(displayName) {
|
|
|
12528
12890
|
const d = displayName.trim();
|
|
12529
12891
|
return d === CLAUDE_CANONICAL_DISPLAY || CLAUDE_DEPRECATED_TWIN.test(d);
|
|
12530
12892
|
}
|
|
12531
|
-
function
|
|
12893
|
+
function hasClaudeCodeToken(userAgent) {
|
|
12532
12894
|
const ua = (userAgent ?? "").toLowerCase();
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12895
|
+
return ua.includes("claude-code") || ua.includes("claude code");
|
|
12896
|
+
}
|
|
12897
|
+
function hasClaudeUserToken(userAgent) {
|
|
12898
|
+
return (userAgent ?? "").toLowerCase().includes("claude-user");
|
|
12899
|
+
}
|
|
12900
|
+
function hasClaudeSearchBotToken(userAgent) {
|
|
12901
|
+
return (userAgent ?? "").toLowerCase().includes("claude-searchbot");
|
|
12902
|
+
}
|
|
12903
|
+
function claudeRuntimeLabel(userAgent, runtimeSurface) {
|
|
12904
|
+
const ua = (userAgent ?? "").toLowerCase();
|
|
12905
|
+
if (ua) {
|
|
12906
|
+
const hasClaudeCode = hasClaudeCodeToken(ua);
|
|
12907
|
+
const hasClaudeUser = hasClaudeUserToken(ua);
|
|
12908
|
+
if (hasClaudeCode && hasClaudeUser) return "Claude Code (web fetch)";
|
|
12909
|
+
if (hasClaudeCode) return "Claude Code";
|
|
12910
|
+
if (ua.includes("claude-cowork")) return "Claude Cowork";
|
|
12911
|
+
if (hasClaudeSearchBotToken(ua)) return "Claude SearchBot";
|
|
12912
|
+
if (hasClaudeUser) return "Claude (web fetch)";
|
|
12913
|
+
}
|
|
12914
|
+
if (runtimeSurface === "cli") {
|
|
12915
|
+
if (ua.startsWith("curl/")) return "Claude Code (curl)";
|
|
12916
|
+
if (ua.startsWith("wget/")) return "Claude Code (wget)";
|
|
12917
|
+
return "Claude Code";
|
|
12918
|
+
}
|
|
12919
|
+
if (runtimeSurface === "native_app") return "Claude Desktop";
|
|
12920
|
+
if (runtimeSurface === "browser") return "Claude (browser)";
|
|
12538
12921
|
return "Claude";
|
|
12539
12922
|
}
|
|
12540
|
-
function refineClaudeDisplayLabel(displayName, userAgent) {
|
|
12541
|
-
return isClaudeProductLabel(displayName) ? claudeRuntimeLabel(userAgent) : displayName;
|
|
12923
|
+
function refineClaudeDisplayLabel(displayName, userAgent, runtimeSurface) {
|
|
12924
|
+
return isClaudeProductLabel(displayName) ? claudeRuntimeLabel(userAgent, runtimeSurface) : displayName;
|
|
12925
|
+
}
|
|
12926
|
+
function refineSessionGrainClaudeLabel(displayName, runtimeSurface) {
|
|
12927
|
+
return refineClaudeDisplayLabel(displayName, null, runtimeSurface);
|
|
12928
|
+
}
|
|
12929
|
+
|
|
12930
|
+
// src/utils/client-ip.ts
|
|
12931
|
+
var MAX_INPUT_LENGTH = 4096;
|
|
12932
|
+
var MAX_TOKEN_LENGTH = 128;
|
|
12933
|
+
var MAX_FORWARDED_HOPS = 32;
|
|
12934
|
+
function hasControlCharacter(value) {
|
|
12935
|
+
for (let i = 0; i < value.length; i++) {
|
|
12936
|
+
const code = value.charCodeAt(i);
|
|
12937
|
+
if (code <= 31 || code === 127) return true;
|
|
12938
|
+
}
|
|
12939
|
+
return false;
|
|
12940
|
+
}
|
|
12941
|
+
function parsePort(value) {
|
|
12942
|
+
return /^(?:0|[1-9]\d{0,4})$/.test(value) && Number(value) <= 65535;
|
|
12943
|
+
}
|
|
12944
|
+
function parseIpv4(value) {
|
|
12945
|
+
const parts = value.split(".");
|
|
12946
|
+
if (parts.length !== 4) return null;
|
|
12947
|
+
const octets = [];
|
|
12948
|
+
for (const part of parts) {
|
|
12949
|
+
if (!/^\d{1,3}$/.test(part)) return null;
|
|
12950
|
+
const octet = Number(part);
|
|
12951
|
+
if (octet > 255) return null;
|
|
12952
|
+
octets.push(octet);
|
|
12953
|
+
}
|
|
12954
|
+
return octets;
|
|
12955
|
+
}
|
|
12956
|
+
function parseHexGroup(value) {
|
|
12957
|
+
if (!/^[0-9a-fA-F]{1,4}$/.test(value)) return null;
|
|
12958
|
+
return Number.parseInt(value, 16);
|
|
12959
|
+
}
|
|
12960
|
+
function parseIpv6(value) {
|
|
12961
|
+
if (!value || value.includes("%") || hasControlCharacter(value)) return null;
|
|
12962
|
+
let address = value;
|
|
12963
|
+
if (address.includes(".")) {
|
|
12964
|
+
const lastColon = address.lastIndexOf(":");
|
|
12965
|
+
if (lastColon < 0) return null;
|
|
12966
|
+
const ipv4 = parseIpv4(address.slice(lastColon + 1));
|
|
12967
|
+
if (!ipv4) return null;
|
|
12968
|
+
const first = ipv4[0] << 8 | ipv4[1];
|
|
12969
|
+
const second = ipv4[2] << 8 | ipv4[3];
|
|
12970
|
+
address = `${address.slice(0, lastColon + 1)}${first.toString(16)}:${second.toString(16)}`;
|
|
12971
|
+
}
|
|
12972
|
+
const doubleColon = address.indexOf("::");
|
|
12973
|
+
if (doubleColon !== address.lastIndexOf("::")) return null;
|
|
12974
|
+
const parseGroups = (part) => {
|
|
12975
|
+
if (!part) return [];
|
|
12976
|
+
const groups2 = part.split(":");
|
|
12977
|
+
const parsed = [];
|
|
12978
|
+
for (const group of groups2) {
|
|
12979
|
+
const number = parseHexGroup(group);
|
|
12980
|
+
if (number === null) return null;
|
|
12981
|
+
parsed.push(number);
|
|
12982
|
+
}
|
|
12983
|
+
return parsed;
|
|
12984
|
+
};
|
|
12985
|
+
if (doubleColon >= 0) {
|
|
12986
|
+
const head = parseGroups(address.slice(0, doubleColon));
|
|
12987
|
+
const tail = parseGroups(address.slice(doubleColon + 2));
|
|
12988
|
+
if (!head || !tail) return null;
|
|
12989
|
+
const missing = 8 - head.length - tail.length;
|
|
12990
|
+
if (missing < 1) return null;
|
|
12991
|
+
return [...head, ...Array(missing).fill(0), ...tail];
|
|
12992
|
+
}
|
|
12993
|
+
const groups = parseGroups(address);
|
|
12994
|
+
return groups?.length === 8 ? groups : null;
|
|
12995
|
+
}
|
|
12996
|
+
function compressIpv6(groups) {
|
|
12997
|
+
const rendered = groups.map((group) => group.toString(16));
|
|
12998
|
+
let bestStart = -1;
|
|
12999
|
+
let bestLength = 1;
|
|
13000
|
+
let runStart = -1;
|
|
13001
|
+
for (let index = 0; index <= groups.length; index += 1) {
|
|
13002
|
+
if (index < groups.length && groups[index] === 0) {
|
|
13003
|
+
if (runStart < 0) runStart = index;
|
|
13004
|
+
continue;
|
|
13005
|
+
}
|
|
13006
|
+
if (runStart >= 0) {
|
|
13007
|
+
const runLength = index - runStart;
|
|
13008
|
+
if (runLength > bestLength) {
|
|
13009
|
+
bestStart = runStart;
|
|
13010
|
+
bestLength = runLength;
|
|
13011
|
+
}
|
|
13012
|
+
runStart = -1;
|
|
13013
|
+
}
|
|
13014
|
+
}
|
|
13015
|
+
if (bestStart < 0) return rendered.join(":");
|
|
13016
|
+
const before = rendered.slice(0, bestStart).join(":");
|
|
13017
|
+
const after = rendered.slice(bestStart + bestLength).join(":");
|
|
13018
|
+
if (!before && !after) return "::";
|
|
13019
|
+
if (!before) return `::${after}`;
|
|
13020
|
+
if (!after) return `${before}::`;
|
|
13021
|
+
return `${before}::${after}`;
|
|
13022
|
+
}
|
|
13023
|
+
function normalizeToken(rawToken) {
|
|
13024
|
+
const token = rawToken.trim();
|
|
13025
|
+
if (!token || token.length > MAX_TOKEN_LENGTH || hasControlCharacter(token)) return null;
|
|
13026
|
+
let address = token;
|
|
13027
|
+
if (token.startsWith("[")) {
|
|
13028
|
+
const closing = token.indexOf("]");
|
|
13029
|
+
if (closing <= 1) return null;
|
|
13030
|
+
const suffix = token.slice(closing + 1);
|
|
13031
|
+
if (suffix && (!suffix.startsWith(":") || !parsePort(suffix.slice(1)))) return null;
|
|
13032
|
+
address = token.slice(1, closing);
|
|
13033
|
+
} else if ((token.match(/:/g) ?? []).length === 1 && token.includes(".")) {
|
|
13034
|
+
const colon = token.indexOf(":");
|
|
13035
|
+
if (!parsePort(token.slice(colon + 1))) return null;
|
|
13036
|
+
address = token.slice(0, colon);
|
|
13037
|
+
}
|
|
13038
|
+
const ipv4 = parseIpv4(address);
|
|
13039
|
+
if (ipv4) return ipv4.join(".");
|
|
13040
|
+
const ipv6 = parseIpv6(address);
|
|
13041
|
+
return ipv6 ? compressIpv6(ipv6) : null;
|
|
13042
|
+
}
|
|
13043
|
+
function boundedTokens(raw) {
|
|
13044
|
+
if (raw == null || !raw || raw.length > MAX_INPUT_LENGTH || hasControlCharacter(raw)) return null;
|
|
13045
|
+
const tokens = raw.split(",");
|
|
13046
|
+
if (tokens.length > MAX_FORWARDED_HOPS) return null;
|
|
13047
|
+
return tokens;
|
|
13048
|
+
}
|
|
13049
|
+
function normalizeClientIp(raw) {
|
|
13050
|
+
const tokens = boundedTokens(raw);
|
|
13051
|
+
if (!tokens) return null;
|
|
13052
|
+
for (const token of tokens) {
|
|
13053
|
+
const normalized = normalizeToken(token);
|
|
13054
|
+
if (normalized) return normalized;
|
|
13055
|
+
}
|
|
13056
|
+
return null;
|
|
13057
|
+
}
|
|
13058
|
+
function getHeader(headers, name) {
|
|
13059
|
+
if ("get" in headers && typeof headers.get === "function") {
|
|
13060
|
+
return headers.get(name) ?? void 0;
|
|
13061
|
+
}
|
|
13062
|
+
const wanted = name.toLowerCase();
|
|
13063
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
13064
|
+
if (key.toLowerCase() !== wanted || value === void 0) continue;
|
|
13065
|
+
return Array.isArray(value) ? value.join(",") : value;
|
|
13066
|
+
}
|
|
13067
|
+
return void 0;
|
|
13068
|
+
}
|
|
13069
|
+
function result(ip, source, trusted) {
|
|
13070
|
+
return ip ? { ip, source, trusted } : null;
|
|
13071
|
+
}
|
|
13072
|
+
function resolveAddress(raw, source) {
|
|
13073
|
+
return result(normalizeClientIp(raw), source, true);
|
|
13074
|
+
}
|
|
13075
|
+
function resolveExplicit(input) {
|
|
13076
|
+
if (input.explicitAddressTrusted !== true) return null;
|
|
13077
|
+
return result(normalizeClientIp(input.explicitAddress), "explicit", true);
|
|
13078
|
+
}
|
|
13079
|
+
function resolveVercel(input) {
|
|
13080
|
+
const platform = result(
|
|
13081
|
+
normalizeClientIp(getHeader(input.headers, "x-vercel-forwarded-for")),
|
|
13082
|
+
"x-vercel-forwarded-for",
|
|
13083
|
+
true
|
|
13084
|
+
);
|
|
13085
|
+
if (platform) return platform;
|
|
13086
|
+
const overwrittenXff = result(
|
|
13087
|
+
normalizeClientIp(getHeader(input.headers, "x-forwarded-for")),
|
|
13088
|
+
"x-forwarded-for",
|
|
13089
|
+
true
|
|
13090
|
+
);
|
|
13091
|
+
if (overwrittenXff) return overwrittenXff;
|
|
13092
|
+
const realIp = result(
|
|
13093
|
+
normalizeClientIp(getHeader(input.headers, "x-real-ip")),
|
|
13094
|
+
"x-real-ip",
|
|
13095
|
+
false
|
|
13096
|
+
);
|
|
13097
|
+
if (realIp) return realIp;
|
|
13098
|
+
return resolveAddress(input.frameworkAddress, "framework") ?? resolveAddress(input.directAddress, "socket") ?? { ip: null, source: "none", trusted: false };
|
|
13099
|
+
}
|
|
13100
|
+
function resolveCloudflare(input) {
|
|
13101
|
+
const cloudflare = result(
|
|
13102
|
+
normalizeClientIp(getHeader(input.headers, "cf-connecting-ip")),
|
|
13103
|
+
"cf-connecting-ip",
|
|
13104
|
+
true
|
|
13105
|
+
);
|
|
13106
|
+
if (cloudflare) return cloudflare;
|
|
13107
|
+
return resolveAddress(input.directAddress, "socket") ?? resolveAddress(input.frameworkAddress, "framework") ?? result(
|
|
13108
|
+
normalizeClientIp(getHeader(input.headers, "x-forwarded-for")),
|
|
13109
|
+
"x-forwarded-for",
|
|
13110
|
+
false
|
|
13111
|
+
) ?? result(normalizeClientIp(getHeader(input.headers, "x-real-ip")), "x-real-ip", false) ?? {
|
|
13112
|
+
ip: null,
|
|
13113
|
+
source: "none",
|
|
13114
|
+
trusted: false
|
|
13115
|
+
};
|
|
13116
|
+
}
|
|
13117
|
+
function resolveTrustedProxy(input, trustedHops) {
|
|
13118
|
+
const raw = getHeader(input.headers, "x-forwarded-for");
|
|
13119
|
+
const tokens = boundedTokens(raw);
|
|
13120
|
+
if (tokens && Number.isInteger(trustedHops) && trustedHops > 0 && tokens.length > trustedHops) {
|
|
13121
|
+
const parsed = tokens.map(normalizeToken);
|
|
13122
|
+
const selectedIndex = tokens.length - trustedHops - 1;
|
|
13123
|
+
const selected = parsed[selectedIndex];
|
|
13124
|
+
if (selected && parsed.every((token) => token !== null)) {
|
|
13125
|
+
return { ip: selected, source: "x-forwarded-for", trusted: true };
|
|
13126
|
+
}
|
|
13127
|
+
}
|
|
13128
|
+
return resolveAddress(input.frameworkAddress, "framework") ?? resolveAddress(input.directAddress, "socket") ?? result(normalizeClientIp(getHeader(input.headers, "x-real-ip")), "x-real-ip", false) ?? {
|
|
13129
|
+
ip: null,
|
|
13130
|
+
source: "none",
|
|
13131
|
+
trusted: false
|
|
13132
|
+
};
|
|
13133
|
+
}
|
|
13134
|
+
function resolveClientIp(input) {
|
|
13135
|
+
const explicit = resolveExplicit(input);
|
|
13136
|
+
if (explicit) return explicit;
|
|
13137
|
+
switch (input.policy.platform) {
|
|
13138
|
+
case "vercel":
|
|
13139
|
+
return resolveVercel(input);
|
|
13140
|
+
case "cloudflare":
|
|
13141
|
+
return resolveCloudflare(input);
|
|
13142
|
+
case "trusted-proxy":
|
|
13143
|
+
return resolveTrustedProxy(input, input.policy.trustedHops);
|
|
13144
|
+
case "direct":
|
|
13145
|
+
return resolveAddress(input.frameworkAddress, "framework") ?? resolveAddress(input.directAddress, "socket") ?? {
|
|
13146
|
+
ip: null,
|
|
13147
|
+
source: "none",
|
|
13148
|
+
trusted: false
|
|
13149
|
+
};
|
|
13150
|
+
}
|
|
12542
13151
|
}
|
|
12543
13152
|
|
|
12544
13153
|
// src/utils/correlation-id.ts
|
|
@@ -12546,7 +13155,7 @@ var CORRELATION_ID_HEADER = "x-kya-correlation-id";
|
|
|
12546
13155
|
var CorrelationIdSchema = external_exports.string().regex(/^[0-9a-f]{32}$/);
|
|
12547
13156
|
var TRACEPARENT_RE = /^(?<ver>[0-9a-f]{2})-(?<trace>[0-9a-f]{32})-(?<span>[0-9a-f]{16})-(?<flags>[0-9a-f]{2})$/;
|
|
12548
13157
|
var ZERO_TRACE_ID = "0".repeat(32);
|
|
12549
|
-
function
|
|
13158
|
+
function getHeader2(headers, name) {
|
|
12550
13159
|
const lower = name.toLowerCase();
|
|
12551
13160
|
if (typeof headers.get === "function") {
|
|
12552
13161
|
const value = headers.get(lower);
|
|
@@ -12578,9 +13187,9 @@ function toStoredCorrelationId(value) {
|
|
|
12578
13187
|
return normalizeHex(value);
|
|
12579
13188
|
}
|
|
12580
13189
|
function extractCorrelationIdFromHeaders(headers) {
|
|
12581
|
-
const fromTrace = extractTraceId(
|
|
13190
|
+
const fromTrace = extractTraceId(getHeader2(headers, "traceparent"));
|
|
12582
13191
|
if (fromTrace) return fromTrace;
|
|
12583
|
-
return normalizeHex(
|
|
13192
|
+
return normalizeHex(getHeader2(headers, CORRELATION_ID_HEADER));
|
|
12584
13193
|
}
|
|
12585
13194
|
function deriveCorrelationId(headers, fallback) {
|
|
12586
13195
|
const fromHeaders = extractCorrelationIdFromHeaders(headers);
|
|
@@ -12716,7 +13325,7 @@ var discoveredToolSchema = external_exports.object({
|
|
|
12716
13325
|
* Schema draft here. The Tool Testing Panel renders a
|
|
12717
13326
|
* skeleton from whatever it gets.
|
|
12718
13327
|
*/
|
|
12719
|
-
inputSchema: external_exports.record(external_exports.unknown()).optional()
|
|
13328
|
+
inputSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
12720
13329
|
}).strict();
|
|
12721
13330
|
var upstreamDiscoveryErrorSchema = external_exports.object({
|
|
12722
13331
|
code: external_exports.enum([
|
|
@@ -12737,7 +13346,7 @@ var upstreamDiscoveryErrorSchema = external_exports.object({
|
|
|
12737
13346
|
}).strict();
|
|
12738
13347
|
var gatewayInternalToolsListSchema = external_exports.object({
|
|
12739
13348
|
totalCount: external_exports.number().int().min(0),
|
|
12740
|
-
upstreamCounts: external_exports.record(external_exports.number().int().min(0)),
|
|
13349
|
+
upstreamCounts: external_exports.record(external_exports.string(), external_exports.number().int().min(0)),
|
|
12741
13350
|
tools: external_exports.array(discoveredToolSchema),
|
|
12742
13351
|
/**
|
|
12743
13352
|
* Sparse map keyed by upstream slug. Empty / absent when every
|
|
@@ -12745,7 +13354,7 @@ var gatewayInternalToolsListSchema = external_exports.object({
|
|
|
12745
13354
|
* when serialized — always-object keeps the shape stable for
|
|
12746
13355
|
* consumers that read `Object.keys(errors).length`.
|
|
12747
13356
|
*/
|
|
12748
|
-
errors: external_exports.record(upstreamDiscoveryErrorSchema)
|
|
13357
|
+
errors: external_exports.record(external_exports.string(), upstreamDiscoveryErrorSchema)
|
|
12749
13358
|
}).strict();
|
|
12750
13359
|
var gatewayInternalDiscoverSuccessSchema = external_exports.object({
|
|
12751
13360
|
tools: external_exports.array(discoveredToolSchema)
|
|
@@ -12888,7 +13497,7 @@ var upstreamServerSchema = external_exports.object({
|
|
|
12888
13497
|
// `staticHeadersEncrypted` before persisting and opportunistically
|
|
12889
13498
|
// migrates any legacy plaintext it finds on every save that touches
|
|
12890
13499
|
// an upstream). Never populated in an API response.
|
|
12891
|
-
staticHeaders: external_exports.record(external_exports.string()).optional(),
|
|
13500
|
+
staticHeaders: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
12892
13501
|
// AES-256-GCM ciphertext (base64: iv|ciphertext|authTag) of the
|
|
12893
13502
|
// JSON-serialized staticHeaders map — the at-rest form going
|
|
12894
13503
|
// forward. Encrypt/decrypt via `@kya-os/checkpoint-db/crypto`'s
|
|
@@ -13032,7 +13641,7 @@ var DEFAULT_EXTERNAL_ACCESS = {
|
|
|
13032
13641
|
var gatewayConfigSchema = external_exports.object({
|
|
13033
13642
|
enabled: external_exports.boolean().default(false),
|
|
13034
13643
|
upstreamServers: external_exports.array(upstreamServerSchema).default([]),
|
|
13035
|
-
roleScopes: external_exports.record(external_exports.array(external_exports.string())).optional(),
|
|
13644
|
+
roleScopes: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).optional(),
|
|
13036
13645
|
oauthClients: external_exports.array(oauthClientSchema).default([]),
|
|
13037
13646
|
rateLimits: external_exports.object({
|
|
13038
13647
|
toolCallsPerMinute: external_exports.number().int().positive().default(DEFAULT_RATE_LIMITS.toolCallsPerMinute)
|
|
@@ -13040,7 +13649,7 @@ var gatewayConfigSchema = external_exports.object({
|
|
|
13040
13649
|
externalAccess: external_exports.object({
|
|
13041
13650
|
enabled: external_exports.boolean().default(DEFAULT_EXTERNAL_ACCESS.enabled),
|
|
13042
13651
|
allowedDids: external_exports.array(external_exports.string()).default(DEFAULT_EXTERNAL_ACCESS.allowedDids),
|
|
13043
|
-
externalScopes: external_exports.record(external_exports.array(external_exports.string())).default(DEFAULT_EXTERNAL_ACCESS.externalScopes)
|
|
13652
|
+
externalScopes: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default(DEFAULT_EXTERNAL_ACCESS.externalScopes)
|
|
13044
13653
|
}).default(DEFAULT_EXTERNAL_ACCESS),
|
|
13045
13654
|
// T6 #2899 M2 — per-org fleet-server endpoint. When set, the gateway's
|
|
13046
13655
|
// DiscoveryUpstreamProvider injects a synthetic `fleet` upstream so
|
|
@@ -13098,11 +13707,11 @@ var gatewayConnectionsSummarySchema = external_exports.object({
|
|
|
13098
13707
|
|
|
13099
13708
|
// src/schemas/index.ts
|
|
13100
13709
|
function validate(schema, data) {
|
|
13101
|
-
const
|
|
13102
|
-
if (
|
|
13103
|
-
return { success: true, data:
|
|
13710
|
+
const result2 = schema.safeParse(data);
|
|
13711
|
+
if (result2.success) {
|
|
13712
|
+
return { success: true, data: result2.data };
|
|
13104
13713
|
}
|
|
13105
|
-
return { success: false, error:
|
|
13714
|
+
return { success: false, error: result2.error };
|
|
13106
13715
|
}
|
|
13107
13716
|
function validateOrThrow(schema, data) {
|
|
13108
13717
|
return schema.parse(data);
|
|
@@ -13253,7 +13862,7 @@ var BehavioralThresholdSchema = external_exports.object({
|
|
|
13253
13862
|
var BehavioralPatternSchema = external_exports.object({
|
|
13254
13863
|
name: external_exports.string().min(1),
|
|
13255
13864
|
type: external_exports.enum(["rapid_requests", "no_interaction", "perfect_scrolling", "sequential_access"]),
|
|
13256
|
-
config: external_exports.record(external_exports.any()),
|
|
13865
|
+
config: external_exports.record(external_exports.string(), external_exports.any()),
|
|
13257
13866
|
confidenceModifier: external_exports.number().min(-1).max(1)
|
|
13258
13867
|
});
|
|
13259
13868
|
var BehavioralRulesSchema = external_exports.object({
|
|
@@ -13276,13 +13885,13 @@ var HeaderRulesSchema = external_exports.object({
|
|
|
13276
13885
|
var IpRangeCollectionSchema = external_exports.union([
|
|
13277
13886
|
// Old structure with providers
|
|
13278
13887
|
external_exports.object({
|
|
13279
|
-
providers: external_exports.record(IpRangeRuleSchema),
|
|
13888
|
+
providers: external_exports.record(external_exports.string(), IpRangeRuleSchema),
|
|
13280
13889
|
updateUrl: external_exports.string().url().optional(),
|
|
13281
13890
|
updateFrequency: external_exports.enum(["hourly", "daily", "weekly", "monthly"]).optional(),
|
|
13282
13891
|
cacheDuration: external_exports.number().min(0).optional()
|
|
13283
13892
|
}),
|
|
13284
13893
|
// New merged structure - IP ranges directly as properties
|
|
13285
|
-
external_exports.record(IpRangeRuleSchema).refine(
|
|
13894
|
+
external_exports.record(external_exports.string(), IpRangeRuleSchema).refine(
|
|
13286
13895
|
(val) => {
|
|
13287
13896
|
return Object.values(val).some(
|
|
13288
13897
|
(v) => v && typeof v === "object" && "ranges" in v && Array.isArray(v.ranges)
|
|
@@ -13301,9 +13910,9 @@ var DetectionRulesSchema = external_exports.object({
|
|
|
13301
13910
|
source: external_exports.string().optional()
|
|
13302
13911
|
}).optional(),
|
|
13303
13912
|
rules: external_exports.object({
|
|
13304
|
-
userAgents: external_exports.record(UserAgentRuleSchema),
|
|
13913
|
+
userAgents: external_exports.record(external_exports.string(), UserAgentRuleSchema),
|
|
13305
13914
|
ipRanges: IpRangeCollectionSchema,
|
|
13306
|
-
signatures: external_exports.record(SignatureRuleSchema),
|
|
13915
|
+
signatures: external_exports.record(external_exports.string(), SignatureRuleSchema),
|
|
13307
13916
|
behavioral: BehavioralRulesSchema,
|
|
13308
13917
|
headers: HeaderRulesSchema
|
|
13309
13918
|
})
|
|
@@ -13345,7 +13954,7 @@ var RuleMatchResultSchema = external_exports.object({
|
|
|
13345
13954
|
rule: external_exports.string().optional(),
|
|
13346
13955
|
category: external_exports.enum(["userAgent", "ipRange", "signature", "behavioral", "header"]).optional(),
|
|
13347
13956
|
confidence: external_exports.number().min(0).max(1).optional(),
|
|
13348
|
-
details: external_exports.record(external_exports.any()).optional()
|
|
13957
|
+
details: external_exports.record(external_exports.string(), external_exports.any()).optional()
|
|
13349
13958
|
});
|
|
13350
13959
|
function validateRules(rules) {
|
|
13351
13960
|
try {
|
|
@@ -13355,7 +13964,7 @@ function validateRules(rules) {
|
|
|
13355
13964
|
if (error instanceof external_exports.ZodError) {
|
|
13356
13965
|
return {
|
|
13357
13966
|
valid: false,
|
|
13358
|
-
errors: error.
|
|
13967
|
+
errors: error.issues.map((e) => ({
|
|
13359
13968
|
path: e.path.join("."),
|
|
13360
13969
|
message: e.message,
|
|
13361
13970
|
type: e.code
|
|
@@ -13385,7 +13994,7 @@ function validateRulesLoose(rules) {
|
|
|
13385
13994
|
if (error instanceof external_exports.ZodError) {
|
|
13386
13995
|
return {
|
|
13387
13996
|
valid: false,
|
|
13388
|
-
errors: error.
|
|
13997
|
+
errors: error.issues.map((e) => ({
|
|
13389
13998
|
path: e.path.join("."),
|
|
13390
13999
|
message: e.message,
|
|
13391
14000
|
type: e.code
|
|
@@ -13426,9 +14035,9 @@ var RuleValidator = class {
|
|
|
13426
14035
|
* Validate and throw on error
|
|
13427
14036
|
*/
|
|
13428
14037
|
static validateOrThrow(rules, mode = "strict") {
|
|
13429
|
-
const
|
|
13430
|
-
if (!
|
|
13431
|
-
const errors =
|
|
14038
|
+
const result2 = this.validate(rules, mode);
|
|
14039
|
+
if (!result2.valid) {
|
|
14040
|
+
const errors = result2.errors?.map((e) => `${e.path}: ${e.message}`).join(", ");
|
|
13432
14041
|
throw new Error(`${RULE_ERRORS.VALIDATION_FAILED}: ${errors}`);
|
|
13433
14042
|
}
|
|
13434
14043
|
return rules;
|
|
@@ -13441,7 +14050,7 @@ var RuleValidator = class {
|
|
|
13441
14050
|
return DetectionRulesSchema.parse(rules);
|
|
13442
14051
|
} catch (error) {
|
|
13443
14052
|
if (error instanceof external_exports.ZodError) {
|
|
13444
|
-
const errors = error.
|
|
14053
|
+
const errors = error.issues.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ");
|
|
13445
14054
|
throw new Error(`${RULE_ERRORS.VALIDATION_FAILED}: ${errors}`);
|
|
13446
14055
|
}
|
|
13447
14056
|
throw error;
|
|
@@ -13499,18 +14108,18 @@ var RuleValidator = class {
|
|
|
13499
14108
|
/**
|
|
13500
14109
|
* Get validation errors as formatted string
|
|
13501
14110
|
*/
|
|
13502
|
-
static formatErrors(
|
|
13503
|
-
if (
|
|
14111
|
+
static formatErrors(result2) {
|
|
14112
|
+
if (result2.valid) {
|
|
13504
14113
|
return "";
|
|
13505
14114
|
}
|
|
13506
|
-
const errors =
|
|
14115
|
+
const errors = result2.errors || [];
|
|
13507
14116
|
return errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n");
|
|
13508
14117
|
}
|
|
13509
14118
|
/**
|
|
13510
14119
|
* Get validation warnings as formatted string
|
|
13511
14120
|
*/
|
|
13512
|
-
static formatWarnings(
|
|
13513
|
-
const warnings =
|
|
14121
|
+
static formatWarnings(result2) {
|
|
14122
|
+
const warnings = result2.warnings || [];
|
|
13514
14123
|
return warnings.map((w) => ` - ${w.path}: ${w.message}`).join("\n");
|
|
13515
14124
|
}
|
|
13516
14125
|
};
|
|
@@ -14250,8 +14859,8 @@ function parsePolicyConfig(data) {
|
|
|
14250
14859
|
return PolicyConfigSchema.parse(data);
|
|
14251
14860
|
}
|
|
14252
14861
|
function safeParsePolicyConfig(data) {
|
|
14253
|
-
const
|
|
14254
|
-
return
|
|
14862
|
+
const result2 = PolicyConfigSchema.safeParse(data);
|
|
14863
|
+
return result2.success ? result2.data : null;
|
|
14255
14864
|
}
|
|
14256
14865
|
function parseEvaluationContext(data) {
|
|
14257
14866
|
return PolicyEvaluationContextSchema.parse(data);
|
|
@@ -15495,7 +16104,7 @@ var vaultResolveMetaSchema = external_exports.object({
|
|
|
15495
16104
|
upstreamSlug: external_exports.string().optional()
|
|
15496
16105
|
}).strict();
|
|
15497
16106
|
var vaultResolveDataSchema = external_exports.object({
|
|
15498
|
-
secrets: external_exports.record(external_exports.string()),
|
|
16107
|
+
secrets: external_exports.record(external_exports.string(), external_exports.string()),
|
|
15499
16108
|
_meta: vaultResolveMetaSchema.optional()
|
|
15500
16109
|
}).strict();
|
|
15501
16110
|
var vaultResolveSuccessSchema = external_exports.object({
|
|
@@ -15634,9 +16243,20 @@ var ReportedPrincipalSchema = external_exports.object({
|
|
|
15634
16243
|
}).describe("Asserted identity of the principal the agent acted for");
|
|
15635
16244
|
var DelegationResultSchema = external_exports.enum(["verified", "failed", "not_presented"]);
|
|
15636
16245
|
var DelegationVerifiedBySchema = external_exports.enum(["reporter", "gateway", "checkpoint"]);
|
|
16246
|
+
var REGISTERED_SID_MAX_LENGTH = 100;
|
|
16247
|
+
var SID_ATTRIBUTABLE_RESULT = "verified";
|
|
15637
16248
|
var ReportedDelegationSchema = external_exports.object({
|
|
15638
16249
|
/** Delegation credential id — the join key into `delegations`. */
|
|
15639
16250
|
jti: NonEmptyTrimmed.optional(),
|
|
16251
|
+
/**
|
|
16252
|
+
* The registered session anchor: the draft-kya-http-02 `sid` claim of the
|
|
16253
|
+
* presented credential (the top-level VC-JWT `sid` minted in
|
|
16254
|
+
* `mint-vc-jwt.ts`), distinct from any gateway or MCP session id. Optional,
|
|
16255
|
+
* and attributed to a session timeline only when `result` is `verified`
|
|
16256
|
+
* ({@link SID_ATTRIBUTABLE_RESULT}); ingest nulls it for any other result.
|
|
16257
|
+
* No refine here: the identity block must never fail a request.
|
|
16258
|
+
*/
|
|
16259
|
+
sid: NonEmptyTrimmed.max(REGISTERED_SID_MAX_LENGTH).optional(),
|
|
15640
16260
|
/** Issuer DID (usually the principal). */
|
|
15641
16261
|
iss: DidStringSchema2.optional(),
|
|
15642
16262
|
/** Audience DID (the intended verifier / resource). */
|
|
@@ -15885,14 +16505,14 @@ function parseJafarFeed(json) {
|
|
|
15885
16505
|
} catch (err) {
|
|
15886
16506
|
throw new JafarParseError("JAFAR feed is not valid JSON", err);
|
|
15887
16507
|
}
|
|
15888
|
-
const
|
|
15889
|
-
if (!
|
|
16508
|
+
const result2 = jafarFeedSchema.safeParse(raw);
|
|
16509
|
+
if (!result2.success) {
|
|
15890
16510
|
throw new JafarParseError(
|
|
15891
|
-
`JAFAR feed failed schema validation: ${
|
|
15892
|
-
|
|
16511
|
+
`JAFAR feed failed schema validation: ${result2.error.message}`,
|
|
16512
|
+
result2.error
|
|
15893
16513
|
);
|
|
15894
16514
|
}
|
|
15895
|
-
return
|
|
16515
|
+
return result2.data;
|
|
15896
16516
|
}
|
|
15897
16517
|
|
|
15898
16518
|
// src/index.ts
|
|
@@ -15938,6 +16558,7 @@ exports.ADMIN_OVERVIEW_LIST_LIMIT_DEFAULT = ADMIN_OVERVIEW_LIST_LIMIT_DEFAULT;
|
|
|
15938
16558
|
exports.ADMIN_OVERVIEW_LIST_LIMIT_MAX = ADMIN_OVERVIEW_LIST_LIMIT_MAX;
|
|
15939
16559
|
exports.ADMIN_OVERVIEW_SECTIONS = ADMIN_OVERVIEW_SECTIONS;
|
|
15940
16560
|
exports.ADMIN_OVERVIEW_WINDOWS = ADMIN_OVERVIEW_WINDOWS;
|
|
16561
|
+
exports.AGENT_CATEGORY_META = AGENT_CATEGORY_META;
|
|
15941
16562
|
exports.AI_AGENT_HEADERS = AI_AGENT_HEADERS;
|
|
15942
16563
|
exports.ANONYMOUS_PRINCIPAL_DID = ANONYMOUS_PRINCIPAL_DID;
|
|
15943
16564
|
exports.API_ERRORS = API_ERRORS;
|
|
@@ -15991,8 +16612,10 @@ exports.ApiResponseSchema = ApiResponseSchema;
|
|
|
15991
16612
|
exports.AssuranceTierSchema = AssuranceTierSchema;
|
|
15992
16613
|
exports.AuthErrorType = AuthErrorType;
|
|
15993
16614
|
exports.AuthProviderTypeSchema = AuthProviderTypeSchema;
|
|
16615
|
+
exports.BARE_ERRORS = BARE_ERRORS;
|
|
15994
16616
|
exports.BASELINE_ALLOW_POLICY_ID = BASELINE_ALLOW_POLICY_ID;
|
|
15995
16617
|
exports.BESPOKE_POLICY_IDS = BESPOKE_POLICY_IDS;
|
|
16618
|
+
exports.BILLING_ERRORS = BILLING_ERRORS;
|
|
15996
16619
|
exports.BLOCKED_PATH = BLOCKED_PATH;
|
|
15997
16620
|
exports.BOT_USER_AGENT_PATTERNS = BOT_USER_AGENT_PATTERNS;
|
|
15998
16621
|
exports.BROWSER_PATTERNS = BROWSER_PATTERNS;
|
|
@@ -16104,6 +16727,7 @@ exports.DELEGATION_PROOF_HEADERS = DELEGATION_PROOF_HEADERS;
|
|
|
16104
16727
|
exports.DEPLOY_STEPS = DEPLOY_STEPS;
|
|
16105
16728
|
exports.DETECTION_ERRORS = DETECTION_ERRORS;
|
|
16106
16729
|
exports.DETECTION_LIMITS = DETECTION_LIMITS;
|
|
16730
|
+
exports.DETECTION_REASON_CODES = DETECTION_REASON_CODES;
|
|
16107
16731
|
exports.DashboardStatsRequestSchema = DashboardStatsRequestSchema;
|
|
16108
16732
|
exports.DatabaseDetectionMetadataSchema = DatabaseDetectionMetadataSchema;
|
|
16109
16733
|
exports.DatabaseStatusSchema = DatabaseStatusSchema;
|
|
@@ -16129,12 +16753,14 @@ exports.DetectionLogSchema = DetectionLogSchema;
|
|
|
16129
16753
|
exports.DetectionMetadataSchema = DetectionMetadataSchema;
|
|
16130
16754
|
exports.DetectionModeSchema = DetectionModeSchema;
|
|
16131
16755
|
exports.DetectionOptionsSchema = DetectionOptionsSchema;
|
|
16756
|
+
exports.DetectionReasonCodeSchema = DetectionReasonCodeSchema;
|
|
16132
16757
|
exports.DetectionReasoningSchema = DetectionReasoningSchema;
|
|
16133
16758
|
exports.DetectionRequestSchema = DetectionRequestSchema;
|
|
16134
16759
|
exports.DetectionResponseSchema = DetectionResponseSchema;
|
|
16135
16760
|
exports.DetectionResultSchema = DetectionResultSchema;
|
|
16136
16761
|
exports.DetectionRuleSchema = DetectionRuleSchema;
|
|
16137
16762
|
exports.DetectionRulesSchema = DetectionRulesSchema;
|
|
16763
|
+
exports.DetectionSignalExposureSchema = DetectionSignalExposureSchema;
|
|
16138
16764
|
exports.DetectionSignalSchema = DetectionSignalSchema;
|
|
16139
16765
|
exports.DetectionStatusSchema = DetectionStatusSchema;
|
|
16140
16766
|
exports.DetectionTestResultSchema = DetectionTestResultSchema;
|
|
@@ -16195,12 +16821,15 @@ exports.KYA_HTTP_ERROR = KYA_HTTP_ERROR;
|
|
|
16195
16821
|
exports.KYA_OS_HANDSHAKE_METHODS = KYA_OS_HANDSHAKE_METHODS;
|
|
16196
16822
|
exports.KYA_OS_WIRE_METHODS = KYA_OS_WIRE_METHODS;
|
|
16197
16823
|
exports.KeyboardEventSchema = KeyboardEventSchema;
|
|
16824
|
+
exports.LOWERCASE_ERRORS = LOWERCASE_ERRORS;
|
|
16198
16825
|
exports.ListProvisioningOrganizationsRequestSchema = ListProvisioningOrganizationsRequestSchema;
|
|
16199
16826
|
exports.ListProvisioningOrganizationsResponseSchema = ListProvisioningOrganizationsResponseSchema;
|
|
16200
16827
|
exports.LoggingConfigSchema = LoggingConfigSchema;
|
|
16201
16828
|
exports.MATCH_ACTIONS = MATCH_ACTIONS;
|
|
16202
16829
|
exports.MAX_BULK_BATCH_SIZE = MAX_BULK_BATCH_SIZE;
|
|
16203
16830
|
exports.MAX_ED25519_KEY_BODY_LENGTH = MAX_ED25519_KEY_BODY_LENGTH;
|
|
16831
|
+
exports.MAX_REASON_CODES_HEADER_BYTES = MAX_REASON_CODES_HEADER_BYTES;
|
|
16832
|
+
exports.MAX_REASON_CODES_ON_WIRE = MAX_REASON_CODES_ON_WIRE;
|
|
16204
16833
|
exports.MCPI_ORG_DID_HOST = MCPI_ORG_DID_HOST;
|
|
16205
16834
|
exports.MCP_CLIENT_DID_HOST = MCP_CLIENT_DID_HOST;
|
|
16206
16835
|
exports.MOBILE_PATTERNS = MOBILE_PATTERNS;
|
|
@@ -16242,6 +16871,7 @@ exports.PIXEL_ERRORS = PIXEL_ERRORS;
|
|
|
16242
16871
|
exports.PIXEL_EVENT_LIMITS = PIXEL_EVENT_LIMITS;
|
|
16243
16872
|
exports.PLAN_FEATURE_LIMITS = PLAN_FEATURE_LIMITS;
|
|
16244
16873
|
exports.PLAN_RATE_LIMITS = PLAN_RATE_LIMITS;
|
|
16874
|
+
exports.POLICY_ERRORS = POLICY_ERRORS;
|
|
16245
16875
|
exports.POLICY_MATCH_TYPES = POLICY_MATCH_TYPES;
|
|
16246
16876
|
exports.PUBLIC_API_ERROR_CODES = PUBLIC_API_ERROR_CODES;
|
|
16247
16877
|
exports.PageContextSchema = PageContextSchema;
|
|
@@ -16309,8 +16939,10 @@ exports.PublishProfileRequestSchema = PublishProfileRequestSchema;
|
|
|
16309
16939
|
exports.QueryFilterSchema = QueryFilterSchema;
|
|
16310
16940
|
exports.QuerySchema = QuerySchema;
|
|
16311
16941
|
exports.RATE_LIMIT_ERRORS = RATE_LIMIT_ERRORS;
|
|
16942
|
+
exports.REGISTERED_SID_MAX_LENGTH = REGISTERED_SID_MAX_LENGTH;
|
|
16312
16943
|
exports.REPORT_AI_AGENT_NAMES = REPORT_AI_AGENT_NAMES;
|
|
16313
16944
|
exports.REPORT_AI_CRAWLER_NAMES = REPORT_AI_CRAWLER_NAMES;
|
|
16945
|
+
exports.RESOURCE_ERRORS = RESOURCE_ERRORS;
|
|
16314
16946
|
exports.RULE_CACHE = RULE_CACHE;
|
|
16315
16947
|
exports.RULE_CATEGORIES = RULE_CATEGORIES;
|
|
16316
16948
|
exports.RULE_CDN = RULE_CDN;
|
|
@@ -16349,6 +16981,7 @@ exports.SECURITY_LIMITS = SECURITY_LIMITS;
|
|
|
16349
16981
|
exports.SERVICE_TRAFFIC_KEYS = SERVICE_TRAFFIC_KEYS;
|
|
16350
16982
|
exports.SESSION_ERRORS = SESSION_ERRORS;
|
|
16351
16983
|
exports.SESSION_LIMITS = SESSION_LIMITS;
|
|
16984
|
+
exports.SID_ATTRIBUTABLE_RESULT = SID_ATTRIBUTABLE_RESULT;
|
|
16352
16985
|
exports.SLUG_REGEX = SLUG_REGEX;
|
|
16353
16986
|
exports.SUSPICIOUS_HEADERS = SUSPICIOUS_HEADERS;
|
|
16354
16987
|
exports.SUSPICIOUS_PATTERNS = SUSPICIOUS_PATTERNS;
|
|
@@ -16402,6 +17035,7 @@ exports.TransportOptionsSchema = TransportOptionsSchema;
|
|
|
16402
17035
|
exports.TransportResponseSchema = TransportResponseSchema;
|
|
16403
17036
|
exports.TransportStateSchema = TransportStateSchema;
|
|
16404
17037
|
exports.UNCALIBRATED_NOISY_OR_PRIOR = UNCALIBRATED_NOISY_OR_PRIOR;
|
|
17038
|
+
exports.UNNAMED_AGENT_LABEL = UNNAMED_AGENT_LABEL;
|
|
16405
17039
|
exports.UPDATE_FREQUENCIES = UPDATE_FREQUENCIES;
|
|
16406
17040
|
exports.USER_AGENT_PATTERNS = USER_AGENT_PATTERNS;
|
|
16407
17041
|
exports.UpdateApiKeySchema = UpdateApiKeySchema;
|
|
@@ -16510,7 +17144,10 @@ exports.fetchPolicy = fetchPolicy;
|
|
|
16510
17144
|
exports.findMatchingPattern = findMatchingPattern;
|
|
16511
17145
|
exports.findStaleVendorRanges = findStaleVendorRanges;
|
|
16512
17146
|
exports.forgotPasswordSchema = forgotPasswordSchema;
|
|
17147
|
+
exports.formatAgentCategory = formatAgentCategory;
|
|
17148
|
+
exports.formatAgentCategoryInline = formatAgentCategoryInline;
|
|
16513
17149
|
exports.formatConfidence = formatConfidence;
|
|
17150
|
+
exports.formatReasonCodesHeader = formatReasonCodesHeader;
|
|
16514
17151
|
exports.fromProviderRegistryFormat = fromProviderRegistryFormat;
|
|
16515
17152
|
exports.fromProviderRegistryFormatSafe = fromProviderRegistryFormatSafe;
|
|
16516
17153
|
exports.gatewayConfigInputSchema = gatewayConfigInputSchema;
|
|
@@ -16537,6 +17174,9 @@ exports.getStepOrder = getStepOrder;
|
|
|
16537
17174
|
exports.getVerificationMethodDescription = getVerificationMethodDescription;
|
|
16538
17175
|
exports.getVerificationReliability = getVerificationReliability;
|
|
16539
17176
|
exports.getVerificationRiskLevel = getVerificationRiskLevel;
|
|
17177
|
+
exports.hasClaudeCodeToken = hasClaudeCodeToken;
|
|
17178
|
+
exports.hasClaudeSearchBotToken = hasClaudeSearchBotToken;
|
|
17179
|
+
exports.hasClaudeUserToken = hasClaudeUserToken;
|
|
16540
17180
|
exports.hasPinnedSigningVendor = hasPinnedSigningVendor;
|
|
16541
17181
|
exports.initializePolicyFetcher = initializePolicyFetcher;
|
|
16542
17182
|
exports.isBespokePolicyId = isBespokePolicyId;
|
|
@@ -16564,6 +17204,7 @@ exports.isValidWasmDetectionResult = isValidWasmDetectionResult;
|
|
|
16564
17204
|
exports.isValidWasmRequestMetadata = isValidWasmRequestMetadata;
|
|
16565
17205
|
exports.lintUnnarrowedDenyRules = lintUnnarrowedDenyRules;
|
|
16566
17206
|
exports.loadRulesAsync = loadRulesAsync;
|
|
17207
|
+
exports.mapDetectionToReasonCodes = mapDetectionToReasonCodes;
|
|
16567
17208
|
exports.mapLegacyAuthType = mapLegacyAuthType;
|
|
16568
17209
|
exports.mapToLegacyAuthType = mapToLegacyAuthType;
|
|
16569
17210
|
exports.matchPath = matchPath;
|
|
@@ -16571,6 +17212,7 @@ exports.mergeWithDefaults = mergeWithDefaults;
|
|
|
16571
17212
|
exports.migrateLegacyDetectionClass = migrateLegacyDetectionClass;
|
|
16572
17213
|
exports.nonNavigablePolicyLabel = nonNavigablePolicyLabel;
|
|
16573
17214
|
exports.normalizeAgentName = normalizeAgentName;
|
|
17215
|
+
exports.normalizeClientIp = normalizeClientIp;
|
|
16574
17216
|
exports.normalizeConfidence = normalizeConfidence;
|
|
16575
17217
|
exports.normalizeDetectionClass = normalizeDetectionClass;
|
|
16576
17218
|
exports.normalizeDetectionClassEnum = normalizeDetectionClassEnum;
|
|
@@ -16591,12 +17233,14 @@ exports.permitDelegationVerdict = permitDelegationVerdict;
|
|
|
16591
17233
|
exports.projectResetRequestSchema = projectResetRequestSchema;
|
|
16592
17234
|
exports.reconstructConfidenceFromEvidence = reconstructConfidenceFromEvidence;
|
|
16593
17235
|
exports.refineClaudeDisplayLabel = refineClaudeDisplayLabel;
|
|
17236
|
+
exports.refineSessionGrainClaudeLabel = refineSessionGrainClaudeLabel;
|
|
16594
17237
|
exports.requestCarriesDelegationProof = requestCarriesDelegationProof;
|
|
16595
17238
|
exports.requiredScopesForRequest = requiredScopesForRequest;
|
|
16596
17239
|
exports.resetPasswordSchema = resetPasswordSchema;
|
|
16597
17240
|
exports.resetPolicyFetcher = resetPolicyFetcher;
|
|
16598
17241
|
exports.resolveAuthorizationHost = resolveAuthorizationHost;
|
|
16599
17242
|
exports.resolveChallengeContext = resolveChallengeContext;
|
|
17243
|
+
exports.resolveClientIp = resolveClientIp;
|
|
16600
17244
|
exports.resolveTrustedDelegationRoots = resolveTrustedDelegationRoots;
|
|
16601
17245
|
exports.safeParsePolicyConfig = safeParsePolicyConfig;
|
|
16602
17246
|
exports.safeUrl = safeUrl;
|