@strimz/shared-types 0.1.1 → 0.2.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.
Files changed (58) hide show
  1. package/dist/api-keys.cjs +6 -1
  2. package/dist/api-keys.cjs.map +1 -1
  3. package/dist/api-keys.d.cts +12 -12
  4. package/dist/api-keys.d.ts +12 -12
  5. package/dist/api-keys.js +6 -1
  6. package/dist/api-keys.js.map +1 -1
  7. package/dist/events.cjs +21 -3
  8. package/dist/events.cjs.map +1 -1
  9. package/dist/events.d.cts +12 -12
  10. package/dist/events.d.ts +12 -12
  11. package/dist/events.js +21 -3
  12. package/dist/events.js.map +1 -1
  13. package/dist/index.cjs +181 -4
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +295 -10
  16. package/dist/index.d.ts +295 -10
  17. package/dist/index.js +160 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/merchants.cjs +59 -1
  20. package/dist/merchants.cjs.map +1 -1
  21. package/dist/merchants.d.cts +171 -1
  22. package/dist/merchants.d.ts +171 -1
  23. package/dist/merchants.js +55 -2
  24. package/dist/merchants.js.map +1 -1
  25. package/dist/payment-sessions.cjs +6 -2
  26. package/dist/payment-sessions.cjs.map +1 -1
  27. package/dist/payment-sessions.d.cts +19 -3
  28. package/dist/payment-sessions.d.ts +19 -3
  29. package/dist/payment-sessions.js +6 -3
  30. package/dist/payment-sessions.js.map +1 -1
  31. package/dist/refunds.cjs +12 -0
  32. package/dist/refunds.cjs.map +1 -1
  33. package/dist/refunds.d.cts +134 -1
  34. package/dist/refunds.d.ts +134 -1
  35. package/dist/refunds.js +11 -1
  36. package/dist/refunds.js.map +1 -1
  37. package/dist/storefronts.cjs +14 -0
  38. package/dist/storefronts.cjs.map +1 -1
  39. package/dist/storefronts.d.cts +37 -1
  40. package/dist/storefronts.d.ts +37 -1
  41. package/dist/storefronts.js +13 -1
  42. package/dist/storefronts.js.map +1 -1
  43. package/dist/webhooks.cjs +6 -0
  44. package/dist/webhooks.cjs.map +1 -1
  45. package/dist/webhooks.d.cts +60 -1
  46. package/dist/webhooks.d.ts +60 -1
  47. package/dist/webhooks.js +6 -1
  48. package/dist/webhooks.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/api-keys.ts +5 -0
  51. package/src/contact.ts +26 -0
  52. package/src/index.ts +2 -0
  53. package/src/merchants.ts +84 -0
  54. package/src/notifications.ts +88 -0
  55. package/src/payment-sessions.ts +24 -2
  56. package/src/refunds.ts +19 -0
  57. package/src/storefronts.ts +24 -0
  58. package/src/webhooks.ts +12 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlEA,KAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAGnE,IAAM,cAAA,GAAiBA,KAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC,CAAA;AAG0BA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOPA,KAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,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AA,EAAS;AAAA,EAC7C,WAAWA,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAGM,IAAM,yBAAA,GAA4BA,MAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF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A,CAAO;AAAA,EAC5C,EAAA,EAAI,QAAA;AAAA,EACJ,UAAA,EAAY,QAAA;AAAA,EACZ,UAAA,EAAY,QAAA;AAAA,EACZ,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,sBAAA;AAAA,EACX,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAASA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,MAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,MAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,KAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,MAAE,MAAA,CAAOA,KAAAA,CAAE,QAAO,EAAGA,KAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,MAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
@@ -189,6 +189,65 @@ declare const webhookDeliverySchema: z.ZodObject<{
189
189
  deliveredAt: string | null;
190
190
  }>;
191
191
  type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
192
+ /**
193
+ * Detail projection returned by GET /v1/webhook-deliveries/:id.
194
+ * Carries the payload envelope, response body, and the deliveryId
195
+ * header the receiver saw. Kept separate so list responses stay slim.
196
+ */
197
+ declare const webhookDeliveryDetailSchema: z.ZodObject<{
198
+ id: z.ZodString;
199
+ merchantId: z.ZodString;
200
+ endpointId: z.ZodString;
201
+ eventId: z.ZodString;
202
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
203
+ status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
204
+ attempt: z.ZodNumber;
205
+ responseCode: z.ZodNullable<z.ZodNumber>;
206
+ responseMs: z.ZodNullable<z.ZodNumber>;
207
+ lastError: z.ZodNullable<z.ZodString>;
208
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
209
+ deliveredAt: z.ZodNullable<z.ZodString>;
210
+ createdAt: z.ZodString;
211
+ } & {
212
+ deliveryId: z.ZodString;
213
+ responseBody: z.ZodNullable<z.ZodString>;
214
+ requestPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
217
+ id: string;
218
+ merchantId: string;
219
+ createdAt: string;
220
+ endpointId: string;
221
+ eventId: string;
222
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
223
+ attempt: number;
224
+ responseCode: number | null;
225
+ responseMs: number | null;
226
+ lastError: string | null;
227
+ nextAttemptAt: string | null;
228
+ deliveredAt: string | null;
229
+ deliveryId: string;
230
+ responseBody: string | null;
231
+ requestPayload: Record<string, unknown>;
232
+ }, {
233
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
234
+ id: string;
235
+ merchantId: string;
236
+ createdAt: string;
237
+ endpointId: string;
238
+ eventId: string;
239
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
240
+ attempt: number;
241
+ responseCode: number | null;
242
+ responseMs: number | null;
243
+ lastError: string | null;
244
+ nextAttemptAt: string | null;
245
+ deliveredAt: string | null;
246
+ deliveryId: string;
247
+ responseBody: string | null;
248
+ requestPayload: Record<string, unknown>;
249
+ }>;
250
+ type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>;
192
251
  declare const replayDeliveryInputSchema: z.ZodObject<{
193
252
  id: z.ZodString;
194
253
  }, "strip", z.ZodTypeAny, {
@@ -198,4 +257,4 @@ declare const replayDeliveryInputSchema: z.ZodObject<{
198
257
  }>;
199
258
  type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>;
200
259
 
201
- export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
260
+ export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
@@ -189,6 +189,65 @@ declare const webhookDeliverySchema: z.ZodObject<{
189
189
  deliveredAt: string | null;
190
190
  }>;
191
191
  type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
192
+ /**
193
+ * Detail projection returned by GET /v1/webhook-deliveries/:id.
194
+ * Carries the payload envelope, response body, and the deliveryId
195
+ * header the receiver saw. Kept separate so list responses stay slim.
196
+ */
197
+ declare const webhookDeliveryDetailSchema: z.ZodObject<{
198
+ id: z.ZodString;
199
+ merchantId: z.ZodString;
200
+ endpointId: z.ZodString;
201
+ eventId: z.ZodString;
202
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
203
+ status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
204
+ attempt: z.ZodNumber;
205
+ responseCode: z.ZodNullable<z.ZodNumber>;
206
+ responseMs: z.ZodNullable<z.ZodNumber>;
207
+ lastError: z.ZodNullable<z.ZodString>;
208
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
209
+ deliveredAt: z.ZodNullable<z.ZodString>;
210
+ createdAt: z.ZodString;
211
+ } & {
212
+ deliveryId: z.ZodString;
213
+ responseBody: z.ZodNullable<z.ZodString>;
214
+ requestPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
217
+ id: string;
218
+ merchantId: string;
219
+ createdAt: string;
220
+ endpointId: string;
221
+ eventId: string;
222
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
223
+ attempt: number;
224
+ responseCode: number | null;
225
+ responseMs: number | null;
226
+ lastError: string | null;
227
+ nextAttemptAt: string | null;
228
+ deliveredAt: string | null;
229
+ deliveryId: string;
230
+ responseBody: string | null;
231
+ requestPayload: Record<string, unknown>;
232
+ }, {
233
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
234
+ id: string;
235
+ merchantId: string;
236
+ createdAt: string;
237
+ endpointId: string;
238
+ eventId: string;
239
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
240
+ attempt: number;
241
+ responseCode: number | null;
242
+ responseMs: number | null;
243
+ lastError: string | null;
244
+ nextAttemptAt: string | null;
245
+ deliveredAt: string | null;
246
+ deliveryId: string;
247
+ responseBody: string | null;
248
+ requestPayload: Record<string, unknown>;
249
+ }>;
250
+ type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>;
192
251
  declare const replayDeliveryInputSchema: z.ZodObject<{
193
252
  id: z.ZodString;
194
253
  }, "strip", z.ZodTypeAny, {
@@ -198,4 +257,4 @@ declare const replayDeliveryInputSchema: z.ZodObject<{
198
257
  }>;
199
258
  type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>;
200
259
 
201
- export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
260
+ export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
package/dist/webhooks.js CHANGED
@@ -98,10 +98,15 @@ var webhookDeliverySchema = z.object({
98
98
  deliveredAt: isoTimestampSchema.nullable(),
99
99
  createdAt: isoTimestampSchema
100
100
  });
101
+ var webhookDeliveryDetailSchema = webhookDeliverySchema.extend({
102
+ deliveryId: z.string(),
103
+ responseBody: z.string().nullable(),
104
+ requestPayload: z.record(z.string(), z.unknown())
105
+ });
101
106
  var replayDeliveryInputSchema = z.object({
102
107
  id: idSchema
103
108
  });
104
109
 
105
- export { createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
110
+ export { createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
106
111
  //# sourceMappingURL=webhooks.js.map
107
112
  //# sourceMappingURL=webhooks.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAA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V,aAAA,EAAeA,EAAE,MAAA;AACnB,CAAC;AAKM,IAAM,2BAAA,GAA8BA,EAAE,IAAA,CAAK;AAAA,EAChD,SAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,qBAAA,GAAwBA,EAAE,MAAA,CAAO;AAAA,EAC5C,EAAA,EAAI,QAAA;AAAA,EACJ,UAAA,EAAY,QAAA;AAAA,EACZ,UAAA,EAAY,QAAA;AAAA,EACZ,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,sBAAA;AAAA,EACX,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAGM,IAAM,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJ,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAGnE,IAAM,cAAA,GAAiB,CAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC,CAAA;AAG0B,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOP,CAAA,CAC9B,MAAA,EAAO,CAC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I,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,EAAE,MAAA,CAAOA,CAAAA,CAAE,QAAO,EAAGA,CAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strimz/shared-types",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Zod schemas and inferred TypeScript types for every Strimz platform entity, API input, and webhook event.",
5
5
  "license": "MIT",
6
6
  "author": "Strimz <hello@strimz.finance>",
package/src/api-keys.ts CHANGED
@@ -36,6 +36,11 @@ export const apiKeyScopeSchema = z.enum([
36
36
  // hosted checkout and merchants embedding the SDK.
37
37
  'relay_read',
38
38
  'relay_write',
39
+ // Self-service key management from an API key holder. Rarely used
40
+ // day-to-day; needed for partner onboarding flows that mint scoped
41
+ // keys per sub-tenant.
42
+ 'api_keys_read',
43
+ 'api_keys_write',
39
44
  ])
40
45
  export type ApiKeyScope = z.infer<typeof apiKeyScopeSchema>
41
46
 
package/src/contact.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Public marketing contact form. Not an authenticated API resource —
3
+ * routed straight to a support inbox by the contact module in
4
+ * `apps/api`. Kept shape-compatible with what the marketing form on
5
+ * the Strimz landing page already validates client-side.
6
+ */
7
+
8
+ import { z } from 'zod'
9
+ import { emailSchema } from './common.js'
10
+
11
+ export const contactTopicSchema = z.enum(['sales', 'support', 'partnership', 'security', 'other'])
12
+ export type ContactTopic = z.infer<typeof contactTopicSchema>
13
+
14
+ export const contactRequestInputSchema = z.object({
15
+ name: z.string().min(2).max(120),
16
+ email: emailSchema,
17
+ company: z.string().min(1).max(120).optional(),
18
+ topic: contactTopicSchema,
19
+ message: z.string().min(20).max(4000),
20
+ })
21
+ export type ContactRequestInput = z.infer<typeof contactRequestInputSchema>
22
+
23
+ export const contactRequestOutputSchema = z.object({
24
+ ok: z.literal(true),
25
+ })
26
+ export type ContactRequestOutput = z.infer<typeof contactRequestOutputSchema>
package/src/index.ts CHANGED
@@ -21,3 +21,5 @@ export * from './storefronts.js'
21
21
  export * from './invoices.js'
22
22
  export * from './events.js'
23
23
  export * from './tokens.js'
24
+ export * from './contact.js'
25
+ export * from './notifications.js'
package/src/merchants.ts CHANGED
@@ -30,6 +30,8 @@ export const merchantSchema = z.object({
30
30
  tier: merchantTierSchema,
31
31
  status: merchantStatusSchema,
32
32
  payoutAddress: evmAddressSchema.nullable(),
33
+ walletAddress: evmAddressSchema.nullable(),
34
+ onboardingCompleted: z.boolean(),
33
35
  defaultCurrency: z.enum(['USDC', 'EURC']),
34
36
  countryCode: z.string().length(2).nullable(),
35
37
  websiteUrl: z.string().url().nullable(),
@@ -52,6 +54,23 @@ export const createMerchantInputSchema = z.object({
52
54
  })
53
55
  export type CreateMerchantInput = z.infer<typeof createMerchantInputSchema>
54
56
 
57
+ /**
58
+ * Merchant email opt-outs, persisted at `Merchant.metadata.emailPrefs`.
59
+ * Both default to true. Welcome, refunds, and admin broadcasts always send.
60
+ */
61
+ export const merchantEmailPrefsSchema = z.object({
62
+ /** "You received X USDC" one-off payment notifications. */
63
+ paymentReceived: z.boolean(),
64
+ /** "You were paid X for subscription Y" per-charge notifications. */
65
+ subscriptionCharged: z.boolean(),
66
+ })
67
+ export type MerchantEmailPrefs = z.infer<typeof merchantEmailPrefsSchema>
68
+
69
+ export const DEFAULT_MERCHANT_EMAIL_PREFS: MerchantEmailPrefs = {
70
+ paymentReceived: true,
71
+ subscriptionCharged: true,
72
+ }
73
+
55
74
  export const updateMerchantInputSchema = z
56
75
  .object({
57
76
  businessName: z.string().min(2).max(120),
@@ -61,6 +80,7 @@ export const updateMerchantInputSchema = z
61
80
  logoUrl: z.string().url().nullable(),
62
81
  countryCode: z.string().length(2).nullable(),
63
82
  metadata: metadataSchema,
83
+ emailPrefs: merchantEmailPrefsSchema.partial(),
64
84
  })
65
85
  .partial()
66
86
  export type UpdateMerchantInput = z.infer<typeof updateMerchantInputSchema>
@@ -70,6 +90,70 @@ export const changeTierInputSchema = z.object({
70
90
  })
71
91
  export type ChangeTierInput = z.infer<typeof changeTierInputSchema>
72
92
 
93
+ /**
94
+ * Self-attested onboarding form the dashboard collects after a
95
+ * merchant first logs in via Privy. On success the API stamps
96
+ * `onboardingCompleted: true` on the row, and the dashboard exits
97
+ * the wizard. Shared here so the API's DTO and the web client's
98
+ * hook can enforce the same shape.
99
+ */
100
+ export const onboardMerchantInputSchema = z.object({
101
+ businessName: z.string().min(2).max(120),
102
+ businessSector: z.string().min(2).max(80),
103
+ countryCode: z
104
+ .string()
105
+ .length(2)
106
+ .regex(/^[A-Z]{2}$/, 'must be a 2-letter ISO country code'),
107
+ websiteUrl: z.string().url().optional(),
108
+ logoUrl: z.string().url().optional(),
109
+ phone: z.string().min(6).max(20).optional(),
110
+ payoutAddress: evmAddressSchema,
111
+ defaultCurrency: z.enum(['USDC', 'EURC']).optional(),
112
+ })
113
+ export type OnboardMerchantInput = z.infer<typeof onboardMerchantInputSchema>
114
+
115
+ export const merchantPublicBrandSchema = z.object({
116
+ id: idSchema,
117
+ businessName: z.string().min(2).max(120),
118
+ logoUrl: z.string().url().nullable(),
119
+ walletAddress: evmAddressSchema.nullable(),
120
+ })
121
+ export type MerchantPublicBrand = z.infer<typeof merchantPublicBrandSchema>
122
+
123
+ /**
124
+ * On-chain balance view for the withdraw page. Strimz is
125
+ * non-custodial: payments settle directly into the merchant's
126
+ * `payoutAddress`, and "withdrawal" means the merchant transferring
127
+ * out with their own wallet. This shape reports current on-chain
128
+ * state so the dashboard renders live balances + decides whether to
129
+ * offer the signing UI.
130
+ */
131
+ export const merchantBalanceSchema = z.object({
132
+ /** Payout wallet, checksummed; null when the merchant hasn't set one. */
133
+ payoutAddress: evmAddressSchema.nullable(),
134
+ /** Privy embedded wallet, checksummed if resolvable. */
135
+ walletAddress: evmAddressSchema.nullable(),
136
+ /**
137
+ * True when `payoutAddress === walletAddress`, i.e. the merchant
138
+ * can sign a transfer from the dashboard via Privy. False for
139
+ * merchants using an external wallet as payout — the UI falls back
140
+ * to "copy the address, transfer with your wallet."
141
+ */
142
+ canSignFromDashboard: z.boolean(),
143
+ balances: z.array(
144
+ z.object({
145
+ currency: z.enum(['USDC', 'EURC']),
146
+ contractAddress: evmAddressSchema,
147
+ /** Base-6 integer as string. */
148
+ raw: z.string(),
149
+ /** Human-formatted, e.g. `1234.56`. */
150
+ formatted: z.string(),
151
+ decimals: z.number().int().min(0).max(30),
152
+ }),
153
+ ),
154
+ })
155
+ export type MerchantBalanceView = z.infer<typeof merchantBalanceSchema>
156
+
73
157
  // ---------- Team members ----------
74
158
 
75
159
  export const merchantMemberSchema = z.object({
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Dashboard notifications. Derived server-side from recent activity
3
+ * (confirmed payment sessions, new subscribers, processed refunds).
4
+ * Read state is tracked on the merchant record via
5
+ * `notificationsLastReadAt` — `event.createdAt <= that timestamp` is
6
+ * "read", anything newer is "unread". No dedicated notifications
7
+ * table because the source rows already exist; a separate table would
8
+ * just be a denormalised copy.
9
+ */
10
+
11
+ import { z } from 'zod'
12
+ import { idSchema, isoTimestampSchema } from './common.js'
13
+
14
+ export const notificationKindSchema = z.enum([
15
+ 'payment_received',
16
+ 'subscription_started',
17
+ 'refund_processed',
18
+ /** Message an admin broadcast to this merchant (or all merchants). */
19
+ 'admin_broadcast',
20
+ ])
21
+ export type NotificationKind = z.infer<typeof notificationKindSchema>
22
+
23
+ // ---------- Admin broadcasts ----------
24
+
25
+ export const broadcastAudienceSchema = z.enum(['all', 'merchant'])
26
+ export type BroadcastAudience = z.infer<typeof broadcastAudienceSchema>
27
+
28
+ export const createBroadcastInputSchema = z
29
+ .object({
30
+ title: z.string().min(4).max(160),
31
+ body: z.string().min(4).max(4000),
32
+ audience: broadcastAudienceSchema.default('all'),
33
+ /** Required when `audience === 'merchant'`; ignored otherwise. */
34
+ merchantId: z.string().optional(),
35
+ })
36
+ .refine((v) => v.audience !== 'merchant' || !!v.merchantId, {
37
+ message: 'merchantId is required when audience is merchant',
38
+ path: ['merchantId'],
39
+ })
40
+ export type CreateBroadcastInput = z.infer<typeof createBroadcastInputSchema>
41
+
42
+ export const broadcastSchema = z.object({
43
+ id: idSchema,
44
+ title: z.string(),
45
+ body: z.string(),
46
+ audience: broadcastAudienceSchema,
47
+ merchantId: idSchema.nullable(),
48
+ merchantEmail: z.string().nullable(),
49
+ senderId: idSchema,
50
+ senderEmail: z.string(),
51
+ emailedAt: isoTimestampSchema.nullable(),
52
+ createdAt: isoTimestampSchema,
53
+ })
54
+ export type Broadcast = z.infer<typeof broadcastSchema>
55
+
56
+ export const broadcastListResponseSchema = z.object({
57
+ data: z.array(broadcastSchema),
58
+ })
59
+ export type BroadcastListResponse = z.infer<typeof broadcastListResponseSchema>
60
+
61
+ export const notificationSchema = z.object({
62
+ /** Deterministic client id — `{kind}:{sourceId}`. Safe for React keys. */
63
+ id: z.string().min(1),
64
+ kind: notificationKindSchema,
65
+ title: z.string().min(1),
66
+ detail: z.string(),
67
+ /** Dashboard route the tray links to. */
68
+ href: z.string().min(1),
69
+ /** ISO timestamp of the source event; drives sort + read comparison. */
70
+ createdAt: isoTimestampSchema,
71
+ /** Server-derived from the merchant's `notificationsLastReadAt`. */
72
+ read: z.boolean(),
73
+ /** Optional foreign key back to the source row (for deep-linking). */
74
+ sourceId: idSchema.optional(),
75
+ })
76
+ export type NotificationView = z.infer<typeof notificationSchema>
77
+
78
+ export const notificationListResponseSchema = z.object({
79
+ data: z.array(notificationSchema),
80
+ unreadCount: z.number().int().min(0),
81
+ lastReadAt: isoTimestampSchema.nullable(),
82
+ })
83
+ export type NotificationListResponse = z.infer<typeof notificationListResponseSchema>
84
+
85
+ export const markNotificationsReadResponseSchema = z.object({
86
+ lastReadAt: isoTimestampSchema,
87
+ })
88
+ export type MarkNotificationsReadResponse = z.infer<typeof markNotificationsReadResponseSchema>
@@ -31,6 +31,28 @@ export const paymentSessionStatusSchema = z.enum([
31
31
  ])
32
32
  export type PaymentSessionStatus = z.infer<typeof paymentSessionStatusSchema>
33
33
 
34
+ /**
35
+ * Merchant-supplied callback URL. The hosted checkout dispatches with
36
+ * `window.location.href = redirectUrl` on completion / cancellation,
37
+ * so we MUST reject anything other than `http://` and `https://`.
38
+ *
39
+ * Why this is a real risk: Zod's `.url()` validates RFC syntax, which
40
+ * accepts `javascript:`, `data:`, `vbscript:`, `file:`, blob:`, etc.
41
+ * A compromised merchant integration or an XSS upstream could ship a
42
+ * session whose redirect URL executes script (or exfiltrates session
43
+ * tokens) on every payer's browser. The damage is per-payer, but the
44
+ * blast radius is "every checkout the merchant runs."
45
+ *
46
+ * Mailto / tel and other handler protocols are also rejected — there
47
+ * is no legitimate flow on a payment checkout that would benefit.
48
+ */
49
+ export const callbackUrlSchema = z
50
+ .string()
51
+ .url()
52
+ .refine((v) => v.startsWith('https://') || v.startsWith('http://'), {
53
+ message: 'must be an http:// or https:// URL',
54
+ })
55
+
34
56
  export const paymentSessionSchema = z.object({
35
57
  id: idSchema,
36
58
  merchantId: idSchema,
@@ -63,8 +85,8 @@ export const paymentSessionSchema = z.object({
63
85
  description: z.string().max(500).nullable(),
64
86
  payerWalletAddress: evmAddressSchema.nullable(),
65
87
  payerEmail: z.string().email().nullable(),
66
- successUrl: z.string().url().nullable(),
67
- cancelUrl: z.string().url().nullable(),
88
+ successUrl: callbackUrlSchema.nullable(),
89
+ cancelUrl: callbackUrlSchema.nullable(),
68
90
  sourceChain: z
69
91
  .enum(['arc', 'ethereum', 'base', 'polygon', 'arbitrum', 'optimism', 'avalanche', 'solana'])
70
92
  .nullable(),
package/src/refunds.ts CHANGED
@@ -66,3 +66,22 @@ export const submitRefundSignatureInputSchema = z.object({
66
66
  refundTxHash: evmTxHashSchema,
67
67
  })
68
68
  export type SubmitRefundSignatureInput = z.infer<typeof submitRefundSignatureInputSchema>
69
+
70
+ /**
71
+ * Response envelope for `POST /v1/refunds`. The API returns the newly
72
+ * created refund plus the concrete ERC-20 transfer the merchant now
73
+ * has to sign from their payout wallet.
74
+ */
75
+ export const refundSigningInstructionsSchema = z.object({
76
+ token: evmAddressSchema,
77
+ to: evmAddressSchema,
78
+ amount: tokenAmountSchema,
79
+ note: z.string(),
80
+ })
81
+ export type RefundSigningInstructions = z.infer<typeof refundSigningInstructionsSchema>
82
+
83
+ export const refundCreateOutputSchema = z.object({
84
+ refund: refundSchema,
85
+ signingInstructions: refundSigningInstructionsSchema,
86
+ })
87
+ export type RefundCreateOutput = z.infer<typeof refundCreateOutputSchema>
@@ -87,3 +87,27 @@ export const createStorefrontProductInputSchema = storefrontProductSchema
87
87
  imageUrl: httpsUrlSchema.optional(),
88
88
  })
89
89
  export type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>
90
+
91
+ /**
92
+ * Payload for the public `/store/:slug/products/:id/checkout` endpoint.
93
+ * Optional customer email flows through into the payment session so
94
+ * the receipt lands in the buyer's inbox after the tx confirms.
95
+ * `returnPath` is used to synthesise the success + cancel URLs when
96
+ * the merchant hasn't wired their own.
97
+ */
98
+ export const storefrontCheckoutInputSchema = z.object({
99
+ customerEmail: z.string().email().optional(),
100
+ returnPath: z.string().max(200).optional(),
101
+ })
102
+ export type StorefrontCheckoutInput = z.infer<typeof storefrontCheckoutInputSchema>
103
+
104
+ /** Response shape from the public product-checkout endpoint. */
105
+ export const storefrontCheckoutResponseSchema = z.object({
106
+ /** Fully-qualified checkout URL — payer redirects here to sign. */
107
+ checkoutUrl: z.string().url(),
108
+ /** Payment-session id (one-time) or plan id (subscription). */
109
+ ref: idSchema,
110
+ /** Which downstream checkout the URL points at. */
111
+ kind: z.enum(['payment_session', 'subscription_plan']),
112
+ })
113
+ export type StorefrontCheckoutResponse = z.infer<typeof storefrontCheckoutResponseSchema>