@prosopo/audio-assets 0.2.4 → 0.2.5

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.
@@ -20,4 +20,4 @@ dist/cjs/phonemes.cjs 3.52 kB │ gzip: 1.12 kB
20
20
  dist/cjs/index.cjs 4.67 kB │ gzip: 1.70 kB
21
21
  dist/cjs/synth.cjs 7.70 kB │ gzip: 2.73 kB
22
22
 
23
- ✓ built in 35ms
23
+ ✓ built in 51ms
@@ -21,4 +21,4 @@ dist/esm/phonemes.js 3.49 kB │ gzip: 1.11 kB
21
21
  dist/esm/index.js 3.81 kB │ gzip: 1.54 kB
22
22
  dist/esm/synth.js 7.61 kB │ gzip: 2.72 kB
23
23
 
24
- ✓ built in 59ms
24
+ ✓ built in 69ms
@@ -1,14 +1,14 @@
1
1
  $ tsc --build --verbose
2
- 12:56:11 PM - Projects in this build:
2
+ 10:55:01 AM - Projects in this build:
3
3
  * ../../dev/config/tsconfig.json
4
4
  * ../puzzle-assets/tsconfig.json
5
5
  * tsconfig.json
6
6
 
7
- 12:56:11 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/vite.esm.config.ts' is older than output '../../dev/config/dist/tsc/tsconfig.tsbuildinfo'
7
+ 10:55:01 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/modifyExportsFiles.test.ts' is older than output '../../dev/config/dist/tsc/tsconfig.tsbuildinfo'
8
8
 
9
- 12:56:11 PM - Project '../puzzle-assets/tsconfig.json' is up to date because newest input '../puzzle-assets/src/background.ts' is older than output '../puzzle-assets/dist/tsc/tsconfig.tsbuildinfo'
9
+ 10:55:01 AM - Project '../puzzle-assets/tsconfig.json' is up to date because newest input '../puzzle-assets/src/types.ts' is older than output '../puzzle-assets/dist/tsc/tsconfig.tsbuildinfo'
10
10
 
11
- 12:56:11 PM - Project 'tsconfig.json' is out of date because output file 'dist/tsc/tsconfig.tsbuildinfo' does not exist
11
+ 10:55:01 AM - Project 'tsconfig.json' is out of date because output file 'dist/tsc/tsconfig.tsbuildinfo' does not exist
12
12
 
13
- 12:56:11 PM - Building project '/home/runner/work/captcha/captcha/packages/audio-assets/tsconfig.json'...
13
+ 10:55:01 AM - Building project '/home/runner/work/captcha/captcha/packages/audio-assets/tsconfig.json'...
14
14
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @prosopo/audio-assets
2
2
 
3
+ ## 0.2.5
4
+ ### Patch Changes
5
+
6
+ - cdea91f: Stop malformed input from turning into silent wrong values or unhandled throws. Numbers from env vars, headers, request fields and CLI flags are now parsed strictly: "12abc" is no longer read as 12, and an empty string is no longer read as 0. A bad request timestamp now gets a 400 response instead of a 500 or NaN. JSON reads name the file or source that was bad, and JSON writes no longer throw on bigints. Composite IP addresses and dates that cannot be read are now rejected instead of crashing or slipping through as an Invalid Date.
7
+ - Updated dependencies [cdea91f]
8
+ - @prosopo/puzzle-assets@0.2.6
9
+
3
10
  ## 0.2.4
4
11
  ### Patch Changes
5
12
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=previewArgs.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewArgs.unit.test.d.ts","sourceRoot":"","sources":["../../../src/tests/previewArgs.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, mkdtempSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { afterEach, describe, expect, it } from "vitest";
7
+ const packageDir = fileURLToPath(new URL("../..", import.meta.url));
8
+ const tsx = join(packageDir, "node_modules/.bin/tsx");
9
+ describe("preview script --count", () => {
10
+ let dir;
11
+ afterEach(() => {
12
+ if (dir)
13
+ rmSync(dir, { recursive: true, force: true });
14
+ dir = undefined;
15
+ });
16
+ it.each(["abc", "12abc", "1.5", "0", "-3", ""])("rejects %j before writing anything", (count) => {
17
+ dir = mkdtempSync(join(tmpdir(), "preview-"));
18
+ const out = join(dir, "out");
19
+ const run = spawnSync(tsx, ["scripts/preview.ts", "--count", count, "--out", out], { cwd: packageDir, encoding: "utf8", timeout: 30_000 });
20
+ expect(run.status).not.toBe(0);
21
+ expect(run.stderr).toContain("--count must be a positive integer");
22
+ expect(existsSync(out)).toBe(false);
23
+ }, 30_000);
24
+ });
25
+ //# sourceMappingURL=previewArgs.unit.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewArgs.unit.test.js","sourceRoot":"","sources":["../../../src/tests/previewArgs.unit.test.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAC;AAEtD,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,IAAI,GAAuB,CAAC;IAC5B,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,GAAG;YAAE,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,GAAG,GAAG,SAAS,CAAC;IACjB,CAAC,CAAC,CAAC;IAIH,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAC9C,oCAAoC,EACpC,CAAC,KAAK,EAAE,EAAE;QACT,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,SAAS,CACpB,GAAG,EACH,CAAC,oBAAoB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EACtD,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CACtD,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAC;QACnE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,EACD,MAAM,CACN,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=previewArgs.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewArgs.unit.test.d.ts","sourceRoot":"","sources":["../../../src/tests/previewArgs.unit.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/audio-assets",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Procedural speech synthesis for the audio captcha",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "homepage": "https://github.com/prosopo/captcha#readme",
29
29
  "dependencies": {
30
- "@prosopo/puzzle-assets": "0.2.5"
30
+ "@prosopo/puzzle-assets": "0.2.6"
31
31
  },
32
32
  "devDependencies": {
33
- "@prosopo/config": "3.5.2",
33
+ "@prosopo/config": "3.5.3",
34
34
  "@types/node": "22.10.2",
35
35
  "@vitest/coverage-v8": "5.0.4",
36
36
  "del-cli": "6.0.0",
@@ -41,13 +41,22 @@ interface Args {
41
41
  clean: boolean;
42
42
  }
43
43
 
44
+ /** `--count` must be a whole number of at least 1; parseInt would read "12abc" as 12 and "abc" as NaN. */
45
+ const parseCount = (value: string): number => {
46
+ const count = Number(value);
47
+ if (value.trim() === "" || !Number.isSafeInteger(count) || count < 1) {
48
+ throw new Error(`--count must be a positive integer, got "${value}"`);
49
+ }
50
+ return count;
51
+ };
52
+
44
53
  const parseArgs = (argv: readonly string[]): Args => {
45
54
  const args: Args = { count: 12, out: "./preview", clean: false };
46
55
  for (let i = 0; i < argv.length; i++) {
47
56
  const flag = argv[i];
48
57
  if (flag === "--count") {
49
58
  const value = argv[++i];
50
- if (value) args.count = Number.parseInt(value, 10);
59
+ if (value !== undefined) args.count = parseCount(value);
51
60
  } else if (flag === "--out") {
52
61
  const value = argv[++i];
53
62
  if (value) args.out = value;