@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.
@@ -1,8 +1,8 @@
1
1
  import * as v from "valibot";
2
- export declare const HCaptchaSecretKeyError: {
3
- Type: string;
4
- Length: string;
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<string>, v.LengthAction<string, 35, string>, v.BrandAction<string, "HCaptchaSecretKey">]>;
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;IACjC,IAAI;IACJ,MAAM;CACP,CAAC;AAEF,eAAO,MAAM,iBAAiB,qIAK7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
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 HCaptchaSecretKeyError = {
2
+ export const HcaptchaSecretKeyError = {
3
3
  Type: "hcaptcha.secret.key.type",
4
- Length: "hcaptcha.secret.key.length",
4
+ InvalidFormat: "hcaptcha.secret.key.invalid.format",
5
5
  };
6
- export const HCaptchaSecretKey = v.pipe(v.string(HCaptchaSecretKeyError.Type), v.length(35, HCaptchaSecretKeyError.Length),
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("HCaptchaSecretKey"));
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,MAAM,EAAE,4BAA4B;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CACrC,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,EACrC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,CAAC,MAAM,CAAC;AAC3C,0CAA0C;AAC1C,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAC7B,CAAC"}
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
- constructor(secretKey: HCaptchaSecretKeyType);
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;AAE9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,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,YAAY,SAAS,EAAE,qBAAqB,EAE3C;IAED,MAAM,IAAI,iBAAiB,CAK1B;CACF"}
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
- constructor(secretKey) {
7
- this.strategy = new ShieldHcaptchaStrategy(secretKey);
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("10000000-aaaa-bbbb-cccc-000000000001"))
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;AAGpD,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;IAElD,YAAY,SAAgC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YACxB,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,sCAAsC,CAAC;gBAAE,OAAO,IAAI,EAAE,CAAC;YACxF,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,gCAAgC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvF,CAAC,CAAC;IACJ,CAAC;CACF"}
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/bun",
3
- "version": "1.18.9",
3
+ "version": "1.18.10",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -1,15 +1,18 @@
1
1
  import * as v from "valibot";
2
2
 
3
- export const HCaptchaSecretKeyError = {
3
+ export const HcaptchaSecretKeyError = {
4
4
  Type: "hcaptcha.secret.key.type",
5
- Length: "hcaptcha.secret.key.length",
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(HCaptchaSecretKeyError.Type),
10
- v.length(35, HCaptchaSecretKeyError.Length),
12
+ v.string(HcaptchaSecretKeyError.Type),
13
+ v.regex(CHARS_WHITELIST, HcaptchaSecretKeyError.InvalidFormat),
11
14
  // Stryker disable next-line StringLiteral
12
- v.brand("HCaptchaSecretKey"),
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 type { HCaptchaSecretKeyType } from "./hcaptcha-secret-key.vo";
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
- constructor(secretKey: HCaptchaSecretKeyType) {
13
- this.strategy = new ShieldHcaptchaStrategy(secretKey);
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("10000000-aaaa-bbbb-cccc-000000000001")) return next();
26
+ if (await this.strategy.evaluate(ShieldHcaptchaLocalHonoStrategy.TOKEN_LOCAL)) return next();
19
27
  throw new HTTPException(403, { message: ShieldHcaptchaLocalStrategyError.Rejected });
20
28
  };
21
29
  }