@strimz/sdk 0.16.0 → 0.18.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 +9 -8
- package/dist/browser-client.cjs +1 -1
- package/dist/browser-client.js +1 -1
- package/dist/eip712.cjs +43 -0
- package/dist/eip712.cjs.map +1 -1
- package/dist/eip712.d.cts +42 -1
- package/dist/eip712.d.ts +42 -1
- package/dist/eip712.js +39 -1
- package/dist/eip712.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/client.ts +1 -1
- package/src/eip712/index.ts +10 -0
- package/src/eip712/subscription-intent.ts +36 -0
- package/src/eip712/view-subscriptions.ts +28 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](./LICENSE)
|
|
10
10
|
|
|
11
11
|
The server-side client for the
|
|
12
|
-
[Strimz API](https://
|
|
12
|
+
[Strimz API](https://docs.strimz.finance/docs/api/overview). Typed
|
|
13
13
|
resources for every endpoint, end-to-end TypeScript types derived
|
|
14
14
|
from the
|
|
15
15
|
[`@strimz/shared-types`](https://www.npmjs.com/package/@strimz/shared-types)
|
|
@@ -174,11 +174,12 @@ For a full hosted-checkout UX with components and hooks, use
|
|
|
174
174
|
|
|
175
175
|
`@strimz/sdk/eip712` builds the typed data a wallet signs:
|
|
176
176
|
`buildReceiveWithAuthorizationTypedData`, `buildPermitTypedData`,
|
|
177
|
-
`buildPayIntentTypedData
|
|
178
|
-
their `*_TYPES` constants. Hosted checkout uses them; you only need
|
|
177
|
+
`buildPayIntentTypedData`, `buildSubscriptionIntentTypedData` and
|
|
178
|
+
`buildCancelSubscriptionTypedData`, with 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`
|
|
181
|
+
A `SubscriptionIntent` names the `payer` and carries the permit's
|
|
182
|
+
`permitValue` and a `nonce`.
|
|
182
183
|
When you relay an enrolment through Strimz, the nonce must be
|
|
183
184
|
`subscriptionIntentNonce(planId, payer, permitNonce)` from
|
|
184
185
|
`@strimz/shared-crypto`, where `permitNonce` is the token's
|
|
@@ -230,7 +231,7 @@ try {
|
|
|
230
231
|
```
|
|
231
232
|
|
|
232
233
|
The full code list is documented at
|
|
233
|
-
[strimz.finance/docs/errors](https://
|
|
234
|
+
[strimz.finance/docs/errors](https://docs.strimz.finance/docs/errors).
|
|
234
235
|
|
|
235
236
|
## Runtime support
|
|
236
237
|
|
|
@@ -243,12 +244,12 @@ The full code list is documented at
|
|
|
243
244
|
| Bun | Should work, not regularly tested |
|
|
244
245
|
| Browsers | Use `StrimzBrowserClient` from `@strimz/sdk/browser` |
|
|
245
246
|
|
|
246
|
-
`StrimzClient` refuses to start in a browser runtime: a page, a web worker, an Electron renderer, or React Native. It throws `StrimzAuthenticationError` with code `secret_key_in_browser` and a message that never contains the key. Node with a DOM shim such as jsdom, Deno, Bun, Vercel Edge and Cloudflare Workers count as servers. There is no option to turn the check off. Create payment sessions on your server and pass the session id to the browser; see [strimz.finance/docs/checkout/server-sessions](https://
|
|
247
|
+
`StrimzClient` refuses to start in a browser runtime: a page, a web worker, an Electron renderer, or React Native. It throws `StrimzAuthenticationError` with code `secret_key_in_browser` and a message that never contains the key. Node with a DOM shim such as jsdom, Deno, Bun, Vercel Edge and Cloudflare Workers count as servers. There is no option to turn the check off. Create payment sessions on your server and pass the session id to the browser; see [strimz.finance/docs/checkout/server-sessions](https://docs.strimz.finance/docs/checkout/server-sessions).
|
|
247
248
|
|
|
248
249
|
## Links
|
|
249
250
|
|
|
250
|
-
- [Documentation](https://
|
|
251
|
-
- [API reference](https://
|
|
251
|
+
- [Documentation](https://docs.strimz.finance/docs)
|
|
252
|
+
- [API reference](https://docs.strimz.finance/docs/api/overview)
|
|
252
253
|
- [Repository](https://github.com/StrimzLab/strimz/tree/main/packages/sdk)
|
|
253
254
|
- [Changelog](./CHANGELOG.md)
|
|
254
255
|
- [Issues](https://github.com/StrimzLab/strimz/issues)
|
package/dist/browser-client.cjs
CHANGED
|
@@ -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.
|
|
99
|
+
var SDK_VERSION = "0.18.0";
|
|
100
100
|
function buildBaseHeaders(apiKey, runtime) {
|
|
101
101
|
return {
|
|
102
102
|
[HEADERS.authorization]: `Bearer ${apiKey}`,
|
package/dist/browser-client.js
CHANGED
|
@@ -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.
|
|
97
|
+
var SDK_VERSION = "0.18.0";
|
|
98
98
|
function buildBaseHeaders(apiKey, runtime) {
|
|
99
99
|
return {
|
|
100
100
|
[HEADERS.authorization]: `Bearer ${apiKey}`,
|
package/dist/eip712.cjs
CHANGED
|
@@ -97,6 +97,7 @@ function buildPayIntentTypedData(params) {
|
|
|
97
97
|
// src/eip712/subscription-intent.ts
|
|
98
98
|
var SUBSCRIPTION_INTENT_TYPES = {
|
|
99
99
|
SubscriptionIntent: [
|
|
100
|
+
{ name: "payer", type: "address" },
|
|
100
101
|
{ name: "merchantId", type: "uint256" },
|
|
101
102
|
{ name: "token", type: "address" },
|
|
102
103
|
{ name: "amount", type: "uint256" },
|
|
@@ -119,6 +120,7 @@ function buildSubscriptionIntentTypedData(params) {
|
|
|
119
120
|
types: SUBSCRIPTION_INTENT_TYPES,
|
|
120
121
|
primaryType: "SubscriptionIntent",
|
|
121
122
|
message: {
|
|
123
|
+
payer: params.payer,
|
|
122
124
|
merchantId: params.merchantId,
|
|
123
125
|
token: params.token,
|
|
124
126
|
amount: params.amount,
|
|
@@ -131,14 +133,55 @@ function buildSubscriptionIntentTypedData(params) {
|
|
|
131
133
|
}
|
|
132
134
|
};
|
|
133
135
|
}
|
|
136
|
+
var CANCEL_SUBSCRIPTION_TYPES = {
|
|
137
|
+
CancelSubscription: [
|
|
138
|
+
{ name: "subscriptionId", type: "uint256" },
|
|
139
|
+
{ name: "deadline", type: "uint256" }
|
|
140
|
+
]
|
|
141
|
+
};
|
|
142
|
+
function buildCancelSubscriptionTypedData(params) {
|
|
143
|
+
return {
|
|
144
|
+
domain: {
|
|
145
|
+
name: "StrimzSubscriptions",
|
|
146
|
+
version: "1",
|
|
147
|
+
chainId: params.chainId,
|
|
148
|
+
verifyingContract: params.verifyingContract
|
|
149
|
+
},
|
|
150
|
+
types: CANCEL_SUBSCRIPTION_TYPES,
|
|
151
|
+
primaryType: "CancelSubscription",
|
|
152
|
+
message: { subscriptionId: params.subscriptionId, deadline: params.deadline }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/eip712/view-subscriptions.ts
|
|
157
|
+
var VIEW_SUBSCRIPTIONS_TYPES = {
|
|
158
|
+
ViewSubscriptions: [
|
|
159
|
+
{ name: "payer", type: "address" },
|
|
160
|
+
{ name: "issuedAt", type: "uint256" }
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
var VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600;
|
|
164
|
+
function buildViewSubscriptionsTypedData(params) {
|
|
165
|
+
return {
|
|
166
|
+
domain: { name: "Strimz", version: "1", chainId: params.chainId },
|
|
167
|
+
types: VIEW_SUBSCRIPTIONS_TYPES,
|
|
168
|
+
primaryType: "ViewSubscriptions",
|
|
169
|
+
message: { payer: params.payer, issuedAt: params.issuedAt }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
134
172
|
|
|
173
|
+
exports.CANCEL_SUBSCRIPTION_TYPES = CANCEL_SUBSCRIPTION_TYPES;
|
|
135
174
|
exports.PAY_INTENT_TYPES = PAY_INTENT_TYPES;
|
|
136
175
|
exports.PERMIT_TYPES = PERMIT_TYPES;
|
|
137
176
|
exports.RECEIVE_WITH_AUTHORIZATION_TYPES = RECEIVE_WITH_AUTHORIZATION_TYPES;
|
|
138
177
|
exports.SUBSCRIPTION_INTENT_TYPES = SUBSCRIPTION_INTENT_TYPES;
|
|
178
|
+
exports.VIEW_SUBSCRIPTIONS_TYPES = VIEW_SUBSCRIPTIONS_TYPES;
|
|
179
|
+
exports.VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS;
|
|
180
|
+
exports.buildCancelSubscriptionTypedData = buildCancelSubscriptionTypedData;
|
|
139
181
|
exports.buildPayIntentTypedData = buildPayIntentTypedData;
|
|
140
182
|
exports.buildPermitTypedData = buildPermitTypedData;
|
|
141
183
|
exports.buildReceiveWithAuthorizationTypedData = buildReceiveWithAuthorizationTypedData;
|
|
142
184
|
exports.buildSubscriptionIntentTypedData = buildSubscriptionIntentTypedData;
|
|
185
|
+
exports.buildViewSubscriptionsTypedData = buildViewSubscriptionsTypedData;
|
|
143
186
|
//# sourceMappingURL=eip712.cjs.map
|
|
144
187
|
//# sourceMappingURL=eip712.cjs.map
|
package/dist/eip712.cjs.map
CHANGED
|
@@ -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,E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jB,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.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"]}
|
|
1
|
+
{"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts","../src/eip712/view-subscriptions.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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,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,SAAS,EAAE,cAAA,EAAgB,OAAO,cAAA,EAAgB,QAAA,EAAU,OAAO,QAAA;AAAS,GAC9E;AACF;;;AC9FO,IAAM,wBAAA,GAA2B;AAAA,EACtC,iBAAA,EAAmB;AAAA,IACjB,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,SAAA;AAAU;AAExC;AAEO,IAAM,mCAAA,GAAsC;AAG5C,SAAS,gCACd,MAAA,EACsC;AACtC,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,GAAA,EAAK,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAChE,KAAA,EAAO,wBAAA;AAAA,IACP,WAAA,EAAa,mBAAA;AAAA,IACb,SAAS,EAAE,KAAA,EAAO,OAAO,KAAA,EAAO,QAAA,EAAU,OAAO,QAAA;AAAS,GAC5D;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 /** The paying wallet. It's signed in, so one signature can't enrol a sibling wallet. */\n payer: `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: 'payer', type: 'address' },\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 payer: params.payer,\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\nexport interface CancelSubscriptionParams {\n chainId: number\n verifyingContract: `0x${string}`\n subscriptionId: bigint\n deadline: bigint\n}\n\n/** Field order matches `CANCEL_SUBSCRIPTION_TYPEHASH` in the contract. */\nexport const CANCEL_SUBSCRIPTION_TYPES = {\n CancelSubscription: [\n { name: 'subscriptionId', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/** What a payer signs so Strimz can cancel for them with `cancelWithSig`. */\nexport function buildCancelSubscriptionTypedData(\n params: CancelSubscriptionParams,\n): Eip712TypedData<'CancelSubscription'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: CANCEL_SUBSCRIPTION_TYPES,\n primaryType: 'CancelSubscription',\n message: { subscriptionId: params.subscriptionId, deadline: params.deadline },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\nexport interface ViewSubscriptionsParams {\n chainId: number\n payer: `0x${string}`\n issuedAt: bigint\n}\n\nexport const VIEW_SUBSCRIPTIONS_TYPES = {\n ViewSubscriptions: [\n { name: 'payer', type: 'address' },\n { name: 'issuedAt', type: 'uint256' },\n ],\n} as const\n\nexport const VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600\n\n/** Proves a wallet owns the address whose subscriptions it asks to see. Costs no gas. */\nexport function buildViewSubscriptionsTypedData(\n params: ViewSubscriptionsParams,\n): Eip712TypedData<'ViewSubscriptions'> {\n return {\n domain: { name: 'Strimz', version: '1', chainId: params.chainId },\n types: VIEW_SUBSCRIPTIONS_TYPES,\n primaryType: 'ViewSubscriptions',\n message: { payer: params.payer, issuedAt: params.issuedAt },\n }\n}\n"]}
|
package/dist/eip712.d.cts
CHANGED
|
@@ -235,6 +235,8 @@ declare function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedDa
|
|
|
235
235
|
interface SubscriptionIntentParams {
|
|
236
236
|
chainId: number;
|
|
237
237
|
verifyingContract: `0x${string}`;
|
|
238
|
+
/** The paying wallet. It's signed in, so one signature can't enrol a sibling wallet. */
|
|
239
|
+
payer: `0x${string}`;
|
|
238
240
|
merchantId: bigint;
|
|
239
241
|
token: `0x${string}`;
|
|
240
242
|
amount: bigint;
|
|
@@ -248,6 +250,9 @@ interface SubscriptionIntentParams {
|
|
|
248
250
|
/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */
|
|
249
251
|
declare const SUBSCRIPTION_INTENT_TYPES: {
|
|
250
252
|
readonly SubscriptionIntent: readonly [{
|
|
253
|
+
readonly name: "payer";
|
|
254
|
+
readonly type: "address";
|
|
255
|
+
}, {
|
|
251
256
|
readonly name: "merchantId";
|
|
252
257
|
readonly type: "uint256";
|
|
253
258
|
}, {
|
|
@@ -278,5 +283,41 @@ declare const SUBSCRIPTION_INTENT_TYPES: {
|
|
|
278
283
|
};
|
|
279
284
|
/** Domain mirrors `EIP712("StrimzSubscriptions", "1")`. */
|
|
280
285
|
declare function buildSubscriptionIntentTypedData(params: SubscriptionIntentParams): Eip712TypedData<'SubscriptionIntent'>;
|
|
286
|
+
interface CancelSubscriptionParams {
|
|
287
|
+
chainId: number;
|
|
288
|
+
verifyingContract: `0x${string}`;
|
|
289
|
+
subscriptionId: bigint;
|
|
290
|
+
deadline: bigint;
|
|
291
|
+
}
|
|
292
|
+
/** Field order matches `CANCEL_SUBSCRIPTION_TYPEHASH` in the contract. */
|
|
293
|
+
declare const CANCEL_SUBSCRIPTION_TYPES: {
|
|
294
|
+
readonly CancelSubscription: readonly [{
|
|
295
|
+
readonly name: "subscriptionId";
|
|
296
|
+
readonly type: "uint256";
|
|
297
|
+
}, {
|
|
298
|
+
readonly name: "deadline";
|
|
299
|
+
readonly type: "uint256";
|
|
300
|
+
}];
|
|
301
|
+
};
|
|
302
|
+
/** What a payer signs so Strimz can cancel for them with `cancelWithSig`. */
|
|
303
|
+
declare function buildCancelSubscriptionTypedData(params: CancelSubscriptionParams): Eip712TypedData<'CancelSubscription'>;
|
|
304
|
+
|
|
305
|
+
interface ViewSubscriptionsParams {
|
|
306
|
+
chainId: number;
|
|
307
|
+
payer: `0x${string}`;
|
|
308
|
+
issuedAt: bigint;
|
|
309
|
+
}
|
|
310
|
+
declare const VIEW_SUBSCRIPTIONS_TYPES: {
|
|
311
|
+
readonly ViewSubscriptions: readonly [{
|
|
312
|
+
readonly name: "payer";
|
|
313
|
+
readonly type: "address";
|
|
314
|
+
}, {
|
|
315
|
+
readonly name: "issuedAt";
|
|
316
|
+
readonly type: "uint256";
|
|
317
|
+
}];
|
|
318
|
+
};
|
|
319
|
+
declare const VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600;
|
|
320
|
+
/** Proves a wallet owns the address whose subscriptions it asks to see. Costs no gas. */
|
|
321
|
+
declare function buildViewSubscriptionsTypedData(params: ViewSubscriptionsParams): Eip712TypedData<'ViewSubscriptions'>;
|
|
281
322
|
|
|
282
|
-
export { type Eip712Domain, type Eip712Field, type Eip712TypedData, type Eip712Types, PAY_INTENT_TYPES, PERMIT_TYPES, type PayIntentParams, type PermitParams, RECEIVE_WITH_AUTHORIZATION_TYPES, type ReceiveWithAuthorizationParams, SUBSCRIPTION_INTENT_TYPES, type SubscriptionIntentParams, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData };
|
|
323
|
+
export { CANCEL_SUBSCRIPTION_TYPES, type CancelSubscriptionParams, type Eip712Domain, type Eip712Field, type Eip712TypedData, type Eip712Types, PAY_INTENT_TYPES, PERMIT_TYPES, type PayIntentParams, type PermitParams, RECEIVE_WITH_AUTHORIZATION_TYPES, type ReceiveWithAuthorizationParams, SUBSCRIPTION_INTENT_TYPES, type SubscriptionIntentParams, VIEW_SUBSCRIPTIONS_TYPES, VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS, type ViewSubscriptionsParams, buildCancelSubscriptionTypedData, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData, buildViewSubscriptionsTypedData };
|
package/dist/eip712.d.ts
CHANGED
|
@@ -235,6 +235,8 @@ declare function buildPayIntentTypedData(params: PayIntentParams): Eip712TypedDa
|
|
|
235
235
|
interface SubscriptionIntentParams {
|
|
236
236
|
chainId: number;
|
|
237
237
|
verifyingContract: `0x${string}`;
|
|
238
|
+
/** The paying wallet. It's signed in, so one signature can't enrol a sibling wallet. */
|
|
239
|
+
payer: `0x${string}`;
|
|
238
240
|
merchantId: bigint;
|
|
239
241
|
token: `0x${string}`;
|
|
240
242
|
amount: bigint;
|
|
@@ -248,6 +250,9 @@ interface SubscriptionIntentParams {
|
|
|
248
250
|
/** Field order matches `SUBSCRIPTION_INTENT_TYPEHASH` in the contract. */
|
|
249
251
|
declare const SUBSCRIPTION_INTENT_TYPES: {
|
|
250
252
|
readonly SubscriptionIntent: readonly [{
|
|
253
|
+
readonly name: "payer";
|
|
254
|
+
readonly type: "address";
|
|
255
|
+
}, {
|
|
251
256
|
readonly name: "merchantId";
|
|
252
257
|
readonly type: "uint256";
|
|
253
258
|
}, {
|
|
@@ -278,5 +283,41 @@ declare const SUBSCRIPTION_INTENT_TYPES: {
|
|
|
278
283
|
};
|
|
279
284
|
/** Domain mirrors `EIP712("StrimzSubscriptions", "1")`. */
|
|
280
285
|
declare function buildSubscriptionIntentTypedData(params: SubscriptionIntentParams): Eip712TypedData<'SubscriptionIntent'>;
|
|
286
|
+
interface CancelSubscriptionParams {
|
|
287
|
+
chainId: number;
|
|
288
|
+
verifyingContract: `0x${string}`;
|
|
289
|
+
subscriptionId: bigint;
|
|
290
|
+
deadline: bigint;
|
|
291
|
+
}
|
|
292
|
+
/** Field order matches `CANCEL_SUBSCRIPTION_TYPEHASH` in the contract. */
|
|
293
|
+
declare const CANCEL_SUBSCRIPTION_TYPES: {
|
|
294
|
+
readonly CancelSubscription: readonly [{
|
|
295
|
+
readonly name: "subscriptionId";
|
|
296
|
+
readonly type: "uint256";
|
|
297
|
+
}, {
|
|
298
|
+
readonly name: "deadline";
|
|
299
|
+
readonly type: "uint256";
|
|
300
|
+
}];
|
|
301
|
+
};
|
|
302
|
+
/** What a payer signs so Strimz can cancel for them with `cancelWithSig`. */
|
|
303
|
+
declare function buildCancelSubscriptionTypedData(params: CancelSubscriptionParams): Eip712TypedData<'CancelSubscription'>;
|
|
304
|
+
|
|
305
|
+
interface ViewSubscriptionsParams {
|
|
306
|
+
chainId: number;
|
|
307
|
+
payer: `0x${string}`;
|
|
308
|
+
issuedAt: bigint;
|
|
309
|
+
}
|
|
310
|
+
declare const VIEW_SUBSCRIPTIONS_TYPES: {
|
|
311
|
+
readonly ViewSubscriptions: readonly [{
|
|
312
|
+
readonly name: "payer";
|
|
313
|
+
readonly type: "address";
|
|
314
|
+
}, {
|
|
315
|
+
readonly name: "issuedAt";
|
|
316
|
+
readonly type: "uint256";
|
|
317
|
+
}];
|
|
318
|
+
};
|
|
319
|
+
declare const VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600;
|
|
320
|
+
/** Proves a wallet owns the address whose subscriptions it asks to see. Costs no gas. */
|
|
321
|
+
declare function buildViewSubscriptionsTypedData(params: ViewSubscriptionsParams): Eip712TypedData<'ViewSubscriptions'>;
|
|
281
322
|
|
|
282
|
-
export { type Eip712Domain, type Eip712Field, type Eip712TypedData, type Eip712Types, PAY_INTENT_TYPES, PERMIT_TYPES, type PayIntentParams, type PermitParams, RECEIVE_WITH_AUTHORIZATION_TYPES, type ReceiveWithAuthorizationParams, SUBSCRIPTION_INTENT_TYPES, type SubscriptionIntentParams, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData };
|
|
323
|
+
export { CANCEL_SUBSCRIPTION_TYPES, type CancelSubscriptionParams, type Eip712Domain, type Eip712Field, type Eip712TypedData, type Eip712Types, PAY_INTENT_TYPES, PERMIT_TYPES, type PayIntentParams, type PermitParams, RECEIVE_WITH_AUTHORIZATION_TYPES, type ReceiveWithAuthorizationParams, SUBSCRIPTION_INTENT_TYPES, type SubscriptionIntentParams, VIEW_SUBSCRIPTIONS_TYPES, VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS, type ViewSubscriptionsParams, buildCancelSubscriptionTypedData, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData, buildViewSubscriptionsTypedData };
|
package/dist/eip712.js
CHANGED
|
@@ -95,6 +95,7 @@ function buildPayIntentTypedData(params) {
|
|
|
95
95
|
// src/eip712/subscription-intent.ts
|
|
96
96
|
var SUBSCRIPTION_INTENT_TYPES = {
|
|
97
97
|
SubscriptionIntent: [
|
|
98
|
+
{ name: "payer", type: "address" },
|
|
98
99
|
{ name: "merchantId", type: "uint256" },
|
|
99
100
|
{ name: "token", type: "address" },
|
|
100
101
|
{ name: "amount", type: "uint256" },
|
|
@@ -117,6 +118,7 @@ function buildSubscriptionIntentTypedData(params) {
|
|
|
117
118
|
types: SUBSCRIPTION_INTENT_TYPES,
|
|
118
119
|
primaryType: "SubscriptionIntent",
|
|
119
120
|
message: {
|
|
121
|
+
payer: params.payer,
|
|
120
122
|
merchantId: params.merchantId,
|
|
121
123
|
token: params.token,
|
|
122
124
|
amount: params.amount,
|
|
@@ -129,7 +131,43 @@ function buildSubscriptionIntentTypedData(params) {
|
|
|
129
131
|
}
|
|
130
132
|
};
|
|
131
133
|
}
|
|
134
|
+
var CANCEL_SUBSCRIPTION_TYPES = {
|
|
135
|
+
CancelSubscription: [
|
|
136
|
+
{ name: "subscriptionId", type: "uint256" },
|
|
137
|
+
{ name: "deadline", type: "uint256" }
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
function buildCancelSubscriptionTypedData(params) {
|
|
141
|
+
return {
|
|
142
|
+
domain: {
|
|
143
|
+
name: "StrimzSubscriptions",
|
|
144
|
+
version: "1",
|
|
145
|
+
chainId: params.chainId,
|
|
146
|
+
verifyingContract: params.verifyingContract
|
|
147
|
+
},
|
|
148
|
+
types: CANCEL_SUBSCRIPTION_TYPES,
|
|
149
|
+
primaryType: "CancelSubscription",
|
|
150
|
+
message: { subscriptionId: params.subscriptionId, deadline: params.deadline }
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/eip712/view-subscriptions.ts
|
|
155
|
+
var VIEW_SUBSCRIPTIONS_TYPES = {
|
|
156
|
+
ViewSubscriptions: [
|
|
157
|
+
{ name: "payer", type: "address" },
|
|
158
|
+
{ name: "issuedAt", type: "uint256" }
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
var VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600;
|
|
162
|
+
function buildViewSubscriptionsTypedData(params) {
|
|
163
|
+
return {
|
|
164
|
+
domain: { name: "Strimz", version: "1", chainId: params.chainId },
|
|
165
|
+
types: VIEW_SUBSCRIPTIONS_TYPES,
|
|
166
|
+
primaryType: "ViewSubscriptions",
|
|
167
|
+
message: { payer: params.payer, issuedAt: params.issuedAt }
|
|
168
|
+
};
|
|
169
|
+
}
|
|
132
170
|
|
|
133
|
-
export { PAY_INTENT_TYPES, PERMIT_TYPES, RECEIVE_WITH_AUTHORIZATION_TYPES, SUBSCRIPTION_INTENT_TYPES, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData };
|
|
171
|
+
export { CANCEL_SUBSCRIPTION_TYPES, PAY_INTENT_TYPES, PERMIT_TYPES, RECEIVE_WITH_AUTHORIZATION_TYPES, SUBSCRIPTION_INTENT_TYPES, VIEW_SUBSCRIPTIONS_TYPES, VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS, buildCancelSubscriptionTypedData, buildPayIntentTypedData, buildPermitTypedData, buildReceiveWithAuthorizationTypedData, buildSubscriptionIntentTypedData, buildViewSubscriptionsTypedData };
|
|
134
172
|
//# sourceMappingURL=eip712.js.map
|
|
135
173
|
//# sourceMappingURL=eip712.js.map
|
package/dist/eip712.js.map
CHANGED
|
@@ -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,E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AU,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/eip712/receive-with-authorization.ts","../src/eip712/permit.ts","../src/eip712/pay-intent.ts","../src/eip712/subscription-intent.ts","../src/eip712/view-subscriptions.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,CA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AA;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,SAAS,EAAE,cAAA,EAAgB,OAAO,cAAA,EAAgB,QAAA,EAAU,OAAO,QAAA;AAAS,GAC9E;AACF;;;AC9FO,IAAM,wBAAA,GAA2B;AAAA,EACtC,iBAAA,EAAmB;AAAA,IACjB,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,SAAA;AAAU;AAExC;AAEO,IAAM,mCAAA,GAAsC;AAG5C,SAAS,gCACd,MAAA,EACsC;AACtC,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,GAAA,EAAK,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAChE,KAAA,EAAO,wBAAA;AAAA,IACP,WAAA,EAAa,mBAAA;AAAA,IACb,SAAS,EAAE,KAAA,EAAO,OAAO,KAAA,EAAO,QAAA,EAAU,OAAO,QAAA;AAAS,GAC5D;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 /** The paying wallet. It's signed in, so one signature can't enrol a sibling wallet. */\n payer: `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: 'payer', type: 'address' },\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 payer: params.payer,\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\nexport interface CancelSubscriptionParams {\n chainId: number\n verifyingContract: `0x${string}`\n subscriptionId: bigint\n deadline: bigint\n}\n\n/** Field order matches `CANCEL_SUBSCRIPTION_TYPEHASH` in the contract. */\nexport const CANCEL_SUBSCRIPTION_TYPES = {\n CancelSubscription: [\n { name: 'subscriptionId', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n} as const\n\n/** What a payer signs so Strimz can cancel for them with `cancelWithSig`. */\nexport function buildCancelSubscriptionTypedData(\n params: CancelSubscriptionParams,\n): Eip712TypedData<'CancelSubscription'> {\n return {\n domain: {\n name: 'StrimzSubscriptions',\n version: '1',\n chainId: params.chainId,\n verifyingContract: params.verifyingContract,\n },\n types: CANCEL_SUBSCRIPTION_TYPES,\n primaryType: 'CancelSubscription',\n message: { subscriptionId: params.subscriptionId, deadline: params.deadline },\n }\n}\n","import type { Eip712TypedData } from './types.js'\n\nexport interface ViewSubscriptionsParams {\n chainId: number\n payer: `0x${string}`\n issuedAt: bigint\n}\n\nexport const VIEW_SUBSCRIPTIONS_TYPES = {\n ViewSubscriptions: [\n { name: 'payer', type: 'address' },\n { name: 'issuedAt', type: 'uint256' },\n ],\n} as const\n\nexport const VIEW_SUBSCRIPTIONS_VALIDITY_SECONDS = 600\n\n/** Proves a wallet owns the address whose subscriptions it asks to see. Costs no gas. */\nexport function buildViewSubscriptionsTypedData(\n params: ViewSubscriptionsParams,\n): Eip712TypedData<'ViewSubscriptions'> {\n return {\n domain: { name: 'Strimz', version: '1', chainId: params.chainId },\n types: VIEW_SUBSCRIPTIONS_TYPES,\n primaryType: 'ViewSubscriptions',\n message: { payer: params.payer, issuedAt: params.issuedAt },\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.
|
|
105
|
+
var SDK_VERSION = "0.18.0";
|
|
106
106
|
function buildBaseHeaders(apiKey, runtime) {
|
|
107
107
|
return {
|
|
108
108
|
[HEADERS.authorization]: `Bearer ${apiKey}`,
|
|
@@ -679,7 +679,7 @@ var AgentsResource = class extends BaseResource {
|
|
|
679
679
|
|
|
680
680
|
// src/client.ts
|
|
681
681
|
var DEFAULT_BASE_URL = "https://api.strimz.finance";
|
|
682
|
-
var SECRET_KEY_IN_BROWSER_MESSAGE = "StrimzClient cannot run in a browser: secret keys must stay on your server. Create payment sessions from a server route and pass the session id to the browser. See https://strimz.finance/docs/checkout/server-sessions";
|
|
682
|
+
var SECRET_KEY_IN_BROWSER_MESSAGE = "StrimzClient cannot run in a browser: secret keys must stay on your server. Create payment sessions from a server route and pass the session id to the browser. See https://docs.strimz.finance/docs/checkout/server-sessions";
|
|
683
683
|
var StrimzClient = class {
|
|
684
684
|
/** Resolved mode, either `test` or `live`. Derived from the API key prefix. */
|
|
685
685
|
mode;
|