@kya-os/checkpoint-shared 1.3.1 → 1.4.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,99 @@
1
1
  # @kya-os/checkpoint-shared
2
2
 
3
- ## Unreleased — error registry single source of truth (#4792)
3
+ ## 1.4.0, Zod 4
4
+
5
+ Flips the package from Zod 3 to Zod 4.5.4 and removes the public API envelope
6
+ helpers that PR #4853 marked deprecated. Rebuild against the new `.d.ts` and
7
+ re-run any consumer that inspects `issues[].code` before adopting.
8
+
9
+ **Minor release with BREAKING changes.** Per project semver policy (see the
10
+ 1.1.0 entry in `@kya-os/checkpoint`'s changelog for the same call) this ships
11
+ as a minor because the only packages on npm that depend on this one are the
12
+ five first-party SDKs (`@kya-os/checkpoint`, `-nextjs`, `-express`,
13
+ `-beacon`, `-wasm-runtime`), and all of them are republished against 1.4.0 in
14
+ this same release. No third-party package declares a dependency on it. Do not
15
+ read the minor as "safe to take blind": the version number carries no warning
16
+ here, so read the list below before upgrading.
17
+
18
+ ### BREAKING
19
+
20
+ - `zod` moves to `^4.5.4` in `dependencies`. The published `.d.ts` now carry
21
+ Zod 4 types, so consumers still on Zod 3 must upgrade `zod` to `^4.5.4`
22
+ before taking this release.
23
+ - Removed `PUBLIC_API_ERROR_CODES`, `PublicApiErrorCode`,
24
+ `createPublicSuccessResponse`, `createPublicErrorResponse`, and
25
+ `createPublicPaginatedResponse` from `api/public.ts` and both barrels.
26
+ These were marked `@deprecated` in #4853: no consumer outside this repo.
27
+ Error codes live in `ERROR_CODES` (`constants/errors.ts`); response
28
+ envelopes are documented per route.
29
+ - `.uuid()` validation is now RFC 9562 strict (versions 1 through 8, plus the
30
+ nil and max UUIDs) everywhere it appears in this package's schemas. A
31
+ production probe of every id column behind a request-path `.uuid()` check
32
+ found zero non-conforming values, so no schema was relaxed to compensate.
33
+ If you generate ids outside RFC 9562, switch to a compliant generator
34
+ before adopting this release.
35
+ - Validation issue `code` values follow Zod 4's renames: `invalid_string` is
36
+ now `invalid_format`, `invalid_enum_value` and `invalid_literal` are both
37
+ now `invalid_value`, union failures are `invalid_union`, and record key
38
+ failures are `invalid_key`. Update any consumer that switches on
39
+ `issues[].code`.
40
+ - Default validation message text now follows Zod 4's wording (for example
41
+ `Invalid input: expected string, received undefined`, `Invalid UUID`,
42
+ `Invalid URL`). Update any consumer that matches on message text instead
43
+ of `code`.
44
+ - `.min()`, `.max()`, and `.length()` on `z.string()` now count Unicode code
45
+ points instead of UTF-16 code units. `z.string().min(2)` now rejects a
46
+ single emoji that Zod 3 accepted, and `z.string().max(1)` now accepts a
47
+ single emoji that Zod 3 rejected. No schema in this package changed for
48
+ this: it is Zod 4's own counting rule.
49
+ - `.datetime()` now requires seconds. `2024-01-01T00:00Z` is rejected as
50
+ `invalid_format`; `2024-01-01T00:00:00Z` still passes. No schema in this
51
+ package changed for this.
52
+ - `z.number()` and `z.coerce.number()` now reject `Infinity` (Zod 3 accepted
53
+ it, so a query param such as `?limit=1e400` coerced to `Infinity` and
54
+ passed before; it now fails validation with a 400), and `.int()` now
55
+ rejects values beyond `Number.MAX_SAFE_INTEGER`. No schema in this
56
+ package changed for this.
57
+ - `.url()` now trims surrounding whitespace from its parsed output:
58
+ `' https://x.com '` now parses to `'https://x.com'` instead of being
59
+ returned unchanged as it was on Zod 3. Internal whitespace is untouched.
60
+ No schema in this package changed for this.
61
+ - Errors thrown by this package's schemas are Zod 4 `ZodError` instances.
62
+ The `.errors` alias is gone: read `.issues` instead. `.flatten()` and
63
+ `.format()` still work but are deprecated in Zod 4.
64
+
65
+ ### Changed
66
+
67
+ - `ipAddressSchema` is now `z.union([z.ipv4(), z.ipv6()], { error: 'Invalid IP
68
+ address' })`. The accept set changed in both directions: RFC 4007
69
+ zone-scoped IPv6 literals (for example `fe80::1%eth0`) are no longer
70
+ accepted, while uncompressed embedded-IPv4 IPv6 forms (for example
71
+ `0:0:0:0:0:0:13.1.68.3`) are now accepted, where Zod 3's regex rejected
72
+ them. A failing value reports `invalid_union` with message `Invalid IP
73
+ address` instead of `invalid_string` / `Invalid ip`.
74
+ - `ProjectSchema.settings`, `PixelSchema.configuration`,
75
+ `ApiKeySchema.rateLimits`, and `PolicyConfigSchema.thresholds` moved from
76
+ `.default({})` to `.prefault({})` so their nested per-field defaults keep
77
+ filling in the way they did on Zod 3. No behaviour change: this kept the
78
+ Zod 3 fill-in, it did not add one.
79
+ - `CollectedDataSchema.detectionResults.wouldDetectAs` and
80
+ `DetectionTestResultSchema.results` (the two `IntegrationType`-keyed
81
+ records in the fingerprint types) now use `z.partialRecord`. The inferred
82
+ type is unchanged (`Partial<Record<IntegrationType, V>>`), and unknown
83
+ keys are still rejected, now reported as `unrecognized_keys`.
84
+ - The `role` field of `assignmentChangeRequestSchema`
85
+ (`src/types/admin.ts`) moved its custom message from Zod 3's `errorMap`
86
+ option to the Zod 4 `error` param. Message text is unchanged.
87
+ - `errors.mdx` (`apps/web` docs) is generated from this package's
88
+ `ERROR_CODES` registry and documents every emitted code; the registry
89
+ itself did not change in this release.
90
+
91
+ ## 1.3.1
92
+
93
+ Both groups below shipped in 1.3.1. The published 1.3.1 tarball labels them
94
+ `Unreleased` because they were never retitled at publish time.
95
+
96
+ ### Error registry single source of truth (#4792)
4
97
 
5
98
  - Extended the shared `ERROR_CODES` registry with every v1 error code emitted
6
99
  across apps/web routes: `BILLING_ERRORS`, `RESOURCE_ERRORS`,
@@ -12,7 +105,7 @@
12
105
  - Added the `./errors` subpath: a pure entrypoint re-exporting only the
13
106
  registry and picker, with no dependency on the rest of the barrel.
14
107
 
15
- ## Unreleased — client-IP resolution (#4794)
108
+ ### Client-IP resolution (#4794)
16
109
 
17
110
  - Added the runtime-agnostic client-IP normalizer and trust resolver.
18
111
  - Added shared Vercel, Cloudflare, trusted-proxy, direct, and authenticated
@@ -6,70 +6,34 @@ declare const BrowserPostureSchema: z.ZodObject<{
6
6
  origin: z.ZodString;
7
7
  session_id: z.ZodString;
8
8
  binding: z.ZodString;
9
- verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
9
+ verdict: z.ZodEnum<{
10
+ human: "human";
11
+ "agent-driven": "agent-driven";
12
+ insufficient: "insufficient";
13
+ }>;
10
14
  score: z.ZodNullable<z.ZodNumber>;
11
15
  scorer_version: z.ZodNumber;
12
- reasons: z.ZodArray<z.ZodString, "many">;
16
+ reasons: z.ZodArray<z.ZodString>;
13
17
  iat: z.ZodNumber;
14
18
  exp: z.ZodNumber;
15
- }, "strip", z.ZodTypeAny, {
16
- verdict: "human" | "agent-driven" | "insufficient";
17
- score: number | null;
18
- reasons: string[];
19
- v: 1;
20
- project_id: string;
21
- origin: string;
22
- session_id: string;
23
- binding: string;
24
- scorer_version: number;
25
- iat: number;
26
- exp: number;
27
- }, {
28
- verdict: "human" | "agent-driven" | "insufficient";
29
- score: number | null;
30
- reasons: string[];
31
- v: 1;
32
- project_id: string;
33
- origin: string;
34
- session_id: string;
35
- binding: string;
36
- scorer_version: number;
37
- iat: number;
38
- exp: number;
39
- }>;
19
+ }, z.core.$strip>;
40
20
  type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
41
21
 
42
22
  declare const BrowserPostureReportSchema: z.ZodObject<{
43
23
  projectId: z.ZodString;
44
24
  sessionId: z.ZodString;
45
- verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
25
+ verdict: z.ZodEnum<{
26
+ human: "human";
27
+ "agent-driven": "agent-driven";
28
+ insufficient: "insufficient";
29
+ }>;
46
30
  score: z.ZodNullable<z.ZodNumber>;
47
31
  scorerVersion: z.ZodNumber;
48
- reasons: z.ZodArray<z.ZodString, "many">;
32
+ reasons: z.ZodArray<z.ZodString>;
49
33
  issuedAt: z.ZodNumber;
50
34
  expiresAt: z.ZodNumber;
51
35
  source: z.ZodLiteral<"verified-posture">;
52
- }, "strip", z.ZodTypeAny, {
53
- projectId: string;
54
- sessionId: string;
55
- verdict: "human" | "agent-driven" | "insufficient";
56
- score: number | null;
57
- scorerVersion: number;
58
- reasons: string[];
59
- issuedAt: number;
60
- expiresAt: number;
61
- source: "verified-posture";
62
- }, {
63
- projectId: string;
64
- sessionId: string;
65
- verdict: "human" | "agent-driven" | "insufficient";
66
- score: number | null;
67
- scorerVersion: number;
68
- reasons: string[];
69
- issuedAt: number;
70
- expiresAt: number;
71
- source: "verified-posture";
72
- }>;
36
+ }, z.core.$strip>;
73
37
  declare function browserPostureReport(posture: BrowserPosture): {
74
38
  projectId: string;
75
39
  sessionId: string;
@@ -6,70 +6,34 @@ declare const BrowserPostureSchema: z.ZodObject<{
6
6
  origin: z.ZodString;
7
7
  session_id: z.ZodString;
8
8
  binding: z.ZodString;
9
- verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
9
+ verdict: z.ZodEnum<{
10
+ human: "human";
11
+ "agent-driven": "agent-driven";
12
+ insufficient: "insufficient";
13
+ }>;
10
14
  score: z.ZodNullable<z.ZodNumber>;
11
15
  scorer_version: z.ZodNumber;
12
- reasons: z.ZodArray<z.ZodString, "many">;
16
+ reasons: z.ZodArray<z.ZodString>;
13
17
  iat: z.ZodNumber;
14
18
  exp: z.ZodNumber;
15
- }, "strip", z.ZodTypeAny, {
16
- verdict: "human" | "agent-driven" | "insufficient";
17
- score: number | null;
18
- reasons: string[];
19
- v: 1;
20
- project_id: string;
21
- origin: string;
22
- session_id: string;
23
- binding: string;
24
- scorer_version: number;
25
- iat: number;
26
- exp: number;
27
- }, {
28
- verdict: "human" | "agent-driven" | "insufficient";
29
- score: number | null;
30
- reasons: string[];
31
- v: 1;
32
- project_id: string;
33
- origin: string;
34
- session_id: string;
35
- binding: string;
36
- scorer_version: number;
37
- iat: number;
38
- exp: number;
39
- }>;
19
+ }, z.core.$strip>;
40
20
  type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
41
21
 
42
22
  declare const BrowserPostureReportSchema: z.ZodObject<{
43
23
  projectId: z.ZodString;
44
24
  sessionId: z.ZodString;
45
- verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
25
+ verdict: z.ZodEnum<{
26
+ human: "human";
27
+ "agent-driven": "agent-driven";
28
+ insufficient: "insufficient";
29
+ }>;
46
30
  score: z.ZodNullable<z.ZodNumber>;
47
31
  scorerVersion: z.ZodNumber;
48
- reasons: z.ZodArray<z.ZodString, "many">;
32
+ reasons: z.ZodArray<z.ZodString>;
49
33
  issuedAt: z.ZodNumber;
50
34
  expiresAt: z.ZodNumber;
51
35
  source: z.ZodLiteral<"verified-posture">;
52
- }, "strip", z.ZodTypeAny, {
53
- projectId: string;
54
- sessionId: string;
55
- verdict: "human" | "agent-driven" | "insufficient";
56
- score: number | null;
57
- scorerVersion: number;
58
- reasons: string[];
59
- issuedAt: number;
60
- expiresAt: number;
61
- source: "verified-posture";
62
- }, {
63
- projectId: string;
64
- sessionId: string;
65
- verdict: "human" | "agent-driven" | "insufficient";
66
- score: number | null;
67
- scorerVersion: number;
68
- reasons: string[];
69
- issuedAt: number;
70
- expiresAt: number;
71
- source: "verified-posture";
72
- }>;
36
+ }, z.core.$strip>;
73
37
  declare function browserPostureReport(posture: BrowserPosture): {
74
38
  projectId: string;
75
39
  sessionId: string;
@@ -5,34 +5,18 @@ import { z } from 'zod';
5
5
  declare const BrowserPostureReportSchema: z.ZodObject<{
6
6
  projectId: z.ZodString;
7
7
  sessionId: z.ZodString;
8
- verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
8
+ verdict: z.ZodEnum<{
9
+ "agent-driven": "agent-driven";
10
+ human: "human";
11
+ insufficient: "insufficient";
12
+ }>;
9
13
  score: z.ZodNullable<z.ZodNumber>;
10
14
  scorerVersion: z.ZodNumber;
11
- reasons: z.ZodArray<z.ZodString, "many">;
15
+ reasons: z.ZodArray<z.ZodString>;
12
16
  issuedAt: z.ZodNumber;
13
17
  expiresAt: z.ZodNumber;
14
18
  source: z.ZodLiteral<"verified-posture">;
15
- }, "strip", z.ZodTypeAny, {
16
- verdict: "agent-driven" | "human" | "insufficient";
17
- score: number | null;
18
- reasons: string[];
19
- projectId: string;
20
- sessionId: string;
21
- scorerVersion: number;
22
- issuedAt: number;
23
- expiresAt: number;
24
- source: "verified-posture";
25
- }, {
26
- verdict: "agent-driven" | "human" | "insufficient";
27
- score: number | null;
28
- reasons: string[];
29
- projectId: string;
30
- sessionId: string;
31
- scorerVersion: number;
32
- issuedAt: number;
33
- expiresAt: number;
34
- source: "verified-posture";
35
- }>;
19
+ }, z.core.$strip>;
36
20
  declare function browserPostureReport(posture: BrowserPosture): {
37
21
  projectId: string;
38
22
  sessionId: string;
@@ -60,37 +44,17 @@ declare const BrowserPostureSchema: z.ZodObject<{
60
44
  origin: z.ZodString;
61
45
  session_id: z.ZodString;
62
46
  binding: z.ZodString;
63
- verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
47
+ verdict: z.ZodEnum<{
48
+ "agent-driven": "agent-driven";
49
+ human: "human";
50
+ insufficient: "insufficient";
51
+ }>;
64
52
  score: z.ZodNullable<z.ZodNumber>;
65
53
  scorer_version: z.ZodNumber;
66
- reasons: z.ZodArray<z.ZodString, "many">;
54
+ reasons: z.ZodArray<z.ZodString>;
67
55
  iat: z.ZodNumber;
68
56
  exp: z.ZodNumber;
69
- }, "strip", z.ZodTypeAny, {
70
- v: 1;
71
- project_id: string;
72
- origin: string;
73
- session_id: string;
74
- binding: string;
75
- verdict: "agent-driven" | "human" | "insufficient";
76
- score: number | null;
77
- scorer_version: number;
78
- reasons: string[];
79
- iat: number;
80
- exp: number;
81
- }, {
82
- v: 1;
83
- project_id: string;
84
- origin: string;
85
- session_id: string;
86
- binding: string;
87
- verdict: "agent-driven" | "human" | "insufficient";
88
- score: number | null;
89
- scorer_version: number;
90
- reasons: string[];
91
- iat: number;
92
- exp: number;
93
- }>;
57
+ }, z.core.$strip>;
94
58
  type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
95
59
  interface BrowserPostureConfig {
96
60
  publicKey: JWK;
@@ -5,34 +5,18 @@ import { z } from 'zod';
5
5
  declare const BrowserPostureReportSchema: z.ZodObject<{
6
6
  projectId: z.ZodString;
7
7
  sessionId: z.ZodString;
8
- verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
8
+ verdict: z.ZodEnum<{
9
+ "agent-driven": "agent-driven";
10
+ human: "human";
11
+ insufficient: "insufficient";
12
+ }>;
9
13
  score: z.ZodNullable<z.ZodNumber>;
10
14
  scorerVersion: z.ZodNumber;
11
- reasons: z.ZodArray<z.ZodString, "many">;
15
+ reasons: z.ZodArray<z.ZodString>;
12
16
  issuedAt: z.ZodNumber;
13
17
  expiresAt: z.ZodNumber;
14
18
  source: z.ZodLiteral<"verified-posture">;
15
- }, "strip", z.ZodTypeAny, {
16
- verdict: "agent-driven" | "human" | "insufficient";
17
- score: number | null;
18
- reasons: string[];
19
- projectId: string;
20
- sessionId: string;
21
- scorerVersion: number;
22
- issuedAt: number;
23
- expiresAt: number;
24
- source: "verified-posture";
25
- }, {
26
- verdict: "agent-driven" | "human" | "insufficient";
27
- score: number | null;
28
- reasons: string[];
29
- projectId: string;
30
- sessionId: string;
31
- scorerVersion: number;
32
- issuedAt: number;
33
- expiresAt: number;
34
- source: "verified-posture";
35
- }>;
19
+ }, z.core.$strip>;
36
20
  declare function browserPostureReport(posture: BrowserPosture): {
37
21
  projectId: string;
38
22
  sessionId: string;
@@ -60,37 +44,17 @@ declare const BrowserPostureSchema: z.ZodObject<{
60
44
  origin: z.ZodString;
61
45
  session_id: z.ZodString;
62
46
  binding: z.ZodString;
63
- verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
47
+ verdict: z.ZodEnum<{
48
+ "agent-driven": "agent-driven";
49
+ human: "human";
50
+ insufficient: "insufficient";
51
+ }>;
64
52
  score: z.ZodNullable<z.ZodNumber>;
65
53
  scorer_version: z.ZodNumber;
66
- reasons: z.ZodArray<z.ZodString, "many">;
54
+ reasons: z.ZodArray<z.ZodString>;
67
55
  iat: z.ZodNumber;
68
56
  exp: z.ZodNumber;
69
- }, "strip", z.ZodTypeAny, {
70
- v: 1;
71
- project_id: string;
72
- origin: string;
73
- session_id: string;
74
- binding: string;
75
- verdict: "agent-driven" | "human" | "insufficient";
76
- score: number | null;
77
- scorer_version: number;
78
- reasons: string[];
79
- iat: number;
80
- exp: number;
81
- }, {
82
- v: 1;
83
- project_id: string;
84
- origin: string;
85
- session_id: string;
86
- binding: string;
87
- verdict: "agent-driven" | "human" | "insufficient";
88
- score: number | null;
89
- scorer_version: number;
90
- reasons: string[];
91
- iat: number;
92
- exp: number;
93
- }>;
57
+ }, z.core.$strip>;
94
58
  type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
95
59
  interface BrowserPostureConfig {
96
60
  publicKey: JWK;