mppx 0.8.19 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +0 -6
  3. package/dist/Challenge.d.ts +7 -0
  4. package/dist/Challenge.js +32 -6
  5. package/dist/Constants.d.ts +1 -0
  6. package/dist/Constants.js +1 -0
  7. package/dist/Credential.d.ts +11 -5
  8. package/dist/Credential.js +8 -8
  9. package/dist/Html.js +1 -1
  10. package/dist/cli/THIRD-PARTY-LICENSES.txt +1 -1
  11. package/dist/cli/cli.d.ts +2 -2
  12. package/dist/cli/cli.js +134 -134
  13. package/dist/cli/plugins/index.js +13 -13
  14. package/dist/cli/sessions/Manager.js +4 -6
  15. package/dist/cli/sessions/commands.d.ts +1 -1
  16. package/dist/cli/sessions/store.js +13 -19
  17. package/dist/cli/validate/index.d.ts +2 -2
  18. package/dist/client/Mppx.d.ts +39 -2
  19. package/dist/client/Mppx.js +102 -46
  20. package/dist/client/Transport.js +1 -1
  21. package/dist/client/internal/protocols/Mpp.d.ts +1 -1
  22. package/dist/client/internal/protocols/Mpp.js +5 -3
  23. package/dist/client/internal/protocols/Protocol.d.ts +3 -1
  24. package/dist/client/internal/protocols/Shared.js +5 -1
  25. package/dist/integrations/x402/Evm.d.ts +29 -0
  26. package/dist/integrations/x402/Evm.js +150 -0
  27. package/dist/integrations/x402/Negotiator.d.ts +36 -0
  28. package/dist/integrations/x402/Negotiator.js +165 -0
  29. package/dist/mcp/internal/Credential.d.ts +9 -0
  30. package/dist/mcp/internal/Credential.js +16 -0
  31. package/dist/mcp/server/Transport.js +2 -4
  32. package/dist/middlewares/express.js +5 -12
  33. package/dist/middlewares/internal/express.d.ts +8 -0
  34. package/dist/middlewares/internal/express.js +24 -0
  35. package/dist/middlewares/internal/node.d.ts +10 -0
  36. package/dist/middlewares/internal/node.js +34 -0
  37. package/dist/proxy/Proxy.js +15 -9
  38. package/dist/server/Mppx.d.ts +2 -0
  39. package/dist/server/Mppx.js +17 -14
  40. package/dist/server/Transport.d.ts +8 -2
  41. package/dist/server/Transport.js +6 -3
  42. package/dist/server/internal/SecretKey.d.ts +3 -0
  43. package/dist/server/internal/SecretKey.js +9 -0
  44. package/dist/server/internal/html/serviceWorker.client.d.ts +1 -1
  45. package/dist/server/internal/html/serviceWorker.client.js +2 -2
  46. package/dist/server/internal/html/serviceWorker.gen.d.ts +1 -1
  47. package/dist/server/internal/html/serviceWorker.gen.js +1 -1
  48. package/dist/stripe/server/internal/html.gen.d.ts +1 -1
  49. package/dist/stripe/server/internal/html.gen.js +1 -1
  50. package/dist/tempo/Methods.d.ts +0 -10
  51. package/dist/tempo/Methods.js +3 -12
  52. package/dist/tempo/client/Charge.d.ts +0 -3
  53. package/dist/tempo/client/Charge.js +3 -13
  54. package/dist/tempo/client/Methods.d.ts +0 -10
  55. package/dist/tempo/internal/account.d.ts +15 -6
  56. package/dist/tempo/internal/account.js +17 -26
  57. package/dist/tempo/internal/defaults.d.ts +0 -11
  58. package/dist/tempo/internal/defaults.js +0 -11
  59. package/dist/tempo/internal/fee-payer.d.ts +21 -3
  60. package/dist/tempo/internal/fee-payer.js +10 -19
  61. package/dist/tempo/internal/remote-fee-payer.d.ts +12 -0
  62. package/dist/tempo/internal/remote-fee-payer.js +17 -0
  63. package/dist/tempo/legacy/client/Session.d.ts +0 -7
  64. package/dist/tempo/server/Charge.d.ts +0 -3
  65. package/dist/tempo/server/Charge.js +26 -68
  66. package/dist/tempo/server/Methods.d.ts +4 -18
  67. package/dist/tempo/server/Methods.js +4 -8
  68. package/dist/tempo/server/internal/html.gen.d.ts +1 -1
  69. package/dist/tempo/server/internal/html.gen.js +1 -1
  70. package/dist/tempo/session/client/ChannelOps.d.ts +0 -14
  71. package/dist/tempo/session/client/ChannelOps.js +0 -22
  72. package/dist/tempo/session/client/ChannelStore.d.ts +5 -0
  73. package/dist/tempo/session/client/ChannelStore.js +2 -2
  74. package/dist/tempo/session/client/CredentialState.d.ts +2 -12
  75. package/dist/tempo/session/client/CredentialState.js +75 -73
  76. package/dist/tempo/session/client/Session.d.ts +2 -9
  77. package/dist/tempo/session/client/Session.js +71 -176
  78. package/dist/tempo/session/client/SessionManager.js +9 -28
  79. package/dist/tempo/session/precompile/Chain.d.ts +0 -4
  80. package/dist/tempo/session/precompile/Chain.js +1 -29
  81. package/dist/tempo/session/precompile/Protocol.d.ts +0 -13
  82. package/dist/tempo/session/precompile/Voucher.d.ts +1 -3
  83. package/dist/tempo/session/precompile/Voucher.js +12 -6
  84. package/dist/tempo/session/server/ChannelStore.d.ts +0 -6
  85. package/dist/tempo/session/server/ChannelStore.js +4 -11
  86. package/dist/tempo/session/server/CredentialVerification.d.ts +7 -9
  87. package/dist/tempo/session/server/CredentialVerification.js +118 -184
  88. package/dist/tempo/session/server/RequestState.d.ts +0 -17
  89. package/dist/tempo/session/server/RequestState.js +15 -59
  90. package/dist/tempo/session/server/Session.d.ts +0 -9
  91. package/dist/tempo/session/server/Session.js +8 -37
  92. package/dist/tempo/session/server/Settlement.d.ts +0 -7
  93. package/dist/tempo/session/server/Settlement.js +16 -50
  94. package/dist/viem/Client.d.ts +7 -2
  95. package/dist/viem/Client.js +17 -5
  96. package/dist/x402/Types.d.ts +2 -0
  97. package/dist/x402/Types.js +2 -0
  98. package/dist/x402/mcp.d.ts +20 -0
  99. package/dist/x402/mcp.js +153 -0
  100. package/dist/x402/middlewares/express.d.ts +23 -0
  101. package/dist/x402/middlewares/express.js +49 -0
  102. package/dist/x402/middlewares/hono.d.ts +13 -0
  103. package/dist/x402/middlewares/hono.js +36 -0
  104. package/dist/x402/middlewares/next.d.ts +17 -0
  105. package/dist/x402/middlewares/next.js +58 -0
  106. package/package.json +41 -1
  107. package/dist/tempo/internal/machine-token-charge.d.ts +0 -51
  108. package/dist/tempo/internal/machine-token-charge.js +0 -113
  109. package/dist/tempo/internal/machine-token-session.d.ts +0 -88
  110. package/dist/tempo/internal/machine-token-session.js +0 -173
  111. package/dist/tempo/internal/signature-envelope.d.ts +0 -14
  112. package/dist/tempo/internal/signature-envelope.js +0 -28
@@ -37,7 +37,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
37
37
  }, import("zod/v4/core").$strip>], "type">;
38
38
  };
39
39
  request: import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniObject<{
40
- machineTokenEnabled: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniBoolean<boolean>>;
41
40
  amount: import("zod/mini").ZodMiniString<string>;
42
41
  chainId: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniNumber<number>>;
43
42
  currency: import("zod/mini").ZodMiniString<string>;
@@ -63,7 +62,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
63
62
  recipient?: string | undefined;
64
63
  amount: string;
65
64
  methodDetails?: {
66
- machineTokenEnabled?: boolean | undefined;
67
65
  chainId?: number | undefined;
68
66
  feePayer?: boolean | undefined;
69
67
  memo?: string | undefined;
@@ -75,7 +73,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
75
73
  supportedModes?: ("pull" | "push")[] | undefined;
76
74
  } | undefined;
77
75
  }, {
78
- machineTokenEnabled?: boolean | undefined;
79
76
  amount: string;
80
77
  chainId?: number | undefined;
81
78
  currency: string;
@@ -107,7 +104,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
107
104
  credential: {
108
105
  payload: import("zod/mini").ZodMiniDiscriminatedUnion<[import("zod/mini").ZodMiniObject<{
109
106
  action: import("zod/mini").ZodMiniLiteral<"open">;
110
- authorizationSignature: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
111
107
  authorizedSigner: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
112
108
  channelId: import("zod/mini").ZodMiniString<string>;
113
109
  cumulativeAmount: import("zod/mini").ZodMiniString<string>;
@@ -124,18 +120,15 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
124
120
  type: import("zod/mini").ZodMiniLiteral<"transaction">;
125
121
  }, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
126
122
  action: import("zod/mini").ZodMiniLiteral<"voucher">;
127
- authorizationSignature: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
128
123
  channelId: import("zod/mini").ZodMiniString<string>;
129
124
  cumulativeAmount: import("zod/mini").ZodMiniString<string>;
130
125
  descriptor: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniCustom<import("../session/precompile/Protocol.js").ChannelDescriptor, import("../session/precompile/Protocol.js").ChannelDescriptor>>;
131
126
  signature: import("zod/mini").ZodMiniString<string>;
132
127
  }, import("zod/v4/core").$strip>, import("zod/mini").ZodMiniObject<{
133
128
  action: import("zod/mini").ZodMiniLiteral<"close">;
134
- authorizationSignature: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
135
129
  channelId: import("zod/mini").ZodMiniString<string>;
136
130
  cumulativeAmount: import("zod/mini").ZodMiniString<string>;
137
131
  descriptor: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniCustom<import("../session/precompile/Protocol.js").ChannelDescriptor, import("../session/precompile/Protocol.js").ChannelDescriptor>>;
138
- refundSignature: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
139
132
  signature: import("zod/mini").ZodMiniString<string>;
140
133
  }, import("zod/v4/core").$strip>], "action">;
141
134
  };
@@ -148,7 +141,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
148
141
  escrowContract: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
149
142
  feePayer: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniBoolean<boolean>, import("zod/mini").ZodMiniCustom<import("viem").Account, import("viem").Account>]>, import("zod/mini").ZodMiniTransform<boolean, boolean | import("viem").Account>>>;
150
143
  feeToken: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
151
- machineTokenEnabled: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniBoolean<boolean>>;
152
144
  minVoucherDelta: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
153
145
  operator: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
154
146
  recipient: import("zod/mini").ZodMiniOptional<import("zod/mini").ZodMiniString<string>>;
@@ -172,7 +164,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
172
164
  chainId?: number | undefined;
173
165
  feePayer?: boolean | undefined;
174
166
  feeToken?: string | undefined;
175
- machineTokenEnabled?: boolean | undefined;
176
167
  operator?: string | undefined;
177
168
  sessionProtocol?: "v1" | "v2" | undefined;
178
169
  sessionSnapshot?: import("../session/Snapshot.js").SessionSnapshot | undefined;
@@ -186,7 +177,6 @@ export declare function tempo(parameters?: tempo.Parameters): readonly [import("
186
177
  escrowContract?: string | undefined;
187
178
  feePayer?: boolean | undefined;
188
179
  feeToken?: string | undefined;
189
- machineTokenEnabled?: boolean | undefined;
190
180
  minVoucherDelta?: string | undefined;
191
181
  operator?: string | undefined;
192
182
  recipient?: string | undefined;
@@ -1,5 +1,8 @@
1
1
  import type { Account, Address } from 'viem';
2
2
  import type { Account as TempoAccount } from 'viem/tempo';
3
+ import * as RemoteFeePayer from './remote-fee-payer.js';
4
+ /** Returns whether a value is a viem account. */
5
+ export declare function is(value: unknown): value is Account;
3
6
  /** Returns whether an account is a Tempo access-key account. */
4
7
  export declare function isAccessKeyAccount(account: Account): account is Account & TempoAccount.AccessKeyAccount;
5
8
  /** Returns the address that should authorize direct account signatures. */
@@ -10,15 +13,18 @@ export declare function getAccountSignerAddress(account: Account): Address;
10
13
  * Accepts either `account` or `recipient` as the parameter name. When the value
11
14
  * is an `Account`, its address is extracted. If `feePayer` is `true`, the
12
15
  * account also acts as the fee payer. Alternatively, a separate `Account`
13
- * can be provided as the fee payer, or a URL string pointing to a fee payer
14
- * relay service (used with `withFeePayer` transport wrapping).
16
+ * can be provided as the fee payer, or remote fee-payer configuration (used
17
+ * with `withFeePayer` transport wrapping).
15
18
  *
16
- * @returns An object with `account`, `feePayer`, `feePayerUrl`, and `recipient`.
19
+ * @returns Resolved account, local fee payer, remote fee payer, and recipient.
17
20
  */
18
21
  export declare function resolve(parameters: resolve.Parameters): {
19
22
  account: Account | undefined;
20
23
  feePayer: Account | undefined;
21
- feePayerUrl: string | undefined;
24
+ remoteFeePayer: Readonly<{
25
+ headers?: Readonly<Record<string, string>> | undefined;
26
+ url: string;
27
+ }> | undefined;
22
28
  recipient: Address | undefined;
23
29
  };
24
30
  export declare namespace resolve {
@@ -26,8 +32,11 @@ export declare namespace resolve {
26
32
  recipient?: Address | undefined;
27
33
  /** Account or address that performs payment operations / receives payment. */
28
34
  account?: Account | Address | undefined;
29
- /** When `true`, the account also sponsors fees. An `Account` object or URL string can also be provided as a dedicated fee payer. */
30
- feePayer?: Account | string | true | undefined;
35
+ /**
36
+ * When `true`, the account also sponsors fees. An `Account` or remote fee-payer
37
+ * configuration can also be provided. A string is shorthand for its URL.
38
+ */
39
+ feePayer?: Account | RemoteFeePayer.Config | string | true | undefined;
31
40
  };
32
41
  }
33
42
  //# sourceMappingURL=account.d.ts.map
@@ -1,3 +1,8 @@
1
+ import * as RemoteFeePayer from './remote-fee-payer.js';
2
+ /** Returns whether a value is a viem account. */
3
+ export function is(value) {
4
+ return typeof value === 'object' && value !== null && 'address' in value;
5
+ }
1
6
  /** Returns whether an account is a Tempo access-key account. */
2
7
  export function isAccessKeyAccount(account) {
3
8
  return 'accessKeyAddress' in account;
@@ -12,34 +17,20 @@ export function getAccountSignerAddress(account) {
12
17
  * Accepts either `account` or `recipient` as the parameter name. When the value
13
18
  * is an `Account`, its address is extracted. If `feePayer` is `true`, the
14
19
  * account also acts as the fee payer. Alternatively, a separate `Account`
15
- * can be provided as the fee payer, or a URL string pointing to a fee payer
16
- * relay service (used with `withFeePayer` transport wrapping).
20
+ * can be provided as the fee payer, or remote fee-payer configuration (used
21
+ * with `withFeePayer` transport wrapping).
17
22
  *
18
- * @returns An object with `account`, `feePayer`, `feePayerUrl`, and `recipient`.
23
+ * @returns Resolved account, local fee payer, remote fee payer, and recipient.
19
24
  */
20
25
  export function resolve(parameters) {
21
- const account = (() => {
22
- if (typeof parameters.account === 'object')
23
- return parameters.account;
24
- return undefined;
25
- })();
26
- const recipient = (() => {
27
- if (parameters.recipient)
28
- return parameters.recipient;
29
- if (typeof parameters.account === 'object')
30
- return parameters.account.address;
31
- return parameters.account;
32
- })();
33
- const feePayerUrl = typeof parameters.feePayer === 'string' ? parameters.feePayer : undefined;
34
- const feePayer = (() => {
35
- if (typeof parameters.feePayer === 'string')
36
- return undefined;
37
- if (typeof parameters.account === 'object' && parameters.feePayer === true)
38
- return parameters.account;
39
- if (typeof parameters.feePayer === 'object')
40
- return parameters.feePayer;
41
- return undefined;
42
- })();
43
- return { account, feePayer, feePayerUrl, recipient: recipient };
26
+ const account = is(parameters.account) ? parameters.account : undefined;
27
+ const recipient = parameters.recipient ?? account?.address ?? parameters.account;
28
+ const remoteFeePayer = RemoteFeePayer.from(parameters.feePayer);
29
+ const feePayer = parameters.feePayer === true
30
+ ? account
31
+ : is(parameters.feePayer)
32
+ ? parameters.feePayer
33
+ : undefined;
34
+ return { account, feePayer, remoteFeePayer, recipient: recipient };
44
35
  }
45
36
  //# sourceMappingURL=account.js.map
@@ -16,17 +16,6 @@ export declare const currency: {
16
16
  readonly 4217: "0x20C000000000000000000000b9537d11c60E8b50";
17
17
  readonly 42431: "0x20c0000000000000000000000000000000000000";
18
18
  };
19
- /** Unified first-party machine-token deployments used by charges and sessions. */
20
- export declare const machineToken: {
21
- readonly 4217: {
22
- readonly swap: '0xd588ED9Ae08643A450157Adaf61c3C0C1BBd0dbb';
23
- readonly token: '0x20c0000000000000000000006637932dE5413804';
24
- };
25
- readonly 42431: {
26
- readonly swap: '0xd588ED9Ae08643A450157Adaf61c3C0C1BBd0dbb';
27
- readonly token: '0x20c0000000000000000000006637932dE5413804';
28
- };
29
- };
30
19
  /**
31
20
  * Default token decimals for TIP-20 stablecoins (e.g. pathUSD, USDC).
32
21
  *
@@ -14,17 +14,6 @@ export const currency = {
14
14
  [chainId.mainnet]: tokens.usdc,
15
15
  [chainId.testnet]: tokens.pathUsd,
16
16
  };
17
- /** Unified first-party machine-token deployments used by charges and sessions. */
18
- export const machineToken = {
19
- [chainId.mainnet]: {
20
- swap: '0xd588ED9Ae08643A450157Adaf61c3C0C1BBd0dbb',
21
- token: '0x20c0000000000000000000006637932dE5413804',
22
- },
23
- [chainId.testnet]: {
24
- swap: '0xd588ED9Ae08643A450157Adaf61c3C0C1BBd0dbb',
25
- token: '0x20c0000000000000000000006637932dE5413804',
26
- },
27
- };
28
17
  /**
29
18
  * Default token decimals for TIP-20 stablecoins (e.g. pathUSD, USDC).
30
19
  *
@@ -29,9 +29,24 @@ export declare function defaultAllowedFeeTokens(chainId: number | undefined): Te
29
29
  export declare function assertAllowedFeeToken(transaction: {
30
30
  feeToken?: unknown;
31
31
  }, allowedFeeTokens: readonly TempoAddress.Address[]): void;
32
+ declare function hostedFeePayerRequest(transaction: SponsoredTransaction): {
33
+ accessList?: any;
34
+ calls: any;
35
+ feePayer: boolean;
36
+ from: any;
37
+ gas?: `0x${string}` | undefined;
38
+ keyAuthorization?: any;
39
+ maxFeePerGas?: `0x${string}` | undefined;
40
+ maxPriorityFeePerGas?: `0x${string}` | undefined;
41
+ nonce: `0x${string}`;
42
+ nonceKey?: `0x${string}` | undefined;
43
+ type: string;
44
+ validAfter?: `0x${string}` | undefined;
45
+ validBefore?: `0x${string}` | undefined;
46
+ };
32
47
  /**
33
- * Co-signs a sender-signed partial sponsorship envelope using a hosted
34
- * fee-payer endpoint without letting the endpoint mutate sender-committed
48
+ * Co-signs a sender-signed partial sponsorship envelope through a hosted
49
+ * fee-payer transport without letting the endpoint mutate sender-committed
35
50
  * transaction fields.
36
51
  *
37
52
  * @returns The serialized co-signed transaction plus the sponsor's recovered
@@ -44,8 +59,11 @@ export declare function fillHostedFeePayerTransaction(parameters: {
44
59
  chainId: number;
45
60
  details: Record<string, string>;
46
61
  policy?: Partial<Policy> | undefined;
62
+ request: (args: {
63
+ method: 'eth_fillTransaction';
64
+ params: readonly [ReturnType<typeof hostedFeePayerRequest>];
65
+ }) => Promise<unknown>;
47
66
  transaction: SponsoredTransaction;
48
- url: string;
49
67
  }): Promise<{
50
68
  feePayer: `0x${string}`;
51
69
  feeToken: TempoAddress.Address;
@@ -116,8 +116,8 @@ function hostedFeePayerRequest(transaction) {
116
116
  };
117
117
  }
118
118
  /**
119
- * Co-signs a sender-signed partial sponsorship envelope using a hosted
120
- * fee-payer endpoint without letting the endpoint mutate sender-committed
119
+ * Co-signs a sender-signed partial sponsorship envelope through a hosted
120
+ * fee-payer transport without letting the endpoint mutate sender-committed
121
121
  * transaction fields.
122
122
  *
123
123
  * @returns The serialized co-signed transaction plus the sponsor's recovered
@@ -125,7 +125,7 @@ function hostedFeePayerRequest(transaction) {
125
125
  * simulate the exact transaction the sponsor broadcasts.
126
126
  */
127
127
  export async function fillHostedFeePayerTransaction(parameters) {
128
- const { allowedFeeTokens, challengeExpires, chainId, details, policy, transaction, url } = parameters;
128
+ const { allowedFeeTokens, challengeExpires, chainId, details, policy, request, transaction } = parameters;
129
129
  assertTransactionPolicy({
130
130
  challengeExpires,
131
131
  chainId,
@@ -133,22 +133,13 @@ export async function fillHostedFeePayerTransaction(parameters) {
133
133
  policy,
134
134
  transaction,
135
135
  });
136
- const response = await fetch(url, {
137
- body: JSON.stringify({
138
- id: 1,
139
- jsonrpc: '2.0',
140
- method: 'eth_fillTransaction',
141
- params: [hostedFeePayerRequest(transaction)],
142
- }, (_key, value) => (typeof value === 'bigint' ? toHex(value) : value)),
143
- headers: { 'content-type': 'application/json' },
144
- method: 'POST',
145
- });
146
- const payload = (await response.json().catch(async () => ({
147
- error: { message: await response.text() },
148
- })));
149
- const filled = payload.result?.tx;
150
- if (!response.ok || payload.error || !filled?.feePayerSignature)
151
- throw new FeePayerValidationError(payload.error?.message ?? 'hosted fee payer failed to sponsor transaction', {});
136
+ const result = (await request({
137
+ method: 'eth_fillTransaction',
138
+ params: [hostedFeePayerRequest(transaction)],
139
+ }));
140
+ const filled = result?.tx;
141
+ if (!filled?.feePayerSignature)
142
+ throw new FeePayerValidationError('hosted fee payer failed to sponsor transaction', {});
152
143
  if (typeof filled.feeToken !== 'string')
153
144
  throw new FeePayerValidationError('hosted fee payer did not return a feeToken', {});
154
145
  assertAllowedFeeToken({ feeToken: filled.feeToken }, allowedFeeTokens);
@@ -0,0 +1,12 @@
1
+ /** Configuration for a remote Tempo fee-payer service. */
2
+ export type Config = Readonly<{
3
+ headers?: Readonly<Record<string, string>> | undefined;
4
+ url: string;
5
+ }>;
6
+ /** Returns whether a value is remote fee-payer configuration. */
7
+ export declare function is(value: unknown): value is Config;
8
+ /** Normalizes remote fee-payer string and object inputs. */
9
+ export declare function from(value: unknown): Config | undefined;
10
+ /** Returns a cloned header record while reserving JSON content type for MPPX. */
11
+ export declare function resolveHeaders(config: Config): Record<string, string>;
12
+ //# sourceMappingURL=remote-fee-payer.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** Returns whether a value is remote fee-payer configuration. */
2
+ export function is(value) {
3
+ return (typeof value === 'object' && value !== null && 'url' in value && typeof value.url === 'string');
4
+ }
5
+ /** Normalizes remote fee-payer string and object inputs. */
6
+ export function from(value) {
7
+ if (typeof value === 'string')
8
+ return { url: value };
9
+ if (is(value))
10
+ return value;
11
+ return undefined;
12
+ }
13
+ /** Returns a cloned header record while reserving JSON content type for MPPX. */
14
+ export function resolveHeaders(config) {
15
+ return Object.fromEntries(Object.entries(config.headers ?? {}).filter(([name]) => name.toLowerCase() !== 'content-type'));
16
+ }
17
+ //# sourceMappingURL=remote-fee-payer.js.map
@@ -65,7 +65,6 @@ export declare function session(parameters?: session.Parameters): Method.Client<
65
65
  credential: {
66
66
  payload: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
67
67
  action: z.ZodMiniLiteral<"open">;
68
- authorizationSignature: z.ZodMiniOptional<z.ZodMiniString<string>>;
69
68
  authorizedSigner: z.ZodMiniOptional<z.ZodMiniString<string>>;
70
69
  channelId: z.ZodMiniString<string>;
71
70
  cumulativeAmount: z.ZodMiniString<string>;
@@ -82,18 +81,15 @@ export declare function session(parameters?: session.Parameters): Method.Client<
82
81
  type: z.ZodMiniLiteral<"transaction">;
83
82
  }, z.core.$strip>, z.ZodMiniObject<{
84
83
  action: z.ZodMiniLiteral<"voucher">;
85
- authorizationSignature: z.ZodMiniOptional<z.ZodMiniString<string>>;
86
84
  channelId: z.ZodMiniString<string>;
87
85
  cumulativeAmount: z.ZodMiniString<string>;
88
86
  descriptor: z.ZodMiniOptional<z.ZodMiniCustom<import("../../session/precompile/Protocol.js").ChannelDescriptor, import("../../session/precompile/Protocol.js").ChannelDescriptor>>;
89
87
  signature: z.ZodMiniString<string>;
90
88
  }, z.core.$strip>, z.ZodMiniObject<{
91
89
  action: z.ZodMiniLiteral<"close">;
92
- authorizationSignature: z.ZodMiniOptional<z.ZodMiniString<string>>;
93
90
  channelId: z.ZodMiniString<string>;
94
91
  cumulativeAmount: z.ZodMiniString<string>;
95
92
  descriptor: z.ZodMiniOptional<z.ZodMiniCustom<import("../../session/precompile/Protocol.js").ChannelDescriptor, import("../../session/precompile/Protocol.js").ChannelDescriptor>>;
96
- refundSignature: z.ZodMiniOptional<z.ZodMiniString<string>>;
97
93
  signature: z.ZodMiniString<string>;
98
94
  }, z.core.$strip>], "action">;
99
95
  };
@@ -106,7 +102,6 @@ export declare function session(parameters?: session.Parameters): Method.Client<
106
102
  escrowContract: z.ZodMiniOptional<z.ZodMiniString<string>>;
107
103
  feePayer: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniCustom<viem_Account, viem_Account>]>, z.ZodMiniTransform<boolean, boolean | viem_Account>>>;
108
104
  feeToken: z.ZodMiniOptional<z.ZodMiniString<string>>;
109
- machineTokenEnabled: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
110
105
  minVoucherDelta: z.ZodMiniOptional<z.ZodMiniString<string>>;
111
106
  operator: z.ZodMiniOptional<z.ZodMiniString<string>>;
112
107
  recipient: z.ZodMiniOptional<z.ZodMiniString<string>>;
@@ -130,7 +125,6 @@ export declare function session(parameters?: session.Parameters): Method.Client<
130
125
  chainId?: number | undefined;
131
126
  feePayer?: boolean | undefined;
132
127
  feeToken?: string | undefined;
133
- machineTokenEnabled?: boolean | undefined;
134
128
  operator?: string | undefined;
135
129
  sessionProtocol?: "v1" | "v2" | undefined;
136
130
  sessionSnapshot?: import("../../session/Snapshot.js").SessionSnapshot | undefined;
@@ -144,7 +138,6 @@ export declare function session(parameters?: session.Parameters): Method.Client<
144
138
  escrowContract?: string | undefined;
145
139
  feePayer?: boolean | undefined;
146
140
  feeToken?: string | undefined;
147
- machineTokenEnabled?: boolean | undefined;
148
141
  minVoucherDelta?: string | undefined;
149
142
  operator?: string | undefined;
150
143
  recipient?: string | undefined;
@@ -45,8 +45,6 @@ export declare namespace charge {
45
45
  } | undefined;
46
46
  };
47
47
  type Parameters = {
48
- /** Enables first-party machine-token settlement for supported Tempo charges. */
49
- machineTokenEnabled?: boolean | undefined;
50
48
  /** Render payment page when Accept header is text/html (e.g. in browsers) */
51
49
  html?: boolean | Html.Config | undefined;
52
50
  /**
@@ -101,7 +99,6 @@ export declare namespace charge {
101
99
  * relay broadcasts pull credentials, while it recognizes a push
102
100
  * credential as already broadcast and returns its receipt without sending
103
101
  * it again.
104
- *
105
102
  */
106
103
  relay?: RelayOptions | undefined;
107
104
  /**