nodpay 0.2.34 → 0.2.35

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NodPay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/SKILL.md CHANGED
@@ -156,7 +156,7 @@ EOA wallets: replace passkey fields with `"humanSignerEoa": "0x..."`.
156
156
 
157
157
  | Flag | Required | Description |
158
158
  |------|----------|-------------|
159
- | `--chain` | ✅ | `ethereum`, `base`, `arbitrum`, `optimism`, `polygon`, `sepolia`, `base_sepolia` |
159
+ | `--chain` | ✅ | `base`, `arbitrum`, `polygon`, `optimism`, `ethereum`, `sepolia`, `base_sepolia` |
160
160
  | `--safe` | ✅ | Wallet address |
161
161
  | `--to` | ✅ | Recipient |
162
162
  | `--value-eth` | ✅ | Amount in ETH |
@@ -165,7 +165,7 @@ EOA wallets: replace passkey fields with `"humanSignerEoa": "0x..."`.
165
165
  | `--recovery-signer` | first tx | Recovery signer address |
166
166
  | `--nonce` | **required** | Nonce for this proposal. Run `txs` first to determine. |
167
167
 
168
- Wallet address is the same across all chains. **Ask which chain if not specified.**
168
+ Wallet address is the same across all chains. **Ask which chain if not specified.** Prefer L2 chains (Base, Arbitrum, etc.) — Ethereum mainnet gas is significantly more expensive.
169
169
 
170
170
  ---
171
171
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodpay",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "NodPay CLI — propose on-chain payments from agent-human shared wallets",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "postpublish": "curl -s https://purge.jsdelivr.net/npm/nodpay@latest/SKILL.md > /dev/null && echo 'jsdelivr cache purged'"
32
32
  },
33
33
  "dependencies": {
34
- "@nodpay/core": "^0.1.2",
34
+ "@nodpay/core": "^0.1.3",
35
35
  "@safe-global/relay-kit": "^4.1.1",
36
36
  "ethers": "^6.16.0"
37
37
  }
@@ -6,7 +6,7 @@
6
6
  * The agent signs first (1 of 2). The serialized SafeOperation is
7
7
  * output so the web app can have the user co-sign and submit.
8
8
  *
9
- * Agent key: read from .nodpay/.env (never from env vars or CLI args).
9
+ * Agent key: read from .nodpay/.env or via --remote-signer (SafeClaw proxy).
10
10
  * Chain config: resolved via --chain from @nodpay/core networks registry.
11
11
  * Bundler: NodPay public proxy (override with OP_STORE_URL for self-hosted).
12
12
  *
@@ -17,6 +17,7 @@
17
17
  * --safe <address> - Wallet (Safe) address
18
18
  * --counterfactual - Safe not yet deployed; include deployment in UserOp
19
19
  * --human-signer-eoa <address> - Human's EOA signer address (for EOA mode)
20
+ * --remote-signer <url> - SafeClaw proxy URL for remote signing (mutually exclusive with --human-signer-eoa)
20
21
  * --salt <nonce> - Salt nonce (required for counterfactual)
21
22
  * --reuse-gas-from <shortHash> - Reuse gas values from a previous op (shortHash prefix of safeOpHash)
22
23
  * --nonce <n> - Required. Use `txs` to find current nonce.
@@ -83,7 +84,7 @@ function loadAgentKey() {
83
84
  } catch {}
84
85
  return null;
85
86
  }
86
- const NODPAY_AGENT_KEY = loadAgentKey();
87
+
87
88
  const DEFAULT_SAFE = null; // always use --safe flag
88
89
 
89
90
  // BUNDLER: NodPay provides a public bundler proxy at nodpay.ai/api/bundler so
@@ -107,13 +108,56 @@ function loadDotEnvVar(name, fallback) {
107
108
  const opStoreBase = loadDotEnvVar('OP_STORE_URL', 'https://nodpay.ai/api');
108
109
  const BUNDLER_URL = `${opStoreBase}/bundler/${CHAIN_ID}`;
109
110
 
110
- if (!NODPAY_AGENT_KEY) {
111
- console.error(JSON.stringify({ error: 'Missing NODPAY_AGENT_KEY in ~/.nodpay/.env — run npx nodpay keygen first' }));
112
- process.exit(1);
113
- }
111
+ // --- Agent key: remote signer (SafeClaw proxy) or local key (~/.nodpay/.env) ---
112
+ const _remoteSignerUrl = process.argv.includes('--remote-signer')
113
+ ? process.argv[process.argv.indexOf('--remote-signer') + 1]
114
+ : undefined;
114
115
 
115
- const agentWallet = new ethers.Wallet(NODPAY_AGENT_KEY);
116
- const AGENT_ADDRESS = agentWallet.address;
116
+ let AGENT_ADDRESS;
117
+ let signHash;
118
+ let _localAgentKey; // only set in local mode, used for SDK init (EOA signer)
119
+
120
+ if (_remoteSignerUrl) {
121
+ // Remote signer mode: get address + signing from SafeClaw proxy
122
+ const addrRes = await fetch(`${_remoteSignerUrl}/address`);
123
+ if (!addrRes.ok) {
124
+ const err = await addrRes.json().catch(() => ({}));
125
+ console.error(JSON.stringify({
126
+ error: err.error || 'Failed to get agent address from remote signer',
127
+ code: err.code || 'REMOTE_SIGNER_ERROR'
128
+ }));
129
+ process.exit(1);
130
+ }
131
+ AGENT_ADDRESS = (await addrRes.json()).address;
132
+
133
+ signHash = async (hash) => {
134
+ const signRes = await fetch(`${_remoteSignerUrl}/sign/${AGENT_ADDRESS}`, {
135
+ method: 'POST',
136
+ headers: { 'Content-Type': 'application/json' },
137
+ body: JSON.stringify({ hash })
138
+ });
139
+ if (!signRes.ok) {
140
+ const err = await signRes.json().catch(() => ({}));
141
+ throw new Error(err.error || 'Remote signing failed');
142
+ }
143
+ return (await signRes.json()).signature;
144
+ };
145
+ } else {
146
+ // Local mode: read key from ~/.nodpay/.env (original behavior)
147
+ const NODPAY_AGENT_KEY = loadAgentKey();
148
+ if (!NODPAY_AGENT_KEY) {
149
+ console.error(JSON.stringify({ error: 'Missing NODPAY_AGENT_KEY in ~/.nodpay/.env — run npx nodpay keygen or use --remote-signer' }));
150
+ process.exit(1);
151
+ }
152
+ _localAgentKey = NODPAY_AGENT_KEY;
153
+ const agentWallet = new ethers.Wallet(NODPAY_AGENT_KEY);
154
+ AGENT_ADDRESS = agentWallet.address;
155
+
156
+ signHash = async (hash) => {
157
+ const sig = agentWallet.signingKey.sign(hash);
158
+ return ethers.Signature.from(sig).serialized;
159
+ };
160
+ }
117
161
 
118
162
  const args = process.argv.slice(2);
119
163
  function getArg(name) {
@@ -139,6 +183,12 @@ const passkeyVerifier = getArg('--passkey-verifier') || '0x445a0683e494ea0c5AF3E
139
183
  const recoverySigner = getArg('--recovery-signer');
140
184
  const isPasskey = !!(passkeyX && passkeyY);
141
185
 
186
+ // Phase 1: --remote-signer + --human-signer-eoa is not supported
187
+ if (_remoteSignerUrl && humanSigner) {
188
+ console.error(JSON.stringify({ error: '--remote-signer and --human-signer-eoa cannot be combined. Remote signer mode only supports passkey wallets.' }));
189
+ process.exit(1);
190
+ }
191
+
142
192
  if (!to) {
143
193
  console.error(JSON.stringify({ error: 'Missing --to <address>' }));
144
194
  process.exit(1);
@@ -290,8 +340,8 @@ try {
290
340
  initOptions.options = { safeAddress: SAFE_ADDRESS };
291
341
  }
292
342
  } else {
293
- // EOA signer: agent key as primary signer
294
- initOptions.signer = NODPAY_AGENT_KEY;
343
+ // EOA signer: agent key as primary signer (requires local key)
344
+ initOptions.signer = _localAgentKey;
295
345
  if (isCounterfactual) {
296
346
  // Canonical owner order: [humanSigner, agentSigner, recoverySigner] — must match frontend
297
347
  const eoaOwners = recoverySigner
@@ -448,11 +498,8 @@ try {
448
498
  verifyingContract: safeOperation.options.moduleAddress,
449
499
  };
450
500
 
451
- // Always sign manually with the agent's private key over the canonical hash
452
- // (Using SDK's signSafeOperation would apply viem hex transforms that produce
453
- // a different hash than getHash(), making server-side verification impossible)
454
- const sig = agentWallet.signingKey.sign(safeOpHash);
455
- const agentSig = ethers.Signature.from(sig).serialized;
501
+ // Sign with agent key: local wallet or remote signer (SafeClaw proxy)
502
+ const agentSig = await signHash(safeOpHash);
456
503
  safeOperation.addSignature({
457
504
  signer: AGENT_ADDRESS,
458
505
  data: agentSig,
@@ -515,6 +562,10 @@ try {
515
562
  agent: AGENT_ADDRESS,
516
563
  agentSignature: safeOperationJson.signatures,
517
564
  createdAt: new Date().toISOString(),
565
+ // SafeClaw integration: passkey coordinates + recovery for approve page fallback
566
+ passkeyX: passkeyX || null,
567
+ passkeyY: passkeyY || null,
568
+ recoveryAddress: recoverySigner || null,
518
569
  };
519
570
 
520
571
  // Extract raw agent signature for server auth
@@ -538,7 +589,12 @@ try {
538
589
  }
539
590
  if (storeData.shortHash) {
540
591
  const webBase = loadDotEnvVar('WEB_APP_URL', 'https://nodpay.ai/');
541
- approveUrl = `${webBase}approve?safeOpHash=${storeData.safeOpHash}`;
592
+ // Build approve URL with passkey params for SafeClaw users (no localStorage)
593
+ const approveParams = new URLSearchParams({ safeOpHash: storeData.safeOpHash });
594
+ if (passkeyX) approveParams.set('px', passkeyX);
595
+ if (passkeyY) approveParams.set('py', passkeyY);
596
+ if (recoverySigner) approveParams.set('recovery', recoverySigner);
597
+ approveUrl = `${webBase}approve?${approveParams.toString()}`;
542
598
  result.approveUrl = approveUrl;
543
599
  result.opStoreSafeOpHash = storeData.safeOpHash;
544
600
  result.opStoreShortHash = storeData.shortHash;