@frak-labs/core-sdk 0.2.1 → 1.0.0-beta.10dada3f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +1 -2
  2. package/cdn/bundle.js +3 -3
  3. package/dist/actions-Bsl5ub7_.js +1 -0
  4. package/dist/actions-C_B0fn1P.cjs +1 -0
  5. package/dist/actions.cjs +1 -1
  6. package/dist/actions.d.cts +3 -3
  7. package/dist/actions.d.ts +3 -3
  8. package/dist/actions.js +1 -1
  9. package/dist/bundle.cjs +1 -1
  10. package/dist/bundle.d.cts +4 -4
  11. package/dist/bundle.d.ts +4 -4
  12. package/dist/bundle.js +1 -1
  13. package/dist/{computeLegacyProductId-CCAZvLa5.d.cts → index-BSGP3dbi.d.ts} +250 -73
  14. package/dist/{siweAuthenticate-CVigMOxz.d.cts → index-Bh0TuKYS.d.ts} +122 -8
  15. package/dist/{siweAuthenticate-CnCZ7mok.d.ts → index-DW8xes2o.d.cts} +122 -8
  16. package/dist/{computeLegacyProductId-b5cUWdAm.d.ts → index-TRJNS6B5.d.cts} +250 -73
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +3 -3
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +1 -1
  21. package/dist/{openSso-B0g7-807.d.cts → openSso-Bvhy_urG.d.cts} +395 -50
  22. package/dist/{openSso-CMzwvaCa.d.ts → openSso-D2kTUv0-.d.ts} +394 -49
  23. package/dist/sdkConfigStore-B6CkorsU.cjs +1 -0
  24. package/dist/sdkConfigStore-Dx0oAVEO.js +1 -0
  25. package/dist/src-CLF8o8WB.cjs +13 -0
  26. package/dist/src-al3X6r-n.js +13 -0
  27. package/package.json +12 -13
  28. package/src/actions/displayEmbeddedWallet.ts +6 -2
  29. package/src/actions/displayModal.ts +6 -2
  30. package/src/actions/displaySharingPage.ts +49 -0
  31. package/src/actions/ensureIdentity.ts +2 -2
  32. package/src/actions/getMerchantInformation.test.ts +13 -1
  33. package/src/actions/getMerchantInformation.ts +20 -5
  34. package/src/actions/getMergeToken.ts +33 -0
  35. package/src/actions/getUserReferralStatus.ts +42 -0
  36. package/src/actions/index.ts +8 -1
  37. package/src/actions/referral/processReferral.test.ts +73 -8
  38. package/src/actions/referral/processReferral.ts +15 -12
  39. package/src/actions/referral/setupReferral.test.ts +79 -0
  40. package/src/actions/referral/setupReferral.ts +32 -0
  41. package/src/actions/trackPurchaseStatus.test.ts +32 -20
  42. package/src/actions/trackPurchaseStatus.ts +3 -5
  43. package/src/actions/wrapper/modalBuilder.test.ts +4 -2
  44. package/src/actions/wrapper/modalBuilder.ts +6 -8
  45. package/src/clients/createIFrameFrakClient.ts +233 -28
  46. package/src/clients/transports/iframeLifecycleManager.test.ts +14 -94
  47. package/src/clients/transports/iframeLifecycleManager.ts +35 -53
  48. package/src/index.ts +25 -5
  49. package/src/stubs/rrweb.ts +9 -0
  50. package/src/types/config.ts +19 -3
  51. package/src/types/context.ts +16 -4
  52. package/src/types/index.ts +15 -1
  53. package/src/types/lifecycle/client.ts +29 -27
  54. package/src/types/lifecycle/iframe.ts +7 -8
  55. package/src/types/resolvedConfig.ts +138 -0
  56. package/src/types/rpc/displaySharingPage.ts +100 -0
  57. package/src/types/rpc/embedded/index.ts +1 -1
  58. package/src/types/rpc/interaction.ts +4 -0
  59. package/src/types/rpc/userReferralStatus.ts +20 -0
  60. package/src/types/rpc.ts +54 -5
  61. package/src/types/tracking.ts +36 -0
  62. package/src/utils/FrakContext.test.ts +179 -1
  63. package/src/utils/FrakContext.ts +83 -8
  64. package/src/utils/analytics/events/component.ts +58 -0
  65. package/src/utils/analytics/events/index.ts +20 -0
  66. package/src/utils/analytics/events/lifecycle.ts +26 -0
  67. package/src/utils/analytics/events/referral.ts +11 -0
  68. package/src/utils/analytics/index.ts +8 -0
  69. package/src/utils/{trackEvent.test.ts → analytics/trackEvent.test.ts} +22 -30
  70. package/src/utils/analytics/trackEvent.ts +34 -0
  71. package/src/utils/backendUrl.test.ts +2 -2
  72. package/src/utils/backendUrl.ts +1 -1
  73. package/src/utils/cache/index.ts +7 -0
  74. package/src/utils/cache/lruMap.test.ts +55 -0
  75. package/src/utils/cache/lruMap.ts +38 -0
  76. package/src/utils/cache/withCache.test.ts +168 -0
  77. package/src/utils/cache/withCache.ts +124 -0
  78. package/src/utils/inAppBrowser.ts +60 -0
  79. package/src/utils/index.ts +11 -5
  80. package/src/utils/mergeAttribution.test.ts +153 -0
  81. package/src/utils/mergeAttribution.ts +75 -0
  82. package/src/utils/sdkConfigStore.test.ts +405 -0
  83. package/src/utils/sdkConfigStore.ts +263 -0
  84. package/src/utils/sso.ts +3 -7
  85. package/dist/setupClient-BduY6Sym.cjs +0 -13
  86. package/dist/setupClient-ftmdQ-I8.js +0 -13
  87. package/dist/siweAuthenticate-BWmI2_TN.cjs +0 -1
  88. package/dist/siweAuthenticate-zczqxm0a.js +0 -1
  89. package/dist/trackEvent-CeLFVzZn.js +0 -1
  90. package/dist/trackEvent-Ew5r5zfI.cjs +0 -1
  91. package/src/utils/merchantId.test.ts +0 -653
  92. package/src/utils/merchantId.ts +0 -143
  93. package/src/utils/trackEvent.ts +0 -41
@@ -1,6 +1,6 @@
1
- import { J as Currency, V as SsoMetadata, Y as FrakWalletSdkConfig, _ as TokenAmountType, a as FrakContextV1, i as FrakContext, l as FrakClient, o as FrakContextV2, z as PrepareSsoParamsType } from "./openSso-B0g7-807.cjs";
1
+ import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, ct as AttributionParams, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, st as AttributionDefaults, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-D2kTUv0-.js";
2
+ import { Hex } from "viem";
2
3
  import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
3
- import { Address, Hex } from "viem";
4
4
 
5
5
  //#region src/types/compression.d.ts
6
6
  /**
@@ -22,35 +22,12 @@ type HashProtectedData<DataType> = Readonly<DataType & {
22
22
  */
23
23
  type KeyProvider<DataType> = (value: DataType) => string[];
24
24
  //#endregion
25
- //#region src/types/tracking.d.ts
26
- type UtmParams = {
27
- source?: string;
28
- medium?: string;
29
- campaign?: string;
30
- term?: string;
31
- content?: string;
32
- };
33
- type TrackArrivalParams = {
34
- /** @deprecated V1 legacy — use referrerClientId for v2 contexts */referrerWallet?: Address;
35
- referrerClientId?: string;
36
- referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
37
- referralTimestamp?: number;
38
- landingUrl?: string;
39
- utmParams?: UtmParams;
40
- };
41
- type TrackArrivalResult = {
42
- success: boolean;
43
- identityGroupId?: string;
44
- touchpointId?: string;
45
- error?: string;
46
- };
47
- //#endregion
48
25
  //#region src/clients/createIFrameFrakClient.d.ts
49
26
  /**
50
27
  * Create a new iframe Frak client
51
28
  * @param args
52
29
  * @param args.config - The configuration to use for the Frak Wallet SDK.
53
- * When `config.domain` is set, it is forwarded to the iframe handshake so the listener resolves the correct merchant in tunneled/proxied environments (e.g. Shopify dev with Cloudflare tunnel).
30
+ * When `config.domain` is set, it is used to resolve the correct merchant config in tunneled/proxied environments (e.g. Shopify dev with Cloudflare tunnel).
54
31
  * @param args.iframe - The iframe to use for the communication
55
32
  * @returns The created Frak Client
56
33
  *
@@ -134,6 +111,112 @@ declare const locales: {
134
111
  readonly gbp: "en-GB";
135
112
  };
136
113
  //#endregion
114
+ //#region src/utils/analytics/events/component.d.ts
115
+ type ButtonBaseProps = {
116
+ placement?: string;
117
+ target_interaction?: string;
118
+ has_reward?: boolean;
119
+ };
120
+ type BannerVariant = "referral" | "inapp";
121
+ type BannerOutcome = "clicked" | "dismissed";
122
+ type PostPurchaseVariant = "referrer" | "referee";
123
+ type ShareClickAction = "share-modal" | "embedded-wallet" | "sharing-page";
124
+ type SdkComponentEventMap = {
125
+ share_button_clicked: ButtonBaseProps & {
126
+ click_action: ShareClickAction;
127
+ };
128
+ share_modal_error: ButtonBaseProps & {
129
+ error?: string;
130
+ };
131
+ open_in_app_clicked: {
132
+ placement?: string;
133
+ path: string;
134
+ };
135
+ app_not_installed: {
136
+ placement?: string;
137
+ path: string;
138
+ };
139
+ banner_impression: {
140
+ placement?: string;
141
+ variant: BannerVariant;
142
+ has_reward?: boolean;
143
+ };
144
+ banner_resolved: {
145
+ placement?: string;
146
+ variant: BannerVariant;
147
+ outcome: BannerOutcome;
148
+ };
149
+ post_purchase_impression: {
150
+ placement?: string;
151
+ variant: PostPurchaseVariant;
152
+ has_reward?: boolean;
153
+ };
154
+ post_purchase_clicked: {
155
+ placement?: string;
156
+ variant: PostPurchaseVariant;
157
+ };
158
+ };
159
+ //#endregion
160
+ //#region src/utils/analytics/events/lifecycle.d.ts
161
+ type SdkHandshakeFailureReason = "timeout" | "origin" | "asset_push" | "unknown";
162
+ type SdkLifecycleEventMap = {
163
+ sdk_initialized: {
164
+ sdkVersion?: string;
165
+ };
166
+ sdk_iframe_connected: {
167
+ handshake_duration_ms: number;
168
+ };
169
+ sdk_iframe_handshake_failed: {
170
+ reason: SdkHandshakeFailureReason;
171
+ };
172
+ /**
173
+ * Emitted by the CDN bootstrap when `initFrakSdk()` throws before a
174
+ * client is available. Uses a transient OpenPanel instance so broken
175
+ * partner integrations are still captured.
176
+ */
177
+ sdk_init_failed: {
178
+ reason: string;
179
+ config_missing?: boolean;
180
+ };
181
+ };
182
+ //#endregion
183
+ //#region src/utils/analytics/events/referral.d.ts
184
+ type SdkReferralEventMap = {
185
+ user_referred_started: {
186
+ referrer?: string;
187
+ referrerClientId?: string;
188
+ referrerWallet?: string;
189
+ walletStatus?: string;
190
+ };
191
+ user_referred_completed: {
192
+ status: "success";
193
+ };
194
+ };
195
+ //#endregion
196
+ //#region src/utils/analytics/events/index.d.ts
197
+ /**
198
+ * Merged SDK event map. Consumed by the SDK's typed `trackEvent`.
199
+ * Stays isolated from wallet-shared because the SDK ships in partner
200
+ * bundles (different OpenPanel client id, no wallet-shared dependency
201
+ * allowed — see `packages/wallet-shared/AGENTS.md`).
202
+ */
203
+ type SdkEventMap = SdkLifecycleEventMap & SdkComponentEventMap & SdkReferralEventMap;
204
+ //#endregion
205
+ //#region src/utils/analytics/trackEvent.d.ts
206
+ /**
207
+ * Track an analytics event via the SDK's OpenPanel instance.
208
+ * Fire-and-forget — silently catches errors so analytics never break a
209
+ * partner integration.
210
+ *
211
+ * The client must be passed explicitly because the OpenPanel instance is
212
+ * scoped to each `FrakClient` (a partner site may hold multiple iframes).
213
+ *
214
+ * @param client - The Frak client instance (no-op if undefined)
215
+ * @param event - Typed event name from the SDK event map
216
+ * @param properties - Typed properties for the given event
217
+ */
218
+ declare function trackEvent<K extends keyof SdkEventMap>(client: FrakClient | undefined, event: K, properties?: SdkEventMap[K]): void;
219
+ //#endregion
137
220
  //#region src/utils/backendUrl.d.ts
138
221
  /**
139
222
  * Get the backend URL for API calls
@@ -143,6 +226,50 @@ declare const locales: {
143
226
  */
144
227
  declare function getBackendUrl(walletUrl?: string): string;
145
228
  //#endregion
229
+ //#region src/utils/cache/withCache.d.ts
230
+ type WithCacheOptions = {
231
+ /** The key to cache the data against */cacheKey: string; /** Time in ms that cached data will remain valid. Default: 30_000 (30s). Set to 0 to disable caching. */
232
+ cacheTime?: number;
233
+ };
234
+ /**
235
+ * Returns the result of a given promise, and caches the result for
236
+ * subsequent invocations against a provided cache key.
237
+ *
238
+ * Also deduplicates concurrent calls — if multiple callers request the same
239
+ * cache key while the promise is pending, they share the same promise.
240
+ *
241
+ * @example
242
+ * ```ts
243
+ * // First call fetches, subsequent calls return cached data for 30s
244
+ * const data = await withCache(
245
+ * () => client.request({ method: "frak_getMerchantInformation" }),
246
+ * { cacheKey: "merchantInfo", cacheTime: 30_000 }
247
+ * );
248
+ * ```
249
+ */
250
+ declare function withCache<TData>(fn: () => Promise<TData>, {
251
+ cacheKey,
252
+ cacheTime
253
+ }: WithCacheOptions): Promise<TData>;
254
+ /**
255
+ * Get a cache handle for a specific key, useful for manual invalidation.
256
+ *
257
+ * @example
258
+ * ```ts
259
+ * // Invalidate merchant info cache after a mutation
260
+ * getCache("frak_getMerchantInformation").clear();
261
+ * ```
262
+ */
263
+ declare function getCache(cacheKey: string): {
264
+ /** Clear both the pending promise and the cached response */clear: () => void; /** Check if a non-expired response exists */
265
+ has: (cacheTime?: number) => boolean;
266
+ };
267
+ /**
268
+ * Clear all cached data (both pending promises and resolved responses).
269
+ * Called automatically when the client is destroyed.
270
+ */
271
+ declare function clearAllCache(): void;
272
+ //#endregion
146
273
  //#region src/utils/clientId.d.ts
147
274
  /**
148
275
  * Client ID utilities for anonymous tracking
@@ -276,17 +403,25 @@ declare function parse({
276
403
  /**
277
404
  * Add or replace the `fCtx` query parameter in a URL with the given context.
278
405
  *
406
+ * Standard affiliation params (`utm_source`, `utm_medium`, `utm_campaign`,
407
+ * `ref`, `via`, ...) are always appended using gap-fill semantics: pre-existing
408
+ * params on the URL are preserved, defaults are derived from the context when
409
+ * applicable, and `attribution` overrides take precedence when provided.
410
+ *
279
411
  * @param args
280
412
  * @param args.url - The URL to update
281
413
  * @param args.context - The context to embed (V1 or V2)
414
+ * @param args.attribution - Optional attribution overrides. Defaults are applied even when omitted.
282
415
  * @returns The updated URL string, or null on failure
283
416
  */
284
417
  declare function update({
285
418
  url,
286
- context
419
+ context,
420
+ attribution
287
421
  }: {
288
422
  url?: string;
289
423
  context: FrakContextV1 | FrakContextV2;
424
+ attribution?: AttributionParams;
290
425
  }): string | null;
291
426
  /**
292
427
  * Remove the `fCtx` query parameter from a URL.
@@ -415,47 +550,104 @@ declare function createIframe({
415
550
  */
416
551
  declare function findIframeInOpener(pathname?: string): Window | null;
417
552
  //#endregion
418
- //#region src/utils/merchantId.d.ts
553
+ //#region src/utils/inAppBrowser.d.ts
554
+ /**
555
+ * Whether the current device runs iOS (including iPadOS 13+).
556
+ */
557
+ declare const isIOS: boolean;
419
558
  /**
420
- * Merchant ID utilities for auto-fetching from backend
559
+ * Whether the current browser is a social media in-app browser
560
+ * (Instagram, Facebook).
421
561
  */
562
+ declare const isInAppBrowser: boolean;
422
563
  /**
423
- * Fetch merchantId from backend by domain
564
+ * Redirect to external browser from in-app WebView.
424
565
  *
425
- * @param domain - The domain to lookup (defaults to current hostname)
426
- * @param walletUrl - Optional wallet URL to derive backend URL
427
- * @returns The merchantId if found, undefined otherwise
566
+ * - **iOS**: Uses `x-safari-https://` scheme server-side 302 redirects
567
+ * to custom URL schemes are silently swallowed by WKWebView.
568
+ * Direct `window.location.href` assignment works (confirmed iOS 17+).
428
569
  *
429
- * @example
430
- * ```ts
431
- * const merchantId = await fetchMerchantId("shop.example.com");
432
- * if (merchantId) {
433
- * // Use merchantId for tracking
434
- * }
435
- * ```
570
+ * - **Android**: Uses backend `/common/social` endpoint which returns a PDF
571
+ * Content-Type response, forcing the WebView to hand off to the default browser.
572
+ *
573
+ * @param targetUrl - The URL to open in the external browser
436
574
  */
437
- declare function fetchMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
575
+ declare function redirectToExternalBrowser(targetUrl: string): void;
576
+ //#endregion
577
+ //#region src/utils/mergeAttribution.d.ts
438
578
  /**
439
- * Clear the cached merchantId
440
- * Useful for testing or when switching domains
579
+ * Inputs for {@link mergeAttribution}.
441
580
  */
442
- declare function clearMerchantIdCache(): void;
581
+ type MergeAttributionInput = {
582
+ /**
583
+ * Per-call attribution override passed to actions like `displaySharingPage`.
584
+ *
585
+ * - `null` explicitly disables attribution (no UTM/ref/via params are added).
586
+ * - `undefined` means "no per-call override" — defaults apply if present.
587
+ * - An object (including `{}`) merges field-by-field with defaults.
588
+ */
589
+ perCall: AttributionParams | null | undefined;
590
+ /**
591
+ * Pre-merged merchant-level defaults (backend config > SDK static config).
592
+ * `utm_content` is intentionally absent from this shape.
593
+ */
594
+ defaults?: AttributionDefaults;
595
+ /**
596
+ * Per-product `utm_content` override (from the currently selected
597
+ * `SharingPageProduct`). Takes precedence over `perCall.utmContent`.
598
+ */
599
+ productUtmContent?: string;
600
+ };
443
601
  /**
444
- * Get merchantId from config or auto-fetch from backend
602
+ * Merge the three attribution layers into a single {@link AttributionParams}
603
+ * value suitable for `FrakContextManager.update`.
445
604
  *
446
- * @param config - The SDK config that may contain merchantId
447
- * @param walletUrl - Optional wallet URL to derive backend URL
448
- * @returns The merchantId if available (from config or fetch), undefined otherwise
449
- */
450
- declare function resolveMerchantId(config: {
451
- metadata?: {
452
- merchantId?: string;
453
- };
454
- }, walletUrl?: string): Promise<string | undefined>;
605
+ * Priority per field:
606
+ * 1. `perCall` (wins)
607
+ * 2. `defaults` (merchant-level, backend > SDK static, already pre-merged)
608
+ * 3. Hardcoded fallbacks resolved later by `FrakContextManager`
609
+ *
610
+ * Special rules:
611
+ * - `perCall === null` returns `undefined` (explicit disable: no UTM/ref/via).
612
+ * - `perCall === undefined` (no opinion) yields at least `{}` so `FrakContextManager`
613
+ * applies its hardcoded defaults (utm_source=frak, utm_medium=referral,
614
+ * utm_campaign=<merchantId>, ref=<clientId>, via=frak).
615
+ * - `utm_content` never comes from `defaults`; only `productUtmContent` or
616
+ * `perCall.utmContent` can populate it.
617
+ */
618
+ declare function mergeAttribution({
619
+ perCall,
620
+ defaults,
621
+ productUtmContent
622
+ }: MergeAttributionInput): AttributionParams | undefined;
623
+ //#endregion
624
+ //#region src/utils/sdkConfigStore.d.ts
625
+ declare const GLOBAL_KEY = "__frakSdkConfig";
626
+ declare global {
627
+ interface Window {
628
+ [GLOBAL_KEY]?: SdkResolvedConfig;
629
+ }
630
+ interface WindowEventMap {
631
+ "frak:config": CustomEvent<SdkResolvedConfig>;
632
+ }
633
+ }
634
+ declare function getConfig(): SdkResolvedConfig;
635
+ declare const sdkConfigStore: {
636
+ getConfig: typeof getConfig;
637
+ readonly isResolved: boolean;
638
+ readonly isCacheFresh: boolean;
639
+ setCacheScope(domain: string, lang?: string): void;
640
+ setConfig(config: SdkResolvedConfig): void;
641
+ reset(): void;
642
+ clearCache(): void;
643
+ resolve(domain?: string, walletUrl?: string, lang?: Language): Promise<MerchantConfigResponse | undefined>;
644
+ getMerchantId(): string | undefined;
645
+ resolveMerchantId(domain?: string, walletUrl?: string): Promise<string | undefined>;
646
+ };
455
647
  //#endregion
456
648
  //#region src/utils/sso.d.ts
457
649
  type AppSpecificSsoMetadata = SsoMetadata & {
458
- name: string;
650
+ name?: string;
459
651
  css?: string;
460
652
  };
461
653
  /**
@@ -489,7 +681,7 @@ type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
489
681
  * // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
490
682
  * ```
491
683
  */
492
- declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string, clientId: string, css?: string): string;
684
+ declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, merchantId: string, name: string | undefined, clientId: string, css?: string): string;
493
685
  /**
494
686
  * Type of compressed the sso data
495
687
  */
@@ -501,28 +693,13 @@ type CompressedSsoData = {
501
693
  l?: "en" | "fr";
502
694
  m: string;
503
695
  md: {
504
- n: string;
696
+ n?: string;
505
697
  css?: string;
506
698
  l?: string;
507
699
  h?: string;
508
700
  };
509
701
  };
510
702
  //#endregion
511
- //#region src/utils/trackEvent.d.ts
512
- /**
513
- * Analytics event names emitted by the SDK
514
- */
515
- type FrakEvent = "share_button_clicked" | "wallet_button_clicked" | "open_in_app_clicked" | "open_in_app_login_clicked" | "app_not_installed" | "share_modal_error" | "user_referred_started" | "user_referred_completed" | "user_referred_error";
516
- type EventProps = Record<string, unknown>;
517
- /**
518
- * Track an analytics event via OpenPanel.
519
- * Fire-and-forget: silently catches errors.
520
- * @param client - The Frak client instance (no-op if undefined)
521
- * @param event - The event name to track
522
- * @param props - Optional event properties
523
- */
524
- declare function trackEvent(client: FrakClient | undefined, event: FrakEvent, props?: EventProps): void;
525
- //#endregion
526
703
  //#region src/utils/computeLegacyProductId.d.ts
527
704
  /**
528
705
  * Compute the legacy product id from a domain
@@ -534,4 +711,4 @@ declare function computeLegacyProductId({
534
711
  domain?: string;
535
712
  }): `0x${string}`;
536
713
  //#endregion
537
- export { getBackendUrl as A, HashProtectedData as B, triggerDeepLinkWithFallback as C, base64urlDecode as D, compressJsonToB64 as E, createIFrameFrakClient as F, TrackArrivalParams as I, TrackArrivalResult as L, locales as M, setupClient as N, base64urlEncode as O, DebugInfoGatherer as P, UtmParams as R, toAndroidIntentUrl as S, decompressJsonFromB64 as T, KeyProvider as V, formatAmount as _, CompressedSsoData as a, isChromiumAndroid as b, clearMerchantIdCache as c, baseIframeProps as d, createIframe as f, getCurrencyAmountKey as g, getSupportedCurrency as h, AppSpecificSsoMetadata as i, LocalesKey as j, getClientId as k, fetchMerchantId as l, getSupportedLocale as m, FrakEvent as n, FullSsoParams as o, findIframeInOpener as p, trackEvent as r, generateSsoUrl as s, computeLegacyProductId as t, resolveMerchantId as u, FrakContextManager as v, DEEP_LINK_SCHEME as w, isFrakDeepLink as x, DeepLinkFallbackOptions as y, CompressedData as z };
714
+ export { getClientId as A, setupClient as B, toAndroidIntentUrl as C, compressJsonToB64 as D, decompressJsonFromB64 as E, trackEvent as F, KeyProvider as G, createIFrameFrakClient as H, SdkEventMap as I, SdkHandshakeFailureReason as L, getCache as M, withCache as N, base64urlDecode as O, getBackendUrl as P, LocalesKey as R, isFrakDeepLink as S, DEEP_LINK_SCHEME as T, CompressedData as U, DebugInfoGatherer as V, HashProtectedData as W, getCurrencyAmountKey as _, generateSsoUrl as a, DeepLinkFallbackOptions as b, mergeAttribution as c, redirectToExternalBrowser as d, baseIframeProps as f, getSupportedCurrency as g, getSupportedLocale as h, FullSsoParams as i, clearAllCache as j, base64urlEncode as k, isIOS as l, findIframeInOpener as m, AppSpecificSsoMetadata as n, sdkConfigStore as o, createIframe as p, CompressedSsoData as r, MergeAttributionInput as s, computeLegacyProductId as t, isInAppBrowser as u, formatAmount as v, triggerDeepLinkWithFallback as w, isChromiumAndroid as x, FrakContextManager as y, locales as z };
@@ -1,13 +1,14 @@
1
- import { A as SendTransactionModalStepType, B as PrepareSsoReturnType, E as ModalRpcMetadata, F as SiweAuthenticationParams, H as FinalActionType, I as LoginModalStepType, O as ModalRpcStepsResultType, P as SiweAuthenticateReturnType, T as DisplayModalParamsType, U as FinalModalStepType, b as DisplayEmbeddedWalletResultType, h as GetMerchantInformationReturnType, i as FrakContext, j as SendTransactionReturnType, k as ModalStepTypes, l as FrakClient, p as WalletStatusReturnType, v as SendInteractionParamsType, y as DisplayEmbeddedWalletParamsType, z as PrepareSsoParamsType } from "./openSso-B0g7-807.cjs";
1
+ import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-D2kTUv0-.js";
2
2
 
3
3
  //#region src/actions/displayEmbeddedWallet.d.ts
4
4
  /**
5
5
  * Function used to display the Frak embedded wallet popup
6
6
  * @param client - The current Frak Client
7
7
  * @param params - The parameter used to customise the embedded wallet
8
+ * @param placement - Optional placement ID to associate with this display request
8
9
  * @returns The embedded wallet display result
9
10
  */
10
- declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
11
+ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType, placement?: string): Promise<DisplayEmbeddedWalletResultType>;
11
12
  //#endregion
12
13
  //#region src/actions/displayModal.d.ts
13
14
  /**
@@ -16,6 +17,7 @@ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbedd
16
17
  * @param args
17
18
  * @param args.steps - The different steps of the modal
18
19
  * @param args.metadata - The metadata for the modal (customization, etc)
20
+ * @param placement - Optional placement ID to associate with this modal display
19
21
  * @returns The result of each modal steps
20
22
  *
21
23
  * @description This function will display a modal to the user with the provided steps and metadata.
@@ -115,7 +117,41 @@ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbedd
115
117
  declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, {
116
118
  steps,
117
119
  metadata
118
- }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
120
+ }: DisplayModalParamsType<T>, placement?: string): Promise<ModalRpcStepsResultType<T>>;
121
+ //#endregion
122
+ //#region src/actions/displaySharingPage.d.ts
123
+ /**
124
+ * Function used to display a sharing page
125
+ * @param client - The current Frak Client
126
+ * @param params - The parameters to customize the sharing page (products, link override, metadata)
127
+ * @param placement - Optional placement ID to associate with this display request
128
+ * @returns The result indicating the user's action (shared, copied, or dismissed)
129
+ *
130
+ * @description This function will display a full-page sharing UI to the user,
131
+ * showing product info, estimated rewards, sharing steps, FAQ, and share/copy buttons.
132
+ * The sharing link is generated from the user's wallet context + merchant info.
133
+ *
134
+ * @remarks
135
+ * - The promise resolves on the first user action (share or copy) but the page stays visible
136
+ * - The user can continue to share/copy multiple times after the initial resolution
137
+ * - Dismissing the page after a share/copy action is a no-op (promise already resolved)
138
+ * - If the user dismisses without any action, the promise resolves with `{ action: "dismissed" }`
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const result = await displaySharingPage(frakClient, {
143
+ * products: [
144
+ * {
145
+ * title: "Babies camel cuir velours bout carré",
146
+ * imageUrl: "https://example.com/product.jpg",
147
+ * },
148
+ * ],
149
+ * });
150
+ *
151
+ * console.log("User action:", result.action); // "shared" | "copied" | "dismissed"
152
+ * ```
153
+ */
154
+ declare function displaySharingPage(client: FrakClient, params: DisplaySharingPageParamsType, placement?: string): Promise<DisplaySharingPageResultType>;
119
155
  //#endregion
120
156
  //#region src/actions/ensureIdentity.d.ts
121
157
  /**
@@ -144,13 +180,70 @@ declare function ensureIdentity(interactionToken: string): Promise<void>;
144
180
  //#endregion
145
181
  //#region src/actions/getMerchantInformation.d.ts
146
182
  /**
147
- * Fetch the current merchant information (name, rewards, tiers) from the wallet iframe
183
+ * Fetch the current merchant information (name, rewards, tiers) from the wallet iframe.
184
+ *
185
+ * Results are cached in memory for 30 seconds by default. Concurrent calls
186
+ * while a request is in-flight are deduplicated automatically.
187
+ *
148
188
  * @param client - The current Frak Client
189
+ * @param options - Optional cache configuration
190
+ * @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
149
191
  * @returns The merchant information including available reward tiers
150
192
  *
151
193
  * @see {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`} for the return type shape
152
194
  */
153
- declare function getMerchantInformation(client: FrakClient): Promise<GetMerchantInformationReturnType>;
195
+ declare function getMerchantInformation(client: FrakClient, options?: {
196
+ cacheTime?: number;
197
+ }): Promise<GetMerchantInformationReturnType>;
198
+ //#endregion
199
+ //#region src/actions/getMergeToken.d.ts
200
+ /**
201
+ * Fetch a merge token for the current anonymous identity.
202
+ *
203
+ * Used by in-app browser redirect flows to preserve identity
204
+ * when switching from a WebView to the system browser.
205
+ * The token is appended as `?fmt=` to the redirect URL.
206
+ *
207
+ * Results are cached in memory for 30 seconds by default. Concurrent calls
208
+ * while a request is in-flight are deduplicated automatically.
209
+ *
210
+ * @param client - The current Frak Client
211
+ * @param options - Optional cache configuration
212
+ * @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
213
+ * @returns The merge token string, or null if unavailable
214
+ */
215
+ declare function getMergeToken(client: FrakClient, options?: {
216
+ cacheTime?: number;
217
+ }): Promise<string | null>;
218
+ //#endregion
219
+ //#region src/actions/getUserReferralStatus.d.ts
220
+ /**
221
+ * Fetch the current user's referral status on the current merchant.
222
+ *
223
+ * The listener resolves the user's identity (via clientId or wallet session)
224
+ * and checks whether a referral link exists where the user is the referee.
225
+ *
226
+ * Results are cached in memory for 30 seconds by default. Concurrent calls
227
+ * while a request is in-flight are deduplicated automatically.
228
+ *
229
+ * Returns `null` when the user's identity cannot be resolved.
230
+ *
231
+ * @param client - The current Frak Client
232
+ * @param options - Optional cache configuration
233
+ * @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
234
+ * @returns The user's referral status, or `null` if identity cannot be resolved
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * const status = await getUserReferralStatus(client);
239
+ * if (status?.isReferred) {
240
+ * console.log("User was referred to this merchant");
241
+ * }
242
+ * ```
243
+ */
244
+ declare function getUserReferralStatus(client: FrakClient, options?: {
245
+ cacheTime?: number;
246
+ }): Promise<UserReferralStatusType | null>;
154
247
  //#endregion
155
248
  //#region src/actions/prepareSso.d.ts
156
249
  /**
@@ -256,6 +349,26 @@ declare function referralInteraction(client: FrakClient, {
256
349
  options?: ProcessReferralOptions;
257
350
  }): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
258
351
  //#endregion
352
+ //#region src/actions/referral/setupReferral.d.ts
353
+ /**
354
+ * Custom event name dispatched on successful referral processing.
355
+ *
356
+ * Fired once per page load when a valid referral context is found in the URL
357
+ * and successfully tracked. Consumers (e.g. `<frak-banner>`) listen for this
358
+ * to display a referral success message.
359
+ */
360
+ declare const REFERRAL_SUCCESS_EVENT = "frak:referral-success";
361
+ /**
362
+ * Process referral context and emit a DOM event on success.
363
+ *
364
+ * - Calls {@link referralInteraction} to detect and track any referral in the URL
365
+ * - On `"success"`, dispatches a bare {@link REFERRAL_SUCCESS_EVENT} on `window`
366
+ * - Silently swallows errors (fire-and-forget during SDK init)
367
+ *
368
+ * @param client - The initialized Frak client
369
+ */
370
+ declare function setupReferral(client: FrakClient): Promise<void>;
371
+ //#endregion
259
372
  //#region src/actions/sendInteraction.d.ts
260
373
  /**
261
374
  * Send an interaction to the backend via the listener RPC.
@@ -322,7 +435,7 @@ declare function sendInteraction(client: FrakClient, params: SendInteractionPara
322
435
  * }
323
436
  *
324
437
  * @remarks
325
- * - Merchant id is resolved in this order: explicit `args.merchantId`, `frak-merchant-id` from session storage, then `fetchMerchantId()`.
438
+ * - Merchant id is resolved in this order: explicit `args.merchantId`, then `sdkConfigStore.resolveMerchantId()` (config store sessionStorage → backend fetch).
326
439
  * - This function supports anonymous users and will use the `x-frak-client-id` header when available.
327
440
  * - At least one identity source must exist (`frak-wallet-interaction-token` or `x-frak-client-id`), otherwise the tracking request is skipped.
328
441
  * - This function will print a warning if used in a non-browser environment or if no identity / merchant id can be resolved.
@@ -380,8 +493,9 @@ type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
380
493
  /**
381
494
  * Display the modal
382
495
  * @param metadataOverride - Function returning optional metadata to override the current modal metadata
496
+ * @param placement - Optional placement ID to associate with this modal display
383
497
  */
384
- display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
498
+ display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined, placement?: string) => Promise<ModalRpcStepsResultType<Steps>>;
385
499
  };
386
500
  /**
387
501
  * Represent the output type of the modal builder
@@ -529,4 +643,4 @@ declare function siweAuthenticate(client: FrakClient, {
529
643
  metadata
530
644
  }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
531
645
  //#endregion
532
- export { displayModal as _, ModalBuilder as a, watchWalletStatus as c, referralInteraction as d, ProcessReferralOptions as f, ensureIdentity as g, getMerchantInformation as h, sendTransaction as i, trackPurchaseStatus as l, prepareSso as m, siweAuthenticate as n, ModalStepBuilder as o, processReferral as p, SendTransactionParams as r, modalBuilder as s, SiweAuthenticateModalParams as t, sendInteraction as u, displayEmbeddedWallet as v };
646
+ export { displayEmbeddedWallet as C, displayModal as S, getUserReferralStatus as _, ModalBuilder as a, ensureIdentity as b, watchWalletStatus as c, REFERRAL_SUCCESS_EVENT as d, setupReferral as f, prepareSso as g, processReferral as h, sendTransaction as i, trackPurchaseStatus as l, ProcessReferralOptions as m, siweAuthenticate as n, ModalStepBuilder as o, referralInteraction as p, SendTransactionParams as r, modalBuilder as s, SiweAuthenticateModalParams as t, sendInteraction as u, getMergeToken as v, displaySharingPage as x, getMerchantInformation as y };