diff --git a/package-lock.json b/package-lock.json index e24268d5..5f1759f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2945,7 +2945,9 @@ } }, "node_modules/zod": { - "version": "3.25.76", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" @@ -2962,10 +2964,10 @@ }, "packages/api-types": { "name": "@codespar/api-types", - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "dependencies": { - "zod": "^3.23.0" + "zod": "^4.6.6" }, "devDependencies": { "@types/node": "^25.6.0", @@ -3039,11 +3041,11 @@ }, "packages/core": { "name": "@codespar/sdk", - "version": "0.16.29", + "version": "0.16.30", "license": "MIT", "dependencies": { "@codespar/types": "^0.10.1 || ^0.11.0", - "zod": "^3.24.0" + "zod": "^4.6.6" }, "devDependencies": { "@types/node": "^25.6.0", @@ -3099,7 +3101,7 @@ }, "packages/langchain": { "name": "@codespar/langchain", - "version": "0.5.1", + "version": "0.5.2", "license": "MIT", "devDependencies": { "@codespar/sdk": "*", @@ -3109,7 +3111,7 @@ "ajv-formats": "^3.0.1", "typescript": "^5.8.0", "vitest": "^3.1.0", - "zod": "^3.25.0", + "zod": "^4.6.6", "zod-to-json-schema": "^3.25.2" }, "peerDependencies": { diff --git a/packages/api-types/CHANGELOG.md b/packages/api-types/CHANGELOG.md new file mode 100644 index 00000000..18412fa3 --- /dev/null +++ b/packages/api-types/CHANGELOG.md @@ -0,0 +1,11 @@ +# @codespar/api-types — CHANGELOG + +## 0.6.0 — 2026-11-15 + +### Security + +- **zod 4 (GHSA-mrhx-c7xc-m3w5, core#214).** It depends on `zod ^4.6.6`. zod up to 4.6.5, and every 3.x, can exhaust memory while validating an oversized array. The schemas are now zod 4 schemas: the shapes and the inferred types are the same. A consumer that passes them to zod 3 tooling (an OpenAPI generator, for example) or composes them with its own zod 3 schemas has to move to zod 4 when it adopts 0.6.0. That is why the version is a minor: `^0.5.0` does not pick it up. + +### Added + +- `AuthTypeSchema` contains `two_header` (#72). It landed after 0.5.0 was published and reaches the registry with this version (core#132). diff --git a/packages/api-types/package.json b/packages/api-types/package.json index 188d88ee..9bfa936b 100644 --- a/packages/api-types/package.json +++ b/packages/api-types/package.json @@ -1,6 +1,6 @@ { "name": "@codespar/api-types", - "version": "0.5.0", + "version": "0.6.0", "description": "Shared REST wire contract for the CodeSpar managed-tier API (api.codespar.dev) — Zod schemas + inferred TypeScript types", "type": "module", "main": "./dist/index.js", @@ -45,7 +45,7 @@ "node": ">=20" }, "dependencies": { - "zod": "^3.23.0" + "zod": "^4.6.6" }, "devDependencies": { "@types/node": "^25.6.0", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index a9459581..f10b4c7b 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,16 @@ # @codespar/sdk — CHANGELOG +## 0.16.30 — 2026-11-15 + +### Security + +- **zod 4 (GHSA-mrhx-c7xc-m3w5, core#214).** The SDK now depends on `zod ^4.6.6`. zod up to 4.6.5, and every 3.x, can exhaust memory while validating an oversized array. `SessionConfigSchema` is now a zod 4 schema with the same shape and the same `SessionConfig` type. Code that only calls `new CodeSpar(...)` / `create(...)` changes nothing. Code that composes `SessionConfigSchema` with its own zod 3 schemas (`.extend`, `.merge`, `z.union`) has to move to zod 4. +- In the schema, `metadata` and `mocks` use the two-argument `z.record(key, value)`. What validates is the same. + +### Changed + +- The OpenAPI snapshot follows the served document (868a0272e249, 390 operations): `GET /v1/account/balances` gains `usdc_accounts[].seed` (the one Test top-up from the treasury, enterprise#2582), and a Shop purchase's `awaiting.reason` gains `identity_required` and `consent_required` (enterprise#2580). An exhaustive `switch` over `awaiting.reason` needs the two new cases. + ## 0.16.29 — 2026-11-11 ### Changed diff --git a/packages/core/openapi-snapshot.json b/packages/core/openapi-snapshot.json index c1dbe9d2..d1b3ac6d 100644 --- a/packages/core/openapi-snapshot.json +++ b/packages/core/openapi-snapshot.json @@ -1,8 +1,8 @@ { "snapshot": { "source": "https://api.codespar.dev/openapi.json", - "fetched_at": "2026-11-11T11:18:25.811Z", - "sha256": "b9b057565a31502b762e37b6c0c713984543f48a2425e34729bf1332afa34cfb", + "fetched_at": "2026-11-15T23:15:37.743Z", + "sha256": "868a0272e249a736c8f2510fb7e7def491fdb6ee509d85fc09e5f2fb32af33bd", "etag": null, "last_modified": null, "info": { @@ -7383,6 +7383,60 @@ "string", "null" ] + }, + "seed": { + "type": [ + "object", + "null" + ], + "properties": { + "state": { + "type": "string", + "enum": [ + "awaiting_treasury", + "sending", + "submitted", + "confirmed", + "not_needed", + "needs_attention" + ] + }, + "amount_atomic": { + "type": "string", + "pattern": "^\\d+$", + "description": "USDC the Test treasury sends (the difference to 100 USDC), 6 decimals." + }, + "treasury_address": { + "type": "string" + }, + "tx_hash": { + "type": [ + "string", + "null" + ] + }, + "gas": { + "type": [ + "string", + "null" + ] + }, + "reason": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "state", + "amount_atomic", + "treasury_address", + "tx_hash", + "gas", + "reason" + ], + "description": "Test only: the one initial top-up from the Test treasury; credited by the importer once the Transfer is confirmed." } }, "required": [ @@ -116961,7 +117015,9 @@ "approval", "challenge", "store_challenge", - "store_cvv_requested" + "store_cvv_requested", + "identity_required", + "consent_required" ] } }, @@ -117198,7 +117254,9 @@ "approval", "challenge", "store_challenge", - "store_cvv_requested" + "store_cvv_requested", + "identity_required", + "consent_required" ] } }, @@ -117730,7 +117788,9 @@ "approval", "challenge", "store_challenge", - "store_cvv_requested" + "store_cvv_requested", + "identity_required", + "consent_required" ] } }, diff --git a/packages/core/package.json b/packages/core/package.json index 3ee596ff..c67ae742 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@codespar/sdk", - "version": "0.16.29", + "version": "0.16.30", "description": "Commerce SDK for AI agents \u2014 sessions, managed auth, Complete Loop orchestration for Latin American APIs", "type": "module", "main": "./dist/index.js", @@ -59,7 +59,7 @@ }, "dependencies": { "@codespar/types": "^0.10.1 || ^0.11.0", - "zod": "^3.24.0" + "zod": "^4.6.6" }, "devDependencies": { "@types/node": "^25.6.0", diff --git a/packages/core/src/generated/openapi.ts b/packages/core/src/generated/openapi.ts index 21c4e3d7..92d166ee 100644 --- a/packages/core/src/generated/openapi.ts +++ b/packages/core/src/generated/openapi.ts @@ -1,5 +1,5 @@ // GENERATED FILE — do not edit. -// Source: openapi-snapshot.json (sha256 b9b057565a31502b762e37b6c0c713984543f48a2425e34729bf1332afa34cfb, fetched 2026-11-11T11:18:25.811Z +// Source: openapi-snapshot.json (sha256 868a0272e249a736c8f2510fb7e7def491fdb6ee509d85fc09e5f2fb32af33bd, fetched 2026-11-15T23:15:37.743Z // from https://api.codespar.dev/openapi.json, API 0.3.0). // Regenerate: npm run spec:generate (in packages/core) export interface paths { @@ -3299,6 +3299,17 @@ export interface paths { faucet: string | null; reason: string | null; checked_at: string | null; + /** @description Test only: the one initial top-up from the Test treasury; credited by the importer once the Transfer is confirmed. */ + seed?: { + /** @enum {string} */ + state: "awaiting_treasury" | "sending" | "submitted" | "confirmed" | "not_needed" | "needs_attention"; + /** @description USDC the Test treasury sends (the difference to 100 USDC), 6 decimals. */ + amount_atomic: string; + treasury_address: string; + tx_hash: string | null; + gas: string | null; + reason: string | null; + } | null; }[]; /** @description The account's money only. Empty when `account.exists` is false (a Test project with no own account yet): the simulator's residue is never presented as the account's balance, nor as a zero one; it is in `simulator_legacy`. */ currencies: { @@ -48388,7 +48399,7 @@ export interface paths { run_state: "ready" | "awaiting_user" | "running" | "interrupted" | "completed" | "cancelled"; awaiting: { /** @enum {string} */ - reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested"; + reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested" | "identity_required" | "consent_required"; } | null; merchant: { id: string; @@ -48447,7 +48458,7 @@ export interface paths { run_state: "ready" | "awaiting_user" | "running" | "interrupted" | "completed" | "cancelled"; awaiting: { /** @enum {string} */ - reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested"; + reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested" | "identity_required" | "consent_required"; } | null; merchant: { id: string; @@ -48657,7 +48668,7 @@ export interface paths { run_state: "ready" | "awaiting_user" | "running" | "interrupted" | "completed" | "cancelled"; awaiting: { /** @enum {string} */ - reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested"; + reason: "instrument" | "store_login" | "cvv" | "approval" | "challenge" | "store_challenge" | "store_cvv_requested" | "identity_required" | "consent_required"; } | null; merchant: { id: string; diff --git a/packages/core/src/generated/operations.ts b/packages/core/src/generated/operations.ts index 094f8f37..202f9f9d 100644 --- a/packages/core/src/generated/operations.ts +++ b/packages/core/src/generated/operations.ts @@ -1,5 +1,5 @@ // GENERATED FILE — do not edit. -// Source: openapi-snapshot.json (sha256 b9b057565a31502b762e37b6c0c713984543f48a2425e34729bf1332afa34cfb, fetched 2026-11-11T11:18:25.811Z +// Source: openapi-snapshot.json (sha256 868a0272e249a736c8f2510fb7e7def491fdb6ee509d85fc09e5f2fb32af33bd, fetched 2026-11-15T23:15:37.743Z // from https://api.codespar.dev/openapi.json, API 0.3.0). // Regenerate: npm run spec:generate (in packages/core) import type { ApiOperationRef } from "../api/types.js"; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index bfb5b35a..6b73e55e 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -114,8 +114,8 @@ export interface LoopResult { // validation, so the client-side schema accepts any object shape // rather than re-encoding the rules and risking drift. const MockValueSchema = z.union([ - z.record(z.unknown()), - z.array(z.record(z.unknown())), + z.record(z.string(), z.unknown()), + z.array(z.record(z.string(), z.unknown())), ]); /** Wire format for a project scope. Shared by the Zod session schema @@ -131,9 +131,9 @@ export const SessionConfigSchema = z.object({ timeout: z.number().optional(), }) .optional(), - metadata: z.record(z.string()).optional(), + metadata: z.record(z.string(), z.string()).optional(), projectId: z.string().regex(PROJECT_ID_REGEX).optional(), - mocks: z.record(MockValueSchema).optional(), + mocks: z.record(z.string(), MockValueSchema).optional(), }); /* ── Payables: documents and batches (/v1/payables/files, /v1/payables/batches) ── */ diff --git a/packages/langchain/CHANGELOG.md b/packages/langchain/CHANGELOG.md index 8f4d451a..1a30c5f0 100644 --- a/packages/langchain/CHANGELOG.md +++ b/packages/langchain/CHANGELOG.md @@ -1,5 +1,11 @@ # @codespar/langchain — changelog +## 0.5.2 — 2026-11-15 + +### Security + +- **zod 4 in development (GHSA-mrhx-c7xc-m3w5, core#214).** The dev dependency goes to `zod ^4.6.6`, and the tests import `zod/v3`, the same entry as `schema.ts`. The peer stays `zod >=3.25.0`: the package reads the classic API through `zod/v3`, which zod 3.25+ and zod 4 both ship. The input bound of 0.5.1 is unchanged. A project on zod 3 still has the advisory in its own tree; moving it to zod >= 4.6.6 is what removes it. + ## 0.5.1 — 2026-11-08 ### Security diff --git a/packages/langchain/package.json b/packages/langchain/package.json index f8a45ec6..d4ee14bc 100644 --- a/packages/langchain/package.json +++ b/packages/langchain/package.json @@ -1,6 +1,6 @@ { "name": "@codespar/langchain", - "version": "0.5.1", + "version": "0.5.2", "description": "LangChain.js adapter for CodeSpar — convert session tools to LangChain StructuredTool format", "type": "module", "main": "./dist/index.js", @@ -48,7 +48,7 @@ "ajv-formats": "^3.0.1", "typescript": "^5.8.0", "vitest": "^3.1.0", - "zod": "^3.25.0", + "zod": "^4.6.6", "zod-to-json-schema": "^3.25.2" } } diff --git a/packages/langchain/src/__tests__/schema.test.ts b/packages/langchain/src/__tests__/schema.test.ts index 609970a8..618718d1 100644 --- a/packages/langchain/src/__tests__/schema.test.ts +++ b/packages/langchain/src/__tests__/schema.test.ts @@ -5,7 +5,7 @@ */ import { describe, it, expect } from "vitest"; -import { z } from "zod"; +import { z } from "zod/v3"; import { CHARGE_DEFINITION, CRYPTO_PAY_DEFINITION, diff --git a/scripts/audit-exceptions.json b/scripts/audit-exceptions.json index de767e43..ab410117 100644 --- a/scripts/audit-exceptions.json +++ b/scripts/audit-exceptions.json @@ -1,13 +1,4 @@ { "_comment": "Read by scripts/audit-gate.mjs. Each entry accepts ONE advisory for ONE package until `expires` (UTC date, exclusive). Only HIGH can be accepted, only when npm offers no fix inside the declared range (none, or a semver-major one). Renewing an entry is a reviewed change, not an edit to keep CI green.", - "exceptions": [ - { - "id": "GHSA-mrhx-c7xc-m3w5", - "package": "zod", - "severity": "high", - "expires": "2026-11-16", - "issue": "https://github.com/codespar/codespar-core/issues/214", - "justification": "Memory exhaustion while validating oversized constrained collections: a denial of service of the process doing the validation, with no data exposure. The only fix is zod >= 4.6.6, a major that changes the public types of @codespar/api-types and @codespar/sdk consumed by codespar-enterprise and codespar-web; no patched 3.x exists. Renewed on 2026-11-09 for seven days only because of the mitigation in #245: a model's tool arguments, the untrusted input that reaches Zod in this repo, are bounded by @codespar/langchain before any schema parses them. The other parses in this repo read developer configuration and first-party API responses. Without #245 this renewal does not stand. The zod 4 migration is tracked in #214 with the coordinated bumps." - } - ] + "exceptions": [] } diff --git a/scripts/publish-drift-baseline.json b/scripts/publish-drift-baseline.json index d6d4aa28..97c79122 100644 --- a/scripts/publish-drift-baseline.json +++ b/scripts/publish-drift-baseline.json @@ -9,13 +9,5 @@ "rather than accumulated. This file is not a place to silence new findings.", "Regenerate a fingerprint with: node scripts/check-publish-drift.mjs --json" ], - "waivers": [ - { - "name": "@codespar/api-types", - "version": "0.5.0", - "fingerprint": "d77dae43ecfca2fe5aa7fb188706fc9bc59b08b890180a9edd4ab4d2d1077c09", - "issue": "core#132", - "note": "The two_header auth type (#72) landed after 0.5.0 was published; the published AuthTypeSchema does not contain it. Additive to a schema, so 0.5.1 vs 0.6.0 is a release decision." - } - ] + "waivers": [] }