@oasisprotocol/privana-sdk 0.5.3 → 0.5.5

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 CHANGED
@@ -54,17 +54,7 @@ function App() {
54
54
  `accountingContract` must be the deployed Privana accounting contract address for the same
55
55
  environment as `apiUrl`.
56
56
 
57
- ### 2. Use the PrivanaButton
58
-
59
- ```tsx
60
- import { PrivanaButton } from '@oasisprotocol/privana-sdk'
61
-
62
- function MyComponent() {
63
- return <PrivanaButton />
64
- }
65
- ```
66
-
67
- ### 3. Or build custom UI with hooks
57
+ ### 2. Or build custom UI with hooks
68
58
 
69
59
  ```tsx
70
60
  import {
@@ -225,33 +215,6 @@ Notes:
225
215
  - staging end-to-end verification requires that registration on the staging deployment.
226
216
  - the standalone localhost popup page used during Firefox debugging was diagnostic only; it is not part of the supported SDK integration path.
227
217
 
228
- ## Components
229
-
230
- ### PrivanaButton
231
-
232
- A customizable button that opens the wallet modal.
233
-
234
- ```tsx
235
- // Basic usage
236
- <PrivanaButton />
237
-
238
- // Custom text
239
- <PrivanaButton>Open Wallet</PrivanaButton>
240
-
241
- // Custom styling
242
- <PrivanaButton variant="default" size="lg" className="my-class" />
243
-
244
- // Full control with render prop
245
- <PrivanaButton
246
- renderButton={({ onClick, isOpen }) => (
247
- <MyButton onClick={onClick}>Custom Button</MyButton>
248
- )}
249
- />
250
-
251
- // Show when wallet disconnected (disabled state)
252
- <PrivanaButton hideWhenDisconnected={false} />
253
- ```
254
-
255
218
  ## Hooks
256
219
 
257
220
  | Hook | Description |
@@ -261,7 +224,7 @@ A customizable button that opens the wallet modal.
261
224
  | `useBatchBalances` | Get multiple token balances |
262
225
  | `useDeposit` | Deposit tokens |
263
226
  | `useDepositVerification` | Run checkDeposit + status polling against an existing on-chain transfer (used by `useDeposit` and `useFiatOnRamp`) |
264
- | `useFiatOnRamp` | Buy crypto via MoonPay; delivered straight to the Privana deposit address (from `/on-ramp` sub-export) |
227
+ | `useFiatOnRamp` | MoonPay on-ramp with provider-neutral recovery, verification, credit, and locking (from `/on-ramp` sub-export) |
265
228
  | `useWithdraw` | Withdraw tokens |
266
229
  | `useLockFunds` | Lock funds for a recipient |
267
230
  | `useUnlockFunds` | Unlock expired locks |
@@ -277,8 +240,13 @@ A customizable button that opens the wallet modal.
277
240
  ## Fiat On-Ramp
278
241
 
279
242
  The fiat on-ramp lets users buy tokens with a card and have them credited to
280
- their Privana balance in one flow. **MoonPay delivers the purchased token
281
- directly to the user's Privana deposit address**.
243
+ their Privana balance in one flow. An internal provider-neutral core owns
244
+ recovery, receipt verification, `/deposits/check`, credit, and optional
245
+ post-credit locking. MoonPay launch and widget behavior live in a thin adapter.
246
+
247
+ **The provider delivers the purchased token directly to the server-derived
248
+ Privana deposit address. Provider orders, amounts, events, and webhooks are
249
+ correlation hints only; the matching on-chain transfer remains authoritative.**
282
250
 
283
251
  Exported from a separate entry point so consumers who don't use the on-ramp
284
252
  don't pay the bundle cost of `@moonpay/moonpay-react`:
@@ -329,15 +297,18 @@ The form:
329
297
  - sets `externalCustomerId = address.toLowerCase()` so the backend can bind the
330
298
  MoonPay transaction to the SIWE-authenticated user,
331
299
  - creates a backend on-ramp intent (`POST /onramp/intent`) and passes its id to
332
- MoonPay as `externalTransactionId` so the webhook can correlate later,
300
+ MoonPay as `externalTransactionId` for exact authenticated recovery,
301
+ - persists at most ten unresolved signed intents under the authenticated user
302
+ and sends them as repeated `externalTransactionId` values on pending reads,
333
303
  - gates the "Buy" button on the configured token's minimum deposit (input-time
334
304
  check) and double-checks the delivered amount before triggering verification,
335
305
  - on MoonPay's `transaction_created`, fire-and-forget calls
336
306
  `POST /onramp/{id}` with the MoonPay transaction id so the backend can
337
- reconcile both ids once the delivery webhook lands,
338
- - listens for MoonPay's `transaction_completed` event, waits up to 120s for
339
- the backend webhook to surface the on-chain tx hash, then triggers Privana
340
- verification (`checkDeposit` + status polling).
307
+ reconcile both ids during provider reads,
308
+ - treats MoonPay events as wake-up hints, polls the authenticated pending read
309
+ for the provider transaction and on-chain hash, derives the delivered amount
310
+ from matching receipt logs, then triggers Privana verification
311
+ (`checkDeposit` + status polling).
341
312
 
342
313
  ### `useFiatOnRamp` for custom UI
343
314
 
@@ -368,29 +339,30 @@ const {
368
339
 
369
340
  ### Pending / recovery
370
341
 
371
- If the user closes the tab between MoonPay completion and verification, the
372
- backend has already received the webhook and the row appears in `pending`.
373
- Render the list with a "Finish verification" CTA that calls
374
- `finishPendingVerification(record)` no wallet signature required, just the
375
- verification poll.
342
+ If the user closes or reloads between launch and verification, the SDK reloads
343
+ its bounded signed-intent set and combines exact provider lookups with the
344
+ authenticated derived-wallet lookup. A corrupt local intent is isolated and
345
+ removed without blocking valid recovery. Render `pending` with a "Finish
346
+ verification" CTA that calls `finishPendingVerification(record)` — no wallet
347
+ signature is required for deposit verification.
376
348
 
377
349
  ### Required backend endpoints
378
350
 
379
351
  The `useFiatOnRamp` hook + form call:
380
352
 
381
353
  - `POST /v1/accounting/onramp/sign-url` — HMAC-signs the MoonPay widget URL
382
- - `POST /v1/accounting/onramp/intent` — creates the Privana intent row that ties a MoonPay transaction to the SIWE'd user + Privana token
383
- - `POST /v1/accounting/onramp/{transaction_id}` — upserts MoonPay transaction metadata (fire-and-forget on `transaction_created`)
384
- - `GET /v1/accounting/onramp/pending` — completed MoonPay txs awaiting verification
354
+ - `POST /v1/accounting/onramp/intent` — mints a signed provider/user/wallet/token/chain/asset intent
355
+ - `POST /v1/accounting/onramp/{transaction_id}` — validates and echoes MoonPay compatibility metadata without becoming order state
356
+ - `GET /v1/accounting/onramp/pending` — bounded provider reads for completed, strictly admitted transactions awaiting verification
385
357
 
386
358
  And the existing deposit verification endpoints:
387
359
 
388
360
  - `POST /v1/accounting/deposits/check`
389
361
  - `GET /v1/accounting/deposits/status/{id}`
390
362
 
391
- MoonPay → backend webhook (`POST /v1/accounting/onramp/webhook`) is what
392
- populates the pending list with the on-chain tx hash. Configure that URL in
393
- your MoonPay dashboard.
363
+ The MoonPay webhook (`POST /v1/accounting/onramp/moonpay/webhook`) is an optional
364
+ verified observability signal. It does not populate order state and is not
365
+ required for recovery or credit.
394
366
 
395
367
  ## License
396
368