@peac/mcp-server 0.11.3 → 0.12.0-preview.2

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/dist/cli.cjs CHANGED
@@ -1171,16 +1171,15 @@ async function handleVerify(params) {
1171
1171
  const claims = result.claims;
1172
1172
  const claimsSummary = {
1173
1173
  iss: claims.iss,
1174
- aud: claims.aud,
1175
- rid: claims.rid,
1176
- variant: result.variant
1174
+ kind: claims.kind,
1175
+ type: claims.type,
1176
+ jti: claims.jti,
1177
+ ...claims.sub !== void 0 && { sub: claims.sub },
1178
+ variant: result.variant,
1179
+ wireVersion: result.wireVersion
1177
1180
  };
1178
- if (result.variant === "commerce") {
1179
- claimsSummary.amt = claims.amt;
1180
- claimsSummary.cur = claims.cur;
1181
- }
1182
1181
  const tr = truncateResponse(
1183
- `Verification PASSED (${result.variant} receipt, kid=${result.kid})`,
1182
+ `Verification PASSED (${result.variant} receipt, kind=${claims.kind ?? "unknown"}, kid=${result.kid})`,
1184
1183
  policy
1185
1184
  );
1186
1185
  return {
@@ -1413,49 +1412,44 @@ async function handleIssue(params) {
1413
1412
  isError: true
1414
1413
  };
1415
1414
  }
1416
- if (input.ttl_seconds !== void 0 && input.ttl_seconds > policy.limits.max_ttl_seconds) {
1417
- return {
1418
- text: `Input rejected: ttl_seconds ${input.ttl_seconds} exceeds max_ttl_seconds ${policy.limits.max_ttl_seconds}`,
1419
- structured: {
1420
- ok: false,
1421
- code: "E_MCP_INVALID_INPUT",
1422
- message: `ttl_seconds ${input.ttl_seconds} exceeds policy max of ${policy.limits.max_ttl_seconds}`
1423
- },
1424
- isError: true
1425
- };
1426
- }
1427
1415
  const keyPatterns = buildKeyPatterns(context.issuerKey.privateKey, context.issuerKey.publicKey);
1428
- const now = Math.floor(Date.now() / 1e3);
1429
- const exp = input.ttl_seconds !== void 0 ? now + input.ttl_seconds : void 0;
1430
1416
  try {
1431
- const result = await protocol.issue({
1417
+ if (input.policy && !input.policy.digest) {
1418
+ return {
1419
+ text: "Issue failed: policy.digest is required when policy block is provided",
1420
+ structured: {
1421
+ ok: false,
1422
+ code: "E_MCP_ISSUE_FAILED",
1423
+ message: "policy.digest is required when policy block is provided (uri/version alone is insufficient for binding)"
1424
+ },
1425
+ isError: true
1426
+ };
1427
+ }
1428
+ const policyBlock = input.policy?.digest ? { digest: input.policy.digest, uri: input.policy.uri, version: input.policy.version } : void 0;
1429
+ const result = await protocol.issueWire02({
1432
1430
  iss: context.issuerId,
1433
- aud: input.aud,
1434
- amt: input.amt,
1435
- cur: input.cur,
1436
- rail: input.rail,
1437
- reference: input.reference,
1438
- asset: input.asset,
1439
- env: input.env,
1440
- network: input.network,
1441
- evidence: input.evidence,
1442
- subject: input.subject,
1443
- exp,
1431
+ kind: input.kind,
1432
+ type: input.type,
1433
+ sub: input.sub,
1434
+ pillars: input.pillars,
1435
+ occurred_at: input.occurred_at,
1436
+ extensions: input.extensions,
1437
+ policy: policyBlock,
1444
1438
  privateKey: context.issuerKey.privateKey,
1445
1439
  kid: context.issuerKey.kid
1446
1440
  });
1447
1441
  const { payload } = crypto.decode(result.jws);
1448
1442
  const claimsSummary = {
1449
1443
  iss: payload.iss,
1450
- aud: payload.aud,
1444
+ kind: payload.kind,
1445
+ type: payload.type,
1451
1446
  iat: payload.iat,
1452
- ...payload.exp !== void 0 ? { exp: payload.exp } : {},
1453
- rid: payload.rid,
1454
- amt: payload.amt,
1455
- cur: payload.cur
1447
+ jti: payload.jti,
1448
+ ...payload.sub !== void 0 ? { sub: payload.sub } : {},
1449
+ ...payload.pillars !== void 0 ? { pillars: payload.pillars } : {}
1456
1450
  };
1457
1451
  const tr = truncateResponse(
1458
- `Receipt issued: rid=${claimsSummary.rid}, ${claimsSummary.amt} ${claimsSummary.cur}`,
1452
+ `Receipt issued: jti=${claimsSummary.jti}, kind=${claimsSummary.kind}, type=${claimsSummary.type}`,
1459
1453
  policy
1460
1454
  );
1461
1455
  const safeText = sanitizeOutput(tr.text, keyPatterns);
@@ -1879,18 +1873,41 @@ var DecodeOutputSchema = zod.z.object({
1879
1873
  verified: zod.z.literal(false)
1880
1874
  });
1881
1875
  var IssueInputSchema = zod.z.object({
1882
- aud: zod.z.string().url().describe("Audience / resource URI (https://)"),
1883
- amt: zod.z.number().int().nonnegative().describe("Amount in smallest currency unit"),
1884
- cur: zod.z.string().regex(/^[A-Z]{3}$/).describe("ISO 4217 currency code (uppercase, e.g. USD)"),
1885
- rail: zod.z.string().describe("Payment rail identifier"),
1886
- reference: zod.z.string().describe("Unique payment reference"),
1887
- asset: zod.z.string().optional().describe("Asset transferred (e.g. USDC) -- defaults to currency"),
1888
- env: zod.z.enum(["live", "test"]).default("test").describe("Environment"),
1889
- network: zod.z.string().optional().describe("Network/chain identifier"),
1890
- evidence: zod.z.unknown().optional().describe("Rail-specific evidence (JSON-safe)"),
1891
- subject: zod.z.string().url().optional().describe("Subject URI (https://)"),
1892
- ttl_seconds: zod.z.number().int().positive().optional().describe("Time-to-live in seconds (computes exp = iat + ttl)"),
1893
- kind: zod.z.string().optional().describe("Receipt kind for policy filtering")
1876
+ kind: zod.z.enum(["evidence", "challenge"]).describe("Structural kind: evidence (records interaction) or challenge (requests action)"),
1877
+ type: zod.z.string().min(1).max(256).refine(
1878
+ (v) => /^https?:\/\//.test(v) || /^[a-zA-Z0-9][a-zA-Z0-9._-]*\.[a-zA-Z0-9._-]+\/[a-zA-Z0-9]/.test(v),
1879
+ {
1880
+ message: "type must be reverse-DNS (e.g. org.peacprotocol/payment) or absolute URI (https://...)"
1881
+ }
1882
+ ).describe("Semantic type in reverse-DNS or absolute URI form (e.g. org.peacprotocol/payment)"),
1883
+ sub: zod.z.string().max(2048).optional().describe("Subject identifier (resource or interaction target)"),
1884
+ pillars: zod.z.array(
1885
+ zod.z.enum([
1886
+ "access",
1887
+ "attribution",
1888
+ "commerce",
1889
+ "compliance",
1890
+ "consent",
1891
+ "identity",
1892
+ "privacy",
1893
+ "provenance",
1894
+ "purpose",
1895
+ "safety"
1896
+ ])
1897
+ ).optional().refine(
1898
+ (arr) => !arr || new Set(arr).size === arr.length && [...arr].sort().every((v, i) => v === arr[i]),
1899
+ { message: "pillars must be unique and sorted ascending" }
1900
+ ).describe("Evidence pillars from closed 10-value taxonomy (sorted ascending)"),
1901
+ occurred_at: zod.z.string().optional().refine((v) => !v || !isNaN(Date.parse(v)), {
1902
+ message: "occurred_at must be a valid ISO 8601 timestamp"
1903
+ }).describe("ISO 8601 timestamp when interaction occurred (evidence kind only)"),
1904
+ extensions: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Extension groups keyed by reverse-DNS identifier"),
1905
+ policy: zod.z.object({
1906
+ uri: zod.z.string().url().max(2048).refine((v) => v.startsWith("https://"), { message: "policy.uri must use HTTPS" }).describe("Policy document URI (HTTPS only)"),
1907
+ version: zod.z.string().max(256).optional().describe("Policy version"),
1908
+ digest: zod.z.string().regex(/^sha256:[0-9a-f]{64}$/).optional().describe("Policy digest in sha256:<64 hex> format")
1909
+ }).optional().describe("Policy binding block"),
1910
+ ttl_seconds: zod.z.number().int().positive().optional().describe("Reserved for future use (Wire 0.2 receipts do not expire)")
1894
1911
  });
1895
1912
  var MetaSchema4 = zod.z.object({
1896
1913
  serverVersion: zod.z.string(),
@@ -1899,12 +1916,12 @@ var MetaSchema4 = zod.z.object({
1899
1916
  });
1900
1917
  var ClaimsSummarySchema = zod.z.object({
1901
1918
  iss: zod.z.string(),
1902
- aud: zod.z.string(),
1919
+ kind: zod.z.string(),
1920
+ type: zod.z.string(),
1903
1921
  iat: zod.z.number(),
1904
- exp: zod.z.number().optional(),
1905
- rid: zod.z.string(),
1906
- amt: zod.z.number(),
1907
- cur: zod.z.string()
1922
+ jti: zod.z.string(),
1923
+ sub: zod.z.string().optional(),
1924
+ pillars: zod.z.array(zod.z.string()).optional()
1908
1925
  });
1909
1926
  var IssueOutputSchema = zod.z.object({
1910
1927
  _meta: MetaSchema4,
@@ -1940,7 +1957,8 @@ function makeMeta(ctx, serverName) {
1940
1957
  serverName,
1941
1958
  serverVersion: ctx.version,
1942
1959
  policyHash: ctx.policyHash,
1943
- protocolVersion: ctx.protocolVersion
1960
+ protocolVersion: ctx.protocolVersion,
1961
+ wireFormatVersion: "0.2"
1944
1962
  };
1945
1963
  }
1946
1964
  function handlerResultToCallToolResult(result, meta) {
@@ -2132,8 +2150,8 @@ function createPeacMcpServer(options) {
2132
2150
  register(
2133
2151
  "peac_issue",
2134
2152
  {
2135
- title: "Issue PEAC Receipt",
2136
- description: "Sign and return a new PEAC receipt JWS. Requires server configured with an Ed25519 issuer key (--issuer-key and --issuer-id).",
2153
+ title: "Issue Wire 0.2 PEAC Receipt",
2154
+ description: "Sign and return a Wire 0.2 PEAC receipt JWS. Accepts kind, type, pillars, extensions, and policy fields. Wire 0.2 only: Wire 0.1 fields are not accepted. Requires server configured with an Ed25519 issuer key (--issuer-key and --issuer-id).",
2137
2155
  inputSchema: IssueInputSchema,
2138
2156
  outputSchema: IssueOutputSchema,
2139
2157
  annotations: ISSUE_TOOL_ANNOTATIONS