@prosopo/puzzle-assets 0.2.4 → 0.2.6
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/.turbo/turbo-build$colon$cjs.log +1 -1
- package/.turbo/turbo-build$colon$esm.log +1 -1
- package/.turbo/turbo-build$colon$tsc.log +4 -4
- package/CHANGELOG.md +10 -0
- package/dist/tsc/tests/previewArgs.unit.test.d.ts +2 -0
- package/dist/tsc/tests/previewArgs.unit.test.d.ts.map +1 -0
- package/dist/tsc/tests/previewArgs.unit.test.js +25 -0
- package/dist/tsc/tests/previewArgs.unit.test.js.map +1 -0
- package/dist/types/tests/previewArgs.unit.test.d.ts +2 -0
- package/dist/types/tests/previewArgs.unit.test.d.ts.map +1 -0
- package/package.json +3 -3
- package/scripts/preview.ts +11 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
$ tsc --build --verbose
|
|
2
|
-
|
|
2
|
+
10:54:47 AM - Projects in this build:
|
|
3
3
|
* ../../dev/config/tsconfig.json
|
|
4
4
|
* tsconfig.json
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
10:54:48 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'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
10:54:48 AM - Project 'tsconfig.json' is out of date because output file 'dist/tsc/tsconfig.tsbuildinfo' does not exist
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
10:54:48 AM - Building project '/home/runner/work/captcha/captcha/packages/puzzle-assets/tsconfig.json'...
|
|
11
11
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @prosopo/puzzle-assets
|
|
2
2
|
|
|
3
|
+
## 0.2.6
|
|
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
|
+
|
|
8
|
+
## 0.2.5
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 1966fc1: Bump the npm-minor-and-patch group across 1 directory with 15 updates
|
|
12
|
+
|
|
3
13
|
## 0.2.4
|
|
4
14
|
### Patch Changes
|
|
5
15
|
|
|
@@ -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 @@
|
|
|
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/puzzle-assets",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Procedural imagery for the slider puzzle captcha",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"sharp": "0.35.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@prosopo/config": "3.5.
|
|
38
|
+
"@prosopo/config": "3.5.3",
|
|
39
39
|
"@types/node": "22.10.2",
|
|
40
40
|
"@vitest/coverage-v8": "5.0.4",
|
|
41
41
|
"del-cli": "6.0.0",
|
|
42
|
-
"dotenv": "18.0.
|
|
42
|
+
"dotenv": "18.0.8",
|
|
43
43
|
"tslib": "2.7.0",
|
|
44
44
|
"tsx": "4.20.3",
|
|
45
45
|
"typescript": "5.6.2",
|
package/scripts/preview.ts
CHANGED
|
@@ -40,13 +40,22 @@ interface Args {
|
|
|
40
40
|
out: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/** `--count` must be a whole number of at least 1; parseInt would read "12abc" as 12 and "abc" as NaN. */
|
|
44
|
+
const parseCount = (value: string): number => {
|
|
45
|
+
const count = Number(value);
|
|
46
|
+
if (value.trim() === "" || !Number.isSafeInteger(count) || count < 1) {
|
|
47
|
+
throw new Error(`--count must be a positive integer, got "${value}"`);
|
|
48
|
+
}
|
|
49
|
+
return count;
|
|
50
|
+
};
|
|
51
|
+
|
|
43
52
|
const parseArgs = (argv: readonly string[]): Args => {
|
|
44
53
|
const args: Args = { count: 24, out: "./preview" };
|
|
45
54
|
for (let i = 0; i < argv.length; i++) {
|
|
46
55
|
const flag = argv[i];
|
|
47
56
|
const value = argv[i + 1];
|
|
48
|
-
if (flag === "--count" && value) {
|
|
49
|
-
args.count =
|
|
57
|
+
if (flag === "--count" && value !== undefined) {
|
|
58
|
+
args.count = parseCount(value);
|
|
50
59
|
i++;
|
|
51
60
|
} else if (flag === "--out" && value) {
|
|
52
61
|
args.out = value;
|