@stridge/kit 0.1.0-alpha.56 → 0.1.0-alpha.58

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.
@@ -58,9 +58,25 @@ declare function KitProvider({
58
58
  support,
59
59
  merchantContext,
60
60
  terms,
61
+ dev,
61
62
  attribution,
62
63
  ...scopeProps
63
64
  }: KitProvider.Props): _$react_jsx_runtime0.JSX.Element;
65
+ /**
66
+ * Development / preview-only knobs for `<KitProvider />`. Grouped under a single `dev` prop so
67
+ * production integrations never reach for these accidentally. Intentionally not re-exported from
68
+ * any public entry barrel — `KitProvider` itself ships only from `@stridge/kit/_internal`.
69
+ */
70
+ interface KitDevConfig {
71
+ /**
72
+ * Unlock the cash payment rail. The cash UI is currently UI-only (no backend), so the rail is
73
+ * fused off everywhere by default; this knob is the only switch that lights it up, and it
74
+ * lives here on the `_internal` provider so production `<StridgeProvider />` consumers cannot
75
+ * surface cash before it ships. The host's `depositMethods.cashRail.enabled` opt-in is still
76
+ * required *in addition* to this gate. Remove once the cash backend lands.
77
+ */
78
+ cashRail?: boolean;
79
+ }
64
80
  declare namespace KitProvider {
65
81
  interface Props extends KitScope.Props {
66
82
  /**
@@ -125,6 +141,11 @@ declare namespace KitProvider {
125
141
  * Merchant-configurable terms link for direct `<KitProvider />` mounts.
126
142
  */
127
143
  terms?: TermsConfig;
144
+ /**
145
+ * Development / preview-only knobs. See {@link KitDevConfig}. Grouped under `dev` so
146
+ * production integrations never reach for them accidentally.
147
+ */
148
+ dev?: KitDevConfig;
128
149
  }
129
150
  }
130
151
  //#endregion
@@ -1 +1 @@
1
- "use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{ActivityDriverProvider as t}from"./flows/activity/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{ActivityControllerProvider as i}from"./flows/activity/orchestrator/controller.js";import{DepositBindingsProvider as a}from"./flows/deposit/bindings/DepositBindings.js";import"./flows/deposit/bindings/index.js";import{DepositDriverProvider as o}from"./flows/deposit/driver/context.js";import{GatewayController as s}from"./flows/deposit/orchestrator/controller.js";import{WithdrawBindingsProvider as c}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{WithdrawDriverProvider as l}from"./flows/withdraw/driver/context.js";import{WithdrawControllerProvider as u}from"./flows/withdraw/orchestrator/controller.js";import{KitScope as d}from"./scope/KitScope.js";import"./scope/index.js";import{SupportConfigContext as f}from"./shared/support/SupportConfigContext.js";import{TermsConfigContext as p}from"./shared/terms/TermsConfigContext.js";import{useMemo as m}from"react";import{jsx as h}from"react/jsx-runtime";import{LazyMotion as g,domMax as _}from"motion/react";function v({children:v,i18n:y,direction:b,deposit:x,depositMethods:S,withdraw:C,activity:w,storage:T,storageNamespace:E,support:D,merchantContext:O,terms:k,attribution:A=`visible`,...j}){let M=n(y?.locale),N=v;C&&(N=h(c,{children:h(l,{driver:C,children:h(u,{children:N})})})),x&&(N=h(a,{children:h(o,{driver:x,children:h(s,{methodsConfig:S,children:N})})})),w&&(N=h(t,{driver:w,children:h(i,{children:N})}));let P=m(()=>({config:D,merchantContext:O??null}),[D,O]),F=D!==void 0||O!==void 0,I=m(()=>({config:k}),[k]),L=k!==void 0,R=h(r,{locale:y?.locale,messages:y?.messages,children:h(d,{...j,direction:b??M,locale:y?.locale,attribution:A,children:h(e,{storage:T,namespace:E,children:N})})});return F&&(R=h(f.Provider,{value:P,children:R})),L&&(R=h(p.Provider,{value:I,children:R})),h(g,{features:_,children:R})}export{v as KitProvider};
1
+ "use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{ActivityDriverProvider as t}from"./flows/activity/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{ActivityControllerProvider as i}from"./flows/activity/orchestrator/controller.js";import{DepositBindingsProvider as a}from"./flows/deposit/bindings/DepositBindings.js";import"./flows/deposit/bindings/index.js";import{DepositDriverProvider as o}from"./flows/deposit/driver/context.js";import{GatewayController as s}from"./flows/deposit/orchestrator/controller.js";import{WithdrawBindingsProvider as c}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{WithdrawDriverProvider as l}from"./flows/withdraw/driver/context.js";import{WithdrawControllerProvider as u}from"./flows/withdraw/orchestrator/controller.js";import{KitScope as d}from"./scope/KitScope.js";import"./scope/index.js";import{SupportConfigContext as f}from"./shared/support/SupportConfigContext.js";import{TermsConfigContext as p}from"./shared/terms/TermsConfigContext.js";import{useMemo as m}from"react";import{jsx as h}from"react/jsx-runtime";import{LazyMotion as g,domMax as _}from"motion/react";function v({children:v,i18n:y,direction:b,deposit:x,depositMethods:S,withdraw:C,activity:w,storage:T,storageNamespace:E,support:D,merchantContext:O,terms:k,dev:A,attribution:j=`visible`,...M}){let N=n(y?.locale),P=v;C&&(P=h(c,{children:h(l,{driver:C,children:h(u,{children:P})})})),x&&(P=h(a,{children:h(o,{driver:x,children:h(s,{methodsConfig:S,cashRailUnlocked:A?.cashRail===!0,children:P})})})),w&&(P=h(t,{driver:w,children:h(i,{children:P})}));let F=m(()=>({config:D,merchantContext:O??null}),[D,O]),I=D!==void 0||O!==void 0,L=m(()=>({config:k}),[k]),R=k!==void 0,z=h(r,{locale:y?.locale,messages:y?.messages,children:h(d,{...M,direction:b??N,locale:y?.locale,attribution:j,children:h(e,{storage:T,namespace:E,children:P})})});return I&&(z=h(f.Provider,{value:F,children:z})),R&&(z=h(p.Provider,{value:L,children:z})),h(g,{features:_,children:z})}export{v as KitProvider};
@@ -3,5 +3,24 @@ import { StridgeEvent } from "../types/index.js";
3
3
  //#region src/events/bus/createBus.d.ts
4
4
  /** Handler shape — accepts a typed event, returns nothing (return values are ignored). */
5
5
  type EventHandler<TEvent extends StridgeEvent = StridgeEvent> = (event: TEvent) => void;
6
+ /**
7
+ * Per-subscription options shared by every subscribe method.
8
+ */
9
+ interface SubscribeOptions {
10
+ /**
11
+ * Immediately replay the active `<flow>.opened` event(s) to this handler at subscribe time,
12
+ * for any flow whose session is currently open. Lets a late subscriber recover the session
13
+ * start (and the `flowId` + frozen `metadata` it carries) instead of silently missing it.
14
+ *
15
+ * Only the `<flow>.opened` event is replayed — never `quote`, `settlement`, or other
16
+ * mid-flow events. The replayed envelope is identical to the one live subscribers received
17
+ * (same `timestamp`, `flowId`, `metadata`); it is not flagged as a replay. Because `opened`
18
+ * events are `tier: "ui"`, replay reaches `subscribeToAll` / `useStridgeEvents` and
19
+ * `subscribeToEvent("<flow>.opened", …)` — the flow-only surfaces never carry it.
20
+ *
21
+ * @defaultValue `false`
22
+ */
23
+ replayOpenSession?: boolean;
24
+ }
6
25
  //#endregion
7
- export { EventHandler };
26
+ export { EventHandler, SubscribeOptions };
@@ -1 +1 @@
1
- function e(){let e=new Set,t=new Set,n=new Map,r=!1;function i(e,t){try{e(t)}catch(e){console.error(`[stridge/kit] handler for "${t.type}" threw:`,e)}}function a(a){if(r)return;if(a.tier===`flow`)for(let t of e)i(t,a);for(let e of t)i(e,a);let o=n.get(a.type);if(o)for(let e of o)i(e,a)}function o(e,t){return e.add(t),()=>{e.delete(t)}}function s(e,t){let r=n.get(e);return r||(r=new Set,n.set(e,r)),r.add(t),()=>{let r=n.get(e);r&&(r.delete(t),r.size===0&&n.delete(e))}}return{emit:a,subscribeToFlow:t=>o(e,t),subscribeToFlowEvent:(e,t)=>s(e,t),subscribeToAll:e=>o(t,e),subscribeToEvent:(e,t)=>s(e,t),dispose:()=>{r=!0,e.clear(),t.clear(),n.clear()}}}export{e as createBus};
1
+ function e(){let e=new Set,t=new Set,n=new Map,r=new Map,i=!1;function a(e,t){try{e(t)}catch(e){console.error(`[stridge/kit] handler for "${t.type}" threw:`,e)}}function o(r){if(i)return;if(r.tier===`flow`)for(let t of e)a(t,r);for(let e of t)a(e,r);let o=n.get(r.type);if(o)for(let e of o)a(e,r)}function s(e,t){return e.add(t),()=>{e.delete(t)}}function c(e,t){let r=n.get(e);return r||(r=new Set,n.set(e,r)),r.add(t),()=>{let r=n.get(e);r&&(r.delete(t),r.size===0&&n.delete(e))}}function l(e,t,n){if(!(i||!t?.replayOpenSession))for(let t of r.values())n(t)&&a(e,t)}return{emit:o,subscribeToFlow:(t,n)=>{let r=s(e,t);return l(t,n,e=>e.tier===`flow`),r},subscribeToFlowEvent:(e,t,n)=>{let r=c(e,t);return l(t,n,t=>t.type===e),r},subscribeToAll:(e,n)=>{let r=s(t,e);return l(e,n,()=>!0),r},subscribeToEvent:(e,t,n)=>{let r=c(e,t);return l(t,n,t=>t.type===e),r},retainOpenSession:e=>{i||r.set(e.flow,e)},releaseOpenSession:e=>{r.delete(e)},dispose:()=>{i=!0,e.clear(),t.clear(),n.clear(),r.clear()}}}export{e as createBus};
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(n){let r=o(e),i=s(n.metadata);i.current=n.metadata,t({state:n.state,settlement:n.settlement,quote:n.quote,fireFsm:(e,t)=>{r&&d(r,e,t,i.current)},fireSettlement:(e,t)=>{r&&p(r,e,t,n.state)},fireQuote:(e,t)=>{r&&t.status===`ready`&&e!==`ready`&&a(r,{type:`deposit.quote.resolved`,flow:`deposit`,tier:`flow`,payload:{quote:t.payload}})}})}function l(e){if(e.name!==`deposit`){if(e.name===`transferCrypto`)return{method:`transfer`};if(e.name===`assetPicker`)return{method:`wallet`};if(e.name===`amountEntry`)return{method:`wallet`,asset:e.ctx.asset};if(e.name!==`cashAmountEntry`&&e.name!==`cashConfirm`){if(e.name===`confirmDeposit`)return{method:`wallet`,asset:e.ctx.asset};if(e.name===`processing`||e.name===`success`)return e.ctx.method===`transfer`?{method:`transfer`}:{method:`wallet`}}}}function u(e){return e.name===`confirmDeposit`?e.ctx.phase.kind===`submitting`?`submitting`:`confirming`:e.name===`processing`?`processing`:e.name===`deposit`||e.name===`assetPicker`||e.name===`amountEntry`||e.name===`cashAmountEntry`||e.name===`cashConfirm`||e.name===`transferCrypto`?`quoting`:`unknown`}function d(e,t,o,s){if(o.name===`confirmDeposit`&&t.name===`confirmDeposit`){f(e,t.ctx.phase,o.ctx.phase,o);return}if(t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`deposit`,s,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:l(o)}}),a(e,{type:`deposit.step.changed`,flow:`deposit`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`deposit`&&o.name===`assetPicker`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`wallet`}}),t.name===`deposit`&&o.name===`transferCrypto`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`transfer`}}),t.name===`assetPicker`&&o.name===`amountEntry`&&a(e,{type:`deposit.asset.clicked`,flow:`deposit`,tier:`ui`,payload:{asset:o.ctx.asset}}),t.name===`amountEntry`&&o.name===`confirmDeposit`&&a(e,{type:`deposit.amount.submitted`,flow:`deposit`,tier:`ui`,payload:{amount:o.ctx.amount}}),o.name===`confirmDeposit`&&f(e,t.name===`confirmDeposit`?t.ctx.phase:void 0,o.ctx.phase,o),t.name===`confirmDeposit`&&o.name===`processing`&&a(e,{type:`deposit.submission.broadcast`,flow:`deposit`,tier:`flow`,payload:{tx:o.ctx.tx}}),t.name!==`error`&&o.name===`error`&&o.ctx.failure){let r=t.name===`confirmDeposit`?t.ctx.phase:void 0,i=n(o.ctx.failure);r?.kind===`submitting`&&a(e,{type:`deposit.submission.failed`,flow:`deposit`,tier:`flow`,payload:i}),a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...i,kind:`unknown`}})}o.name!==`closed`&&t.name!==`closed`&&`backTarget`in t.ctx&&o.name===t.ctx.backTarget&&a(e,{type:`deposit.back.clicked`,flow:`deposit`,tier:`ui`,payload:{fromStep:t.name}}),t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`deposit.cancelled`,flow:`deposit`,tier:`flow`,payload:{phase:u(t)}}),r(e,`deposit`,{type:`deposit.closed`,flow:`deposit`,tier:`ui`,payload:{atStep:t.name}}))}}function f(e,t,r,i){t?.kind!==r.kind&&((r.kind===`loading`||r.kind===`regenerating`)&&(a(e,{type:`deposit.quote.requested`,flow:`deposit`,tier:`flow`,payload:{input:{asset:i.ctx.asset,amount:i.ctx.amount}}}),r.kind===`regenerating`&&(t?.kind===`submitting`?a(e,{type:`deposit.submission.declined`,flow:`deposit`,tier:`flow`,payload:{}}):t?.kind===`ready`&&a(e,{type:`deposit.quote.expired`,flow:`deposit`,tier:`flow`,payload:{}}))),r.kind===`failed`&&a(e,{type:`deposit.quote.failed`,flow:`deposit`,tier:`flow`,payload:n(r.failure)}),r.kind===`submitting`&&a(e,{type:`deposit.submission.confirmed`,flow:`deposit`,tier:`ui`,payload:{}}))}function p(e,t,r,o){if(r.status!==`ready`&&r.status!==`stale`)return;let s=r.payload;if(s.kind===`pending`){t===null?(o.name===`closed`&&i(e,`deposit`,void 0,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:void 0}}),a(e,{type:`deposit.settlement.resumed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}})):a(e,{type:`deposit.settlement.progressed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}if(s.kind===`succeeded`){a(e,{type:`deposit.settlement.succeeded`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}s.kind===`failed`&&a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...n({reason:m(s.failureKind)}),kind:s.failureKind,...s.txHash?.value?{txHash:s.txHash.value}:{}}})}function m(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useDepositEmissions};
1
+ "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(n){let r=o(e),i=s(n.metadata);i.current=n.metadata,t({state:n.state,settlement:n.settlement,quote:n.quote,fireFsm:(e,t)=>{r&&d(r,e,t,i.current)},fireSettlement:(e,t)=>{r&&p(r,e,t,n.state)},fireQuote:(e,t)=>{r&&t.status===`ready`&&e!==`ready`&&a(r,{type:`deposit.quote.resolved`,flow:`deposit`,tier:`flow`,payload:{quote:t.payload}})}})}function l(e){if(e.name!==`deposit`){if(e.name===`transferCrypto`)return{method:`transfer`};if(e.name===`assetPicker`)return{method:`wallet`};if(e.name===`amountEntry`)return{method:`wallet`,asset:e.ctx.asset};if(e.name!==`cashAmountEntry`&&e.name!==`cashConfirm`){if(e.name===`confirmDeposit`)return{method:`wallet`,asset:e.ctx.asset};if(e.name===`processing`||e.name===`success`)return e.ctx.method===`transfer`?{method:`transfer`}:{method:`wallet`}}}}function u(e){return e.name===`confirmDeposit`?e.ctx.phase.kind===`submitting`?`submitting`:`confirming`:e.name===`processing`?`processing`:e.name===`deposit`||e.name===`assetPicker`||e.name===`amountEntry`||e.name===`cashAmountEntry`||e.name===`cashConfirm`||e.name===`transferCrypto`?`quoting`:`unknown`}function d(e,t,o,s){if(o.name===`confirmDeposit`&&t.name===`confirmDeposit`){f(e,t.ctx.phase,o.ctx.phase,o);return}if(t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`deposit`,s,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:l(o)}}),a(e,{type:`deposit.step.changed`,flow:`deposit`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`deposit`&&o.name===`assetPicker`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`wallet`}}),t.name===`deposit`&&o.name===`transferCrypto`&&a(e,{type:`deposit.method.clicked`,flow:`deposit`,tier:`ui`,payload:{method:`transfer`}}),t.name===`assetPicker`&&o.name===`amountEntry`&&a(e,{type:`deposit.asset.clicked`,flow:`deposit`,tier:`ui`,payload:{asset:o.ctx.asset}}),t.name===`amountEntry`&&o.name===`confirmDeposit`&&a(e,{type:`deposit.amount.submitted`,flow:`deposit`,tier:`ui`,payload:{amount:o.ctx.amount}}),o.name===`confirmDeposit`&&f(e,t.name===`confirmDeposit`?t.ctx.phase:void 0,o.ctx.phase,o),t.name===`confirmDeposit`&&o.name===`processing`&&a(e,{type:`deposit.submission.broadcast`,flow:`deposit`,tier:`flow`,payload:{tx:o.ctx.tx}}),t.name!==`error`&&o.name===`error`&&o.ctx.failure){let r=t.name===`confirmDeposit`?t.ctx.phase:void 0,i=n(o.ctx.failure,o.ctx.failure.cause);r?.kind===`submitting`&&a(e,{type:`deposit.submission.failed`,flow:`deposit`,tier:`flow`,payload:i}),a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...i,kind:`unknown`}})}o.name!==`closed`&&t.name!==`closed`&&`backTarget`in t.ctx&&o.name===t.ctx.backTarget&&a(e,{type:`deposit.back.clicked`,flow:`deposit`,tier:`ui`,payload:{fromStep:t.name}}),t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`deposit.cancelled`,flow:`deposit`,tier:`flow`,payload:{phase:u(t)}}),r(e,`deposit`,{type:`deposit.closed`,flow:`deposit`,tier:`ui`,payload:{atStep:t.name}}))}}function f(e,t,r,i){t?.kind!==r.kind&&((r.kind===`loading`||r.kind===`regenerating`)&&(a(e,{type:`deposit.quote.requested`,flow:`deposit`,tier:`flow`,payload:{input:{asset:i.ctx.asset,amount:i.ctx.amount}}}),r.kind===`regenerating`&&(t?.kind===`submitting`?a(e,{type:`deposit.submission.declined`,flow:`deposit`,tier:`flow`,payload:{}}):t?.kind===`ready`&&a(e,{type:`deposit.quote.expired`,flow:`deposit`,tier:`flow`,payload:{}}))),r.kind===`failed`&&a(e,{type:`deposit.quote.failed`,flow:`deposit`,tier:`flow`,payload:n(r.failure,r.failure.cause)}),r.kind===`submitting`&&a(e,{type:`deposit.submission.confirmed`,flow:`deposit`,tier:`ui`,payload:{}}))}function p(e,t,r,o){if(r.status!==`ready`&&r.status!==`stale`)return;let s=r.payload;if(s.kind===`pending`){t===null?(o.name===`closed`&&i(e,`deposit`,void 0,{type:`deposit.opened`,flow:`deposit`,tier:`ui`,payload:{input:void 0}}),a(e,{type:`deposit.settlement.resumed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}})):a(e,{type:`deposit.settlement.progressed`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}if(s.kind===`succeeded`){a(e,{type:`deposit.settlement.succeeded`,flow:`deposit`,tier:`flow`,payload:{settlement:s}});return}s.kind===`failed`&&a(e,{type:`deposit.settlement.failed`,flow:`deposit`,tier:`flow`,payload:{...n({reason:m(s.failureKind)}),kind:s.failureKind,...s.txHash?.value?{txHash:s.txHash.value}:{}}})}function m(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useDepositEmissions};
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(r){let i=o(e),c=s(r.metadata);c.current=r.metadata,t({state:r.state,settlement:r.settlement,quote:r.quote,fireFsm:(e,t)=>{i&&u(i,e,t,c.current)},fireSettlement:(e,t)=>{i&&d(i,t)},fireQuote:(e,t)=>{i&&t.status!==e&&(t.status===`ready`&&a(i,{type:`withdraw.quote.resolved`,flow:`withdraw`,tier:`flow`,payload:{quote:t.payload}}),t.status===`error`&&a(i,{type:`withdraw.quote.failed`,flow:`withdraw`,tier:`flow`,payload:n({reason:t.error.message||`Quote failed.`,...t.error.name?{code:t.error.name}:{}},t.error)}))}})}function l(e){return e.name===`form`?`quoting`:e.name===`submitting`?`confirming`:e.name===`inProgress`?`processing`:`unknown`}function u(e,t,o,s){let c=t.name===`form`&&!!t.ctx?.notice;if(o.name===`form`&&o.ctx?.notice&&!c&&a(e,{type:`withdraw.submission.declined`,flow:`withdraw`,tier:`flow`,payload:{}}),t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`withdraw`,s,{type:`withdraw.opened`,flow:`withdraw`,tier:`ui`,payload:{}}),a(e,{type:`withdraw.step.changed`,flow:`withdraw`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`form`&&o.name===`submitting`&&a(e,{type:`withdraw.submission.confirmed`,flow:`withdraw`,tier:`ui`,payload:{}}),t.name===`submitting`&&o.name===`inProgress`&&o.ctx.tx&&a(e,{type:`withdraw.submission.broadcast`,flow:`withdraw`,tier:`flow`,payload:{input:o.ctx.input,tx:o.ctx.tx}}),o.name===`error`){let t=o.ctx.failure;if(t!==void 0&&o.ctx.tx===void 0&&t){let r=n(t);a(e,{type:`withdraw.submission.failed`,flow:`withdraw`,tier:`flow`,payload:r}),a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...r,kind:`unknown`}})}}t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`withdraw.cancelled`,flow:`withdraw`,tier:`flow`,payload:{phase:l(t)}}),r(e,`withdraw`,{type:`withdraw.closed`,flow:`withdraw`,tier:`ui`,payload:{atStep:t.name}}))}}function d(e,t){if(t.status!==`ready`&&t.status!==`stale`)return;let r=t.payload;if(r.kind===`pending`){a(e,{type:`withdraw.settlement.progressed`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}if(r.kind===`succeeded`){a(e,{type:`withdraw.settlement.succeeded`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}r.kind===`failed`&&a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...n({reason:f(r.failureKind)}),kind:r.failureKind,...r.txHash?.value?{txHash:r.txHash.value}:{}}})}function f(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useWithdrawEmissions};
1
+ "use client";import{StridgeEventsContext as e}from"../context.js";import{useDialogLifecycle as t}from"../../shared/orchestrator/useDialogLifecycle.js";import"../../shared/orchestrator/index.js";import{mapFailureInfoToPayload as n}from"./mapFailure.js";import{closeFlowSession as r,openFlowSession as i,publishEvent as a}from"../publish.js";import{use as o,useRef as s}from"react";function c(r){let i=o(e),c=s(r.metadata);c.current=r.metadata,t({state:r.state,settlement:r.settlement,quote:r.quote,fireFsm:(e,t)=>{i&&u(i,e,t,c.current)},fireSettlement:(e,t)=>{i&&d(i,t)},fireQuote:(e,t)=>{i&&t.status!==e&&(t.status===`ready`&&a(i,{type:`withdraw.quote.resolved`,flow:`withdraw`,tier:`flow`,payload:{quote:t.payload}}),t.status===`error`&&a(i,{type:`withdraw.quote.failed`,flow:`withdraw`,tier:`flow`,payload:n({reason:t.error.message||`Quote failed.`,...t.error.name?{code:t.error.name}:{}},t.error)}))}})}function l(e){return e.name===`form`?`quoting`:e.name===`submitting`?`confirming`:e.name===`inProgress`?`processing`:`unknown`}function u(e,t,o,s){let c=t.name===`form`&&!!t.ctx?.notice;if(o.name===`form`&&o.ctx?.notice&&!c&&a(e,{type:`withdraw.submission.declined`,flow:`withdraw`,tier:`flow`,payload:{}}),t.name!==o.name){if(t.name===`closed`&&o.name!==`closed`&&i(e,`withdraw`,s,{type:`withdraw.opened`,flow:`withdraw`,tier:`ui`,payload:{}}),a(e,{type:`withdraw.step.changed`,flow:`withdraw`,tier:`ui`,payload:{from:t.name,to:o.name}}),t.name===`form`&&o.name===`submitting`&&a(e,{type:`withdraw.submission.confirmed`,flow:`withdraw`,tier:`ui`,payload:{}}),t.name===`submitting`&&o.name===`inProgress`&&o.ctx.tx&&a(e,{type:`withdraw.submission.broadcast`,flow:`withdraw`,tier:`flow`,payload:{input:o.ctx.input,tx:o.ctx.tx}}),o.name===`error`){let t=o.ctx.failure;if(t!==void 0&&o.ctx.tx===void 0&&t){let r=n(t,t.cause);a(e,{type:`withdraw.submission.failed`,flow:`withdraw`,tier:`flow`,payload:r}),a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...r,kind:`unknown`}})}}t.name!==`closed`&&o.name===`closed`&&(t.name===`success`||t.name===`error`||a(e,{type:`withdraw.cancelled`,flow:`withdraw`,tier:`flow`,payload:{phase:l(t)}}),r(e,`withdraw`,{type:`withdraw.closed`,flow:`withdraw`,tier:`ui`,payload:{atStep:t.name}}))}}function d(e,t){if(t.status!==`ready`&&t.status!==`stale`)return;let r=t.payload;if(r.kind===`pending`){a(e,{type:`withdraw.settlement.progressed`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}if(r.kind===`succeeded`){a(e,{type:`withdraw.settlement.succeeded`,flow:`withdraw`,tier:`flow`,payload:{settlement:r}});return}r.kind===`failed`&&a(e,{type:`withdraw.settlement.failed`,flow:`withdraw`,tier:`flow`,payload:{...n({reason:f(r.failureKind)}),kind:r.failureKind,...r.txHash?.value?{txHash:r.txHash.value}:{}}})}function f(e){return e===`slippage`?`Quote slipped before settlement landed.`:e===`insufficient-gas`?`Bridge gas budget exhausted before settlement.`:e===`execution-reverted`?`Destination transaction reverted on-chain.`:`Settlement failed.`}export{c as useWithdrawEmissions};
@@ -1,8 +1,9 @@
1
1
  import { StridgeEvent } from "../types/index.js";
2
+ import { SubscribeOptions } from "../bus/createBus.js";
2
3
 
3
4
  //#region src/events/hooks/useStridgeEvent.d.ts
4
5
  declare function useStridgeEvent<TType extends StridgeEvent["type"]>(type: TType, handler: (event: Extract<StridgeEvent, {
5
6
  type: TType;
6
- }>) => void): void;
7
+ }>) => void, options?: SubscribeOptions): void;
7
8
  //#endregion
8
9
  export { useStridgeEvent };
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a){let o=n(e),s=t(a);r(()=>{if(o)return o.bus.subscribeToEvent(i,e=>s.current(e))},[o,s,i])}export{i as useStridgeEvent};
1
+ "use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a,o){let s=n(e),c=t(a),l=o?.replayOpenSession??!1;r(()=>{if(s)return s.bus.subscribeToEvent(i,e=>c.current(e),{replayOpenSession:l})},[s,c,i,l])}export{i as useStridgeEvent};
@@ -1,5 +1,5 @@
1
1
  import { FlowEvent, StridgeEvent } from "../types/index.js";
2
- import { EventHandler } from "../bus/createBus.js";
2
+ import { EventHandler, SubscribeOptions } from "../bus/createBus.js";
3
3
 
4
4
  //#region src/events/hooks/useStridgeEventBus.d.ts
5
5
  /**
@@ -8,17 +8,18 @@ import { EventHandler } from "../bus/createBus.js";
8
8
  *
9
9
  * `subscribeToFlow` / `subscribeToFlowEvent` narrow the handler to `flow:*` events only
10
10
  * (headless-safe). `subscribeToAll` / `subscribeToEvent` are the firehose — they see every
11
- * event the kit emits regardless of tier.
11
+ * event the kit emits regardless of tier, and accept {@link SubscribeOptions} (e.g.
12
+ * `replayOpenSession`) since the `<flow>.opened` event they can replay is `tier: "ui"`.
12
13
  */
13
14
  interface PublicStridgeEventBus {
14
15
  subscribeToFlow: (handler: EventHandler<FlowEvent>) => () => void;
15
16
  subscribeToFlowEvent: <TType extends FlowEvent["type"]>(type: TType, handler: EventHandler<Extract<FlowEvent, {
16
17
  type: TType;
17
18
  }>>) => () => void;
18
- subscribeToAll: (handler: EventHandler<StridgeEvent>) => () => void;
19
+ subscribeToAll: (handler: EventHandler<StridgeEvent>, options?: SubscribeOptions) => () => void;
19
20
  subscribeToEvent: <TType extends StridgeEvent["type"]>(type: TType, handler: EventHandler<Extract<StridgeEvent, {
20
21
  type: TType;
21
- }>>) => () => void;
22
+ }>>, options?: SubscribeOptions) => () => void;
22
23
  }
23
24
  /**
24
25
  * Returns the provider-scoped bus accessor, or `null` when no `<StridgeProvider>` is
@@ -1,6 +1,7 @@
1
1
  import { StridgeEvent } from "../types/index.js";
2
+ import { SubscribeOptions } from "../bus/createBus.js";
2
3
 
3
4
  //#region src/events/hooks/useStridgeEvents.d.ts
4
- declare function useStridgeEvents(handler: (event: StridgeEvent) => void): void;
5
+ declare function useStridgeEvents(handler: (event: StridgeEvent) => void, options?: SubscribeOptions): void;
5
6
  //#endregion
6
7
  export { useStridgeEvents };
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i){let a=n(e),o=t(i);r(()=>{if(a)return a.bus.subscribeToAll(e=>o.current(e))},[a,o])}export{i as useStridgeEvents};
1
+ "use client";import{StridgeEventsContext as e}from"../context.js";import{useStableHandler as t}from"./useStableHandler.js";import{use as n,useEffect as r}from"react";function i(i,a){let o=n(e),s=t(i),c=a?.replayOpenSession??!1;r(()=>{if(o)return o.bus.subscribeToAll(e=>s.current(e),{replayOpenSession:c})},[o,s,c])}export{i as useStridgeEvents};
@@ -1,3 +1,4 @@
1
+ import { KIT_VERSION } from "../version.js";
1
2
  import { FlowIdKey } from "./bus/flowIdRegistry.js";
2
3
  import { useCurrentFlowId } from "./hooks/useCurrentFlowId.js";
3
4
  import { FailureCode, FailurePayloadBase, StridgeEventBase, StridgeEventFlow, StridgeEventTier } from "./types/envelope.js";
@@ -6,10 +7,11 @@ import { DepositAmountChangedEvent, DepositAmountSubmittedEvent, DepositAssetCli
6
7
  import { KitEvent, KitSupportClickedEvent, KitTermsClickedEvent } from "./types/kit.js";
7
8
  import { WithdrawAmountChangedEvent, WithdrawBreakdownClickedEvent, WithdrawCancelPhase, WithdrawCancelledEvent, WithdrawClosedEvent, WithdrawEvent, WithdrawFlowEvent, WithdrawMaxClickedEvent, WithdrawOpenedEvent, WithdrawQuoteExpiredEvent, WithdrawQuoteFailedEvent, WithdrawQuoteRequestedEvent, WithdrawQuoteResolvedEvent, WithdrawReceiveChainChangedEvent, WithdrawReceiveTokenChangedEvent, WithdrawRecipientChangedEvent, WithdrawSettlementFailedEvent, WithdrawSettlementFailurePayload, WithdrawSettlementProgressedEvent, WithdrawSettlementSucceededEvent, WithdrawStepChangedEvent, WithdrawSubmissionBroadcastEvent, WithdrawSubmissionConfirmedEvent, WithdrawSubmissionDeclinedEvent, WithdrawSubmissionFailedEvent, WithdrawSubmitClickedEvent, WithdrawUiEvent } from "./types/withdraw.js";
8
9
  import { FlowEvent, FlowEventType, StridgeEvent, StridgeEventType, UiEvent, UiEventType } from "./types/index.js";
10
+ import { EventHandler, SubscribeOptions } from "./bus/createBus.js";
9
11
  import { useStridgeEvent } from "./hooks/useStridgeEvent.js";
10
- import { EventHandler } from "./bus/createBus.js";
11
12
  import { PublicStridgeEventBus, useStridgeEventBus } from "./hooks/useStridgeEventBus.js";
12
13
  import { useStridgeEvents } from "./hooks/useStridgeEvents.js";
13
14
  import { useStridgeFlowEvent } from "./hooks/useStridgeFlowEvent.js";
14
15
  import { useStridgeFlowEvents } from "./hooks/useStridgeFlowEvents.js";
15
- export { type ActivityClosedEvent, type ActivityEvent, type ActivityOpenedEvent, type ActivitySelectionVia, type ActivitySettlementSelectedEvent, type ActivityStepChangedEvent, type ActivityUiEvent, type DepositAmountChangedEvent, type DepositAmountSubmittedEvent, type DepositAssetClickedEvent, type DepositBackClickedEvent, type DepositCancelPhase, type DepositCancelledEvent, type DepositClosedEvent, type DepositConfirmClickedEvent, type DepositEvent, type DepositFlowEvent, type DepositMaxClickedEvent, type DepositMethodClickedEvent, type DepositOpenedEvent, type DepositQuoteExpiredEvent, type DepositQuoteFailedEvent, type DepositQuoteRequestInput, type DepositQuoteRequestedEvent, type DepositQuoteResolvedEvent, type DepositSettlementFailedEvent, type DepositSettlementFailurePayload, type DepositSettlementProgressedEvent, type DepositSettlementResumedEvent, type DepositSettlementSucceededEvent, type DepositStepChangedEvent, type DepositSubmissionBroadcastEvent, type DepositSubmissionConfirmedEvent, type DepositSubmissionDeclinedEvent, type DepositSubmissionFailedEvent, type DepositTransferAddressCopiedEvent, type DepositTransferChainChangedEvent, type DepositTransferTokenChangedEvent, type DepositUiEvent, type EventHandler, type FailureCode, type FailurePayloadBase, type FlowEvent, type FlowEventType, type FlowIdKey, type KitEvent, type KitSupportClickedEvent, type KitTermsClickedEvent, type PublicStridgeEventBus, type StridgeEvent, type StridgeEventBase, type StridgeEventFlow, type StridgeEventTier, type StridgeEventType, type UiEvent, type UiEventType, type WithdrawAmountChangedEvent, type WithdrawBreakdownClickedEvent, type WithdrawCancelPhase, type WithdrawCancelledEvent, type WithdrawClosedEvent, type WithdrawEvent, type WithdrawFlowEvent, type WithdrawMaxClickedEvent, type WithdrawOpenedEvent, type WithdrawQuoteExpiredEvent, type WithdrawQuoteFailedEvent, type WithdrawQuoteRequestedEvent, type WithdrawQuoteResolvedEvent, type WithdrawReceiveChainChangedEvent, type WithdrawReceiveTokenChangedEvent, type WithdrawRecipientChangedEvent, type WithdrawSettlementFailedEvent, type WithdrawSettlementFailurePayload, type WithdrawSettlementProgressedEvent, type WithdrawSettlementSucceededEvent, type WithdrawStepChangedEvent, type WithdrawSubmissionBroadcastEvent, type WithdrawSubmissionConfirmedEvent, type WithdrawSubmissionDeclinedEvent, type WithdrawSubmissionFailedEvent, type WithdrawSubmitClickedEvent, type WithdrawUiEvent, useCurrentFlowId, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents };
16
+ import { RedactEventOptions, redactEvent } from "./redact.js";
17
+ export { type ActivityClosedEvent, type ActivityEvent, type ActivityOpenedEvent, type ActivitySelectionVia, type ActivitySettlementSelectedEvent, type ActivityStepChangedEvent, type ActivityUiEvent, type DepositAmountChangedEvent, type DepositAmountSubmittedEvent, type DepositAssetClickedEvent, type DepositBackClickedEvent, type DepositCancelPhase, type DepositCancelledEvent, type DepositClosedEvent, type DepositConfirmClickedEvent, type DepositEvent, type DepositFlowEvent, type DepositMaxClickedEvent, type DepositMethodClickedEvent, type DepositOpenedEvent, type DepositQuoteExpiredEvent, type DepositQuoteFailedEvent, type DepositQuoteRequestInput, type DepositQuoteRequestedEvent, type DepositQuoteResolvedEvent, type DepositSettlementFailedEvent, type DepositSettlementFailurePayload, type DepositSettlementProgressedEvent, type DepositSettlementResumedEvent, type DepositSettlementSucceededEvent, type DepositStepChangedEvent, type DepositSubmissionBroadcastEvent, type DepositSubmissionConfirmedEvent, type DepositSubmissionDeclinedEvent, type DepositSubmissionFailedEvent, type DepositTransferAddressCopiedEvent, type DepositTransferChainChangedEvent, type DepositTransferTokenChangedEvent, type DepositUiEvent, type EventHandler, type FailureCode, type FailurePayloadBase, type FlowEvent, type FlowEventType, type FlowIdKey, KIT_VERSION, type KitEvent, type KitSupportClickedEvent, type KitTermsClickedEvent, type PublicStridgeEventBus, type RedactEventOptions, type StridgeEvent, type StridgeEventBase, type StridgeEventFlow, type StridgeEventTier, type StridgeEventType, type SubscribeOptions, type UiEvent, type UiEventType, type WithdrawAmountChangedEvent, type WithdrawBreakdownClickedEvent, type WithdrawCancelPhase, type WithdrawCancelledEvent, type WithdrawClosedEvent, type WithdrawEvent, type WithdrawFlowEvent, type WithdrawMaxClickedEvent, type WithdrawOpenedEvent, type WithdrawQuoteExpiredEvent, type WithdrawQuoteFailedEvent, type WithdrawQuoteRequestedEvent, type WithdrawQuoteResolvedEvent, type WithdrawReceiveChainChangedEvent, type WithdrawReceiveTokenChangedEvent, type WithdrawRecipientChangedEvent, type WithdrawSettlementFailedEvent, type WithdrawSettlementFailurePayload, type WithdrawSettlementProgressedEvent, type WithdrawSettlementSucceededEvent, type WithdrawStepChangedEvent, type WithdrawSubmissionBroadcastEvent, type WithdrawSubmissionConfirmedEvent, type WithdrawSubmissionDeclinedEvent, type WithdrawSubmissionFailedEvent, type WithdrawSubmitClickedEvent, type WithdrawUiEvent, redactEvent, useCurrentFlowId, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents };
@@ -1 +1 @@
1
- import{useCurrentFlowId as e}from"./hooks/useCurrentFlowId.js";import{useStridgeEvent as t}from"./hooks/useStridgeEvent.js";import{useStridgeEventBus as n}from"./hooks/useStridgeEventBus.js";import{useStridgeEvents as r}from"./hooks/useStridgeEvents.js";import{useStridgeFlowEvent as i}from"./hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as a}from"./hooks/useStridgeFlowEvents.js";import"./hooks/index.js";export{e as useCurrentFlowId,t as useStridgeEvent,n as useStridgeEventBus,r as useStridgeEvents,i as useStridgeFlowEvent,a as useStridgeFlowEvents};
1
+ import{KIT_VERSION as e}from"../version.js";import{useCurrentFlowId as t}from"./hooks/useCurrentFlowId.js";import{useStridgeEvent as n}from"./hooks/useStridgeEvent.js";import{useStridgeEventBus as r}from"./hooks/useStridgeEventBus.js";import{useStridgeEvents as i}from"./hooks/useStridgeEvents.js";import{useStridgeFlowEvent as a}from"./hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as o}from"./hooks/useStridgeFlowEvents.js";import"./hooks/index.js";import{redactEvent as s}from"./redact.js";export{e as KIT_VERSION,s as redactEvent,t as useCurrentFlowId,n as useStridgeEvent,r as useStridgeEventBus,i as useStridgeEvents,a as useStridgeFlowEvent,o as useStridgeFlowEvents};
@@ -1 +1 @@
1
- function e({bus:e,flowIds:t,metadata:n},r){let i=null;if(r.flow!==`kit`&&(i=t.current(r.flow),i===null)){process.env.NODE_ENV!==`production`&&console.warn(`[stridge/kit] tried to emit "${r.type}" but no active "${r.flow}" flow — the event was dropped. This usually means an emit fired before "opened" or after the terminal event.`);return}let a=r.flow===`kit`?{}:n.read(r.flow),o={type:r.type,flow:r.flow,tier:r.tier,timestamp:Date.now(),flowId:i,payload:r.payload,metadata:a};e.emit(o)}function t(t,n,i,a){r(n,a.flow,`openFlowSession`),t.flowIds.open(n),t.metadata.snapshot(n,i),e(t,{...a,flow:n})}function n(t,n,i){r(n,i.flow,`closeFlowSession`),e(t,{...i,flow:n}),t.flowIds.close(n),t.metadata.clear(n)}function r(e,t,n){process.env.NODE_ENV!==`production`&&e!==t&&console.error(`[stridge/kit] ${n}() called with flow="${e}" but partial.flow="${t}". Override applied (envelope will carry "${e}") but this is a sign of a copy-paste bug in the emit site.`)}export{n as closeFlowSession,t as openFlowSession,e as publishEvent};
1
+ function e({bus:e,flowIds:t,metadata:n},r){let i=null;if(r.flow!==`kit`&&(i=t.current(r.flow),i===null))return process.env.NODE_ENV!==`production`&&console.warn(`[stridge/kit] tried to emit "${r.type}" but no active "${r.flow}" flow — the event was dropped. This usually means an emit fired before "opened" or after the terminal event.`),null;let a=r.flow===`kit`?{}:n.read(r.flow),o={type:r.type,flow:r.flow,tier:r.tier,timestamp:Date.now(),flowId:i,payload:r.payload,metadata:a};return e.emit(o),o}function t(t,n,i,a){r(n,a.flow,`openFlowSession`),t.flowIds.open(n),t.metadata.snapshot(n,i);let o=e(t,{...a,flow:n});o&&t.bus.retainOpenSession(o)}function n(t,n,i){r(n,i.flow,`closeFlowSession`),e(t,{...i,flow:n}),t.bus.releaseOpenSession(n),t.flowIds.close(n),t.metadata.clear(n)}function r(e,t,n){process.env.NODE_ENV!==`production`&&e!==t&&console.error(`[stridge/kit] ${n}() called with flow="${e}" but partial.flow="${t}". Override applied (envelope will carry "${e}") but this is a sign of a copy-paste bug in the emit site.`)}export{n as closeFlowSession,t as openFlowSession,e as publishEvent};
@@ -0,0 +1,34 @@
1
+ import { StridgeEvent } from "./types/index.js";
2
+
3
+ //#region src/events/redact.d.ts
4
+ /** Options for {@link redactEvent}. Both default to `true`. */
5
+ interface RedactEventOptions {
6
+ /**
7
+ * Mask EVM-address-like substrings (`0x` + 40 hex) anywhere in the payload to
8
+ * `0x1234…cdef`. Only EVM addresses are matched — the pattern is precise enough to avoid
9
+ * mangling unrelated hex (tx hashes are 64 hex and are left intact). Defaults to `true`.
10
+ */
11
+ maskAddresses?: boolean;
12
+ /**
13
+ * Drop `payload.cause` (the debug-only raw error). Defaults to `true`. Set `false` only if
14
+ * the destination is an error tracker that should keep the stack and you accept the
15
+ * forwarded contents.
16
+ */
17
+ dropCause?: boolean;
18
+ }
19
+ /**
20
+ * Return a privacy-redacted deep copy of `event`, safe to forward to a third-party analytics
21
+ * backend. Drops `payload.cause` and masks EVM addresses by default; preserves `type`, `flow`,
22
+ * `tier`, `timestamp`, `flowId`, and consumer-supplied `metadata`. The input is never mutated.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * useStridgeEvents((e) => {
27
+ * const safe = redactEvent(e);
28
+ * mixpanel.track(safe.type, { flowId: safe.flowId, ...safe.payload });
29
+ * });
30
+ * ```
31
+ */
32
+ declare function redactEvent<E extends StridgeEvent>(event: E, options?: RedactEventOptions): E;
33
+ //#endregion
34
+ export { RedactEventOptions, redactEvent };
@@ -0,0 +1 @@
1
+ const e=/0x[0-9a-fA-F]{40}(?![0-9a-fA-F])/g;function t(t){return t.replace(e,e=>`${e.slice(0,6)}…${e.slice(-4)}`)}function n(e,r,i,a){if(typeof e==`string`)return r.maskAddresses?t(e):e;if(typeof e!=`object`||!e||a>=8)return e;let o=i.get(e);if(o!==void 0)return o;if(Array.isArray(e)){let t=[];i.set(e,t);for(let o of e)t.push(n(o,r,i,a+1));return t}let s={};i.set(e,s);for(let[t,o]of Object.entries(e)){if(t===`cause`){if(r.dropCause)continue;s[t]=o;continue}s[t]=n(o,r,i,a+1)}return s}function r(e,t){let r={maskAddresses:t?.maskAddresses??!0,dropCause:t?.dropCause??!0},i=n(e.payload,r,new WeakMap,0);return{...e,payload:i}}export{r as redactEvent};
@@ -1 +1 @@
1
- "use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as s}from"../driver/context.js";import{initialState as c,reducer as l}from"./reducer.js";import{resolveAssetById as u}from"./resolveAssetById.js";import{createContext as d,use as f,useCallback as p,useEffect as m,useMemo as h,useReducer as g,useRef as _}from"react";import{jsx as v}from"react/jsx-runtime";const y={id:`ELhVSL`,message:`Failed to submit deposit.`},b={id:`Ej5HL9`,message:`Signature declined. Please try again.`},x=d(null);x.displayName=`GatewayControllerStateContext`;const S=d(null);S.displayName=`GatewayControllerStableContext`;function C(){let e=f(x),t=f(S);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function w(){let e=f(S);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function T(){return f(S)}const E=d(void 0);E.displayName=`DepositMethodsConfigContext`;function D(){return f(E)}function O(e){let t=D();return h(()=>t?e.filter(e=>e.value===`cash`?t.cashRail?.disabled!==!0:!0):e,[e,t])}function k(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function A(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function j(){return w().actions}function M({methodsConfig:t,children:n}){let r=s(),a=e(),[o,u]=g(l,c),d=P(o,u,r,a);F(o,u,r),I(o,u,r,a);let f=i(o),p=N(o,u,r,d,t);return v(E,{value:t,children:v(S,{value:h(()=>({dispatch:u,controller:p,actions:d}),[u,p,d]),children:v(x,{value:h(()=>({state:o,effectiveState:f}),[o,f]),children:n})})})}function N(e,t,n,r,i){let a=_(n);a.current=n;let o=_(i);o.current=i;let s=p(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=u(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=p(()=>{t({type:`CLOSE`})},[t]);return h(()=>({open:s,close:c,actions:r}),[s,c,r])}function P(e,r,i,o){let s=_(e);s.current=e;let c=_(i);c.current=i;let l=_(o);l.current=o;let u=_(r);u.current=r;let{i18n:d}=t(),f=_(d);f.current=d;let m=p((e,t)=>{let r=c.current,i=new AbortController,o=R(e,t);r.submitDeposit(o,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(y));if(a(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(b)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),g=p(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),v=p(e=>{u.current({type:`CASH_METHOD_SELECTED`,cashMethod:e})},[]),x=p(e=>{u.current({type:`CASH_AMOUNT_CONFIRMED`,amount:e})},[]),S=p(()=>{u.current({type:`CASH_METHOD_READY`})},[]),C=p(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),w=p(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),T=p(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),m(n,r)},[m]),E=p(()=>{u.current({type:`BACK`})},[]),D=p(()=>{u.current({type:`CLOSE`})},[]),O=p(()=>{u.current({type:`SUCCESS_DONE`})},[]),k=p(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),A=p((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),j=p((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),M=p(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),N=p(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),P=p(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return h(()=>({selectMethod:g,selectCashMethod:v,confirmCashAmount:x,cashMethodReady:S,confirmAsset:C,confirmAmount:w,confirmDeposit:T,back:E,close:D,successDone:O,tryAgain:k,resumeToProcessing:A,resumeToSuccess:j,resumeToError:M,openActivity:N,selectSettlement:P}),[g,v,x,S,C,w,T,E,D,O,k,A,j,M,N,P])}function F(e,t,r){m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=L(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,r,t]),m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function I(e,t,n,i){let a=_(i);a.current=i;let s=e.name===`processing`?e.ctx.tx:void 0;o(n,s?{tx:s}:void 0,s?.hash),m(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{a.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let c=e.name===`activityList`||e.name===`activityDetail`;m(()=>{if(!c||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[c,i]),m(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||c||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,c,n]);let l=_(e);l.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}l.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let u=_(null);m(()=>{let e=()=>{let e=n.getSnapshot(),r=l.current,i=e.quote;i.status!==u.current&&(u.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name}}))},r=n.subscribe(e);return e(),r},[n,t])}function L(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function R(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{M as GatewayController,C as useControllerContext,j as useDepositActions,A as useDepositEffectiveState,D as useDepositMethodsConfig,k as useDepositState,O as useEnabledRails,T as useOptionalStableControllerContext,w as useStableControllerContext};
1
+ "use client";import{useOptionalActivityDriverInstance as e}from"../../activity/driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useDepositDriverInstance as s}from"../driver/context.js";import{initialState as c,reducer as l}from"./reducer.js";import{resolveAssetById as u}from"./resolveAssetById.js";import{createContext as d,use as f,useCallback as p,useEffect as m,useMemo as h,useReducer as g,useRef as _}from"react";import{jsx as v}from"react/jsx-runtime";const y={id:`ELhVSL`,message:`Failed to submit deposit.`},b={id:`Ej5HL9`,message:`Signature declined. Please try again.`},x=d(null);x.displayName=`GatewayControllerStateContext`;const S=d(null);S.displayName=`GatewayControllerStableContext`;function C(){let e=f(x),t=f(S);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function w(){let e=f(S);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function T(){return f(S)}const E=d(void 0);E.displayName=`DepositMethodsConfigContext`;function D(){return f(E)}const O=d(!1);O.displayName=`CashRailUnlockedContext`;function k(){return f(O)}function A(e){let t=D();return h(()=>t?e.filter(e=>e.value===`cash`?t.cashRail?.disabled!==!0:!0):e,[e,t])}function j(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function M(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function N(){return w().actions}function P({methodsConfig:t,cashRailUnlocked:n=!1,children:r}){let a=s(),o=e(),[u,d]=g(l,c),f=I(u,d,a,o);L(u,d,a),R(u,d,a,o);let p=i(u),m=F(u,d,a,f,t);return v(E,{value:t,children:v(O,{value:n,children:v(S,{value:h(()=>({dispatch:d,controller:m,actions:f}),[d,m,f]),children:v(x,{value:h(()=>({state:u,effectiveState:p}),[u,p]),children:r})})})})}function F(e,t,n,r,i){let a=_(n);a.current=n;let o=_(i);o.current=i;let s=p(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=u(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=p(()=>{t({type:`CLOSE`})},[t]);return h(()=>({open:s,close:c,actions:r}),[s,c,r])}function I(e,r,i,o){let s=_(e);s.current=e;let c=_(i);c.current=i;let l=_(o);l.current=o;let u=_(r);u.current=r;let{i18n:d}=t(),f=_(d);f.current=d;let m=p((e,t)=>{let r=c.current,i=new AbortController,o=B(e,t);r.submitDeposit(o,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(y));if(a(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(b)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),g=p(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),v=p(e=>{u.current({type:`CASH_METHOD_SELECTED`,cashMethod:e})},[]),x=p(e=>{u.current({type:`CASH_AMOUNT_CONFIRMED`,amount:e})},[]),S=p(()=>{u.current({type:`CASH_METHOD_READY`})},[]),C=p(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),w=p(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),T=p(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),m(n,r)},[m]),E=p(()=>{u.current({type:`BACK`})},[]),D=p(()=>{u.current({type:`CLOSE`})},[]),O=p(()=>{u.current({type:`SUCCESS_DONE`})},[]),k=p(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),A=p((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),j=p((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),M=p(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),N=p(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),P=p(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return h(()=>({selectMethod:g,selectCashMethod:v,confirmCashAmount:x,cashMethodReady:S,confirmAsset:C,confirmAmount:w,confirmDeposit:T,back:E,close:D,successDone:O,tryAgain:k,resumeToProcessing:A,resumeToSuccess:j,resumeToError:M,openActivity:N,selectSettlement:P}),[g,v,x,S,C,w,T,E,D,O,k,A,j,M,N,P])}function L(e,t,r){m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=z(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,r,t]),m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function R(e,t,n,i){let a=_(i);a.current=i;let s=e.name===`processing`?e.ctx.tx:void 0;o(n,s?{tx:s}:void 0,s?.hash),m(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{a.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let c=e.name===`activityList`||e.name===`activityDetail`;m(()=>{if(!c||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[c,i]),m(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||c||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,c,n]);let l=_(e);l.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}l.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let u=_(null);m(()=>{let e=()=>{let e=n.getSnapshot(),r=l.current,i=e.quote;i.status!==u.current&&(u.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name,cause:i.error}}))},r=n.subscribe(e);return e(),r},[n,t])}function z(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function B(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{P as GatewayController,k as useCashRailUnlocked,C as useControllerContext,N as useDepositActions,M as useDepositEffectiveState,D as useDepositMethodsConfig,j as useDepositState,A as useEnabledRails,T as useOptionalStableControllerContext,w as useStableControllerContext};
@@ -1 +1 @@
1
- "use client";import{useOptionalKitStorage as e}from"../../../../storage/context.js";import"../../../../storage/index.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useDepositActions as r,useDepositEffectiveState as i,useDepositMethodsConfig as a,useEnabledRails as o}from"../../orchestrator/controller.js";import{ApplePayIcon as s}from"../../../../shared/icons/ApplePayIcon.js";import{BitcoinIcon as c}from"../../../../shared/icons/BitcoinIcon.js";import{CardIcon as ee}from"../../../../shared/icons/CardIcon.js";import{CashIcon as te}from"../../../../shared/icons/CashIcon.js";import{GooglePayIcon as l}from"../../../../shared/icons/GooglePayIcon.js";import{QrCodeIcon as u}from"../../../../shared/icons/QrCodeIcon.js";import{WalletIcon as ne}from"../../../../shared/icons/WalletIcon.js";import"../../../../icons/index.js";import{DialogShell as d}from"../../../../shared/dialog/DialogShell.js";import{Image as f}from"../../../../shared/ui/Image/Image.js";import{Skeleton as p}from"../../../../shared/ui/Skeleton/Skeleton.js";import"../../../../shared/ui/Skeleton/index.js";import{TokenLogo as m}from"../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../shared/ui/TokenLogo/index.js";import"../../../../ui/index.js";import{Deposit as h}from"./compound/Deposit.js";import"./compound/index.js";import{useMemo as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";const b={width:18,height:18,"aria-hidden":!0},x={card:`card`,"apple-pay":`applePay`,"google-pay":`googlePay`},S=`deposit.last-rail`;function C({children:d,...f}){let m=n(),C=i().name,{selectMethod:w,selectCashMethod:T}=r(),E=a(),D=e(),{_:O}=t(),k=m.wallet,A=k.status===`ready`||k.status===`stale`?k.payload:void 0,j=A!==void 0,M=m.brand,N=M.status===`ready`||M.status===`stale`?M.payload:void 0,P=m.addresses,F=P.status===`ready`||P.status===`stale`?P.payload:[],I=m.balances.status===`error`,L=!A?.balanceTotalUsd?.formatted&&!I,R=!!m.brand,z=N?.name?O({id:`ogD_nm`,message:`Deposit to {0}`,values:{0:N.name}}):void 0,B=g(()=>re(F),[F]),V=E?.wallet,H=E?.transfer,U=E?.card,W=E?.applePay,G=E?.googlePay,ie=E?.cashRail?.enabled===!0,K=m.cashMethods,q=K?.status,J=q===`ready`||q===`stale`?K?.payload:void 0,Y=ie&&J!==void 0,ae=g(()=>{let e=!j||L,t=V?.disabled??!1,n=e||t,r=t?V?.disabledHint:void 0,i=(()=>{if(t)return r;if(!j)return O({id:`5AApJw`,message:`Connect a wallet to continue`});if(A?.balanceTotalUsd?.formatted)return A.balanceTotalUsd.formatted;if(!I)return v(p,{width:56,height:12})})(),a=[{id:`wallet`,title:O({id:`sb9Y58`,message:`Wallet`}),icon:v(ne,{...b}),...A&&!t?{titleAdornment:A.address.formatted}:{},...i===void 0?{}:{meta:i},recommended:!0,disabled:n,onSelect:n?void 0:()=>w(`wallet`)}];if(R){let e=H?.disabled??!1,t=e?H?.disabledHint:void 0,n=e?t:[O({id:`qtoOYG`,message:`No limit`}),O({id:`D79cZK`,message:`Instant`})];a.push({id:`transfer`,title:O({id:`3dqPLT`,message:`Transfer Crypto`}),icon:v(u,{...b}),...n===void 0?{}:{meta:n},...B?{trailing:B}:{},disabled:e,onSelect:e?void 0:()=>w(`transfer`)})}return a},[A,I,L,j,R,B,V,H,w,O]),X=g(()=>{let e=(e,n)=>{if(e!==void 0)return e;if(!n)return;let r=[];n.limit?.formatted&&r.push(O({id:`jtKSW-`,message:`{0} limit`,values:{0:n.limit.formatted}}));let i=t(n.processingTime);return i&&r.push(i),r.length>0?r:void 0},t=e=>{if(e)return e.value===0?O({id:`D79cZK`,message:`Instant`}):e.formatted||void 0},n=(t,n,r,i,a)=>{let o=i?.disabled??!1,s=e(o?i?.disabledHint:void 0,a);return{id:t,title:n,icon:r,...s===void 0?{}:{meta:s},metaEmphasis:`uniform`,disabled:o,onSelect:o?void 0:()=>T(x[t])}};return{card:n(`card`,O({id:`kryGs-`,message:`Card`}),v(ee,{...b}),U,J?.card),applePay:n(`apple-pay`,O({id:`6ws9A3`,message:`Apple Pay`}),v(s,{...b}),W,J?.applePay),googlePay:n(`google-pay`,O({id:`ybKOj4`,message:`Google Pay`}),v(l,{...b}),G,J?.googlePay)}},[U,W,G,J,T,O]),Z=o(g(()=>{let e=[{value:`crypto`,label:O({id:`CS69m9`,message:`Use Crypto`}),icon:v(c,{width:12,height:12,"aria-hidden":!0})}];return Y&&e.push({value:`cash`,label:O({id:`LSs4cd`,message:`Use Cash`}),icon:v(te,{width:12,height:12,"aria-hidden":!0})}),e},[O,Y]));if(C!==`deposit`)return null;let Q={crypto:v(h.Methods,{}),cash:y(h.Methods,{children:[v(h.MethodSection,{label:O({id:`y1ypMV`,message:`Most popular`}),children:v(h.Method,{...X.card})}),y(h.MethodSection,{label:O({id:`xOUCt3`,message:`Other options`}),children:[v(h.Method,{...X.applePay}),v(h.Method,{...X.googlePay})]})]})},[$]=Z,oe=D?.get(S)??null,se=Z.find(e=>e.value===oe)?.value??$?.value,ce=y(_,{children:[v(h.Header,{}),v(h.Body,{children:Z.length>=2?v(h.RailPicker,{defaultValue:se,rails:Z,onValueChange:e=>D?.set(S,e),children:Z.map(e=>v(h.Rail,{value:e.value,children:Q[e.value]},e.value))}):Q[$?.value??`crypto`]})]});return v(h,{...f,...z?{title:z}:{},methods:ae,children:d??ce})}function re(e){if(e.length!==0)return v(f.Group,{max:4,overflow:Math.max(0,e.length-4),size:`md`,children:e.map(e=>v(m,{isNative:!0,symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},hideChainBadge:!0},e.eip155Id??e.networkName))})}function w({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return v(d,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:v(C,{...i})})}(function(e){e.Dialog=w,e.Header=h.Header,e.Body=h.Body,e.Methods=h.Methods,e.Method=h.Method,e.MethodSection=h.MethodSection,e.Steps=h.Steps,e.Step=h.Step,e.RailPicker=h.RailPicker,e.Rail=h.Rail})(C||={});export{C as Deposit};
1
+ "use client";import{useOptionalKitStorage as e}from"../../../../storage/context.js";import"../../../../storage/index.js";import{useLingui as t}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as n}from"../../driver/context.js";import{useCashRailUnlocked as r,useDepositActions as i,useDepositEffectiveState as a,useDepositMethodsConfig as o,useEnabledRails as s}from"../../orchestrator/controller.js";import{ApplePayIcon as c}from"../../../../shared/icons/ApplePayIcon.js";import{BitcoinIcon as l}from"../../../../shared/icons/BitcoinIcon.js";import{CardIcon as ee}from"../../../../shared/icons/CardIcon.js";import{CashIcon as u}from"../../../../shared/icons/CashIcon.js";import{GooglePayIcon as d}from"../../../../shared/icons/GooglePayIcon.js";import{QrCodeIcon as te}from"../../../../shared/icons/QrCodeIcon.js";import{WalletIcon as ne}from"../../../../shared/icons/WalletIcon.js";import"../../../../icons/index.js";import{DialogShell as f}from"../../../../shared/dialog/DialogShell.js";import{Image as p}from"../../../../shared/ui/Image/Image.js";import{Skeleton as re}from"../../../../shared/ui/Skeleton/Skeleton.js";import"../../../../shared/ui/Skeleton/index.js";import{TokenLogo as m}from"../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../shared/ui/TokenLogo/index.js";import"../../../../ui/index.js";import{Deposit as h}from"./compound/Deposit.js";import"./compound/index.js";import{useMemo as g}from"react";import{Fragment as ie,jsx as _,jsxs as v}from"react/jsx-runtime";const y={width:18,height:18,"aria-hidden":!0},ae={card:`card`,"apple-pay":`applePay`,"google-pay":`googlePay`},b=`deposit.last-rail`;function x({children:f,...p}){let m=n(),x=a().name,{selectMethod:S,selectCashMethod:C}=i(),w=o(),T=r(),E=e(),{_:D}=t(),O=m.wallet,k=O.status===`ready`||O.status===`stale`?O.payload:void 0,A=k!==void 0,j=m.brand,M=j.status===`ready`||j.status===`stale`?j.payload:void 0,N=m.addresses,P=N.status===`ready`||N.status===`stale`?N.payload:[],F=m.balances.status===`error`,I=!k?.balanceTotalUsd?.formatted&&!F,L=!!m.brand,R=M?.name?D({id:`ogD_nm`,message:`Deposit to {0}`,values:{0:M.name}}):void 0,z=g(()=>oe(P),[P]),B=w?.wallet,V=w?.transfer,H=w?.card,U=w?.applePay,W=w?.googlePay,G=w?.cashRail?.enabled===!0,K=m.cashMethods,q=K?.status,J=q===`ready`||q===`stale`?K?.payload:void 0,Y=T&&G&&J!==void 0,se=g(()=>{let e=!A||I,t=B?.disabled??!1,n=e||t,r=t?B?.disabledHint:void 0,i=(()=>{if(t)return r;if(!A)return D({id:`5AApJw`,message:`Connect a wallet to continue`});if(k?.balanceTotalUsd?.formatted)return k.balanceTotalUsd.formatted;if(!F)return _(re,{width:56,height:12})})(),a=[{id:`wallet`,title:D({id:`sb9Y58`,message:`Wallet`}),icon:_(ne,{...y}),...k&&!t?{titleAdornment:k.address.formatted}:{},...i===void 0?{}:{meta:i},recommended:!0,disabled:n,onSelect:n?void 0:()=>S(`wallet`)}];if(L){let e=V?.disabled??!1,t=e?V?.disabledHint:void 0,n=e?t:[D({id:`qtoOYG`,message:`No limit`}),D({id:`D79cZK`,message:`Instant`})];a.push({id:`transfer`,title:D({id:`3dqPLT`,message:`Transfer Crypto`}),icon:_(te,{...y}),...n===void 0?{}:{meta:n},...z?{trailing:z}:{},disabled:e,onSelect:e?void 0:()=>S(`transfer`)})}return a},[k,F,I,A,L,z,B,V,S,D]),X=g(()=>{let e=(e,n)=>{if(e!==void 0)return e;if(!n)return;let r=[];n.limit?.formatted&&r.push(D({id:`jtKSW-`,message:`{0} limit`,values:{0:n.limit.formatted}}));let i=t(n.processingTime);return i&&r.push(i),r.length>0?r:void 0},t=e=>{if(e)return e.value===0?D({id:`D79cZK`,message:`Instant`}):e.formatted||void 0},n=(t,n,r,i,a)=>{let o=i?.disabled??!1,s=e(o?i?.disabledHint:void 0,a);return{id:t,title:n,icon:r,...s===void 0?{}:{meta:s},metaEmphasis:`uniform`,disabled:o,onSelect:o?void 0:()=>C(ae[t])}};return{card:n(`card`,D({id:`kryGs-`,message:`Card`}),_(ee,{...y}),H,J?.card),applePay:n(`apple-pay`,D({id:`6ws9A3`,message:`Apple Pay`}),_(c,{...y}),U,J?.applePay),googlePay:n(`google-pay`,D({id:`ybKOj4`,message:`Google Pay`}),_(d,{...y}),W,J?.googlePay)}},[H,U,W,J,C,D]),Z=s(g(()=>{let e=[{value:`crypto`,label:D({id:`CS69m9`,message:`Use Crypto`}),icon:_(l,{width:12,height:12,"aria-hidden":!0})}];return Y&&e.push({value:`cash`,label:D({id:`LSs4cd`,message:`Use Cash`}),icon:_(u,{width:12,height:12,"aria-hidden":!0})}),e},[D,Y]));if(x!==`deposit`)return null;let Q={crypto:_(h.Methods,{}),cash:v(h.Methods,{children:[_(h.MethodSection,{label:D({id:`y1ypMV`,message:`Most popular`}),children:_(h.Method,{...X.card})}),v(h.MethodSection,{label:D({id:`xOUCt3`,message:`Other options`}),children:[_(h.Method,{...X.applePay}),_(h.Method,{...X.googlePay})]})]})},[$]=Z,ce=E?.get(b)??null,le=Z.find(e=>e.value===ce)?.value??$?.value,ue=v(ie,{children:[_(h.Header,{}),_(h.Body,{children:Z.length>=2?_(h.RailPicker,{defaultValue:le,rails:Z,onValueChange:e=>E?.set(b,e),children:Z.map(e=>_(h.Rail,{value:e.value,children:Q[e.value]},e.value))}):Q[$?.value??`crypto`]})]});return _(h,{...p,...R?{title:R}:{},methods:se,children:f??ue})}function oe(e){if(e.length!==0)return _(p.Group,{max:4,overflow:Math.max(0,e.length-4),size:`md`,children:e.map(e=>_(m,{isNative:!0,symbol:e.networkName,...e.eip155Id?{chainId:Number(e.eip155Id)}:{},...e.chainLogoUrl?{logoUrl:e.chainLogoUrl}:{},hideChainBadge:!0},e.eip155Id??e.networkName))})}function S({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return _(f,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:_(x,{...i})})}(function(e){e.Dialog=S,e.Header=h.Header,e.Body=h.Body,e.Methods=h.Methods,e.Method=h.Method,e.MethodSection=h.MethodSection,e.Steps=h.Steps,e.Step=h.Step,e.RailPicker=h.RailPicker,e.Rail=h.Rail})(x||={});export{x as Deposit};
package/dist/index.d.ts CHANGED
@@ -21,16 +21,19 @@ import { createKitStorage } from "./storage/createKitStorage.js";
21
21
  import { DEFAULT_KIT_STORAGE_NAMESPACE, KitStorageProvider, useKitStorage, useKitStorageValue, useOptionalKitStorage } from "./storage/context.js";
22
22
  import { useActivitySnapshot } from "./flows/activity/driver/context.js";
23
23
  import { StridgeEnvironment } from "./drivers/stridge/types.js";
24
+ import { KIT_VERSION } from "./version.js";
24
25
  import { FlowIdKey } from "./events/bus/flowIdRegistry.js";
25
26
  import { useCurrentFlowId } from "./events/hooks/useCurrentFlowId.js";
26
27
  import { ActivityActions, ActivityController, ActivityState, ActivityStateName } from "./flows/activity/orchestrator/types.js";
27
28
  import { WithdrawActions, WithdrawController, WithdrawState, WithdrawStateName, WithdrawSubmitActions, WithdrawSubmitCallback, WithdrawSubmitInput, WithdrawalFormSnapshot } from "./flows/withdraw/orchestrator/types.js";
28
29
  import { FlowEvent, StridgeEvent, UiEvent } from "./events/types/index.js";
30
+ import { SubscribeOptions } from "./events/bus/createBus.js";
29
31
  import { useStridgeEvent } from "./events/hooks/useStridgeEvent.js";
30
32
  import { PublicStridgeEventBus, useStridgeEventBus } from "./events/hooks/useStridgeEventBus.js";
31
33
  import { useStridgeEvents } from "./events/hooks/useStridgeEvents.js";
32
34
  import { useStridgeFlowEvent } from "./events/hooks/useStridgeFlowEvent.js";
33
35
  import { useStridgeFlowEvents } from "./events/hooks/useStridgeFlowEvents.js";
36
+ import { RedactEventOptions, redactEvent } from "./events/redact.js";
34
37
  import { useActivityState } from "./flows/activity/orchestrator/controller.js";
35
38
  import { useActivity, useOptionalActivity, useOptionalPrefetchActivity, usePrefetchActivity } from "./flows/activity/orchestrator/useActivity.js";
36
39
  import { useDepositState } from "./flows/deposit/orchestrator/controller.js";
@@ -45,4 +48,4 @@ import { useWithdrawState } from "./flows/withdraw/orchestrator/controller.js";
45
48
  import { useOptionalWithdraw, usePrefetchWithdraw, useWithdraw } from "./flows/withdraw/orchestrator/useWithdraw.js";
46
49
  import { ConnectWalletConfig } from "./shared/wallet/ConnectWalletContext.js";
47
50
  import { StridgeAppearance, StridgeAsset, StridgeDepositDestination, StridgeDepositFlowConfig, StridgeDepositMethodConfig, StridgeDepositMethodsConfig, StridgeFlowOwner, StridgePrefetchConfig, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig } from "./stridge/StridgeProvider.js";
48
- export { type ActivityActions, type ActivityAmount, type ActivityController, type ActivityDirection, type ActivityDriver, type ActivityOpenInput, type ActivityPayload, type ActivityRowPayload, type ActivitySnapshot, type ActivityState, type ActivityStateName, type ActivityStatus, type ActivityStatusType, type BannerAckBucket, type CardBrand, type CardData, type CashMethodCapability, type CashMethodId, type CashMethodsPayload, type ChainLogoInput, type ChainLogoMeta, type ChainType, type ConnectWalletConfig, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositBindings, type DepositController, type DepositMethod, type DepositMethodConfig, type DepositMethodsConfig, type OpenInput as DepositOpenInput, type DepositRailConfig, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type FlowEvent, type FlowIdKey, type IntercomMerchantContext, KitPortalScope, KitStorageProvider, type LogosNamespace, type Presentation, type PresentationConfig, type PresentationMode, type PublicStridgeEventBus, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeDepositMethodConfig, type StridgeDepositMethodsConfig, type StridgeEnvironment, type StridgeEvent, type StridgeFlowOwner, type StridgePrefetchConfig, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SupportConfig, type SupportOpenContext, type TermsConfig, type TermsSelectContext, type TokenLogoInput, type TokenizationResult, type TxRef, type UiEvent, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, resolveStorageAdapter, toChainType, useActivity, useActivitySnapshot, useActivityState, useBannerAck, useBannerAckForSettlement, useCurrentFlowId, useDeposit, useDepositBindings, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalActivity, useOptionalDeposit, useOptionalKitStorage, useOptionalPrefetchActivity, useOptionalWithdraw, usePrefetchActivity, usePrefetchDeposit, usePrefetchWithdraw, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
51
+ export { type ActivityActions, type ActivityAmount, type ActivityController, type ActivityDirection, type ActivityDriver, type ActivityOpenInput, type ActivityPayload, type ActivityRowPayload, type ActivitySnapshot, type ActivityState, type ActivityStateName, type ActivityStatus, type ActivityStatusType, type BannerAckBucket, type CardBrand, type CardData, type CashMethodCapability, type CashMethodId, type CashMethodsPayload, type ChainLogoInput, type ChainLogoMeta, type ChainType, type ConnectWalletConfig, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositBindings, type DepositController, type DepositMethod, type DepositMethodConfig, type DepositMethodsConfig, type OpenInput as DepositOpenInput, type DepositRailConfig, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type FlowEvent, type FlowIdKey, type IntercomMerchantContext, KIT_VERSION, KitPortalScope, KitStorageProvider, type LogosNamespace, type Presentation, type PresentationConfig, type PresentationMode, type PublicStridgeEventBus, type RedactEventOptions, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeDepositMethodConfig, type StridgeDepositMethodsConfig, type StridgeEnvironment, type StridgeEvent, type StridgeFlowOwner, type StridgePrefetchConfig, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SubscribeOptions, type SupportConfig, type SupportOpenContext, type TermsConfig, type TermsSelectContext, type TokenLogoInput, type TokenizationResult, type TxRef, type UiEvent, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, redactEvent, resolveStorageAdapter, toChainType, useActivity, useActivitySnapshot, useActivityState, useBannerAck, useBannerAckForSettlement, useCurrentFlowId, useDeposit, useDepositBindings, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalActivity, useOptionalDeposit, useOptionalKitStorage, useOptionalPrefetchActivity, useOptionalWithdraw, usePrefetchActivity, usePrefetchDeposit, usePrefetchWithdraw, useStridgeEvent, useStridgeEventBus, useStridgeEvents, useStridgeFlowEvent, useStridgeFlowEvents, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p,useOptionalKitStorage as m}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as h,bucketFromSettlement as g,useBannerAck as _,useBannerAckForSettlement as v}from"./banners/useBannerAck.js";import"./banners/index.js";import{useCurrentFlowId as y}from"./events/hooks/useCurrentFlowId.js";import{useStridgeEvent as b}from"./events/hooks/useStridgeEvent.js";import{useStridgeEventBus as x}from"./events/hooks/useStridgeEventBus.js";import{useStridgeEvents as S}from"./events/hooks/useStridgeEvents.js";import{useStridgeFlowEvent as C}from"./events/hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as w}from"./events/hooks/useStridgeFlowEvents.js";import"./events/index.js";import{useActivitySnapshot as T}from"./flows/activity/driver/context.js";import{useActivityState as E}from"./flows/activity/orchestrator/controller.js";import{useActivity as D,useOptionalActivity as O,useOptionalPrefetchActivity as k,usePrefetchActivity as A}from"./flows/activity/orchestrator/useActivity.js";import"./flows/activity/orchestrator/index.js";import{useDepositBindings as j}from"./flows/deposit/bindings/DepositBindings.js";import"./flows/deposit/bindings/index.js";import{useDepositSnapshot as M}from"./flows/deposit/driver/context.js";import{useDepositState as N}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as P,useOptionalDeposit as F,usePrefetchDeposit as I}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as L}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as R}from"./flows/withdraw/driver/context.js";import{useWithdrawState as z}from"./flows/withdraw/orchestrator/controller.js";import{useOptionalWithdraw as B,usePrefetchWithdraw as V,useWithdraw as H}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as U}from"./scope/context.js";import{KitPortalScope as W}from"./scope/KitPortalScope.js";import{StridgeProvider as G}from"./stridge/StridgeProvider.js";export{u as DEFAULT_KIT_STORAGE_NAMESPACE,W as KitPortalScope,d as KitStorageProvider,G as StridgeProvider,h as bannerAckStorageKey,g as bucketFromSettlement,l as createKitStorage,a as createLocalStorageAdapter,o as createMemoryStorageAdapter,s as createSessionStorageAdapter,e as isValidAddressForChainType,t as isValidEvmAddress,n as isValidTronAddress,i as logos,c as resolveStorageAdapter,r as toChainType,D as useActivity,T as useActivitySnapshot,E as useActivityState,_ as useBannerAck,v as useBannerAckForSettlement,y as useCurrentFlowId,P as useDeposit,j as useDepositBindings,M as useDepositSnapshot,N as useDepositState,U as useKitConfig,f as useKitStorage,p as useKitStorageValue,O as useOptionalActivity,F as useOptionalDeposit,m as useOptionalKitStorage,k as useOptionalPrefetchActivity,B as useOptionalWithdraw,A as usePrefetchActivity,I as usePrefetchDeposit,V as usePrefetchWithdraw,b as useStridgeEvent,x as useStridgeEventBus,S as useStridgeEvents,C as useStridgeFlowEvent,w as useStridgeFlowEvents,H as useWithdraw,L as useWithdrawBindings,R as useWithdrawSnapshot,z as useWithdrawState};
1
+ import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p,useOptionalKitStorage as m}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as h,bucketFromSettlement as g,useBannerAck as _,useBannerAckForSettlement as v}from"./banners/useBannerAck.js";import"./banners/index.js";import{KIT_VERSION as y}from"./version.js";import{useCurrentFlowId as b}from"./events/hooks/useCurrentFlowId.js";import{useStridgeEvent as x}from"./events/hooks/useStridgeEvent.js";import{useStridgeEventBus as S}from"./events/hooks/useStridgeEventBus.js";import{useStridgeEvents as C}from"./events/hooks/useStridgeEvents.js";import{useStridgeFlowEvent as w}from"./events/hooks/useStridgeFlowEvent.js";import{useStridgeFlowEvents as T}from"./events/hooks/useStridgeFlowEvents.js";import{redactEvent as E}from"./events/redact.js";import"./events/index.js";import{useActivitySnapshot as D}from"./flows/activity/driver/context.js";import{useActivityState as O}from"./flows/activity/orchestrator/controller.js";import{useActivity as k,useOptionalActivity as A,useOptionalPrefetchActivity as j,usePrefetchActivity as M}from"./flows/activity/orchestrator/useActivity.js";import"./flows/activity/orchestrator/index.js";import{useDepositBindings as N}from"./flows/deposit/bindings/DepositBindings.js";import"./flows/deposit/bindings/index.js";import{useDepositSnapshot as P}from"./flows/deposit/driver/context.js";import{useDepositState as F}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as I,useOptionalDeposit as L,usePrefetchDeposit as R}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as z}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as B}from"./flows/withdraw/driver/context.js";import{useWithdrawState as V}from"./flows/withdraw/orchestrator/controller.js";import{useOptionalWithdraw as H,usePrefetchWithdraw as U,useWithdraw as W}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as G}from"./scope/context.js";import{KitPortalScope as K}from"./scope/KitPortalScope.js";import{StridgeProvider as q}from"./stridge/StridgeProvider.js";export{u as DEFAULT_KIT_STORAGE_NAMESPACE,y as KIT_VERSION,K as KitPortalScope,d as KitStorageProvider,q as StridgeProvider,h as bannerAckStorageKey,g as bucketFromSettlement,l as createKitStorage,a as createLocalStorageAdapter,o as createMemoryStorageAdapter,s as createSessionStorageAdapter,e as isValidAddressForChainType,t as isValidEvmAddress,n as isValidTronAddress,i as logos,E as redactEvent,c as resolveStorageAdapter,r as toChainType,k as useActivity,D as useActivitySnapshot,O as useActivityState,_ as useBannerAck,v as useBannerAckForSettlement,b as useCurrentFlowId,I as useDeposit,N as useDepositBindings,P as useDepositSnapshot,F as useDepositState,G as useKitConfig,f as useKitStorage,p as useKitStorageValue,A as useOptionalActivity,L as useOptionalDeposit,m as useOptionalKitStorage,j as useOptionalPrefetchActivity,H as useOptionalWithdraw,M as usePrefetchActivity,R as usePrefetchDeposit,U as usePrefetchWithdraw,x as useStridgeEvent,S as useStridgeEventBus,C as useStridgeEvents,w as useStridgeFlowEvent,T as useStridgeFlowEvents,W as useWithdraw,z as useWithdrawBindings,B as useWithdrawSnapshot,V as useWithdrawState};
package/dist/package.js CHANGED
@@ -1 +1 @@
1
- var e=`0.1.0-alpha.56`;export{e as version};
1
+ var e=`0.1.0-alpha.58`;export{e as version};
@@ -1 +1 @@
1
- function e(e,t){if(e instanceof Error){let n=e.cause;if(n&&typeof n==`object`){let r=n;if(r.success===!1&&typeof r.error==`string`&&r.error.trim())return{reason:e.message||t,code:r.error}}return{reason:e.message||t,code:e.name}}return{reason:t}}export{e as toFailure};
1
+ function e(e,t){if(e instanceof Error){let n=e.cause;if(n&&typeof n==`object`){let r=n;if(r.success===!1&&typeof r.error==`string`&&r.error.trim())return{reason:e.message||t,code:r.error,cause:e}}return{reason:e.message||t,code:e.name,cause:e}}return{reason:t,cause:e}}export{e as toFailure};
@@ -15,6 +15,14 @@
15
15
  interface FailureInfo {
16
16
  reason: string;
17
17
  code?: string;
18
+ /**
19
+ * The original thrown value (typically an `Error` with a stack), retained for debugging and
20
+ * error reporting. Rides through to the event bus as {@link FailurePayloadBase.cause} so
21
+ * consumers can `Sentry.captureException(e.payload.cause)` with a real stack instead of a
22
+ * bare reason string. `undefined` for failures with no JS error origin (e.g. settlement
23
+ * failures decoded from a driver `failureKind` enum). Never rendered to users.
24
+ */
25
+ cause?: unknown;
18
26
  }
19
27
  //#endregion
20
28
  export { FailureInfo };
@@ -151,6 +151,16 @@ interface StridgeDevConfig {
151
151
  * returns no address.
152
152
  */
153
153
  userAddressOverride?: Address;
154
+ /**
155
+ * Unlock the cash payment rail (Card / Apple Pay / Google Pay). The cash flow is currently
156
+ * UI-only with no backend, so the rail is fused off for every integration by default and this
157
+ * knob is the only switch that surfaces it. Reserved for Stridge's own demo / preview surfaces
158
+ * while cash bakes — production integrations should not flip it. The
159
+ * `flows.deposit.methods.cashRail.enabled` opt-in is still required *in addition* to this gate;
160
+ * this knob will be removed (and the rail governed by the opt-in alone) once the cash backend
161
+ * ships.
162
+ */
163
+ cashRail?: boolean;
154
164
  }
155
165
  /**
156
166
  * Persistence configuration for the kit's per-tab state (settlement banner acks, future kit-wide
@@ -1 +1 @@
1
- "use client";import{StridgeEventsContext as e}from"../events/context.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{createStridgeCatalog as n}from"../drivers/stridge/catalog.js";import{createStridgeActivityDriver as r}from"../drivers/stridge/createStridgeActivityDriver.js";import{createStridgeDepositDriver as i}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as a}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{createBus as ee}from"../events/bus/createBus.js";import{createFlowIdRegistry as te}from"../events/bus/flowIdRegistry.js";import{createMetadataStore as o}from"../events/bus/metadata.js";import"../events/bus/index.js";import{KitProvider as s}from"../KitProvider.js";import{resolveMerchantLink as c}from"../shared/merchant-link/resolveMerchantLink.js";import"../shared/merchant-link/index.js";import{useIntercomMerchantContext as l}from"../shared/support/useIntercomMerchantContext.js";import{useMerchantContext as u}from"../shared/support/useMerchantContext.js";import"../shared/support/index.js";import{useDeepMemo as d}from"../shared/utils/useDeepMemo.js";import{ConnectWalletContext as f}from"../shared/wallet/ConnectWalletContext.js";import{DepositOwnerContext as p}from"./depositOwner.js";import{useOptionalWagmi as m}from"./optionalWagmi.js";import{createStubDepositDriver as h,createStubWithdrawDriver as g}from"./stubs.js";import{useEffect as _,useMemo as v,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";function x({gatewayKey:x,environment:S,asset:C,flows:w,appearance:T,i18n:E,storage:D,dev:O,support:k,terms:ne,prefetch:A,connectWallet:j,className:re,children:ie}){if(!w.deposit&&!w.withdraw)throw Error("<StridgeProvider /> requires at least one of `flows.deposit` or `flows.withdraw`.");if(!C)throw Error("<StridgeProvider /> requires `asset: { networkId, symbol }`.");let{config:M,address:N}=m(),P=v(()=>t(E??{}),[E?.locale,E?.messages]),F=y(P);F.current=P;let I=d(C),L=d(w.deposit),R=d(w.withdraw),z=I.networkId,B=I.symbol,V=L?.owner?.address??N??O?.userAddressOverride,H=R?.owner.address,U=v(()=>n({projectKey:x,...S?{environment:S}:{}}),[x,S]),W=v(()=>{if(!(!L||!V))return i({userAddress:V,projectKey:x,destination:{network_id:z,asset_symbol:B,to_address:L.destination.address},wagmiConfig:M,catalog:U,getI18n:()=>F.current,...S?{environment:S}:{},...L.minAmountUsd===void 0?{}:{minAmountUsd:L.minAmountUsd},...L.maxAmountUsd===void 0?{}:{maxAmountUsd:L.maxAmountUsd},...L.metadata?{metadata:L.metadata}:{}})},[L,V,x,S,z,B,M,U]),G=v(()=>h(),[]),K=L?W??G:void 0,q=v(()=>{if(!(!R||!H))return a({userAddress:H,projectKey:x,currency:{networkId:z,assetSymbol:B},wagmiConfig:M,catalog:U,getI18n:()=>F.current,...S?{environment:S}:{},...R.minAmountUsd===void 0?{}:{minAmountUsd:R.minAmountUsd},...R.maxAmountUsd===void 0?{}:{maxAmountUsd:R.maxAmountUsd},...R.metadata?{metadata:R.metadata}:{}})},[R,H,x,S,z,B,M,U]),J=v(()=>g(),[]),Y=R?q??J:void 0,X=(L?V:void 0)??(R?H:void 0),Z=v(()=>{if(X)return r({userAddress:X,projectKey:x,catalog:U,...S?{environment:S}:{}})},[X,x,S,U]);_(()=>{if(!A)return;let e=A===!0||A.includes(`deposit`),t=A===!0||A.includes(`withdraw`),n=A===!0||A.includes(`activity`)||e||t;e&&W?.arm(),t&&q?.arm(),n&&Z?.arm()},[A,W,q,Z]);let ae=v(()=>L?{resolved:V!==void 0}:null,[L,V]),oe=v(()=>j?{onClick:j.onClick,...j.label===void 0?{}:{label:j.label}}:null,[j?.onClick,j?.label]),Q=V??H,$=u({gatewayKey:x,environment:S??`production`,assetChain:z,assetSymbol:B,...Q?{userAddress:Q}:{},...W?{depositDriver:W}:{}});return l(c(k?{url:k.url,onSelect:k.onOpen}:void 0).kind===`default`?$:null),b(e,{value:v(()=>({bus:ee(),flowIds:te(),metadata:o()}),[]),children:b(f,{value:oe,children:b(p,{value:ae,children:b(s,{theme:T?.theme,accent:T?.accent,radius:T?.radius,direction:T?.direction,attribution:T?.attribution,presentation:T?.presentation,i18n:E,storage:D?.driver,storageNamespace:D?.namespace,className:re,support:k,merchantContext:$,terms:ne,...K?{deposit:K}:{},...L?.methods?{depositMethods:L.methods}:{},...Y?{withdraw:Y}:{},...Z?{activity:Z}:{},children:ie})})})})}export{x as StridgeProvider};
1
+ "use client";import{StridgeEventsContext as e}from"../events/context.js";import{createKitI18n as t}from"../shared/i18n/createKitI18n.js";import"../i18n/index.js";import{createStridgeCatalog as n}from"../drivers/stridge/catalog.js";import{createStridgeActivityDriver as r}from"../drivers/stridge/createStridgeActivityDriver.js";import{createStridgeDepositDriver as i}from"../drivers/stridge/createStridgeDepositDriver.js";import{createStridgeWithdrawDriver as a}from"../drivers/stridge/createStridgeWithdrawDriver.js";import"../_internal/drivers/stridge/index.js";import{createBus as ee}from"../events/bus/createBus.js";import{createFlowIdRegistry as te}from"../events/bus/flowIdRegistry.js";import{createMetadataStore as o}from"../events/bus/metadata.js";import"../events/bus/index.js";import{KitProvider as s}from"../KitProvider.js";import{resolveMerchantLink as c}from"../shared/merchant-link/resolveMerchantLink.js";import"../shared/merchant-link/index.js";import{useIntercomMerchantContext as l}from"../shared/support/useIntercomMerchantContext.js";import{useMerchantContext as u}from"../shared/support/useMerchantContext.js";import"../shared/support/index.js";import{useDeepMemo as d}from"../shared/utils/useDeepMemo.js";import{ConnectWalletContext as f}from"../shared/wallet/ConnectWalletContext.js";import{DepositOwnerContext as p}from"./depositOwner.js";import{useOptionalWagmi as m}from"./optionalWagmi.js";import{createStubDepositDriver as h,createStubWithdrawDriver as g}from"./stubs.js";import{useEffect as ne,useMemo as _,useRef as v}from"react";import{jsx as y}from"react/jsx-runtime";function b({gatewayKey:b,environment:x,asset:S,flows:C,appearance:w,i18n:T,storage:E,dev:D,support:O,terms:k,prefetch:A,connectWallet:j,className:re,children:ie}){if(!C.deposit&&!C.withdraw)throw Error("<StridgeProvider /> requires at least one of `flows.deposit` or `flows.withdraw`.");if(!S)throw Error("<StridgeProvider /> requires `asset: { networkId, symbol }`.");let{config:M,address:N}=m(),P=_(()=>t(T??{}),[T?.locale,T?.messages]),F=v(P);F.current=P;let I=d(S),L=d(C.deposit),R=d(C.withdraw),z=I.networkId,B=I.symbol,V=L?.owner?.address??N??D?.userAddressOverride,H=R?.owner.address,U=_(()=>n({projectKey:b,...x?{environment:x}:{}}),[b,x]),W=_(()=>{if(!(!L||!V))return i({userAddress:V,projectKey:b,destination:{network_id:z,asset_symbol:B,to_address:L.destination.address},wagmiConfig:M,catalog:U,getI18n:()=>F.current,...x?{environment:x}:{},...L.minAmountUsd===void 0?{}:{minAmountUsd:L.minAmountUsd},...L.maxAmountUsd===void 0?{}:{maxAmountUsd:L.maxAmountUsd},...L.metadata?{metadata:L.metadata}:{}})},[L,V,b,x,z,B,M,U]),G=_(()=>h(),[]),K=L?W??G:void 0,q=_(()=>{if(!(!R||!H))return a({userAddress:H,projectKey:b,currency:{networkId:z,assetSymbol:B},wagmiConfig:M,catalog:U,getI18n:()=>F.current,...x?{environment:x}:{},...R.minAmountUsd===void 0?{}:{minAmountUsd:R.minAmountUsd},...R.maxAmountUsd===void 0?{}:{maxAmountUsd:R.maxAmountUsd},...R.metadata?{metadata:R.metadata}:{}})},[R,H,b,x,z,B,M,U]),J=_(()=>g(),[]),Y=R?q??J:void 0,X=(L?V:void 0)??(R?H:void 0),Z=_(()=>{if(X)return r({userAddress:X,projectKey:b,catalog:U,...x?{environment:x}:{}})},[X,b,x,U]);ne(()=>{if(!A)return;let e=A===!0||A.includes(`deposit`),t=A===!0||A.includes(`withdraw`),n=A===!0||A.includes(`activity`)||e||t;e&&W?.arm(),t&&q?.arm(),n&&Z?.arm()},[A,W,q,Z]);let ae=_(()=>L?{resolved:V!==void 0}:null,[L,V]),oe=_(()=>j?{onClick:j.onClick,...j.label===void 0?{}:{label:j.label}}:null,[j?.onClick,j?.label]),Q=V??H,$=u({gatewayKey:b,environment:x??`production`,assetChain:z,assetSymbol:B,...Q?{userAddress:Q}:{},...W?{depositDriver:W}:{}});return l(c(O?{url:O.url,onSelect:O.onOpen}:void 0).kind===`default`?$:null),y(e,{value:_(()=>({bus:ee(),flowIds:te(),metadata:o()}),[]),children:y(f,{value:oe,children:y(p,{value:ae,children:y(s,{theme:w?.theme,accent:w?.accent,radius:w?.radius,direction:w?.direction,attribution:w?.attribution,presentation:w?.presentation,i18n:T,storage:E?.driver,storageNamespace:E?.namespace,className:re,support:O,merchantContext:$,terms:k,...K?{deposit:K}:{},...L?.methods?{depositMethods:L.methods}:{},...Y?{withdraw:Y}:{},...Z?{activity:Z}:{},...D?.cashRail?{dev:{cashRail:!0}}:{},children:ie})})})})}export{b as StridgeProvider};
@@ -0,0 +1,10 @@
1
+ //#region src/version.d.ts
2
+ /**
3
+ * Resolved at build time by tsdown's `define` (the `__STRIDGE_KIT_VERSION__` token is replaced
4
+ * with the `package.json` version string). The `typeof` guard keeps the reference safe in test
5
+ * runners and any environment where the token was not substituted — there it falls back to the
6
+ * sentinel `"0.0.0-dev"` instead of throwing on an undeclared identifier.
7
+ */
8
+ declare const KIT_VERSION: string;
9
+ //#endregion
10
+ export { KIT_VERSION };
@@ -0,0 +1 @@
1
+ const e=`0.1.0-alpha.58`;export{e as KIT_VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stridge/kit",
3
- "version": "0.1.0-alpha.56",
3
+ "version": "0.1.0-alpha.58",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [