@strimz/sdk 0.13.1 → 0.15.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/README.md CHANGED
@@ -90,7 +90,7 @@ signatures and response types come from
90
90
  | `customers` | `retrieve`, `list`, `upsert` |
91
91
  | `paymentSessions` | `create`, `retrieve`, `list`, `cancel`, `expire` |
92
92
  | `transactions` | `retrieve`, `list` |
93
- | `subscriptionPlans` | `create`, `retrieve`, `list`, `archive` |
93
+ | `subscriptionPlans` | `create`, `retrieve`, `list`, `update`, `archive` |
94
94
  | `subscriptions` | `retrieve`, `list`, `cancel` |
95
95
  | `refunds` | `create`, `retrieve`, `list`, `submitSignature` |
96
96
  | `webhookEndpoints` | `create`, `retrieve`, `list`, `enable`, `disable`, `rotateSecret` |
@@ -178,6 +178,12 @@ For a full hosted-checkout UX with components and hooks, use
178
178
  their `*_TYPES` constants. Hosted checkout uses them; you only need
179
179
  them if you build your own signing UI.
180
180
 
181
+ A `SubscriptionIntent` carries the permit's `permitValue` and a `nonce`.
182
+ When you relay an enrolment through Strimz, the nonce must be
183
+ `subscriptionIntentNonce(planId, payer, permitNonce)` from
184
+ `@strimz/shared-crypto`, where `permitNonce` is the token's
185
+ `nonces(payer)` at signing time.
186
+
181
187
  ## Error handling
182
188
 
183
189
  Every error thrown by the SDK is a typed subclass of `StrimzError`.
@@ -96,7 +96,7 @@ var HEADERS = {
96
96
  sdkRuntime: "X-Strimz-Sdk-Runtime"
97
97
  };
98
98
  var SDK_NAME = "@strimz/sdk";
99
- var SDK_VERSION = "0.13.1";
99
+ var SDK_VERSION = "0.15.0";
100
100
  function buildBaseHeaders(apiKey, runtime) {
101
101
  return {
102
102
  [HEADERS.authorization]: `Bearer ${apiKey}`,
@@ -94,7 +94,7 @@ var HEADERS = {
94
94
  sdkRuntime: "X-Strimz-Sdk-Runtime"
95
95
  };
96
96
  var SDK_NAME = "@strimz/sdk";
97
- var SDK_VERSION = "0.13.1";
97
+ var SDK_VERSION = "0.15.0";
98
98
  function buildBaseHeaders(apiKey, runtime) {
99
99
  return {
100
100
  [HEADERS.authorization]: `Bearer ${apiKey}`,
package/dist/eip712.cjs CHANGED
@@ -103,7 +103,9 @@ var SUBSCRIPTION_INTENT_TYPES = {
103
103
  { name: "interval", type: "uint32" },
104
104
  { name: "startAt", type: "uint64" },
105
105
  { name: "endAt", type: "uint64" },
106
- { name: "permitDeadline", type: "uint256" }
106
+ { name: "permitDeadline", type: "uint256" },
107
+ { name: "permitValue", type: "uint256" },
108
+ { name: "nonce", type: "bytes32" }
107
109
  ]
108
110
  };
109
111
  function buildSubscriptionIntentTypedData(params) {
@@ -123,7 +125,9 @@ function buildSubscriptionIntentTypedData(params) {
123
125
  interval: params.interval,
124
126
  startAt: params.startAt,
125
127
  endAt: params.endAt,
126
- permitDeadline: params.permitDeadline
128
+ permitDeadline: params.permitDeadline,
129
+ permitValue: params.permitValue,
130
+ nonce: params.nonce
127
131
  }
128
132
  };
129
133
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts"],"names":[],"mappings":";;;AA8CO,IAAM,gCAAA,GAAmC;AAAA,EAC9C,wBAAA,EAA0B;AAAA,IACxB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC;AAWO,SAAS,uCACd,MAAA,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A,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,SAAA,EAAU;AAAA,IAClC,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,QAAA,EAAS;AAAA,IACnC,EAAE,IAAA,EAAM,SAAA,EAAW,IAAA,EAAM,QAAA,EAAS;AAAA,IAClC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,QAAA,EAAS;AAAA,IAChC,EAAE,IAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,SAAA;AAAU;AAE9C;AAGO,SAAS,iCACd,MAAA,EACuC;AACvC,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,qBAAA;AAAA,MACN,OAAA,EAAS,GAAA;AAAA,MACT,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,mBAAmB,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,KAAA,EAAO,yBAAA;AAAA,IACP,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,gBAAgB,MAAA,CAAO;AAAA;AACzB,GACF;AACF","file":"eip712.cjs","sourcesContent":["import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-3009 ReceiveWithAuthorization typed-data.\n *\n * - `chainId` is the EVM chain id (Arc Testnet = 5042002).\n * - `token` is the ERC-20 contract whose `receiveWithAuthorization` is\n * being invoked. Usually USDC at `0x36...` on Arc.\n * - `tokenName` and `tokenVersion` form the EIP-712 domain. Real USDC\n * on most chains uses `name=\"USD Coin\"` and `version=\"2\"`; tests\n * use whatever the mock token reports. Always read these from the\n * token contract at runtime to avoid drift.\n * - `from` is the payer. The wallet that produces the signature must\n * match this address.\n * - `to` is the recipient of the funds. For Strimz this is the\n * StrimzPayments contract address (the contract pulls funds into\n * itself, then forwards the fee and net split).\n * - `value` is the gross amount in token base units.\n * - `validAfter` / `validBefore` are unix-second timestamps bounding\n * the signature's validity. Strimz's default checkout window is\n * 5 minutes; integrators may widen this for usage-based billing.\n * - `nonce` is a single-use 32-byte value. Generate with crypto.randomBytes\n * (server) or crypto.getRandomValues (browser). The token contract\n * tracks `(authorizer, nonce) -> used` and rejects replays.\n */\nexport interface ReceiveWithAuthorizationParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n from: `0x${string}`\n to: `0x${string}`\n value: bigint\n validAfter: bigint\n validBefore: bigint\n nonce: `0x${string}`\n}\n\n/**\n * EIP-712 type definition for `ReceiveWithAuthorization`. Stable, and\n * shared by every EIP-3009 implementation (USDC, EURC, etc.).\n *\n * Exported so consumers can introspect or extend with sibling\n * primitive types (e.g. for x402 batched signing schemes that wrap\n * multiple authorizations in one signature).\n */\nexport const RECEIVE_WITH_AUTHORIZATION_TYPES = {\n ReceiveWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-3009\n * `ReceiveWithAuthorization` signature. Returns the canonical shape\n * compatible with viem, ethers, Privy, and Reown.\n *\n * Pass the result to `walletClient.signTypedData(typedData)` (viem)\n * or `signer._signTypedData(domain, types, message)` (ethers). The\n * SDK does not bind to a specific signer.\n */\nexport function buildReceiveWithAuthorizationTypedData(\n params: ReceiveWithAuthorizationParams,\n): Eip712TypedData<'ReceiveWithAuthorization'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: RECEIVE_WITH_AUTHORIZATION_TYPES,\n primaryType: 'ReceiveWithAuthorization',\n message: {\n from: params.from,\n to: params.to,\n value: params.value,\n validAfter: params.validAfter,\n validBefore: params.validBefore,\n nonce: params.nonce,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-2612 Permit typed-data.\n *\n * - `chainId`, `token`, `tokenName`, `tokenVersion` form the EIP-712\n * domain (same shape as the EIP-3009 builder).\n * - `owner` is the token holder authorising the allowance. Must match\n * the signing wallet.\n * - `spender` is the contract that will pull funds. For Strimz\n * subscriptions this is the StrimzSubscriptions contract.\n * - `value` is the allowance to grant in token base units.\n * `type(uint256).max` produces an unlimited allowance and is the\n * common case for subscription enrolment.\n * - `nonce` is the owner's *current* `nonces(owner)` reading from the\n * token contract. The SDK does not fetch this. The caller is\n * expected to have just queried it. Race-free: the token rejects\n * stale nonces, so a concurrent permit on the same owner causes one\n * to fail predictably.\n * - `deadline` is the unix-second timestamp after which the permit\n * expires. Strimz default for subscription enrolment is 24h. Enough\n * headroom for a slow merchant submit pipeline without leaving an\n * indefinite signature window.\n */\nexport interface PermitParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n owner: `0x${string}`\n spender: `0x${string}`\n value: bigint\n nonce: bigint\n deadline: bigint\n}\n\n/**\n * EIP-712 type definition for `Permit`. Stable across every EIP-2612\n * implementation (USDC, EURC, DAI v2, etc.).\n */\nexport const PERMIT_TYPES = {\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-2612 `Permit` signature.\n * Returns the canonical shape compatible with viem, ethers, Privy,\n * and Reown.\n */\nexport function buildPermitTypedData(params: PermitParams): Eip712TypedData<'Permit'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: PERMIT_TYPES,\n primaryType: 'Permit',\n message: {\n owner: params.owner,\n spender: params.spender,\n value: params.value,\n nonce: params.nonce,\n deadline: params.deadline,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz PayIntent. Payer signs this alongside the\n * EIP-3009 auth. Without it, a valid auth sig can be redirected to\n * pay a different merchant.\n *\n * Every field must match the corresponding argument the API will\n * submit on-chain — the contract compares them via ecrecover.\n */\nexport interface PayIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n nonce: `0x${string}`\n validBefore: bigint\n ref: `0x${string}`\n}\n\n/** Field order matches `PAY_INTENT_TYPEHASH` in `StrimzPayments.sol`. */\nexport const PAY_INTENT_TYPES = {\n PayIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'ref', type: 'bytes32' },\n ],\n} as const\n\n/** Domain name + version mirror `EIP712(\"StrimzPayments\", \"1\")`. */\nexport function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedData<'PayIntent'> {\n return {\n domain: {\n name: 'StrimzPayments',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: PAY_INTENT_TYPES,\n primaryType: 'PayIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n nonce: params.nonce,\n validBefore: params.validBefore,\n ref: params.ref,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz SubscriptionIntent. Payer signs this\n * alongside the ERC-2612 permit. Without it, a valid permit can be\n * used to enrol the payer in a plan they never picked.\n *\n * `permitDeadline` ties this intent to the accompanying permit —\n * they expire together.\n */\nexport interface SubscriptionIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n interval: number\n startAt: bigint\n endAt: bigint\n permitDeadline: bigint\n}\n\n/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */\nexport const SUBSCRIPTION_INTENT_TYPES = {\n SubscriptionIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'interval', type: 'uint32' },\n { name: 'startAt', type: 'uint64' },\n { name: 'endAt', type: 'uint64' },\n { name: 'permitDeadline', type: 'uint256' },\n ],\n} as const\n\n/** Domain mirrors `EIP712(\"StrimzSubscriptions\", \"1\")`. */\nexport function buildSubscriptionIntentTypedData(\n params: SubscriptionIntentParams,\n): Eip712TypedData<'SubscriptionIntent'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: SUBSCRIPTION_INTENT_TYPES,\n primaryType: 'SubscriptionIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n interval: params.interval,\n startAt: params.startAt,\n endAt: params.endAt,\n permitDeadline: params.permitDeadline,\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts"],"names":[],"mappings":";;;AA8CO,IAAM,gCAAA,GAAmC;AAAA,EAC9C,wBAAA,EAA0B;AAAA,IACxB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,S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AA,MAChB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,gBAAgB,MAAA,CAAO,cAAA;AAAA,MACvB,aAAa,MAAA,CAAO,WAAA;AAAA,MACpB,OAAO,MAAA,CAAO;AAAA;AAChB,GACF;AACF","file":"eip712.cjs","sourcesContent":["import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-3009 ReceiveWithAuthorization typed-data.\n *\n * - `chainId` is the EVM chain id (Arc Testnet = 5042002).\n * - `token` is the ERC-20 contract whose `receiveWithAuthorization` is\n * being invoked. Usually USDC at `0x36...` on Arc.\n * - `tokenName` and `tokenVersion` form the EIP-712 domain. Real USDC\n * on most chains uses `name=\"USD Coin\"` and `version=\"2\"`; tests\n * use whatever the mock token reports. Always read these from the\n * token contract at runtime to avoid drift.\n * - `from` is the payer. The wallet that produces the signature must\n * match this address.\n * - `to` is the recipient of the funds. For Strimz this is the\n * StrimzPayments contract address (the contract pulls funds into\n * itself, then forwards the fee and net split).\n * - `value` is the gross amount in token base units.\n * - `validAfter` / `validBefore` are unix-second timestamps bounding\n * the signature's validity. Strimz's default checkout window is\n * 5 minutes; integrators may widen this for usage-based billing.\n * - `nonce` is a single-use 32-byte value. Generate with crypto.randomBytes\n * (server) or crypto.getRandomValues (browser). The token contract\n * tracks `(authorizer, nonce) -> used` and rejects replays.\n */\nexport interface ReceiveWithAuthorizationParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n from: `0x${string}`\n to: `0x${string}`\n value: bigint\n validAfter: bigint\n validBefore: bigint\n nonce: `0x${string}`\n}\n\n/**\n * EIP-712 type definition for `ReceiveWithAuthorization`. Stable, and\n * shared by every EIP-3009 implementation (USDC, EURC, etc.).\n *\n * Exported so consumers can introspect or extend with sibling\n * primitive types (e.g. for x402 batched signing schemes that wrap\n * multiple authorizations in one signature).\n */\nexport const RECEIVE_WITH_AUTHORIZATION_TYPES = {\n ReceiveWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-3009\n * `ReceiveWithAuthorization` signature. Returns the canonical shape\n * compatible with viem, ethers, Privy, and Reown.\n *\n * Pass the result to `walletClient.signTypedData(typedData)` (viem)\n * or `signer._signTypedData(domain, types, message)` (ethers). The\n * SDK does not bind to a specific signer.\n */\nexport function buildReceiveWithAuthorizationTypedData(\n params: ReceiveWithAuthorizationParams,\n): Eip712TypedData<'ReceiveWithAuthorization'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: RECEIVE_WITH_AUTHORIZATION_TYPES,\n primaryType: 'ReceiveWithAuthorization',\n message: {\n from: params.from,\n to: params.to,\n value: params.value,\n validAfter: params.validAfter,\n validBefore: params.validBefore,\n nonce: params.nonce,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-2612 Permit typed-data.\n *\n * - `chainId`, `token`, `tokenName`, `tokenVersion` form the EIP-712\n * domain (same shape as the EIP-3009 builder).\n * - `owner` is the token holder authorising the allowance. Must match\n * the signing wallet.\n * - `spender` is the contract that will pull funds. For Strimz\n * subscriptions this is the StrimzSubscriptions contract.\n * - `value` is the allowance to grant in token base units.\n * `type(uint256).max` produces an unlimited allowance and is the\n * common case for subscription enrolment.\n * - `nonce` is the owner's *current* `nonces(owner)` reading from the\n * token contract. The SDK does not fetch this. The caller is\n * expected to have just queried it. Race-free: the token rejects\n * stale nonces, so a concurrent permit on the same owner causes one\n * to fail predictably.\n * - `deadline` is the unix-second timestamp after which the permit\n * expires. Strimz default for subscription enrolment is 24h. Enough\n * headroom for a slow merchant submit pipeline without leaving an\n * indefinite signature window.\n */\nexport interface PermitParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n owner: `0x${string}`\n spender: `0x${string}`\n value: bigint\n nonce: bigint\n deadline: bigint\n}\n\n/**\n * EIP-712 type definition for `Permit`. Stable across every EIP-2612\n * implementation (USDC, EURC, DAI v2, etc.).\n */\nexport const PERMIT_TYPES = {\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-2612 `Permit` signature.\n * Returns the canonical shape compatible with viem, ethers, Privy,\n * and Reown.\n */\nexport function buildPermitTypedData(params: PermitParams): Eip712TypedData<'Permit'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: PERMIT_TYPES,\n primaryType: 'Permit',\n message: {\n owner: params.owner,\n spender: params.spender,\n value: params.value,\n nonce: params.nonce,\n deadline: params.deadline,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz PayIntent. Payer signs this alongside the\n * EIP-3009 auth. Without it, a valid auth sig can be redirected to\n * pay a different merchant.\n *\n * Every field must match the corresponding argument the API will\n * submit on-chain — the contract compares them via ecrecover.\n */\nexport interface PayIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n nonce: `0x${string}`\n validBefore: bigint\n ref: `0x${string}`\n}\n\n/** Field order matches `PAY_INTENT_TYPEHASH` in `StrimzPayments.sol`. */\nexport const PAY_INTENT_TYPES = {\n PayIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'ref', type: 'bytes32' },\n ],\n} as const\n\n/** Domain name + version mirror `EIP712(\"StrimzPayments\", \"1\")`. */\nexport function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedData<'PayIntent'> {\n return {\n domain: {\n name: 'StrimzPayments',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: PAY_INTENT_TYPES,\n primaryType: 'PayIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n nonce: params.nonce,\n validBefore: params.validBefore,\n ref: params.ref,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz SubscriptionIntent. Payer signs this\n * alongside the ERC-2612 permit. Without it, a valid permit can be\n * used to enrol the payer in a plan they never picked.\n *\n * `permitDeadline` and `permitValue` tie this intent to the accompanying\n * permit. `nonce` is spent once on chain; the Strimz API only accepts\n * `subscriptionIntentNonce(planId, payer, the token's permit nonce)` from\n * `@strimz/shared-crypto`, so a retried signup can't enrol twice.\n */\nexport interface SubscriptionIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n interval: number\n startAt: bigint\n endAt: bigint\n permitDeadline: bigint\n permitValue: bigint\n nonce: `0x${string}`\n}\n\n/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */\nexport const SUBSCRIPTION_INTENT_TYPES = {\n SubscriptionIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'interval', type: 'uint32' },\n { name: 'startAt', type: 'uint64' },\n { name: 'endAt', type: 'uint64' },\n { name: 'permitDeadline', type: 'uint256' },\n { name: 'permitValue', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/** Domain mirrors `EIP712(\"StrimzSubscriptions\", \"1\")`. */\nexport function buildSubscriptionIntentTypedData(\n params: SubscriptionIntentParams,\n): Eip712TypedData<'SubscriptionIntent'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: SUBSCRIPTION_INTENT_TYPES,\n primaryType: 'SubscriptionIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n interval: params.interval,\n startAt: params.startAt,\n endAt: params.endAt,\n permitDeadline: params.permitDeadline,\n permitValue: params.permitValue,\n nonce: params.nonce,\n },\n }\n}\n"]}
package/dist/eip712.d.cts CHANGED
@@ -227,8 +227,10 @@ declare function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedDa
227
227
  * alongside the ERC-2612 permit. Without it, a valid permit can be
228
228
  * used to enrol the payer in a plan they never picked.
229
229
  *
230
- * `permitDeadline` ties this intent to the accompanying permit —
231
- * they expire together.
230
+ * `permitDeadline` and `permitValue` tie this intent to the accompanying
231
+ * permit. `nonce` is spent once on chain; the Strimz API only accepts
232
+ * `subscriptionIntentNonce(planId, payer, the token's permit nonce)` from
233
+ * `@strimz/shared-crypto`, so a retried signup can't enrol twice.
232
234
  */
233
235
  interface SubscriptionIntentParams {
234
236
  chainId: number;
@@ -240,6 +242,8 @@ interface SubscriptionIntentParams {
240
242
  startAt: bigint;
241
243
  endAt: bigint;
242
244
  permitDeadline: bigint;
245
+ permitValue: bigint;
246
+ nonce: `0x${string}`;
243
247
  }
244
248
  /** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */
245
249
  declare const SUBSCRIPTION_INTENT_TYPES: {
@@ -264,6 +268,12 @@ declare const SUBSCRIPTION_INTENT_TYPES: {
264
268
  }, {
265
269
  readonly name: "permitDeadline";
266
270
  readonly type: "uint256";
271
+ }, {
272
+ readonly name: "permitValue";
273
+ readonly type: "uint256";
274
+ }, {
275
+ readonly name: "nonce";
276
+ readonly type: "bytes32";
267
277
  }];
268
278
  };
269
279
  /** Domain mirrors `EIP712("StrimzSubscriptions", "1")`. */
package/dist/eip712.d.ts CHANGED
@@ -227,8 +227,10 @@ declare function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedDa
227
227
  * alongside the ERC-2612 permit. Without it, a valid permit can be
228
228
  * used to enrol the payer in a plan they never picked.
229
229
  *
230
- * `permitDeadline` ties this intent to the accompanying permit —
231
- * they expire together.
230
+ * `permitDeadline` and `permitValue` tie this intent to the accompanying
231
+ * permit. `nonce` is spent once on chain; the Strimz API only accepts
232
+ * `subscriptionIntentNonce(planId, payer, the token's permit nonce)` from
233
+ * `@strimz/shared-crypto`, so a retried signup can't enrol twice.
232
234
  */
233
235
  interface SubscriptionIntentParams {
234
236
  chainId: number;
@@ -240,6 +242,8 @@ interface SubscriptionIntentParams {
240
242
  startAt: bigint;
241
243
  endAt: bigint;
242
244
  permitDeadline: bigint;
245
+ permitValue: bigint;
246
+ nonce: `0x${string}`;
243
247
  }
244
248
  /** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */
245
249
  declare const SUBSCRIPTION_INTENT_TYPES: {
@@ -264,6 +268,12 @@ declare const SUBSCRIPTION_INTENT_TYPES: {
264
268
  }, {
265
269
  readonly name: "permitDeadline";
266
270
  readonly type: "uint256";
271
+ }, {
272
+ readonly name: "permitValue";
273
+ readonly type: "uint256";
274
+ }, {
275
+ readonly name: "nonce";
276
+ readonly type: "bytes32";
267
277
  }];
268
278
  };
269
279
  /** Domain mirrors `EIP712("StrimzSubscriptions", "1")`. */
package/dist/eip712.js CHANGED
@@ -101,7 +101,9 @@ var SUBSCRIPTION_INTENT_TYPES = {
101
101
  { name: "interval", type: "uint32" },
102
102
  { name: "startAt", type: "uint64" },
103
103
  { name: "endAt", type: "uint64" },
104
- { name: "permitDeadline", type: "uint256" }
104
+ { name: "permitDeadline", type: "uint256" },
105
+ { name: "permitValue", type: "uint256" },
106
+ { name: "nonce", type: "bytes32" }
105
107
  ]
106
108
  };
107
109
  function buildSubscriptionIntentTypedData(params) {
@@ -121,7 +123,9 @@ function buildSubscriptionIntentTypedData(params) {
121
123
  interval: params.interval,
122
124
  startAt: params.startAt,
123
125
  endAt: params.endAt,
124
- permitDeadline: params.permitDeadline
126
+ permitDeadline: params.permitDeadline,
127
+ permitValue: params.permitValue,
128
+ nonce: params.nonce
125
129
  }
126
130
  };
127
131
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts"],"names":[],"mappings":";AA8CO,IAAM,gCAAA,GAAmC;AAAA,EAC9C,wBAAA,EAA0B;AAAA,IACxB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC;AAWO,SAAS,uCACd,MAAA,EAC6C;AAC7C,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,MAAM,MAAA,CAAO,SAAA;AAAA,MACb,SAAS,MAAA,CAAO,YAAA;AAAA,MAChB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,mBAAmB,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,KAAA,EAAO,gCAAA;AAAA,IACP,WAAA,EAAa,0BAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,MAAM,MAAA,CAAO,IAAA;AAAA,MACb,IAAI,MAAA,CAAO,EAAA;AAAA,MACX,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB,aAAa,MAAA,CAAO,WAAA;AAAA,MACpB,OAAO,MAAA,CAAO;AAAA;AAChB,GACF;AACF;;;AC/CO,IAAM,YAAA,GAAe;AAAA,EAC1B,MAAA,EAAQ;AAAA,IACN,EAAE,IAAA,EAAM,OAAA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AAA,CAAO,OAAA;AAAA,MAChB,mBAAmB,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,KAAA,EAAO,yBAAA;AAAA,IACP,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,gBAAgB,MAAA,CAAO;AAAA;AACzB,GACF;AACF","file":"eip712.js","sourcesContent":["import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-3009 ReceiveWithAuthorization typed-data.\n *\n * - `chainId` is the EVM chain id (Arc Testnet = 5042002).\n * - `token` is the ERC-20 contract whose `receiveWithAuthorization` is\n * being invoked. Usually USDC at `0x36...` on Arc.\n * - `tokenName` and `tokenVersion` form the EIP-712 domain. Real USDC\n * on most chains uses `name=\"USD Coin\"` and `version=\"2\"`; tests\n * use whatever the mock token reports. Always read these from the\n * token contract at runtime to avoid drift.\n * - `from` is the payer. The wallet that produces the signature must\n * match this address.\n * - `to` is the recipient of the funds. For Strimz this is the\n * StrimzPayments contract address (the contract pulls funds into\n * itself, then forwards the fee and net split).\n * - `value` is the gross amount in token base units.\n * - `validAfter` / `validBefore` are unix-second timestamps bounding\n * the signature's validity. Strimz's default checkout window is\n * 5 minutes; integrators may widen this for usage-based billing.\n * - `nonce` is a single-use 32-byte value. Generate with crypto.randomBytes\n * (server) or crypto.getRandomValues (browser). The token contract\n * tracks `(authorizer, nonce) -> used` and rejects replays.\n */\nexport interface ReceiveWithAuthorizationParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n from: `0x${string}`\n to: `0x${string}`\n value: bigint\n validAfter: bigint\n validBefore: bigint\n nonce: `0x${string}`\n}\n\n/**\n * EIP-712 type definition for `ReceiveWithAuthorization`. Stable, and\n * shared by every EIP-3009 implementation (USDC, EURC, etc.).\n *\n * Exported so consumers can introspect or extend with sibling\n * primitive types (e.g. for x402 batched signing schemes that wrap\n * multiple authorizations in one signature).\n */\nexport const RECEIVE_WITH_AUTHORIZATION_TYPES = {\n ReceiveWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-3009\n * `ReceiveWithAuthorization` signature. Returns the canonical shape\n * compatible with viem, ethers, Privy, and Reown.\n *\n * Pass the result to `walletClient.signTypedData(typedData)` (viem)\n * or `signer._signTypedData(domain, types, message)` (ethers). The\n * SDK does not bind to a specific signer.\n */\nexport function buildReceiveWithAuthorizationTypedData(\n params: ReceiveWithAuthorizationParams,\n): Eip712TypedData<'ReceiveWithAuthorization'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: RECEIVE_WITH_AUTHORIZATION_TYPES,\n primaryType: 'ReceiveWithAuthorization',\n message: {\n from: params.from,\n to: params.to,\n value: params.value,\n validAfter: params.validAfter,\n validBefore: params.validBefore,\n nonce: params.nonce,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-2612 Permit typed-data.\n *\n * - `chainId`, `token`, `tokenName`, `tokenVersion` form the EIP-712\n * domain (same shape as the EIP-3009 builder).\n * - `owner` is the token holder authorising the allowance. Must match\n * the signing wallet.\n * - `spender` is the contract that will pull funds. For Strimz\n * subscriptions this is the StrimzSubscriptions contract.\n * - `value` is the allowance to grant in token base units.\n * `type(uint256).max` produces an unlimited allowance and is the\n * common case for subscription enrolment.\n * - `nonce` is the owner's *current* `nonces(owner)` reading from the\n * token contract. The SDK does not fetch this. The caller is\n * expected to have just queried it. Race-free: the token rejects\n * stale nonces, so a concurrent permit on the same owner causes one\n * to fail predictably.\n * - `deadline` is the unix-second timestamp after which the permit\n * expires. Strimz default for subscription enrolment is 24h. Enough\n * headroom for a slow merchant submit pipeline without leaving an\n * indefinite signature window.\n */\nexport interface PermitParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n owner: `0x${string}`\n spender: `0x${string}`\n value: bigint\n nonce: bigint\n deadline: bigint\n}\n\n/**\n * EIP-712 type definition for `Permit`. Stable across every EIP-2612\n * implementation (USDC, EURC, DAI v2, etc.).\n */\nexport const PERMIT_TYPES = {\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-2612 `Permit` signature.\n * Returns the canonical shape compatible with viem, ethers, Privy,\n * and Reown.\n */\nexport function buildPermitTypedData(params: PermitParams): Eip712TypedData<'Permit'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: PERMIT_TYPES,\n primaryType: 'Permit',\n message: {\n owner: params.owner,\n spender: params.spender,\n value: params.value,\n nonce: params.nonce,\n deadline: params.deadline,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz PayIntent. Payer signs this alongside the\n * EIP-3009 auth. Without it, a valid auth sig can be redirected to\n * pay a different merchant.\n *\n * Every field must match the corresponding argument the API will\n * submit on-chain — the contract compares them via ecrecover.\n */\nexport interface PayIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n nonce: `0x${string}`\n validBefore: bigint\n ref: `0x${string}`\n}\n\n/** Field order matches `PAY_INTENT_TYPEHASH` in `StrimzPayments.sol`. */\nexport const PAY_INTENT_TYPES = {\n PayIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'ref', type: 'bytes32' },\n ],\n} as const\n\n/** Domain name + version mirror `EIP712(\"StrimzPayments\", \"1\")`. */\nexport function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedData<'PayIntent'> {\n return {\n domain: {\n name: 'StrimzPayments',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: PAY_INTENT_TYPES,\n primaryType: 'PayIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n nonce: params.nonce,\n validBefore: params.validBefore,\n ref: params.ref,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz SubscriptionIntent. Payer signs this\n * alongside the ERC-2612 permit. Without it, a valid permit can be\n * used to enrol the payer in a plan they never picked.\n *\n * `permitDeadline` ties this intent to the accompanying permit —\n * they expire together.\n */\nexport interface SubscriptionIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n interval: number\n startAt: bigint\n endAt: bigint\n permitDeadline: bigint\n}\n\n/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */\nexport const SUBSCRIPTION_INTENT_TYPES = {\n SubscriptionIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'interval', type: 'uint32' },\n { name: 'startAt', type: 'uint64' },\n { name: 'endAt', type: 'uint64' },\n { name: 'permitDeadline', type: 'uint256' },\n ],\n} as const\n\n/** Domain mirrors `EIP712(\"StrimzSubscriptions\", \"1\")`. */\nexport function buildSubscriptionIntentTypedData(\n params: SubscriptionIntentParams,\n): Eip712TypedData<'SubscriptionIntent'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: SUBSCRIPTION_INTENT_TYPES,\n primaryType: 'SubscriptionIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n interval: params.interval,\n startAt: params.startAt,\n endAt: params.endAt,\n permitDeadline: params.permitDeadline,\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts"],"names":[],"mappings":";AA8CO,IAAM,gCAAA,GAAmC;AAAA,EAC9C,wBAAA,EAA0B;AAAA,IACxB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC;AAWO,SAAS,uCACd,MAAA,EAC6C;AAC7C,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,MAAM,MAAA,CAAO,SAAA;AAAA,MACb,SAAS,MAAA,CAAO,YAAA;AAAA,MAChB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,mBAAmB,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,KAAA,EAAO,gCAAA;AAAA,IACP,WAAA,EAAa,0BAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,MAAM,MAAA,CAAO,IAAA;AAAA,MACb,IAAI,MAAA,CAAO,EAAA;AAAA,MACX,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,YAAY,MAAA,CAAO,UAAA;AAAA,M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SAAA,EAAU;AAAA,IAC1C,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC;AAGO,SAAS,iCACd,MAAA,EACuC;AACvC,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,qBAAA;AAAA,MACN,OAAA,EAAS,GAAA;AAAA,MACT,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,mBAAmB,MAAA,CAAO;AAAA,KAC5B;AAAA,IACA,KAAA,EAAO,yBAAA;AAAA,IACP,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACP,YAAY,MAAA,CAAO,UAAA;AAAA,MACnB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,SAAS,MAAA,CAAO,OAAA;AAAA,MAChB,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,gBAAgB,MAAA,CAAO,cAAA;AAAA,MACvB,aAAa,MAAA,CAAO,WAAA;AAAA,MACpB,OAAO,MAAA,CAAO;AAAA;AAChB,GACF;AACF","file":"eip712.js","sourcesContent":["import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-3009 ReceiveWithAuthorization typed-data.\n *\n * - `chainId` is the EVM chain id (Arc Testnet = 5042002).\n * - `token` is the ERC-20 contract whose `receiveWithAuthorization` is\n * being invoked. Usually USDC at `0x36...` on Arc.\n * - `tokenName` and `tokenVersion` form the EIP-712 domain. Real USDC\n * on most chains uses `name=\"USD Coin\"` and `version=\"2\"`; tests\n * use whatever the mock token reports. Always read these from the\n * token contract at runtime to avoid drift.\n * - `from` is the payer. The wallet that produces the signature must\n * match this address.\n * - `to` is the recipient of the funds. For Strimz this is the\n * StrimzPayments contract address (the contract pulls funds into\n * itself, then forwards the fee and net split).\n * - `value` is the gross amount in token base units.\n * - `validAfter` / `validBefore` are unix-second timestamps bounding\n * the signature's validity. Strimz's default checkout window is\n * 5 minutes; integrators may widen this for usage-based billing.\n * - `nonce` is a single-use 32-byte value. Generate with crypto.randomBytes\n * (server) or crypto.getRandomValues (browser). The token contract\n * tracks `(authorizer, nonce) -> used` and rejects replays.\n */\nexport interface ReceiveWithAuthorizationParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n from: `0x${string}`\n to: `0x${string}`\n value: bigint\n validAfter: bigint\n validBefore: bigint\n nonce: `0x${string}`\n}\n\n/**\n * EIP-712 type definition for `ReceiveWithAuthorization`. Stable, and\n * shared by every EIP-3009 implementation (USDC, EURC, etc.).\n *\n * Exported so consumers can introspect or extend with sibling\n * primitive types (e.g. for x402 batched signing schemes that wrap\n * multiple authorizations in one signature).\n */\nexport const RECEIVE_WITH_AUTHORIZATION_TYPES = {\n ReceiveWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-3009\n * `ReceiveWithAuthorization` signature. Returns the canonical shape\n * compatible with viem, ethers, Privy, and Reown.\n *\n * Pass the result to `walletClient.signTypedData(typedData)` (viem)\n * or `signer._signTypedData(domain, types, message)` (ethers). The\n * SDK does not bind to a specific signer.\n */\nexport function buildReceiveWithAuthorizationTypedData(\n params: ReceiveWithAuthorizationParams,\n): Eip712TypedData<'ReceiveWithAuthorization'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: RECEIVE_WITH_AUTHORIZATION_TYPES,\n primaryType: 'ReceiveWithAuthorization',\n message: {\n from: params.from,\n to: params.to,\n value: params.value,\n validAfter: params.validAfter,\n validBefore: params.validBefore,\n nonce: params.nonce,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the EIP-2612 Permit typed-data.\n *\n * - `chainId`, `token`, `tokenName`, `tokenVersion` form the EIP-712\n * domain (same shape as the EIP-3009 builder).\n * - `owner` is the token holder authorising the allowance. Must match\n * the signing wallet.\n * - `spender` is the contract that will pull funds. For Strimz\n * subscriptions this is the StrimzSubscriptions contract.\n * - `value` is the allowance to grant in token base units.\n * `type(uint256).max` produces an unlimited allowance and is the\n * common case for subscription enrolment.\n * - `nonce` is the owner's *current* `nonces(owner)` reading from the\n * token contract. The SDK does not fetch this. The caller is\n * expected to have just queried it. Race-free: the token rejects\n * stale nonces, so a concurrent permit on the same owner causes one\n * to fail predictably.\n * - `deadline` is the unix-second timestamp after which the permit\n * expires. Strimz default for subscription enrolment is 24h. Enough\n * headroom for a slow merchant submit pipeline without leaving an\n * indefinite signature window.\n */\nexport interface PermitParams {\n chainId: number\n token: `0x${string}`\n tokenName: string\n tokenVersion: string\n owner: `0x${string}`\n spender: `0x${string}`\n value: bigint\n nonce: bigint\n deadline: bigint\n}\n\n/**\n * EIP-712 type definition for `Permit`. Stable across every EIP-2612\n * implementation (USDC, EURC, DAI v2, etc.).\n */\nexport const PERMIT_TYPES = {\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/**\n * Build the typed-data structure for an EIP-2612 `Permit` signature.\n * Returns the canonical shape compatible with viem, ethers, Privy,\n * and Reown.\n */\nexport function buildPermitTypedData(params: PermitParams): Eip712TypedData<'Permit'> {\n return {\n domain: {\n name: params.tokenName,\n version: params.tokenVersion,\n chainId: params.chainId,\n verifyingContract: params.token,\n },\n types: PERMIT_TYPES,\n primaryType: 'Permit',\n message: {\n owner: params.owner,\n spender: params.spender,\n value: params.value,\n nonce: params.nonce,\n deadline: params.deadline,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz PayIntent. Payer signs this alongside the\n * EIP-3009 auth. Without it, a valid auth sig can be redirected to\n * pay a different merchant.\n *\n * Every field must match the corresponding argument the API will\n * submit on-chain — the contract compares them via ecrecover.\n */\nexport interface PayIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n nonce: `0x${string}`\n validBefore: bigint\n ref: `0x${string}`\n}\n\n/** Field order matches `PAY_INTENT_TYPEHASH` in `StrimzPayments.sol`. */\nexport const PAY_INTENT_TYPES = {\n PayIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'ref', type: 'bytes32' },\n ],\n} as const\n\n/** Domain name + version mirror `EIP712(\"StrimzPayments\", \"1\")`. */\nexport function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedData<'PayIntent'> {\n return {\n domain: {\n name: 'StrimzPayments',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: PAY_INTENT_TYPES,\n primaryType: 'PayIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n nonce: params.nonce,\n validBefore: params.validBefore,\n ref: params.ref,\n },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\n/**\n * Inputs for the Strimz SubscriptionIntent. Payer signs this\n * alongside the ERC-2612 permit. Without it, a valid permit can be\n * used to enrol the payer in a plan they never picked.\n *\n * `permitDeadline` and `permitValue` tie this intent to the accompanying\n * permit. `nonce` is spent once on chain; the Strimz API only accepts\n * `subscriptionIntentNonce(planId, payer, the token's permit nonce)` from\n * `@strimz/shared-crypto`, so a retried signup can't enrol twice.\n */\nexport interface SubscriptionIntentParams {\n chainId: number\n verifyingContract: `0x${string}`\n merchantId: bigint\n token: `0x${string}`\n amount: bigint\n interval: number\n startAt: bigint\n endAt: bigint\n permitDeadline: bigint\n permitValue: bigint\n nonce: `0x${string}`\n}\n\n/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */\nexport const SUBSCRIPTION_INTENT_TYPES = {\n SubscriptionIntent: [\n { name: 'merchantId', type: 'uint256' },\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'interval', type: 'uint32' },\n { name: 'startAt', type: 'uint64' },\n { name: 'endAt', type: 'uint64' },\n { name: 'permitDeadline', type: 'uint256' },\n { name: 'permitValue', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const\n\n/** Domain mirrors `EIP712(\"StrimzSubscriptions\", \"1\")`. */\nexport function buildSubscriptionIntentTypedData(\n params: SubscriptionIntentParams,\n): Eip712TypedData<'SubscriptionIntent'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: SUBSCRIPTION_INTENT_TYPES,\n primaryType: 'SubscriptionIntent',\n message: {\n merchantId: params.merchantId,\n token: params.token,\n amount: params.amount,\n interval: params.interval,\n startAt: params.startAt,\n endAt: params.endAt,\n permitDeadline: params.permitDeadline,\n permitValue: params.permitValue,\n nonce: params.nonce,\n },\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -102,7 +102,7 @@ var HEADERS = {
102
102
  sdkRuntime: "X-Strimz-Sdk-Runtime"
103
103
  };
104
104
  var SDK_NAME = "@strimz/sdk";
105
- var SDK_VERSION = "0.13.1";
105
+ var SDK_VERSION = "0.15.0";
106
106
  function buildBaseHeaders(apiKey, runtime) {
107
107
  return {
108
108
  [HEADERS.authorization]: `Bearer ${apiKey}`,
@@ -469,6 +469,15 @@ var SubscriptionPlansResource = class extends BaseResource {
469
469
  list(params) {
470
470
  return this.listPage("/v1/subscription-plans", sharedTypes.subscriptionPlanSchema, params);
471
471
  }
472
+ /** Only the return URLs can change. `null` clears one. */
473
+ update(id, input) {
474
+ sharedTypes.updateSubscriptionPlanInputSchema.parse(input);
475
+ return this.patch(
476
+ `/v1/subscription-plans/${encodeURIComponent(id)}`,
477
+ input,
478
+ sharedTypes.subscriptionPlanSchema
479
+ );
480
+ }
472
481
  archive(id, options) {
473
482
  return this.post(
474
483
  `/v1/subscription-plans/${encodeURIComponent(id)}/archive`,