@oasisprotocol/privana-sdk 0.5.4 → 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
@@ -224,7 +224,7 @@ Notes:
224
224
  | `useBatchBalances` | Get multiple token balances |
225
225
  | `useDeposit` | Deposit tokens |
226
226
  | `useDepositVerification` | Run checkDeposit + status polling against an existing on-chain transfer (used by `useDeposit` and `useFiatOnRamp`) |
227
- | `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) |
228
228
  | `useWithdraw` | Withdraw tokens |
229
229
  | `useLockFunds` | Lock funds for a recipient |
230
230
  | `useUnlockFunds` | Unlock expired locks |
@@ -240,8 +240,13 @@ Notes:
240
240
  ## Fiat On-Ramp
241
241
 
242
242
  The fiat on-ramp lets users buy tokens with a card and have them credited to
243
- their Privana balance in one flow. **MoonPay delivers the purchased token
244
- 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.**
245
250
 
246
251
  Exported from a separate entry point so consumers who don't use the on-ramp
247
252
  don't pay the bundle cost of `@moonpay/moonpay-react`:
@@ -292,15 +297,18 @@ The form:
292
297
  - sets `externalCustomerId = address.toLowerCase()` so the backend can bind the
293
298
  MoonPay transaction to the SIWE-authenticated user,
294
299
  - creates a backend on-ramp intent (`POST /onramp/intent`) and passes its id to
295
- 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,
296
303
  - gates the "Buy" button on the configured token's minimum deposit (input-time
297
304
  check) and double-checks the delivered amount before triggering verification,
298
305
  - on MoonPay's `transaction_created`, fire-and-forget calls
299
306
  `POST /onramp/{id}` with the MoonPay transaction id so the backend can
300
- reconcile both ids once the delivery webhook lands,
301
- - listens for MoonPay's `transaction_completed` event, waits up to 120s for
302
- the backend webhook to surface the on-chain tx hash, then triggers Privana
303
- 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).
304
312
 
305
313
  ### `useFiatOnRamp` for custom UI
306
314
 
@@ -331,29 +339,30 @@ const {
331
339
 
332
340
  ### Pending / recovery
333
341
 
334
- If the user closes the tab between MoonPay completion and verification, the
335
- backend has already received the webhook and the row appears in `pending`.
336
- Render the list with a "Finish verification" CTA that calls
337
- `finishPendingVerification(record)` no wallet signature required, just the
338
- 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.
339
348
 
340
349
  ### Required backend endpoints
341
350
 
342
351
  The `useFiatOnRamp` hook + form call:
343
352
 
344
353
  - `POST /v1/accounting/onramp/sign-url` — HMAC-signs the MoonPay widget URL
345
- - `POST /v1/accounting/onramp/intent` — creates the Privana intent row that ties a MoonPay transaction to the SIWE'd user + Privana token
346
- - `POST /v1/accounting/onramp/{transaction_id}` — upserts MoonPay transaction metadata (fire-and-forget on `transaction_created`)
347
- - `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
348
357
 
349
358
  And the existing deposit verification endpoints:
350
359
 
351
360
  - `POST /v1/accounting/deposits/check`
352
361
  - `GET /v1/accounting/deposits/status/{id}`
353
362
 
354
- MoonPay → backend webhook (`POST /v1/accounting/onramp/webhook`) is what
355
- populates the pending list with the on-chain tx hash. Configure that URL in
356
- 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.
357
366
 
358
367
  ## License
359
368