@bgord/bun 1.23.0 → 1.23.2
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/dist/error-classifier-http-exception-hono.strategy.d.ts +2 -4
- package/dist/error-classifier-http-exception-hono.strategy.d.ts.map +1 -1
- package/dist/error-classifier-http-exception-hono.strategy.js +5 -4
- package/dist/error-classifier-http-exception-hono.strategy.js.map +1 -1
- package/dist/error-classifier-invariant.strategy.d.ts +4 -5
- package/dist/error-classifier-invariant.strategy.d.ts.map +1 -1
- package/dist/error-classifier-invariant.strategy.js +11 -7
- package/dist/error-classifier-invariant.strategy.js.map +1 -1
- package/dist/error-classifier-validation.strategy.d.ts +2 -4
- package/dist/error-classifier-validation.strategy.d.ts.map +1 -1
- package/dist/error-classifier-validation.strategy.js +3 -3
- package/dist/error-classifier-validation.strategy.js.map +1 -1
- package/dist/error-hono.handler.d.ts +2 -2
- package/dist/error-hono.handler.d.ts.map +1 -1
- package/dist/error-hono.handler.js +2 -2
- package/dist/error-hono.handler.js.map +1 -1
- package/dist/error.handler.d.ts +6 -4
- package/dist/error.handler.d.ts.map +1 -1
- package/dist/error.handler.js +7 -6
- package/dist/error.handler.js.map +1 -1
- package/dist/file-type-detector-fixed.strategy.d.ts +8 -0
- package/dist/file-type-detector-fixed.strategy.d.ts.map +1 -0
- package/dist/file-type-detector-fixed.strategy.js +10 -0
- package/dist/file-type-detector-fixed.strategy.js.map +1 -0
- package/dist/file-type-detector-magic-bytes.strategy.d.ts +6 -0
- package/dist/file-type-detector-magic-bytes.strategy.d.ts.map +1 -0
- package/dist/file-type-detector-magic-bytes.strategy.js +25 -0
- package/dist/file-type-detector-magic-bytes.strategy.js.map +1 -0
- package/dist/file-type-detector-text.strategy.d.ts +8 -0
- package/dist/file-type-detector-text.strategy.d.ts.map +1 -0
- package/dist/file-type-detector-text.strategy.js +22 -0
- package/dist/file-type-detector-text.strategy.js.map +1 -0
- package/dist/file-type-detector.strategy.d.ts +5 -0
- package/dist/file-type-detector.strategy.d.ts.map +1 -0
- package/dist/file-type-detector.strategy.js +2 -0
- package/dist/file-type-detector.strategy.js.map +1 -0
- package/dist/file-uploader-hono.middleware.d.ts +6 -1
- package/dist/file-uploader-hono.middleware.d.ts.map +1 -1
- package/dist/file-uploader-hono.middleware.js +2 -2
- package/dist/file-uploader-hono.middleware.js.map +1 -1
- package/dist/file-uploader.middleware.d.ts +7 -1
- package/dist/file-uploader.middleware.d.ts.map +1 -1
- package/dist/file-uploader.middleware.js +6 -3
- package/dist/file-uploader.middleware.js.map +1 -1
- package/dist/hcaptcha.service.d.ts +1 -0
- package/dist/hcaptcha.service.d.ts.map +1 -1
- package/dist/healthcheck.handler.d.ts +1 -1
- package/dist/healthcheck.handler.d.ts.map +1 -1
- package/dist/healthcheck.handler.js +1 -1
- package/dist/healthcheck.handler.js.map +1 -1
- package/dist/http-exception-errors.d.ts +20 -0
- package/dist/http-exception-errors.d.ts.map +1 -0
- package/dist/http-exception-errors.js +31 -0
- package/dist/http-exception-errors.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/readiness.handler.d.ts +2 -0
- package/dist/readiness.handler.d.ts.map +1 -1
- package/dist/readiness.handler.js +1 -1
- package/dist/readiness.handler.js.map +1 -1
- package/dist/remote-file-storage-disk.adapter.d.ts.map +1 -1
- package/dist/remote-file-storage-disk.adapter.js +4 -1
- package/dist/remote-file-storage-disk.adapter.js.map +1 -1
- package/dist/sealer-aes-gcm.adapter.d.ts.map +1 -1
- package/dist/sealer-aes-gcm.adapter.js +8 -3
- package/dist/sealer-aes-gcm.adapter.js.map +1 -1
- package/dist/security-rule-user-agent.strategy.d.ts.map +1 -1
- package/dist/security-rule-user-agent.strategy.js +4 -3
- package/dist/security-rule-user-agent.strategy.js.map +1 -1
- package/dist/security-rule-violation-threshold.strategy.d.ts +3 -0
- package/dist/security-rule-violation-threshold.strategy.d.ts.map +1 -1
- package/dist/security-rule-violation-threshold.strategy.js +3 -3
- package/dist/security-rule-violation-threshold.strategy.js.map +1 -1
- package/dist/shield-body-limit.strategy.d.ts.map +1 -1
- package/dist/shield-body-limit.strategy.js +3 -1
- package/dist/shield-body-limit.strategy.js.map +1 -1
- package/dist/shield-hcaptcha-hono-local.strategy.d.ts +1 -0
- package/dist/shield-hcaptcha-hono-local.strategy.d.ts.map +1 -1
- package/dist/shield-hcaptcha-hono-local.strategy.js +5 -1
- package/dist/shield-hcaptcha-hono-local.strategy.js.map +1 -1
- package/dist/shield-hcaptcha-hono.strategy.d.ts +2 -2
- package/dist/shield-hcaptcha-hono.strategy.d.ts.map +1 -1
- package/dist/shield-hcaptcha-hono.strategy.js +3 -3
- package/dist/shield-hcaptcha-hono.strategy.js.map +1 -1
- package/dist/shield-hcaptcha.strategy.d.ts +6 -2
- package/dist/shield-hcaptcha.strategy.d.ts.map +1 -1
- package/dist/shield-hcaptcha.strategy.js +9 -5
- package/dist/shield-hcaptcha.strategy.js.map +1 -1
- package/dist/shield-recaptcha.strategy.d.ts +4 -0
- package/dist/shield-recaptcha.strategy.d.ts.map +1 -1
- package/dist/shield-recaptcha.strategy.js +4 -0
- package/dist/shield-recaptcha.strategy.js.map +1 -1
- package/dist/subject-segment-remote-ip.strategy.d.ts +7 -0
- package/dist/subject-segment-remote-ip.strategy.d.ts.map +1 -0
- package/dist/subject-segment-remote-ip.strategy.js +8 -0
- package/dist/subject-segment-remote-ip.strategy.js.map +1 -0
- package/dist/subject-segment-request.strategy.d.ts +2 -2
- package/dist/subject-segment-request.strategy.d.ts.map +1 -1
- package/dist/subject-segment-request.strategy.js.map +1 -1
- package/dist/webhook-body-builder-signed-headers.strategy.d.ts +8 -0
- package/dist/webhook-body-builder-signed-headers.strategy.d.ts.map +1 -0
- package/dist/webhook-body-builder-signed-headers.strategy.js +11 -0
- package/dist/webhook-body-builder-signed-headers.strategy.js.map +1 -0
- package/dist/webhook-signature.vo.d.ts +2 -1
- package/dist/webhook-signature.vo.d.ts.map +1 -1
- package/dist/webhook-signature.vo.js +4 -1
- package/dist/webhook-signature.vo.js.map +1 -1
- package/dist/webhook-verifier-sha256.strategy.d.ts.map +1 -1
- package/dist/webhook-verifier-sha256.strategy.js +4 -3
- package/dist/webhook-verifier-sha256.strategy.js.map +1 -1
- package/dist/woodchopper.d.ts +1 -1
- package/dist/woodchopper.d.ts.map +1 -1
- package/dist/woodchopper.js +1 -3
- package/dist/woodchopper.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +7 -1
- package/src/error-classifier-http-exception-hono.strategy.ts +14 -3
- package/src/error-classifier-invariant.strategy.ts +19 -9
- package/src/error-classifier-validation.strategy.ts +9 -5
- package/src/error-hono.handler.ts +3 -3
- package/src/error.handler.ts +19 -11
- package/src/file-type-detector-fixed.strategy.ts +10 -0
- package/src/file-type-detector-magic-bytes.strategy.ts +32 -0
- package/src/file-type-detector-text.strategy.ts +25 -0
- package/src/file-type-detector.strategy.ts +5 -0
- package/src/file-uploader-hono.middleware.ts +5 -2
- package/src/file-uploader.middleware.ts +10 -3
- package/src/hcaptcha.service.ts +1 -1
- package/src/healthcheck.handler.ts +2 -2
- package/src/http-exception-errors.ts +31 -0
- package/src/index.ts +7 -1
- package/src/readiness.handler.ts +6 -2
- package/src/remote-file-storage-disk.adapter.ts +4 -1
- package/src/sealer-aes-gcm.adapter.ts +7 -3
- package/src/security-rule-user-agent.strategy.ts +4 -3
- package/src/security-rule-violation-threshold.strategy.ts +14 -8
- package/src/shield-body-limit.strategy.ts +3 -1
- package/src/shield-hcaptcha-hono-local.strategy.ts +6 -1
- package/src/shield-hcaptcha-hono.strategy.ts +7 -4
- package/src/shield-hcaptcha.strategy.ts +8 -3
- package/src/shield-recaptcha.strategy.ts +9 -2
- package/src/subject-segment-remote-ip.strategy.ts +14 -0
- package/src/subject-segment-request.strategy.ts +2 -0
- package/src/webhook-body-builder-signed-headers.strategy.ts +12 -0
- package/src/webhook-signature.vo.ts +5 -0
- package/src/webhook-verifier-sha256.strategy.ts +4 -3
- package/src/woodchopper.ts +2 -4
- package/dist/invariant-error-handler.service.d.ts +0 -13
- package/dist/invariant-error-handler.service.d.ts.map +0 -1
- package/dist/invariant-error-handler.service.js +0 -15
- package/dist/invariant-error-handler.service.js.map +0 -1
- package/src/invariant-error-handler.service.ts +0 -21
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HTTPException } from "hono/http-exception";
|
|
2
2
|
import { RequestContextHonoAdapter } from "./request-context-hono.adapter";
|
|
3
|
-
import { ShieldHcaptchaStrategy, ShieldHcaptchaStrategyError } from "./shield-hcaptcha.strategy";
|
|
3
|
+
import { ShieldHcaptchaStrategy, ShieldHcaptchaStrategyError, } from "./shield-hcaptcha.strategy";
|
|
4
4
|
export class ShieldHcaptchaHonoStrategy {
|
|
5
5
|
strategy;
|
|
6
|
-
constructor(
|
|
7
|
-
this.strategy = new ShieldHcaptchaStrategy(
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.strategy = new ShieldHcaptchaStrategy(config);
|
|
8
8
|
}
|
|
9
9
|
handle() {
|
|
10
10
|
return async (c, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-hcaptcha-hono.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha-hono.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"shield-hcaptcha-hono.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha-hono.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAEL,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,OAAO,0BAA0B;IACpB,QAAQ,CAAyB;IAElD,YAAY,MAA4B;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC,CAAC,CAAC,CAAC;YAEjD,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,OAAO,IAAI,EAAE,CAAC;YACzD,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,2BAA2B,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClF,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -4,10 +4,14 @@ export declare const ShieldHcaptchaStrategyError: {
|
|
|
4
4
|
Rejected: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const ShieldHcaptchaStrategyField = "h-captcha-response";
|
|
7
|
+
export type ShieldHcaptchaConfig = {
|
|
8
|
+
secretKey: HCaptchaSecretKeyType;
|
|
9
|
+
hostname: string;
|
|
10
|
+
};
|
|
7
11
|
export declare class ShieldHcaptchaStrategy {
|
|
8
|
-
private readonly
|
|
12
|
+
private readonly config;
|
|
9
13
|
private readonly hcaptcha;
|
|
10
|
-
constructor(
|
|
14
|
+
constructor(config: ShieldHcaptchaConfig);
|
|
11
15
|
evaluate(context: HasRequestForm & HasRequestJson): Promise<boolean>;
|
|
12
16
|
}
|
|
13
17
|
//# sourceMappingURL=shield-hcaptcha.strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-hcaptcha.strategy.d.ts","sourceRoot":"","sources":["../src/shield-hcaptcha.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7E,eAAO,MAAM,2BAA2B;IAAK,QAAQ;CAA8B,CAAC;AAEpF,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"shield-hcaptcha.strategy.d.ts","sourceRoot":"","sources":["../src/shield-hcaptcha.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7E,eAAO,MAAM,2BAA2B;IAAK,QAAQ;CAA8B,CAAC;AAEpF,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG;IAAE,SAAS,EAAE,qBAAqB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAElD,YAA6B,MAAM,EAAE,oBAAoB,EAAI;IAEvD,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBzE;CACF"}
|
|
@@ -2,10 +2,10 @@ import { HCaptchaService } from "./hcaptcha.service";
|
|
|
2
2
|
export const ShieldHcaptchaStrategyError = { Rejected: "shield.hcaptcha.rejected" };
|
|
3
3
|
export const ShieldHcaptchaStrategyField = "h-captcha-response";
|
|
4
4
|
export class ShieldHcaptchaStrategy {
|
|
5
|
-
|
|
5
|
+
config;
|
|
6
6
|
hcaptcha = new HCaptchaService();
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
9
|
}
|
|
10
10
|
async evaluate(context) {
|
|
11
11
|
try {
|
|
@@ -16,8 +16,12 @@ export class ShieldHcaptchaStrategy {
|
|
|
16
16
|
const token = fromForm ?? (typeof fromJson === "string" ? fromJson : undefined);
|
|
17
17
|
if (!token)
|
|
18
18
|
return false;
|
|
19
|
-
const result = await this.hcaptcha.verify(this.secretKey, token);
|
|
20
|
-
|
|
19
|
+
const result = await this.hcaptcha.verify(this.config.secretKey, token);
|
|
20
|
+
if (!result.success)
|
|
21
|
+
return false;
|
|
22
|
+
if (result.hostname !== this.config.hostname)
|
|
23
|
+
return false;
|
|
24
|
+
return true;
|
|
21
25
|
}
|
|
22
26
|
catch {
|
|
23
27
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-hcaptcha.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,QAAQ,EAAE,0BAA0B,EAAE,CAAC;AAEpF,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"shield-hcaptcha.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,QAAQ,EAAE,0BAA0B,EAAE,CAAC;AAEpF,MAAM,CAAC,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;AAIhE,MAAM,OAAO,sBAAsB;IAGJ,MAAM;IAFlB,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IAElD,YAA6B,MAA4B;sBAA5B,MAAM;IAAyB,CAAC;IAE7D,KAAK,CAAC,QAAQ,CAAC,OAAwC;QACrD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAE1C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC;YACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAEnD,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAEhF,IAAI,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAC;YAEzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAExE,IAAI,CAAC,MAAM,CAAC,OAAO;gBAAE,OAAO,KAAK,CAAC;YAClC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAE3D,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -2,11 +2,15 @@ import type { RecaptchaSecretKeyType } from "./recaptcha-secret-key.vo";
|
|
|
2
2
|
import type { HasIdentityIp, HasRequestForm, HasRequestJson } from "./request-context.port";
|
|
3
3
|
export type ShieldRecaptchaConfig = {
|
|
4
4
|
secretKey: RecaptchaSecretKeyType;
|
|
5
|
+
hostname: string;
|
|
6
|
+
action?: string;
|
|
5
7
|
threshold?: number;
|
|
6
8
|
};
|
|
7
9
|
export type RecaptchaResult = {
|
|
8
10
|
success: boolean;
|
|
9
11
|
score: number;
|
|
12
|
+
hostname?: string;
|
|
13
|
+
action?: string;
|
|
10
14
|
};
|
|
11
15
|
export declare const ShieldRecaptchaStrategyError: {
|
|
12
16
|
Rejected: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-recaptcha.strategy.d.ts","sourceRoot":"","sources":["../src/shield-recaptcha.strategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE5F,MAAM,MAAM,qBAAqB,GAAG;
|
|
1
|
+
{"version":3,"file":"shield-recaptcha.strategy.d.ts","sourceRoot":"","sources":["../src/shield-recaptcha.strategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE5F,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,sBAAsB,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtG,eAAO,MAAM,4BAA4B;IAAK,QAAQ;CAA+B,CAAC;AAEtF,eAAO,MAAM,4BAA4B,yBAAyB,CAAC;AAEnE,qBAAa,uBAAuB;IAQtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAGzB;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAEhD,YAA6B,MAAM,EAAE,qBAAqB,EAAI;IAExD,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAqCzF;CACF"}
|
|
@@ -34,6 +34,10 @@ export class ShieldRecaptchaStrategy {
|
|
|
34
34
|
return false;
|
|
35
35
|
if (typeof result.score !== "number" || result.score < threshold)
|
|
36
36
|
return false;
|
|
37
|
+
if (result.hostname !== this.config.hostname)
|
|
38
|
+
return false;
|
|
39
|
+
if (this.config.action !== undefined && result.action !== this.config.action)
|
|
40
|
+
return false;
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
39
43
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-recaptcha.strategy.js","sourceRoot":"","sources":["../src/shield-recaptcha.strategy.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"shield-recaptcha.strategy.js","sourceRoot":"","sources":["../src/shield-recaptcha.strategy.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAY7B,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC;AAEtF,MAAM,CAAC,MAAM,4BAA4B,GAAG,sBAAsB,CAAC;AAEnE,MAAM,OAAO,uBAAuB;IAQL,MAAM;IAP3B,MAAM,CAAU,GAAG,GAAG,CAAC,CAAC,KAAK,CACnC,KAAK,CAAC,eAAe,EACrB,iDAAiD,CAClD,CAAC;IAEM,MAAM,CAAU,iBAAiB,GAAG,GAAG,CAAC;IAEhD,YAA6B,MAA6B;sBAA7B,MAAM;IAA0B,CAAC;IAE9D,KAAK,CAAC,QAAQ,CAAC,OAAwD;QACrE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,uBAAuB,CAAC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I,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAC3D,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAC;YAE3F,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HasIdentityRemoteIp } from "./request-context.port";
|
|
2
|
+
import { type SubjectSegmentRequestStrategy, type SubjectSegmentType } from "./subject-segment-request.strategy";
|
|
3
|
+
export declare class SubjectSegmentRemoteIpStrategy implements SubjectSegmentRequestStrategy {
|
|
4
|
+
readonly label = "remote-ip";
|
|
5
|
+
create(context: HasIdentityRemoteIp): SubjectSegmentType;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=subject-segment-remote-ip.strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subject-segment-remote-ip.strategy.d.ts","sourceRoot":"","sources":["../src/subject-segment-remote-ip.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,kBAAkB,EACxB,MAAM,oCAAoC,CAAC;AAE5C,qBAAa,8BAA+B,YAAW,6BAA6B;IAClF,QAAQ,CAAC,KAAK,eAAe;IAE7B,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAEvD;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SubjectSegmentRequestEmpty, } from "./subject-segment-request.strategy";
|
|
2
|
+
export class SubjectSegmentRemoteIpStrategy {
|
|
3
|
+
label = "remote-ip";
|
|
4
|
+
create(context) {
|
|
5
|
+
return context.identity.remoteIp() ?? SubjectSegmentRequestEmpty;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=subject-segment-remote-ip.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subject-segment-remote-ip.strategy.js","sourceRoot":"","sources":["../src/subject-segment-remote-ip.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,GAG3B,MAAM,oCAAoC,CAAC;AAE5C,MAAM,OAAO,8BAA8B;IAChC,KAAK,GAAG,WAAW,CAAC;IAE7B,MAAM,CAAC,OAA4B;QACjC,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,0BAA0B,CAAC;IACnE,CAAC;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { HasIdentityIp, HasIdentityUserId, HasRequestCookie, HasRequestHeader, HasRequestMethod, HasRequestParam, HasRequestPath, HasRequestQueries } from "./request-context.port";
|
|
1
|
+
import type { HasIdentityIp, HasIdentityRemoteIp, HasIdentityUserId, HasRequestCookie, HasRequestHeader, HasRequestMethod, HasRequestParam, HasRequestPath, HasRequestQueries } from "./request-context.port";
|
|
2
2
|
export type SubjectSegmentType = string | null;
|
|
3
3
|
export type SubjectSegmentsRawType = ReadonlyArray<readonly [string, SubjectSegmentType]>;
|
|
4
4
|
export declare const SubjectSegmentRequestEmpty: SubjectSegmentType;
|
|
5
|
-
type RequestContextCapabilities = HasRequestCookie & HasRequestHeader & HasRequestMethod & HasRequestPath & HasRequestQueries & HasRequestParam & HasIdentityIp & HasIdentityUserId;
|
|
5
|
+
type RequestContextCapabilities = HasRequestCookie & HasRequestHeader & HasRequestMethod & HasRequestPath & HasRequestQueries & HasRequestParam & HasIdentityIp & HasIdentityRemoteIp & HasIdentityUserId;
|
|
6
6
|
export interface SubjectSegmentRequestStrategy {
|
|
7
7
|
readonly label: string;
|
|
8
8
|
create(context: RequestContextCapabilities): SubjectSegmentType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-segment-request.strategy.d.ts","sourceRoot":"","sources":["../src/subject-segment-request.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/C,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE1F,eAAO,MAAM,0BAA0B,EAAE,kBAAyB,CAAC;AAEnE,KAAK,0BAA0B,GAAG,gBAAgB,GAChD,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,aAAa,GACb,iBAAiB,CAAC;AAEpB,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,kBAAkB,CAAC;CACjE"}
|
|
1
|
+
{"version":3,"file":"subject-segment-request.strategy.d.ts","sourceRoot":"","sources":["../src/subject-segment-request.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/C,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE1F,eAAO,MAAM,0BAA0B,EAAE,kBAAyB,CAAC;AAEnE,KAAK,0BAA0B,GAAG,gBAAgB,GAChD,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,aAAa,GACb,mBAAmB,GACnB,iBAAiB,CAAC;AAEpB,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,kBAAkB,CAAC;CACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subject-segment-request.strategy.js","sourceRoot":"","sources":["../src/subject-segment-request.strategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subject-segment-request.strategy.js","sourceRoot":"","sources":["../src/subject-segment-request.strategy.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,0BAA0B,GAAuB,IAAI,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HasRequestHeader, HasRequestText } from "./request-context.port";
|
|
2
|
+
import type { WebhookBodyBuilderStrategy } from "./webhook-body-builder.strategy";
|
|
3
|
+
export declare class WebhookBodyBuilderSignedHeadersStrategy implements WebhookBodyBuilderStrategy {
|
|
4
|
+
private readonly headers;
|
|
5
|
+
constructor(headers: ReadonlyArray<string>);
|
|
6
|
+
build(context: HasRequestHeader & HasRequestText): Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=webhook-body-builder-signed-headers.strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-body-builder-signed-headers.strategy.d.ts","sourceRoot":"","sources":["../src/webhook-body-builder-signed-headers.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,qBAAa,uCAAwC,YAAW,0BAA0B;IAC5E,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,EAAI;IAEzD,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAIvE;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class WebhookBodyBuilderSignedHeadersStrategy {
|
|
2
|
+
headers;
|
|
3
|
+
constructor(headers) {
|
|
4
|
+
this.headers = headers;
|
|
5
|
+
}
|
|
6
|
+
async build(context) {
|
|
7
|
+
const headers = this.headers.map((name) => [name, context.request.header(name) ?? null]);
|
|
8
|
+
return JSON.stringify([headers, await context.request.text()]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=webhook-body-builder-signed-headers.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-body-builder-signed-headers.strategy.js","sourceRoot":"","sources":["../src/webhook-body-builder-signed-headers.strategy.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,uCAAuC;IACrB,OAAO;IAApC,YAA6B,OAA8B;uBAA9B,OAAO;IAA0B,CAAC;IAE/D,KAAK,CAAC,KAAK,CAAC,OAA0C;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -2,7 +2,8 @@ import * as v from "valibot";
|
|
|
2
2
|
export declare const WebhookSignatureError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Empty: string;
|
|
5
|
+
InvalidHex: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const WebhookSignature: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.NonEmptyAction<string, string>, v.BrandAction<string, "WebhookSignature">]>;
|
|
7
|
+
export declare const WebhookSignature: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.NonEmptyAction<string, string>, v.RegexAction<string, string>, v.BrandAction<string, "WebhookSignature">]>;
|
|
7
8
|
export type WebhookSignatureType = v.InferOutput<typeof WebhookSignature>;
|
|
8
9
|
//# sourceMappingURL=webhook-signature.vo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-signature.vo.d.ts","sourceRoot":"","sources":["../src/webhook-signature.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,qBAAqB;IAChC,IAAI;IACJ,KAAK;
|
|
1
|
+
{"version":3,"file":"webhook-signature.vo.d.ts","sourceRoot":"","sources":["../src/webhook-signature.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,qBAAqB;IAChC,IAAI;IACJ,KAAK;IACL,UAAU;CACX,CAAC;AAKF,eAAO,MAAM,gBAAgB,iKAM5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -2,8 +2,11 @@ import * as v from "valibot";
|
|
|
2
2
|
export const WebhookSignatureError = {
|
|
3
3
|
Type: "webhook.signature.type",
|
|
4
4
|
Empty: "webhook.signature.empty",
|
|
5
|
+
InvalidHex: "webhook.signature.invalid.hex",
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
// Hex chars allowed
|
|
8
|
+
const CHARS_WHITELIST = /^[a-fA-F0-9]+$/;
|
|
9
|
+
export const WebhookSignature = v.pipe(v.string(WebhookSignatureError.Type), v.nonEmpty(WebhookSignatureError.Empty), v.regex(CHARS_WHITELIST, WebhookSignatureError.InvalidHex),
|
|
7
10
|
// Stryker disable next-line StringLiteral
|
|
8
11
|
v.brand("WebhookSignature"));
|
|
9
12
|
//# sourceMappingURL=webhook-signature.vo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-signature.vo.js","sourceRoot":"","sources":["../src/webhook-signature.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,yBAAyB;
|
|
1
|
+
{"version":3,"file":"webhook-signature.vo.js","sourceRoot":"","sources":["../src/webhook-signature.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,yBAAyB;IAChC,UAAU,EAAE,+BAA+B;CAC5C,CAAC;AAEF,oBAAoB;AACpB,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CACpC,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,EACpC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,EACvC,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE,qBAAqB,CAAC,UAAU,CAAC;AAC1D,0CAA0C;AAC1C,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-verifier-sha256.strategy.d.ts","sourceRoot":"","sources":["../src/webhook-verifier-sha256.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,KAAK,MAAM,GAAG;IAAE,uBAAuB,EAAE,+BAA+B,CAAA;CAAE,CAAC;AAE3E,qBAAa,6BAA8B,YAAW,uBAAuB;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAnC,YAA6B,MAAM,EAAE,MAAM,EAAI;IAE/C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"webhook-verifier-sha256.strategy.d.ts","sourceRoot":"","sources":["../src/webhook-verifier-sha256.strategy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,KAAK,MAAM,GAAG;IAAE,uBAAuB,EAAE,+BAA+B,CAAA;CAAE,CAAC;AAE3E,qBAAa,6BAA8B,YAAW,uBAAuB;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAnC,YAA6B,MAAM,EAAE,MAAM,EAAI;IAE/C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAM7D;CACF"}
|
|
@@ -5,10 +5,11 @@ export class WebhookVerifierSha256Strategy {
|
|
|
5
5
|
this.config = config;
|
|
6
6
|
}
|
|
7
7
|
verify(body, signature) {
|
|
8
|
-
const digest = this.config.WebhookSignatureCreator.create(body);
|
|
9
|
-
|
|
8
|
+
const digest = Buffer.from(this.config.WebhookSignatureCreator.create(body));
|
|
9
|
+
const candidate = Buffer.from(signature);
|
|
10
|
+
if (digest.length !== candidate.length)
|
|
10
11
|
return false;
|
|
11
|
-
return timingSafeEqual(
|
|
12
|
+
return timingSafeEqual(digest, candidate);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=webhook-verifier-sha256.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-verifier-sha256.strategy.js","sourceRoot":"","sources":["../src/webhook-verifier-sha256.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C,MAAM,OAAO,6BAA6B;IACX,MAAM;IAAnC,YAA6B,MAAc;sBAAd,MAAM;IAAW,CAAC;IAE/C,MAAM,CAAC,IAAY,EAAE,SAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-verifier-sha256.strategy.js","sourceRoot":"","sources":["../src/webhook-verifier-sha256.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C,MAAM,OAAO,6BAA6B;IACX,MAAM;IAAnC,YAA6B,MAAc;sBAAd,MAAM;IAAW,CAAC;IAE/C,MAAM,CAAC,IAAY,EAAE,SAA+B;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7E,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QACrD,OAAO,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
package/dist/woodchopper.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type WoodchopperConfig = {
|
|
|
10
10
|
level: LogLevelEnum;
|
|
11
11
|
environment: NodeEnvironmentEnum;
|
|
12
12
|
dispatcher: WoodchopperDispatcher;
|
|
13
|
-
redactor
|
|
13
|
+
redactor: RedactorStrategy;
|
|
14
14
|
diagnostics?: WoodchopperDiagnosticsStrategy;
|
|
15
15
|
};
|
|
16
16
|
type Dependencies = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"woodchopper.d.ts","sourceRoot":"","sources":["../src/woodchopper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,UAAU,EACf,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG/E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,aAAa,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,qBAAqB,CAAC;IAClC,QAAQ,
|
|
1
|
+
{"version":3,"file":"woodchopper.d.ts","sourceRoot":"","sources":["../src/woodchopper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,UAAU,EACf,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM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-58,9 +58,7 @@ export class Woodchopper {
|
|
|
58
58
|
}
|
|
59
59
|
let withRedaction;
|
|
60
60
|
try {
|
|
61
|
-
withRedaction = this.config.redactor
|
|
62
|
-
? this.config.redactor.redact(withInjectedFields)
|
|
63
|
-
: withInjectedFields;
|
|
61
|
+
withRedaction = this.config.redactor.redact(withInjectedFields);
|
|
64
62
|
}
|
|
65
63
|
catch (error) {
|
|
66
64
|
this.stats.recordDropped();
|
package/dist/woodchopper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"woodchopper.js","sourceRoot":"","sources":["../src/woodchopper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAML,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,GAGZ,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAa/D,MAAM,kBAAkB,GAAuD;IAC7E,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9C,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAChD,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9C,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG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K,GAAG,WAAW,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACvD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"better-auth": "1.7.2",
|
|
30
30
|
"cspell": "10.1.1",
|
|
31
31
|
"fallow": "3.20.0",
|
|
32
|
-
"lefthook": "2.1.
|
|
32
|
+
"lefthook": "2.1.12",
|
|
33
33
|
"lockfile-lint": "5.0.1",
|
|
34
34
|
"nodemailer": "9.0.6",
|
|
35
35
|
"publint": "0.3.24",
|
package/readme.md
CHANGED
|
@@ -207,6 +207,10 @@ src/
|
|
|
207
207
|
├── file-renamer-node.adapter.ts
|
|
208
208
|
├── file-renamer-noop.adapter.ts
|
|
209
209
|
├── file-renamer.port.ts
|
|
210
|
+
├── file-type-detector-fixed.strategy.ts
|
|
211
|
+
├── file-type-detector-magic-bytes.strategy.ts
|
|
212
|
+
├── file-type-detector-text.strategy.ts
|
|
213
|
+
├── file-type-detector.strategy.ts
|
|
210
214
|
├── file-uploader-hono.middleware.ts
|
|
211
215
|
├── file-uploader.middleware.ts
|
|
212
216
|
├── file-writer-forgiving.adapter.ts
|
|
@@ -239,6 +243,7 @@ src/
|
|
|
239
243
|
├── healthcheck-hono.handler.ts
|
|
240
244
|
├── healthcheck.handler.ts
|
|
241
245
|
├── hostname.vo.ts
|
|
246
|
+
├── http-exception-errors.ts
|
|
242
247
|
├── http-logger-hono.middleware.ts
|
|
243
248
|
├── http-logger.middleware.ts
|
|
244
249
|
├── id-provider-crypto.adapter.ts
|
|
@@ -288,7 +293,6 @@ src/
|
|
|
288
293
|
├── in-flight-requests-tracker.service.ts
|
|
289
294
|
├── in-flight-requests.middleware.ts
|
|
290
295
|
├── instrumentation.service.ts
|
|
291
|
-
├── invariant-error-handler.service.ts
|
|
292
296
|
├── invariant.service.ts
|
|
293
297
|
├── job-claimer-noop.adapter.ts
|
|
294
298
|
├── job-claimer-sqlite.adapter.ts
|
|
@@ -615,6 +619,7 @@ src/
|
|
|
615
619
|
├── subject-segment-param.strategy.ts
|
|
616
620
|
├── subject-segment-path.strategy.ts
|
|
617
621
|
├── subject-segment-query.strategy.ts
|
|
622
|
+
├── subject-segment-remote-ip.strategy.ts
|
|
618
623
|
├── subject-segment-request.strategy.ts
|
|
619
624
|
├── subject-segment-user.strategy.ts
|
|
620
625
|
├── temporary-file-absolute.adapter.ts
|
|
@@ -653,6 +658,7 @@ src/
|
|
|
653
658
|
├── weak-etag-extractor-param.strategy.ts
|
|
654
659
|
├── weak-etag-extractor.middleware.ts
|
|
655
660
|
├── weak-etag-extractor.strategy.ts
|
|
661
|
+
├── webhook-body-builder-signed-headers.strategy.ts
|
|
656
662
|
├── webhook-body-builder-text.strategy.ts
|
|
657
663
|
├── webhook-body-builder.strategy.ts
|
|
658
664
|
├── webhook-id-extractor-header.strategy.ts
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { HTTPException } from "hono/http-exception";
|
|
2
2
|
import type { ErrorClassifierStrategy } from "./error-classifier.strategy";
|
|
3
3
|
|
|
4
|
-
export type ErrorClassifierHttpExceptionConfig =
|
|
4
|
+
export type ErrorClassifierHttpExceptionConfig = ReadonlyArray<string | Record<string, string>>;
|
|
5
5
|
|
|
6
6
|
export class ErrorClassifierHttpExceptionHonoStrategy implements ErrorClassifierStrategy {
|
|
7
|
-
|
|
7
|
+
private readonly errors: ReadonlySet<string>;
|
|
8
|
+
|
|
9
|
+
constructor(config: ErrorClassifierHttpExceptionConfig) {
|
|
10
|
+
this.errors = new Set(
|
|
11
|
+
config.flatMap((entry) => (typeof entry === "string" ? [entry] : Object.values(entry))),
|
|
12
|
+
);
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
classify(error: unknown): Response | null {
|
|
10
16
|
if (!(error instanceof HTTPException)) return null;
|
|
11
17
|
|
|
12
|
-
if (!this.
|
|
18
|
+
if (!this.errors.has(error.message)) {
|
|
19
|
+
return Response.json(
|
|
20
|
+
{ message: "general.unknown" },
|
|
21
|
+
{ status: error.status, headers: error.res?.headers },
|
|
22
|
+
);
|
|
23
|
+
}
|
|
13
24
|
|
|
14
25
|
return Response.json({ message: error.message }, { status: error.status, headers: error.res?.headers });
|
|
15
26
|
}
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import type { ErrorClassifierStrategy } from "./error-classifier.strategy";
|
|
2
|
-
import type
|
|
3
|
-
import { InvariantErrorHandler } from "./invariant-error-handler.service";
|
|
2
|
+
import { type Invariant, InvariantFailureKind } from "./invariant.service";
|
|
4
3
|
|
|
5
|
-
export type ErrorClassifierInvariantConfig =
|
|
4
|
+
export type ErrorClassifierInvariantConfig = ReadonlyArray<Record<string, Invariant<any>>>;
|
|
6
5
|
|
|
7
6
|
export class ErrorClassifierInvariantStrategy implements ErrorClassifierStrategy {
|
|
8
|
-
|
|
7
|
+
private static readonly code: Record<InvariantFailureKind, number> = {
|
|
8
|
+
[InvariantFailureKind.forbidden]: 403,
|
|
9
|
+
[InvariantFailureKind.not_found]: 404,
|
|
10
|
+
[InvariantFailureKind.precondition]: 400,
|
|
11
|
+
};
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
private readonly invariants: ReadonlyArray<Invariant<any>>;
|
|
14
|
+
|
|
15
|
+
constructor(config: ErrorClassifierInvariantConfig) {
|
|
16
|
+
this.invariants = config.flatMap((module) => Object.values(module));
|
|
17
|
+
}
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
classify(error: unknown): Response | null {
|
|
20
|
+
const invariant = this.invariants.find((candidate) => error instanceof candidate.error);
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
if (!invariant) return null;
|
|
16
23
|
|
|
17
|
-
return Response.json(
|
|
24
|
+
return Response.json(
|
|
25
|
+
{ message: invariant.message },
|
|
26
|
+
{ status: ErrorClassifierInvariantStrategy.code[invariant.kind] },
|
|
27
|
+
);
|
|
18
28
|
}
|
|
19
29
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { ErrorClassifierStrategy } from "./error-classifier.strategy";
|
|
2
2
|
|
|
3
|
-
export type ErrorClassifierValidationConfig =
|
|
3
|
+
export type ErrorClassifierValidationConfig = ReadonlyArray<string | Record<string, string>>;
|
|
4
4
|
|
|
5
5
|
type ValidationErrorLike = { issues: ReadonlyArray<{ message: string }> };
|
|
6
6
|
|
|
7
7
|
export class ErrorClassifierValidationStrategy implements ErrorClassifierStrategy {
|
|
8
|
-
|
|
8
|
+
private readonly errors: ReadonlySet<string>;
|
|
9
|
+
|
|
10
|
+
constructor(config: ErrorClassifierValidationConfig) {
|
|
11
|
+
this.errors = new Set(
|
|
12
|
+
config.flatMap((entry) => (typeof entry === "string" ? [entry] : Object.values(entry))),
|
|
13
|
+
);
|
|
14
|
+
}
|
|
9
15
|
|
|
10
16
|
classify(error: unknown): Response | null {
|
|
11
17
|
if (!ErrorClassifierValidationStrategy.isValidationError(error)) return null;
|
|
12
18
|
|
|
13
|
-
const validationError = error.issues.find((issue) =>
|
|
14
|
-
this.config.validationErrors.includes(issue.message),
|
|
15
|
-
);
|
|
19
|
+
const validationError = error.issues.find((issue) => this.errors.has(issue.message));
|
|
16
20
|
|
|
17
21
|
return Response.json({ message: validationError?.message ?? "payload.invalid.error" }, { status: 400 });
|
|
18
22
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type * as hono from "hono";
|
|
2
|
-
import { ErrorHandler, type ErrorHandlerConfig } from "./error.handler";
|
|
2
|
+
import { ErrorHandler, type ErrorHandlerConfig, type ErrorHandlerDependencies } from "./error.handler";
|
|
3
3
|
import { RequestContextHonoAdapter } from "./request-context-hono.adapter";
|
|
4
4
|
|
|
5
5
|
export class ErrorHonoHandler {
|
|
6
6
|
private readonly handler: ErrorHandler;
|
|
7
7
|
|
|
8
|
-
constructor(config: ErrorHandlerConfig) {
|
|
9
|
-
this.handler = new ErrorHandler(config);
|
|
8
|
+
constructor(config: ErrorHandlerConfig, deps: ErrorHandlerDependencies) {
|
|
9
|
+
this.handler = new ErrorHandler(config, deps);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
handle(): hono.ErrorHandler {
|
package/src/error.handler.ts
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import type { ErrorClassifierStrategy } from "./error-classifier.strategy";
|
|
2
2
|
import { ErrorClassifierUnknownStrategy } from "./error-classifier-unknown.strategy";
|
|
3
|
+
import { ErrorClassifierWithLoggerStrategy } from "./error-classifier-with-logger.strategy";
|
|
4
|
+
import type { LoggerPort } from "./logger.port";
|
|
3
5
|
import type { HasRequestUrl } from "./request-context.port";
|
|
4
6
|
|
|
5
|
-
export type ErrorHandlerConfig =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
7
|
+
export type ErrorHandlerConfig = ReadonlyArray<ErrorClassifierStrategy>;
|
|
8
|
+
|
|
9
|
+
export type ErrorHandlerDependencies = { Logger: LoggerPort };
|
|
9
10
|
|
|
10
11
|
export class ErrorHandler {
|
|
11
12
|
private static readonly unknown = new ErrorClassifierUnknownStrategy();
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
private readonly terminal: ErrorClassifierStrategy;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly config: ErrorHandlerConfig,
|
|
18
|
+
deps: ErrorHandlerDependencies,
|
|
19
|
+
) {
|
|
20
|
+
this.terminal = new ErrorClassifierWithLoggerStrategy(
|
|
21
|
+
{ operation: "unknown_error" },
|
|
22
|
+
{ inner: ErrorHandler.unknown, Logger: deps.Logger },
|
|
23
|
+
);
|
|
24
|
+
}
|
|
14
25
|
|
|
15
26
|
handle(error: unknown, context: HasRequestUrl): Response {
|
|
16
|
-
for (const classifier of this.config
|
|
27
|
+
for (const classifier of this.config) {
|
|
17
28
|
const response = classifier.classify(error, context);
|
|
18
29
|
|
|
19
30
|
if (response) return response;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (fallback) return fallback;
|
|
25
|
-
|
|
26
|
-
return ErrorHandler.unknown.classify(error);
|
|
33
|
+
// Stryker disable next-line all: the terminal classifier always returns a response
|
|
34
|
+
return this.terminal.classify(error, context) ?? ErrorHandler.unknown.classify(error);
|
|
27
35
|
}
|
|
28
36
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
import type { FileTypeDetectorStrategy } from "./file-type-detector.strategy";
|
|
3
|
+
|
|
4
|
+
export class FileTypeDetectorFixedStrategy implements FileTypeDetectorStrategy {
|
|
5
|
+
constructor(private readonly mime: tools.Mime | null) {}
|
|
6
|
+
|
|
7
|
+
async detect(_file: File): Promise<tools.Mime | null> {
|
|
8
|
+
return this.mime;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// cSpell:ignore ftyp
|
|
2
|
+
import * as tools from "@bgord/tools";
|
|
3
|
+
import type { FileTypeDetectorStrategy } from "./file-type-detector.strategy";
|
|
4
|
+
|
|
5
|
+
type Signature = { mime: tools.Mime; offset: number; bytes: ReadonlyArray<number> };
|
|
6
|
+
|
|
7
|
+
const ASCII = (value: string): ReadonlyArray<number> => [...value].map((char) => char.charCodeAt(0));
|
|
8
|
+
|
|
9
|
+
const SIGNATURES: ReadonlyArray<Signature> = [
|
|
10
|
+
{ mime: tools.Mimes.png.mime, offset: 0, bytes: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a] },
|
|
11
|
+
{ mime: tools.Mimes.webp.mime, offset: 8, bytes: ASCII("WEBP") },
|
|
12
|
+
{ mime: tools.Mimes.wav.mime, offset: 8, bytes: ASCII("WAVE") },
|
|
13
|
+
{ mime: tools.Mimes.mp4.mime, offset: 4, bytes: ASCII("ftyp") },
|
|
14
|
+
{ mime: tools.Mimes.pdf.mime, offset: 0, bytes: ASCII("%PDF-") },
|
|
15
|
+
{ mime: tools.Mimes.zip.mime, offset: 0, bytes: [0x50, 0x4b, 0x03, 0x04] },
|
|
16
|
+
{ mime: tools.Mimes.jpg.mime, offset: 0, bytes: [0xff, 0xd8, 0xff] },
|
|
17
|
+
{ mime: tools.Mimes.tar.mime, offset: 0, bytes: [0x1f, 0x8b] },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export class FileTypeDetectorMagicBytesStrategy implements FileTypeDetectorStrategy {
|
|
21
|
+
async detect(file: File): Promise<tools.Mime | null> {
|
|
22
|
+
const bytes = new Uint8Array(await file.slice(0, 12).arrayBuffer());
|
|
23
|
+
|
|
24
|
+
for (const signature of SIGNATURES) {
|
|
25
|
+
if (signature.bytes.every((byte, index) => bytes[signature.offset + index] === byte)) {
|
|
26
|
+
return signature.mime;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|