@yodlpay/react-native 0.8.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,128 +1,28 @@
1
- import { output, z } from "zod";
2
1
  import { ReactElement, ReactNode } from "react";
3
2
  import { ViewStyle } from "react-native";
4
-
5
- //#region ../sdk-core/dist/host-sYc0ZjUh.d.mts
6
- //#endregion
7
- //#region src/theme/schemas.d.ts
8
- /** What a host may ask for: an explicit mode, or "follow the host appearance". */
9
- declare const yodlThemeModeSchema: z.ZodEnum<{
10
- system: "system";
11
- light: "light";
12
- dark: "dark";
13
- }>;
14
- /** What `system` resolves to once the host appearance is known. */
15
- /**
16
- * One customizable Yodl theme: a light/dark palette pair plus optional media.
17
- * `font` and the radii sit at the top level rather than inside a palette
18
- * because none of them is a color and none varies by mode.
19
- *
20
- * `radiusControl` is the one radius most integrators set; `radiusSurface`
21
- * defaults to it (clamped, so a pill control does not make cards lozenges) and
22
- * exists for themes that want cards and sheets to differ from their buttons.
23
- */
24
- declare const yodlThemeSchema: z.ZodObject<{
25
- name: z.ZodOptional<z.ZodString>;
26
- font: z.ZodOptional<z.ZodEnum<{
27
- system: "system";
28
- inter: "inter";
29
- geist: "geist";
30
- mono: "mono";
31
- }>>;
32
- radiusControl: z.ZodOptional<z.ZodString>;
33
- radiusSurface: z.ZodOptional<z.ZodString>;
34
- light: z.ZodOptional<z.ZodObject<{
35
- bg: z.ZodOptional<z.ZodString>;
36
- surface: z.ZodOptional<z.ZodString>;
37
- surfaceSecondary: z.ZodOptional<z.ZodString>;
38
- text: z.ZodOptional<z.ZodString>;
39
- textSecondary: z.ZodOptional<z.ZodString>;
40
- textMuted: z.ZodOptional<z.ZodString>;
41
- border: z.ZodOptional<z.ZodString>;
42
- success: z.ZodOptional<z.ZodString>;
43
- error: z.ZodOptional<z.ZodString>;
44
- warning: z.ZodOptional<z.ZodString>;
45
- accent: z.ZodOptional<z.ZodString>;
46
- bgDeep: z.ZodOptional<z.ZodString>;
47
- surfaceHover: z.ZodOptional<z.ZodString>;
48
- skeleton: z.ZodOptional<z.ZodString>;
49
- accentStrong: z.ZodOptional<z.ZodString>;
50
- accentDeep: z.ZodOptional<z.ZodString>;
51
- brandSurface: z.ZodOptional<z.ZodString>;
52
- brandSheet: z.ZodOptional<z.ZodString>;
53
- brandText: z.ZodOptional<z.ZodString>;
54
- brandButton: z.ZodOptional<z.ZodString>;
55
- brandButtonText: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strip>>;
57
- dark: z.ZodOptional<z.ZodObject<{
58
- bg: z.ZodOptional<z.ZodString>;
59
- surface: z.ZodOptional<z.ZodString>;
60
- surfaceSecondary: z.ZodOptional<z.ZodString>;
61
- text: z.ZodOptional<z.ZodString>;
62
- textSecondary: z.ZodOptional<z.ZodString>;
63
- textMuted: z.ZodOptional<z.ZodString>;
64
- border: z.ZodOptional<z.ZodString>;
65
- success: z.ZodOptional<z.ZodString>;
66
- error: z.ZodOptional<z.ZodString>;
67
- warning: z.ZodOptional<z.ZodString>;
68
- accent: z.ZodOptional<z.ZodString>;
69
- bgDeep: z.ZodOptional<z.ZodString>;
70
- surfaceHover: z.ZodOptional<z.ZodString>;
71
- skeleton: z.ZodOptional<z.ZodString>;
72
- accentStrong: z.ZodOptional<z.ZodString>;
73
- accentDeep: z.ZodOptional<z.ZodString>;
74
- brandSurface: z.ZodOptional<z.ZodString>;
75
- brandSheet: z.ZodOptional<z.ZodString>;
76
- brandText: z.ZodOptional<z.ZodString>;
77
- brandButton: z.ZodOptional<z.ZodString>;
78
- brandButtonText: z.ZodOptional<z.ZodString>;
79
- }, z.core.$strip>>;
80
- images: z.ZodOptional<z.ZodObject<{
81
- light: z.ZodOptional<z.ZodObject<{
82
- payBackground: z.ZodOptional<z.ZodString>;
83
- processing: z.ZodOptional<z.ZodString>;
84
- loading: z.ZodOptional<z.ZodString>;
85
- }, z.core.$strip>>;
86
- dark: z.ZodOptional<z.ZodObject<{
87
- payBackground: z.ZodOptional<z.ZodString>;
88
- processing: z.ZodOptional<z.ZodString>;
89
- loading: z.ZodOptional<z.ZodString>;
90
- }, z.core.$strip>>;
91
- }, z.core.$strict>>;
92
- }, z.core.$strip>;
93
- /**
94
- * The complete host-controlled theme state for one hosted session. `theme: null` means
95
- * host-controlled stock Yodl, which is distinct from "no host authority at all" — the
96
- * latter is expressed by not sending an envelope. Versioned so the protocol can change
97
- * without silently misinterpreting older payloads.
98
- */
99
- //#endregion
100
- //#region src/theme/contract.d.ts
101
- type YodlThemeMode = output<typeof yodlThemeModeSchema>;
102
- type YodlTheme = output<typeof yodlThemeSchema>;
103
- //#endregion
104
- //#region src/types.d.ts
105
- /** Any JSON-RPC payload value — used wherever provider params/results cross the wire. */
106
- type JsonValue = string | number | boolean | null | JsonValue[] | {
107
- [key: string]: JsonValue;
108
- };
3
+ //#region ../sdk-core/dist/messages-BnJRdNU0.d.mts
4
+ /** submitted: on-chain, not yet indexed by Yodl. processing: indexed, not settled (incl. a failure whose refund is in flight). */
5
+ type PaymentStatus = 'submitted' | 'processing' | 'success' | 'failure';
109
6
  /**
110
- * Minimal EIP-1193 provider interface.
111
- * Works with any wallet SDK: Privy, MetaMask, Coinbase, Rainbow, WalletConnect, etc.
7
+ * Where a payment payload's figures came from. `optimistic` means Yodl's backend
8
+ * has not indexed the transaction yet, so every figure is the paying device's
9
+ * own pre-submit data. Independent of `status`: a payload can be `indexed` while
10
+ * the payment is still processing.
112
11
  */
113
- interface EIP1193Provider {
114
- request: (args: {
115
- method: string;
116
- params?: JsonValue[] | object;
117
- }) => Promise<JsonValue>;
118
- }
119
- type SupportedChainIds = number[];
120
- type YodlPaymentLifecycleStatus = 'submitted' | 'processing' | 'success' | 'failure';
12
+ type YodlPaymentDetailsSource = 'optimistic' | 'indexed';
121
13
  type YodlSignupStatus = 'checking' | 'signed_out' | 'signing_up' | 'signed_up';
122
14
  /** Whether the Yodl UI moves to its own status screen once a payment is submitted. */
123
15
  type YodlNavigateOnSubmit = 'always' | 'never';
16
+ /**
17
+ * Nullability here follows what the hosted page actually emits, not what is
18
+ * convenient to consume: it forwards a receipt's own `null`s rather than
19
+ * normalising them, so a host that assumes `string` will crash on a real
20
+ * payment. Narrow at the call site.
21
+ */
124
22
  interface YodlPaymentDetails {
125
- status: YodlPaymentLifecycleStatus;
23
+ status: PaymentStatus;
24
+ /** Optional: hosted builds older than the one that introduced it omit it. */
25
+ source?: YodlPaymentDetailsSource;
126
26
  transaction: {
127
27
  hash: string;
128
28
  chainId?: string | number;
@@ -135,7 +35,7 @@ interface YodlPaymentDetails {
135
35
  recipient?: {
136
36
  type?: string;
137
37
  title?: string;
138
- subtitle?: string;
38
+ subtitle?: string | null;
139
39
  iconUrl?: string | null;
140
40
  };
141
41
  invoice?: {
@@ -145,7 +45,7 @@ interface YodlPaymentDetails {
145
45
  settlementCurrency?: string;
146
46
  } | null;
147
47
  token?: {
148
- symbol?: string;
48
+ symbol?: string | null;
149
49
  amountGross?: string;
150
50
  amountNet?: string;
151
51
  };
@@ -154,7 +54,7 @@ interface YodlPaymentDetails {
154
54
  };
155
55
  recovery?: {
156
56
  refundTxHash?: string | null;
157
- status?: 'pending' | 'success';
57
+ status?: string;
158
58
  } | null;
159
59
  rewards?: {
160
60
  points?: number;
@@ -162,8 +62,104 @@ interface YodlPaymentDetails {
162
62
  streakMultiplier?: string;
163
63
  berserMultiplier?: number;
164
64
  };
165
- raw?: JsonValue;
65
+ raw?: unknown;
66
+ }
67
+ //#endregion
68
+ //#region ../sdk-core/dist/index-CmnifaLY.d.mts
69
+ //#endregion
70
+ //#region src/evm/wallet-provider.d.ts
71
+ /**
72
+ * An EIP-1193 provider, declared structurally so anything shaped like one
73
+ * satisfies it — a browser wallet, a host-injected WebView provider, or a
74
+ * decorator such as `withYodl7702`.
75
+ *
76
+ * Deliberately *not* viem's `EIP1193Provider`, which is
77
+ * `EIP1193Events & { request: EIP1193RequestFn<EIP1474Methods> }` and so makes
78
+ * `on`/`removeListener` mandatory. Two providers this package has to accept
79
+ * cannot promise them: `withYodl7702` re-exposes them only when the provider it
80
+ * wraps has them, and a host bridge injected into a WebView frequently
81
+ * implements `request` alone. Nothing here subscribes to provider events — the
82
+ * chain switch polls `eth_chainId` instead — so requiring them would be asking
83
+ * for a capability this package never uses. viem's `custom()` types its own
84
+ * argument just as loosely, so no cast is needed on the way in either.
85
+ *
86
+ * `request` is declared as a method rather than a property on purpose: method
87
+ * bivariance is what lets a provider typed `params?: JsonValue[] | object`
88
+ * satisfy this without a cast.
89
+ */
90
+ interface EIP1193Provider {
91
+ request(args: {
92
+ method: string;
93
+ params?: readonly unknown[] | object;
94
+ }): Promise<unknown>;
95
+ }
96
+ //#endregion
97
+ //#region ../sdk-core/dist/host-COukZkft.d.mts
98
+ //#endregion
99
+ //#region src/theme/contract.d.ts
100
+ /** What a host may ask for: an explicit mode, or "follow the host appearance". */
101
+ type YodlThemeMode = 'system' | 'light' | 'dark';
102
+ /**
103
+ * One per-mode palette. Every key is optional — missing keys fall back to the
104
+ * stock Yodl palette, and the fine-tune keys are derived from their core keys
105
+ * downstream. Colors are hex, `rgb()` or `rgba()`.
106
+ */
107
+ interface YodlThemeModeTokens {
108
+ bg?: string | undefined;
109
+ surface?: string | undefined;
110
+ surfaceSecondary?: string | undefined;
111
+ text?: string | undefined;
112
+ textSecondary?: string | undefined;
113
+ textMuted?: string | undefined;
114
+ border?: string | undefined;
115
+ success?: string | undefined;
116
+ error?: string | undefined;
117
+ warning?: string | undefined;
118
+ accent?: string | undefined;
119
+ bgDeep?: string | undefined;
120
+ surfaceHover?: string | undefined;
121
+ skeleton?: string | undefined;
122
+ accentStrong?: string | undefined;
123
+ accentDeep?: string | undefined;
124
+ brandSurface?: string | undefined;
125
+ brandSheet?: string | undefined;
126
+ brandText?: string | undefined;
127
+ brandButton?: string | undefined;
128
+ brandButtonText?: string | undefined;
129
+ }
130
+ /** The faces the hosted UI ships; see `THEME_FONT_VALUES` for why it is closed. */
131
+ type YodlThemeFont = 'system' | 'inter' | 'geist' | 'mono';
132
+ /** The three media slots the hosted UI can theme, for a single mode. https URLs only. */
133
+ interface YodlThemeImages {
134
+ /** Full-bleed backdrop behind the payment (amount entry) screen. */
135
+ payBackground?: string | undefined;
136
+ /** Alias for `loading` (used when it is unset). */
137
+ processing?: string | undefined;
138
+ /** Full-screen splash on the in-app loading screens; video or any `<img>` format. */
139
+ loading?: string | undefined;
166
140
  }
141
+ /** Media is per mode. */
142
+ interface YodlThemeImageSets {
143
+ light?: YodlThemeImages | undefined;
144
+ dark?: YodlThemeImages | undefined;
145
+ }
146
+ /**
147
+ * One customizable Yodl theme: a light/dark palette pair plus optional media.
148
+ * `font` and the radii sit at the top level because none of them is a color
149
+ * and none varies by mode. `radiusSurface` defaults to `radiusControl`.
150
+ */
151
+ interface YodlTheme {
152
+ name?: string | undefined;
153
+ font?: YodlThemeFont | undefined;
154
+ radiusControl?: string | undefined;
155
+ radiusSurface?: string | undefined;
156
+ light?: YodlThemeModeTokens | undefined;
157
+ dark?: YodlThemeModeTokens | undefined;
158
+ images?: YodlThemeImageSets | undefined;
159
+ }
160
+ //#endregion
161
+ //#region src/types.d.ts
162
+ type SupportedChainIds = number[];
167
163
  /** Runtime wallet connection shared across the provider, context, and Yodl UI host. */
168
164
  interface YodlWallet {
169
165
  /** EIP-1193 provider from the host wallet SDK. */
@@ -262,18 +258,7 @@ type YodlDashboardProps = YodlComponentProps;
262
258
  * <YodlProvider> and loads the dashboard route on the configured Yodl host.
263
259
  * The Yodl UI is origin-locked to that host.
264
260
  */
265
- declare function YodlDashboard({
266
- onTransactionSent,
267
- onPaymentDetails,
268
- onError,
269
- fetchEmailAttestation,
270
- renderLoading,
271
- onReady,
272
- style,
273
- backgroundColor,
274
- theme,
275
- themeMode
276
- }: YodlDashboardProps): import("react/jsx-runtime").JSX.Element;
261
+ declare function YodlDashboard({ onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlDashboardProps): import("react").JSX.Element;
277
262
  //#endregion
278
263
  //#region src/components/YodlPayment.d.ts
279
264
  interface YodlPaymentProps extends YodlComponentProps {
@@ -292,20 +277,7 @@ interface YodlPaymentProps extends YodlComponentProps {
292
277
  * (e.g. the `/resolve` screen on the configured host). The Yodl UI is
293
278
  * origin-locked to that host. Renders nothing for empty/unsupported QR data.
294
279
  */
295
- declare function YodlPayment({
296
- qrData,
297
- navigateOnSubmit,
298
- onTransactionSent,
299
- onPaymentDetails,
300
- onError,
301
- fetchEmailAttestation,
302
- renderLoading,
303
- onReady,
304
- style,
305
- backgroundColor,
306
- theme,
307
- themeMode
308
- }: YodlPaymentProps): import("react/jsx-runtime").JSX.Element | null;
280
+ declare function YodlPayment({ qrData, navigateOnSubmit, onTransactionSent, onPaymentDetails, onError, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlPaymentProps): import("react").JSX.Element | null;
309
281
  //#endregion
310
282
  //#region src/components/YodlSignup.d.ts
311
283
  interface YodlSignupProps extends YodlVisualProps {
@@ -329,30 +301,18 @@ interface YodlSignupProps extends YodlVisualProps {
329
301
  * verification code entry, and the final signed-up screen, while callbacks let
330
302
  * the native app observe status and completion.
331
303
  */
332
- declare function YodlSignup({
333
- onStatusChange,
334
- onSignedUp,
335
- onError,
336
- onDismiss,
337
- fetchEmailAttestation,
338
- renderLoading,
339
- onReady,
340
- style,
341
- backgroundColor,
342
- theme,
343
- themeMode
344
- }: YodlSignupProps): import("react/jsx-runtime").JSX.Element;
304
+ declare function YodlSignup({ onStatusChange, onSignedUp, onError, onDismiss, fetchEmailAttestation, renderLoading, onReady, style, backgroundColor, theme, themeMode }: YodlSignupProps): import("react").JSX.Element;
345
305
  //#endregion
346
306
  //#region src/sdk/yodl.d.ts
347
307
  /**
348
308
  * App-host configuration for the Yodl React Native SDK.
349
- * Injected once via {@link createSdk}.
309
+ * Injected once via {@link createYodlSdk}.
350
310
  *
351
311
  * No RPC endpoint is needed: the embedded Yodl UI reads chain state through its
352
312
  * own provider, and the injected wallet bridge only forwards signing/wallet
353
313
  * methods to the host wallet.
354
314
  */
355
- interface YodlConfig {
315
+ interface YodlSdkConfig {
356
316
  /** Your integration wallet address. Identifies you to Yodl and attributes payments on chain. */
357
317
  integrationAddress: `0x${string}`;
358
318
  /** Base URL for the Yodl UI (default: https://sdk-webview.yodl.me). */
@@ -361,7 +321,7 @@ interface YodlConfig {
361
321
  supportedChainIds: SupportedChainIds;
362
322
  }
363
323
  /** Config with defaults applied — what components read from the instance. */
364
- type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
324
+ type ResolvedYodlSdkConfig = Omit<YodlSdkConfig, 'yodlUiBaseUrl'> & {
365
325
  yodlUiBaseUrl: string;
366
326
  };
367
327
  /**
@@ -369,20 +329,20 @@ type ResolvedYodlConfig = Omit<YodlConfig, 'yodlUiBaseUrl'> & {
369
329
  * and the components read at runtime. Stateless QR helpers are exported as
370
330
  * standalone functions (e.g. {@link isPaymentQr}) rather than instance methods.
371
331
  */
372
- declare class Yodl {
373
- readonly config: ResolvedYodlConfig;
374
- constructor(config: YodlConfig);
332
+ declare class YodlSdk {
333
+ readonly config: ResolvedYodlSdkConfig;
334
+ constructor(config: YodlSdkConfig);
375
335
  }
376
336
  /**
377
337
  * Create a Yodl SDK instance. Factory pattern, consistent with
378
- * `@yodlpay/sdk-core`'s `createSdk` / config-once convention.
338
+ * `@yodlpay/sdk-core`'s `createYodlClient` / config-once convention.
379
339
  */
380
- declare function createSdk(config: YodlConfig): Yodl;
340
+ declare function createYodlSdk(config: YodlSdkConfig): YodlSdk;
381
341
  //#endregion
382
342
  //#region src/provider/context.d.ts
383
343
  interface YodlProviderProps extends YodlHostThemeProps {
384
- /** The SDK instance created via createSdk(). */
385
- sdk: Yodl;
344
+ /** The SDK instance created via createYodlSdk(). */
345
+ sdk: YodlSdk;
386
346
  /** EIP-1193 provider from the host wallet SDK. */
387
347
  provider: YodlWallet['provider'];
388
348
  /** Connected wallet address. */
@@ -395,15 +355,7 @@ interface YodlProviderProps extends YodlHostThemeProps {
395
355
  * Supplies the SDK instance, runtime wallet state (provider/address/chainId), and
396
356
  * the optional host theme state to the Yodl components via React context.
397
357
  */
398
- declare function YodlProvider({
399
- sdk,
400
- provider,
401
- address,
402
- chainId,
403
- theme,
404
- themeMode,
405
- children
406
- }: YodlProviderProps): import("react/jsx-runtime").JSX.Element;
358
+ declare function YodlProvider({ sdk, provider, address, chainId, theme, themeMode, children }: YodlProviderProps): import("react").JSX.Element;
407
359
  //#endregion
408
360
  //#region src/sdk/qr.d.ts
409
361
  /**
@@ -417,4 +369,4 @@ declare function YodlProvider({
417
369
  */
418
370
  declare function isPaymentQr(qrData: string | string[]): boolean;
419
371
  //#endregion
420
- export { type EIP1193Provider, type SupportedChainIds, Yodl, type YodlConfig, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentLifecycleStatus, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createSdk, isPaymentQr };
372
+ export { type EIP1193Provider, type PaymentStatus, type SupportedChainIds, YodlDashboard, type YodlDashboardProps, type YodlEmailAttestation, type YodlEmailAttestationFetcher, type YodlEmailAttestationRequest, type YodlNavigateOnSubmit, YodlPayment, type YodlPaymentDetails, type YodlPaymentDetailsSource, type YodlPaymentProps, YodlProvider, type YodlProviderProps, YodlSdk, type YodlSdkConfig, YodlSignup, type YodlSignupProps, type YodlSignupStatus, type YodlTheme, type YodlThemeMode, createYodlSdk, isPaymentQr };