@rhinestone/deposit-modal 0.0.0-dev-20260729182851 → 0.0.0-dev-20260730153145

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 (42) hide show
  1. package/README.md +57 -32
  2. package/dist/{DepositModalReown-KO52JUL4.cjs → DepositModalReown-U5EHFQRK.cjs} +9 -9
  3. package/dist/{DepositModalReown-P4JDIMTF.mjs → DepositModalReown-YDELSYCS.mjs} +5 -5
  4. package/dist/{chunk-7MVW7CEJ.cjs → chunk-2MNDZ4E6.cjs} +185 -123
  5. package/dist/{chunk-P4TMKJJU.mjs → chunk-4GMACNN7.mjs} +1 -1
  6. package/dist/{chunk-IADW7PHH.mjs → chunk-BDRGXYDX.mjs} +136 -74
  7. package/dist/{chunk-4NJ6Q3J6.mjs → chunk-BHLLQUWO.mjs} +2 -6
  8. package/dist/{chunk-7MODHUEP.cjs → chunk-J4ZCXBCL.cjs} +57 -57
  9. package/dist/{chunk-Q7WRDBSJ.mjs → chunk-JPSMRSOQ.mjs} +4 -4
  10. package/dist/chunk-LFQMZS5O.cjs +11 -0
  11. package/dist/{chunk-W4U5KHEO.mjs → chunk-LG5JKKA2.mjs} +1 -1
  12. package/dist/{chunk-NAHHUQIS.cjs → chunk-LX2IDGJU.cjs} +21 -25
  13. package/dist/{chunk-BAPBC6TI.cjs → chunk-OKMLSIBM.cjs} +3 -3
  14. package/dist/{chunk-QHPPDDYT.cjs → chunk-R5R7Z74J.cjs} +67 -67
  15. package/dist/{chunk-YPAWXCMN.cjs → chunk-RODMYHXE.cjs} +259 -259
  16. package/dist/{chunk-UQRQYBZT.mjs → chunk-TMRHKSUO.mjs} +2 -2
  17. package/dist/chunk-ZED6TQNS.mjs +11 -0
  18. package/dist/claim.cjs +5 -5
  19. package/dist/claim.d.cts +3 -3
  20. package/dist/claim.d.ts +3 -3
  21. package/dist/claim.mjs +4 -4
  22. package/dist/constants.cjs +2 -2
  23. package/dist/constants.d.cts +1 -1
  24. package/dist/constants.d.ts +1 -1
  25. package/dist/constants.mjs +1 -1
  26. package/dist/deposit.cjs +6 -6
  27. package/dist/deposit.d.cts +2 -2
  28. package/dist/deposit.d.ts +2 -2
  29. package/dist/deposit.mjs +5 -5
  30. package/dist/index.cjs +8 -8
  31. package/dist/index.d.cts +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.mjs +7 -7
  34. package/dist/{types-CUj-rF6J.d.cts → types-C0SGf-21.d.cts} +73 -48
  35. package/dist/{types-CUj-rF6J.d.ts → types-C0SGf-21.d.ts} +73 -48
  36. package/dist/withdraw.cjs +5 -5
  37. package/dist/withdraw.d.cts +2 -2
  38. package/dist/withdraw.d.ts +2 -2
  39. package/dist/withdraw.mjs +4 -4
  40. package/package.json +1 -1
  41. package/dist/chunk-7TKMYD4H.mjs +0 -6
  42. package/dist/chunk-DMEK466U.cjs +0 -6
package/README.md CHANGED
@@ -103,7 +103,9 @@ The user picks the destination chain, token, recipient, and amount in the modal;
103
103
 
104
104
  ## Claim a failed deposit
105
105
 
106
- `ClaimModal` lets a user get a failed or rejected EVM deposit sent back to them on its source chain. They paste the deposit's transaction hash and name a destination — **no wallet connection is involved at any point**, and there is no chain to pick: the hash is looked up across every chain, including ones the deposit flow itself doesn't list.
106
+ `ClaimModal` lets a user get a failed or rejected EVM deposit sent back to them on its source chain. They paste the deposit's transaction hash and name a destination, and there is no chain to pick: the hash is looked up across every chain, including ones the deposit flow itself doesn't list.
107
+
108
+ **The modal never runs a connect step** — it has no wallet UI and asks for no provider. It does need a signature from the deposit's `recipient`, which it requests through `signRecovery` using whatever wallet your app already holds for that user. For an embedded wallet that is headless and the user sees nothing but the confirmation your own SDK shows.
107
109
 
108
110
  ```tsx
109
111
  import { ClaimModal } from "@rhinestone/deposit-modal/claim";
@@ -111,7 +113,7 @@ import { ClaimModal } from "@rhinestone/deposit-modal/claim";
111
113
  <ClaimModal
112
114
  isOpen={claimOpen}
113
115
  onClose={() => setClaimOpen(false)}
114
- refundEndpoint="/api/refund"
116
+ signRecovery={({ typedData }) => wallet.signTypedData(typedData)}
115
117
  backendUrl={process.env.NEXT_PUBLIC_DEPOSIT_PROXY_URL}
116
118
  // Optional prefills:
117
119
  defaultTxHash={depositTxHash}
@@ -120,16 +122,62 @@ import { ClaimModal } from "@rhinestone/deposit-modal/claim";
120
122
  />
121
123
  ```
122
124
 
123
- ### Why you have to authorize it
125
+ ### Why the user signs
126
+
127
+ Deposit accounts are owned by the Rhinestone service, so the account holding the
128
+ funds has no user key and cannot sign for its own refund. But the deposit's
129
+ `recipient` — the in-app wallet the funds were headed to — *is* a key your user
130
+ holds. So that is what authorizes the recovery.
131
+
132
+ `signRecovery` is handed the exact typed data to sign plus the `signer` address the
133
+ processor will verify against, and returns a signature:
134
+
135
+ ```tsx
136
+ <ClaimModal
137
+ isOpen={isOpen}
138
+ onClose={() => setIsOpen(false)}
139
+ backendUrl={process.env.NEXT_PUBLIC_DEPOSIT_PROXY_URL}
140
+ signRecovery={({ typedData }) => wallet.signTypedData(typedData)}
141
+ />
142
+ ```
143
+
144
+ Return whatever that address's own verifier accepts:
145
+
146
+ | recipient is | return |
147
+ |---|---|
148
+ | embedded EOA (Privy, Turnkey, Dynamic) | `signTypedData` — the raw 65-byte signature |
149
+ | deployed smart account | a signature valid under its ERC-1271 `isValidSignature` |
150
+ | undeployed smart account | an ERC-6492 wrapper — `SignatureErc6492.wrap` from `ox/erc6492`, which ships with viem |
151
+
152
+ A raw owner signature is usually **not** enough for a smart account: a Safe expects
153
+ its own message wrapping, so go through your account SDK rather than signing the
154
+ struct directly with the owner key.
124
155
 
125
- Deposit accounts are owned by the Rhinestone service, so there is no user wallet that can sign for a refund — and when the deposit arrived from an exchange, the sender can't sign either. Whether a deposit belongs to a given user is something **only your app knows**: you authenticated them, and you chose the `recipient` you passed to the widget.
156
+ Your app needs no backend and no shared secret for any of this. The request goes
157
+ straight from the browser through your `deposit-widget-proxy`, which adds only the
158
+ project API key — and that key cannot move funds through this route without a valid
159
+ signature, so there is no privilege for a page to borrow.
126
160
 
127
- So `refundEndpoint` points at something you control. Two shapes:
161
+ Two properties fall out of signing that are worth knowing:
128
162
 
129
- **Your own backend** — same-origin, so the session cookie authenticates it. `createRefundHandler` does everything except the auth decision:
163
+ - **The destination is inside the signed struct.** The processor cannot pay anywhere
164
+ else, so the success screen states what the user signed rather than trusting the
165
+ endpoint to report where the money went. `defaultRefundDestination` only *seeds*
166
+ the field; whatever the user submits is what they sign.
167
+ - **Failures carry a structured code**, so the modal knows when a retry helps. A
168
+ verification outage is retryable; a rejected signature or a deposit already
169
+ claimed is not. HTTP status alone can't separate those.
170
+
171
+ ### If your users can't sign
172
+
173
+ A lost embedded wallet, or a `recipient` your app controls rather than the user, both
174
+ leave nothing to sign with. `createRefundHandler` from
175
+ `@rhinestone/deposit-modal/server` is still exported for that case — it authorizes on
176
+ your say-so instead, verifying the deposit belongs to the recipient you name before
177
+ spending your API key:
130
178
 
131
179
  ```ts
132
- // app/api/refund/route.ts
180
+ // your own route, driving your own UI
133
181
  import { createRefundHandler } from "@rhinestone/deposit-modal/server";
134
182
 
135
183
  export const POST = createRefundHandler({
@@ -137,36 +185,13 @@ export const POST = createRefundHandler({
137
185
  async authorize(request) {
138
186
  const session = await getSession(request);
139
187
  if (!session) return null; // → 401
140
- // The deposit `recipient` you passed the widget. Used ONLY to prove the
141
- // deposit is this user's — it does not decide where the money goes.
142
188
  return { depositRecipient: session.depositRecipient };
143
189
  },
144
190
  });
145
191
  ```
146
192
 
147
- It verifies the deposit really belongs to that recipient before spending your API key, and 403s otherwise. Return `refundDestination` from `authorize` to pin where funds go and take that choice away from the browser — the handler reports the effective destination back, so the modal's success screen and `complete` event name the address that was actually paid rather than the one the browser asked for.
148
-
149
- `defaultRefundDestination` on the modal only *seeds* that field and the user can edit it; `refundDestination` from `authorize` overrides whatever they submitted.
150
-
151
- If you write your own endpoint instead, echo a `destination` in the success body whenever you override the requested one, for the same reason.
152
-
153
- **A deposit-widget-proxy** — cross-origin, so cookies don't travel. Set `REFUND_TOKEN_SECRET` on the proxy and mint a short-lived token instead:
154
-
155
- ```tsx
156
- <ClaimModal
157
- refundEndpoint="https://your-proxy.example/deposits/refund"
158
- backendUrl={process.env.NEXT_PUBLIC_DEPOSIT_PROXY_URL}
159
- getUserToken={(refund) =>
160
- fetch("/api/refund-token", {
161
- method: "POST",
162
- body: JSON.stringify(refund),
163
- }).then((r) => r.json()).then((r) => r.token)
164
- }
165
- /* … */
166
- />
167
- ```
168
-
169
- Bind the token to the specific refund it authorizes, not just to the user — an identity-only token is a bearer credential spendable on any destination. See the deposit-widget-proxy README for the mint endpoint.
193
+ The modal does not drive this path — you'd build that UI yourself, or route the user
194
+ to support.
170
195
 
171
196
  `GET /deposits` still needs to be proxied for the lookup step, as before.
172
197
 
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkYPAWXCMNcjs = require('./chunk-YPAWXCMN.cjs');
4
- require('./chunk-QHPPDDYT.cjs');
5
- require('./chunk-BAPBC6TI.cjs');
3
+ var _chunkRODMYHXEcjs = require('./chunk-RODMYHXE.cjs');
4
+ require('./chunk-R5R7Z74J.cjs');
5
+ require('./chunk-OKMLSIBM.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunkNAHHUQIScjs = require('./chunk-NAHHUQIS.cjs');
10
- require('./chunk-DMEK466U.cjs');
9
+ var _chunkLX2IDGJUcjs = require('./chunk-LX2IDGJU.cjs');
10
+ require('./chunk-LFQMZS5O.cjs');
11
11
  require('./chunk-YEBXUUH3.cjs');
12
12
 
13
13
 
@@ -88,14 +88,14 @@ function buildTransports(rpcUrls) {
88
88
  const transports = {};
89
89
  for (const network of EVM_NETWORKS) {
90
90
  const id = Number(network.id);
91
- transports[id] = _viem.http.call(void 0, _chunkNAHHUQIScjs.rpcUrlFor.call(void 0, rpcUrls, id));
91
+ transports[id] = _viem.http.call(void 0, _chunkLX2IDGJUcjs.rpcUrlFor.call(void 0, rpcUrls, id));
92
92
  }
93
93
  return transports;
94
94
  }
95
95
  function getEvmRpcFingerprint(rpcUrls) {
96
96
  return EVM_NETWORKS.map((network) => {
97
97
  const id = Number(network.id);
98
- return `${id}=${_nullishCoalesce(_chunkNAHHUQIScjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
98
+ return `${id}=${_nullishCoalesce(_chunkLX2IDGJUcjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
99
99
  }).join("|");
100
100
  }
101
101
  var cachedAdapter = null;
@@ -189,7 +189,7 @@ function useReownWallet() {
189
189
  await switchChainAsync({ chainId });
190
190
  }
191
191
  } catch (err) {
192
- if (_chunkNAHHUQIScjs.isUnsupportedChainSwitchError.call(void 0, err)) {
192
+ if (_chunkLX2IDGJUcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
193
193
  throw new Error(
194
194
  `Switch to ${_chunkH577RJN5cjs.getChainName.call(void 0, chainId)} in your wallet to continue`
195
195
  );
@@ -223,7 +223,7 @@ function DepositModalWithReown(props) {
223
223
  reown.disconnect();
224
224
  }, [reown.disconnect]);
225
225
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
226
- _chunkYPAWXCMNcjs.DepositModalInner,
226
+ _chunkRODMYHXEcjs.DepositModalInner,
227
227
  {
228
228
  ...props,
229
229
  reownWallet: reownWithSolana,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-Q7WRDBSJ.mjs";
4
- import "./chunk-W4U5KHEO.mjs";
5
- import "./chunk-P4TMKJJU.mjs";
3
+ } from "./chunk-JPSMRSOQ.mjs";
4
+ import "./chunk-LG5JKKA2.mjs";
5
+ import "./chunk-4GMACNN7.mjs";
6
6
  import {
7
7
  isUnsupportedChainSwitchError,
8
8
  rpcUrlFor
9
- } from "./chunk-4NJ6Q3J6.mjs";
10
- import "./chunk-7TKMYD4H.mjs";
9
+ } from "./chunk-BHLLQUWO.mjs";
10
+ import "./chunk-ZED6TQNS.mjs";
11
11
  import "./chunk-ILT2PITN.mjs";
12
12
  import {
13
13
  SUPPORTED_CHAINS,