request-wallet-sign 0.1.2 → 0.2.1

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 (2) hide show
  1. package/bin/index.js +37 -6
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -474,6 +474,9 @@ export function buildHtml(req, port, networkUrl, opts = {}) {
474
474
  .network-info.tunnel { background: #0d1e16; border-color: #1e5f3a; }
475
475
  .network-info.tunnel a { color: #4ade80; }
476
476
  .cross-device { margin-top: 1.25rem; }
477
+ .cd-link { display: inline-block; margin-top: 0.75rem; color: #64748b; font-size: 0.8rem;
478
+ text-decoration: underline; cursor: pointer; }
479
+ .cd-link:hover { color: #94a3b8; }
477
480
  .net-caveat { margin-top: 0.5rem; padding: 0.5rem 0.75rem; border-radius: 8px;
478
481
  background: #2a1e08; border: 1px solid #5f4a1e; color: #fbbf24;
479
482
  font-size: 0.75rem; line-height: 1.4; }
@@ -534,10 +537,13 @@ export function buildHtml(req, port, networkUrl, opts = {}) {
534
537
  </div>
535
538
  <button class="icon-btn" id="cd-check-btn" style="display:none">Check reachability</button>
536
539
  <div id="cd-status" class="net-caveat" style="display:none"></div>
537
- ${networkUrl ? `<div class="network-info">
538
- <span>📱 Same network:</span>
539
- <a href="${escHtml(networkUrl)}" target="_blank">${escHtml(networkUrl)}</a>
540
- <button class="icon-btn" id="copy-url-btn">⧉ Copy</button>
540
+ ${networkUrl ? `<a href="#" id="cd-lan-toggle" class="cd-link">Or use a local-network address instead</a>
541
+ <div id="cd-lan" style="display:none">
542
+ <div class="network-info">
543
+ <span>📱 Same network:</span>
544
+ <a href="${escHtml(networkUrl)}" target="_blank">${escHtml(networkUrl)}</a>
545
+ <button class="icon-btn" id="copy-url-btn">⧉ Copy</button>
546
+ </div>
541
547
  </div>` : ''}
542
548
  </div>
543
549
  </div>
@@ -600,6 +606,7 @@ function txDataText() {
600
606
  out.valueEth = formatEther(REQUEST.value) + ' ' + (meta.symbol || 'ETH');
601
607
  if (REQUEST.data) out.data = REQUEST.data;
602
608
  if (REQUEST.gas) out.gas = REQUEST.gas;
609
+ if (REQUEST.authorizationList) out.authorizationList = REQUEST.authorizationList;
603
610
  } else if (REQUEST._type === 'signTypedData') {
604
611
  out.typedData = REQUEST.typedData;
605
612
  } else {
@@ -681,14 +688,19 @@ async function switchChain(account) {
681
688
  }
682
689
 
683
690
  async function buildTx(account) {
691
+ // An EIP-7702 authorizationList (e.g. relaying someone else's signed
692
+ // authorization) makes this a type-4 transaction; otherwise plain EIP-1559.
693
+ const authList = Array.isArray(REQUEST.authorizationList) && REQUEST.authorizationList.length
694
+ ? REQUEST.authorizationList : null;
684
695
  const tx = {
685
- type: '0x2',
696
+ type: authList ? '0x4' : '0x2',
686
697
  from: account,
687
698
  chainId: hex(REQUEST.chainId),
688
699
  value: REQUEST.value || '0x0',
689
700
  };
690
701
  if (REQUEST.to) tx.to = REQUEST.to;
691
702
  if (REQUEST.data) tx.data = REQUEST.data;
703
+ if (authList) tx.authorizationList = authList;
692
704
 
693
705
  // Gas limit
694
706
  if (REQUEST.gas) {
@@ -913,6 +925,19 @@ async function renderWhatThisDoes() {
913
925
 
914
926
  const { to, data, value } = REQUEST;
915
927
 
928
+ // EIP-7702: this tx also installs account delegation(s) — the highest-impact
929
+ // part, so surface each delegate target up front (Details shows the full tx).
930
+ if (Array.isArray(REQUEST.authorizationList) && REQUEST.authorizationList.length) {
931
+ const fields = REQUEST.authorizationList.map((a, i) => ({
932
+ label: 'Delegate #' + (i + 1),
933
+ value: (a && a.address) ? a.address : '(unknown target)',
934
+ danger: true,
935
+ }));
936
+ if (to) fields.push({ label: 'Then calls', value: to });
937
+ showWhat('Authorize account delegation (EIP-7702)', fields);
938
+ return;
939
+ }
940
+
916
941
  // Contract deployment
917
942
  if (!to && data && data.length > 2) {
918
943
  const bytes = Math.floor((data.length - 2) / 2);
@@ -973,7 +998,7 @@ async function startTunnel() {
973
998
  const btn = document.getElementById('cross-device-btn');
974
999
  document.getElementById('cd-panel').style.display = 'block';
975
1000
  btn.disabled = true;
976
- btn.innerHTML = '<span class="spinner"></span>Starting secure tunnel…';
1001
+ btn.innerHTML = '<span class="spinner"></span>Opening tunnel…';
977
1002
  try {
978
1003
  const res = await fetch('/tunnel/start', { method: 'POST' }).then(r => r.json());
979
1004
  if (res.url) {
@@ -1006,6 +1031,12 @@ const cdBtn = document.getElementById('cross-device-btn');
1006
1031
  if (cdBtn) cdBtn.addEventListener('click', startTunnel);
1007
1032
  const cdCheck = document.getElementById('cd-check-btn');
1008
1033
  if (cdCheck) cdCheck.addEventListener('click', checkTunnel);
1034
+ const cdLanToggle = document.getElementById('cd-lan-toggle');
1035
+ if (cdLanToggle) cdLanToggle.addEventListener('click', e => {
1036
+ e.preventDefault();
1037
+ document.getElementById('cd-lan').style.display = 'block';
1038
+ cdLanToggle.style.display = 'none';
1039
+ });
1009
1040
  const copyTunnelBtn = document.getElementById('copy-tunnel-btn');
1010
1041
  if (copyTunnelBtn) copyTunnelBtn.addEventListener('click', e =>
1011
1042
  copyText(document.getElementById('cd-tunnel-link').href, e.currentTarget));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "request-wallet-sign",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Let AI agents surface wallet signing requests to users via a local browser page",
5
5
  "type": "module",
6
6
  "engines": {