@bgord/bun 1.18.9 → 1.18.10
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/hcaptcha-secret-key.vo.d.ts +4 -4
- package/dist/hcaptcha-secret-key.vo.d.ts.map +1 -1
- package/dist/hcaptcha-secret-key.vo.js +6 -4
- package/dist/hcaptcha-secret-key.vo.js.map +1 -1
- package/dist/shield-hcaptcha-hono-local.strategy.d.ts +3 -2
- package/dist/shield-hcaptcha-hono-local.strategy.d.ts.map +1 -1
- package/dist/shield-hcaptcha-hono-local.strategy.js +7 -3
- package/dist/shield-hcaptcha-hono-local.strategy.js.map +1 -1
- package/package.json +1 -1
- package/src/hcaptcha-secret-key.vo.ts +9 -6
- package/src/shield-hcaptcha-hono-local.strategy.ts +12 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
export declare const
|
|
3
|
-
Type:
|
|
4
|
-
|
|
2
|
+
export declare const HcaptchaSecretKeyError: {
|
|
3
|
+
readonly Type: "hcaptcha.secret.key.type";
|
|
4
|
+
readonly InvalidFormat: "hcaptcha.secret.key.invalid.format";
|
|
5
5
|
};
|
|
6
|
-
export declare const HCaptchaSecretKey: v.SchemaWithPipe<readonly [v.StringSchema<
|
|
6
|
+
export declare const HCaptchaSecretKey: v.SchemaWithPipe<readonly [v.StringSchema<"hcaptcha.secret.key.type">, v.RegexAction<string, "hcaptcha.secret.key.invalid.format">, v.BrandAction<string, "HcaptchaSecretKey">]>;
|
|
7
7
|
export type HCaptchaSecretKeyType = v.InferOutput<typeof HCaptchaSecretKey>;
|
|
8
8
|
//# sourceMappingURL=hcaptcha-secret-key.vo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hcaptcha-secret-key.vo.d.ts","sourceRoot":"","sources":["../src/hcaptcha-secret-key.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,sBAAsB;
|
|
1
|
+
{"version":3,"file":"hcaptcha-secret-key.vo.d.ts","sourceRoot":"","sources":["../src/hcaptcha-secret-key.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,sBAAsB;aACjC,IAAI,EAAE,0BAA0B;aAChC,aAAa,EAAE,oCAAoC;CAC3C,CAAC;AAKX,eAAO,MAAM,iBAAiB,kLAK7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
export const
|
|
2
|
+
export const HcaptchaSecretKeyError = {
|
|
3
3
|
Type: "hcaptcha.secret.key.type",
|
|
4
|
-
|
|
4
|
+
InvalidFormat: "hcaptcha.secret.key.invalid.format",
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
// 0x followed by 40 hex chars (standard) or ES_ followed by 32 hex chars (Enterprise)
|
|
7
|
+
const CHARS_WHITELIST = /^(0x[a-fA-F0-9]{40}|ES_[a-fA-F0-9]{32})$/;
|
|
8
|
+
export const HCaptchaSecretKey = v.pipe(v.string(HcaptchaSecretKeyError.Type), v.regex(CHARS_WHITELIST, HcaptchaSecretKeyError.InvalidFormat),
|
|
7
9
|
// Stryker disable next-line StringLiteral
|
|
8
|
-
v.brand("
|
|
10
|
+
v.brand("HcaptchaSecretKey"));
|
|
9
11
|
//# sourceMappingURL=hcaptcha-secret-key.vo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hcaptcha-secret-key.vo.js","sourceRoot":"","sources":["../src/hcaptcha-secret-key.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,0BAA0B;IAChC,
|
|
1
|
+
{"version":3,"file":"hcaptcha-secret-key.vo.js","sourceRoot":"","sources":["../src/hcaptcha-secret-key.vo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,0BAA0B;IAChC,aAAa,EAAE,oCAAoC;CAC3C,CAAC;AAEX,sFAAsF;AACtF,MAAM,eAAe,GAAG,0CAA0C,CAAC;AAEnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CACrC,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,EACrC,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE,sBAAsB,CAAC,aAAa,CAAC;AAC9D,0CAA0C;AAC1C,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAC7B,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from "hono";
|
|
2
|
-
import type { HCaptchaSecretKeyType } from "./hcaptcha-secret-key.vo";
|
|
3
2
|
import type { MiddlewareHonoPort } from "./middleware-hono.port";
|
|
4
3
|
export declare const ShieldHcaptchaLocalStrategyError: {
|
|
5
4
|
Rejected: string;
|
|
6
5
|
};
|
|
7
6
|
export declare class ShieldHcaptchaLocalHonoStrategy implements MiddlewareHonoPort {
|
|
8
7
|
private readonly strategy;
|
|
9
|
-
|
|
8
|
+
private static readonly SECRET_KEY_LOCAL;
|
|
9
|
+
private static readonly TOKEN_LOCAL;
|
|
10
|
+
constructor();
|
|
10
11
|
handle(): MiddlewareHandler;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=shield-hcaptcha-hono-local.strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-hcaptcha-hono-local.strategy.d.ts","sourceRoot":"","sources":["../src/shield-hcaptcha-hono-local.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"shield-hcaptcha-hono-local.strategy.d.ts","sourceRoot":"","sources":["../src/shield-hcaptcha-hono-local.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAI9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,eAAO,MAAM,gCAAgC;IAAK,QAAQ;CAAoC,CAAC;AAE/F,qBAAa,+BAAgC,YAAW,kBAAkB;IACxE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAElD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAGtC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAA0C;IAE7E,cAEC;IAED,MAAM,IAAI,iBAAiB,CAK1B;CACF"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { HTTPException } from "hono/http-exception";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { HCaptchaSecretKey } from "./hcaptcha-secret-key.vo";
|
|
2
4
|
import { ShieldHcaptchaStrategy } from "./shield-hcaptcha.strategy";
|
|
3
5
|
export const ShieldHcaptchaLocalStrategyError = { Rejected: "shield.hcaptcha.local.rejected" };
|
|
4
6
|
export class ShieldHcaptchaLocalHonoStrategy {
|
|
5
7
|
strategy;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
static SECRET_KEY_LOCAL = v.parse(HCaptchaSecretKey, "0x0000000000000000000000000000000000000000");
|
|
9
|
+
static TOKEN_LOCAL = "10000000-aaaa-bbbb-cccc-000000000001";
|
|
10
|
+
constructor() {
|
|
11
|
+
this.strategy = new ShieldHcaptchaStrategy(ShieldHcaptchaLocalHonoStrategy.SECRET_KEY_LOCAL);
|
|
8
12
|
}
|
|
9
13
|
handle() {
|
|
10
14
|
return async (_c, next) => {
|
|
11
|
-
if (await this.strategy.evaluate(
|
|
15
|
+
if (await this.strategy.evaluate(ShieldHcaptchaLocalHonoStrategy.TOKEN_LOCAL))
|
|
12
16
|
return next();
|
|
13
17
|
throw new HTTPException(403, { message: ShieldHcaptchaLocalStrategyError.Rejected });
|
|
14
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-hcaptcha-hono-local.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha-hono-local.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"shield-hcaptcha-hono-local.strategy.js","sourceRoot":"","sources":["../src/shield-hcaptcha-hono-local.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,QAAQ,EAAE,gCAAgC,EAAE,CAAC;AAE/F,MAAM,OAAO,+BAA+B;IACzB,QAAQ,CAAyB;IAE1C,MAAM,CAAU,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAChD,iBAAiB,EACjB,4CAA4C,CAC7C,CAAC;IAEM,MAAM,CAAU,WAAW,GAAG,sCAAsC,CAAC;IAE7E;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,CAAC,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YACxB,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,+BAA+B,CAAC,WAAW,CAAC;gBAAE,OAAO,IAAI,EAAE,CAAC;YAC7F,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,gCAAgC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvF,CAAC,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const HcaptchaSecretKeyError = {
|
|
4
4
|
Type: "hcaptcha.secret.key.type",
|
|
5
|
-
|
|
6
|
-
};
|
|
5
|
+
InvalidFormat: "hcaptcha.secret.key.invalid.format",
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
// 0x followed by 40 hex chars (standard) or ES_ followed by 32 hex chars (Enterprise)
|
|
9
|
+
const CHARS_WHITELIST = /^(0x[a-fA-F0-9]{40}|ES_[a-fA-F0-9]{32})$/;
|
|
7
10
|
|
|
8
11
|
export const HCaptchaSecretKey = v.pipe(
|
|
9
|
-
v.string(
|
|
10
|
-
v.
|
|
12
|
+
v.string(HcaptchaSecretKeyError.Type),
|
|
13
|
+
v.regex(CHARS_WHITELIST, HcaptchaSecretKeyError.InvalidFormat),
|
|
11
14
|
// Stryker disable next-line StringLiteral
|
|
12
|
-
v.brand("
|
|
15
|
+
v.brand("HcaptchaSecretKey"),
|
|
13
16
|
);
|
|
14
17
|
|
|
15
18
|
export type HCaptchaSecretKeyType = v.InferOutput<typeof HCaptchaSecretKey>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from "hono";
|
|
2
2
|
import { HTTPException } from "hono/http-exception";
|
|
3
|
-
import
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { HCaptchaSecretKey } from "./hcaptcha-secret-key.vo";
|
|
4
5
|
import type { MiddlewareHonoPort } from "./middleware-hono.port";
|
|
5
6
|
import { ShieldHcaptchaStrategy } from "./shield-hcaptcha.strategy";
|
|
6
7
|
|
|
@@ -9,13 +10,20 @@ export const ShieldHcaptchaLocalStrategyError = { Rejected: "shield.hcaptcha.loc
|
|
|
9
10
|
export class ShieldHcaptchaLocalHonoStrategy implements MiddlewareHonoPort {
|
|
10
11
|
private readonly strategy: ShieldHcaptchaStrategy;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
private static readonly SECRET_KEY_LOCAL = v.parse(
|
|
14
|
+
HCaptchaSecretKey,
|
|
15
|
+
"0x0000000000000000000000000000000000000000",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
private static readonly TOKEN_LOCAL = "10000000-aaaa-bbbb-cccc-000000000001";
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
this.strategy = new ShieldHcaptchaStrategy(ShieldHcaptchaLocalHonoStrategy.SECRET_KEY_LOCAL);
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
handle(): MiddlewareHandler {
|
|
17
25
|
return async (_c, next) => {
|
|
18
|
-
if (await this.strategy.evaluate(
|
|
26
|
+
if (await this.strategy.evaluate(ShieldHcaptchaLocalHonoStrategy.TOKEN_LOCAL)) return next();
|
|
19
27
|
throw new HTTPException(403, { message: ShieldHcaptchaLocalStrategyError.Rejected });
|
|
20
28
|
};
|
|
21
29
|
}
|