@frak-labs/core-sdk 1.0.2-beta.64c76510 → 1.0.2-beta.75bb63ae

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 (88) hide show
  1. package/README.md +0 -1
  2. package/package.json +4 -4
  3. package/src/actions/ensureIdentity.ts +3 -3
  4. package/src/actions/openSso.ts +4 -4
  5. package/src/actions/referral/processReferral.test.ts +38 -22
  6. package/src/actions/referral/processReferral.ts +6 -4
  7. package/src/actions/referral/referralInteraction.test.ts +7 -7
  8. package/src/actions/referral/referralInteraction.ts +1 -1
  9. package/src/actions/sendInteraction.ts +1 -1
  10. package/src/actions/trackPurchaseStatus.test.ts +4 -4
  11. package/src/actions/trackPurchaseStatus.ts +3 -3
  12. package/src/actions/wrapper/siweAuthenticate.test.ts +1 -5
  13. package/src/actions/wrapper/siweAuthenticate.ts +25 -1
  14. package/src/clients/createIFrameFrakClient.ts +5 -21
  15. package/src/clients/index.ts +0 -1
  16. package/src/clients/transports/iframeLifecycleManager.test.ts +10 -10
  17. package/src/clients/transports/iframeLifecycleManager.ts +3 -3
  18. package/src/config/index.ts +3 -0
  19. package/src/{utils → config}/sdkConfigStore.ts +1 -1
  20. package/src/{utils/constants.test.ts → constants.test.ts} +1 -6
  21. package/src/context/address.ts +76 -0
  22. package/src/{utils/FrakContext.test.ts → context/frakContext.test.ts} +4 -2
  23. package/src/{utils/FrakContext.ts → context/frakContext.ts} +4 -4
  24. package/src/{utils → context}/frakContextV2Codec.test.ts +1 -1
  25. package/src/{utils → context}/frakContextV2Codec.ts +6 -6
  26. package/src/context/index.ts +6 -0
  27. package/src/index.ts +17 -22
  28. package/src/stubs/rrweb.ts +8 -4
  29. package/src/types/client.ts +0 -3
  30. package/src/types/config.ts +11 -0
  31. package/src/types/index.ts +1 -0
  32. package/src/utils/{deepLinkWithFallback.ts → browser/deepLinkWithFallback.ts} +1 -1
  33. package/src/utils/{inAppBrowser.ts → browser/inAppBrowser.ts} +13 -0
  34. package/src/utils/browser/index.ts +13 -0
  35. package/src/utils/{formatAmount.test.ts → format/formatAmount.test.ts} +1 -1
  36. package/src/utils/{formatAmount.ts → format/formatAmount.ts} +1 -1
  37. package/src/utils/{getCurrencyAmountKey.test.ts → format/getCurrencyAmountKey.test.ts} +2 -2
  38. package/src/utils/{getCurrencyAmountKey.ts → format/getCurrencyAmountKey.ts} +1 -1
  39. package/src/utils/{getSupportedCurrency.test.ts → format/getSupportedCurrency.test.ts} +2 -2
  40. package/src/utils/{getSupportedCurrency.ts → format/getSupportedCurrency.ts} +2 -2
  41. package/src/utils/{getSupportedLocale.test.ts → format/getSupportedLocale.test.ts} +3 -3
  42. package/src/utils/{getSupportedLocale.ts → format/getSupportedLocale.ts} +2 -2
  43. package/src/utils/format/index.ts +4 -0
  44. package/src/utils/{iframeHelper.test.ts → iframe/iframeHelper.test.ts} +3 -3
  45. package/src/utils/{iframeHelper.ts → iframe/iframeHelper.ts} +3 -3
  46. package/src/utils/iframe/index.ts +6 -0
  47. package/src/utils/index.ts +31 -24
  48. package/src/utils/sso/index.ts +6 -0
  49. package/src/utils/{sso.ts → sso/sso.ts} +2 -2
  50. package/cdn/bundle.js +0 -14
  51. package/dist/actions-DihYM-OG.js +0 -1
  52. package/dist/actions-cYbmqewX.cjs +0 -1
  53. package/dist/actions.cjs +0 -1
  54. package/dist/actions.d.cts +0 -3
  55. package/dist/actions.d.ts +0 -3
  56. package/dist/actions.js +0 -1
  57. package/dist/bundle.cjs +0 -1
  58. package/dist/bundle.d.cts +0 -4
  59. package/dist/bundle.d.ts +0 -4
  60. package/dist/bundle.js +0 -1
  61. package/dist/index-BhBuaCRl.d.cts +0 -707
  62. package/dist/index-BsBbSMxk.d.cts +0 -646
  63. package/dist/index-CeX1Tl7W.d.ts +0 -707
  64. package/dist/index-quaxtKRh.d.ts +0 -646
  65. package/dist/index.cjs +0 -1
  66. package/dist/index.d.cts +0 -3
  67. package/dist/index.d.ts +0 -3
  68. package/dist/index.js +0 -1
  69. package/dist/openSso-DyUQew2K.d.ts +0 -1392
  70. package/dist/openSso-rQhLhPbq.d.cts +0 -1392
  71. package/dist/sdkConfigStore-BXzz5PlK.js +0 -1
  72. package/dist/sdkConfigStore-DDL_fjYX.cjs +0 -1
  73. package/dist/src-CMaRNkkJ.cjs +0 -13
  74. package/dist/src-DMFOQMm6.js +0 -13
  75. package/src/clients/DebugInfo.test.ts +0 -418
  76. package/src/clients/DebugInfo.ts +0 -182
  77. package/src/utils/computeLegacyProductId.ts +0 -11
  78. /package/src/{utils → clients}/ssoUrlListener.test.ts +0 -0
  79. /package/src/{utils → clients}/ssoUrlListener.ts +0 -0
  80. /package/src/{utils → config}/backendUrl.test.ts +0 -0
  81. /package/src/{utils → config}/backendUrl.ts +0 -0
  82. /package/src/{utils → config}/clientId.test.ts +0 -0
  83. /package/src/{utils → config}/clientId.ts +0 -0
  84. /package/src/{utils → config}/sdkConfigStore.test.ts +0 -0
  85. /package/src/{utils/constants.ts → constants.ts} +0 -0
  86. /package/src/{utils → context}/mergeAttribution.test.ts +0 -0
  87. /package/src/{utils → context}/mergeAttribution.ts +0 -0
  88. /package/src/utils/{deepLinkWithFallback.test.ts → browser/deepLinkWithFallback.test.ts} +0 -0
@@ -1,1392 +0,0 @@
1
- import { Address, Hex } from "viem";
2
- import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
3
- import { OpenPanel } from "@openpanel/web";
4
- import { SiweMessage } from "viem/siwe";
5
-
6
- //#region src/types/tracking.d.ts
7
- type UtmParams = {
8
- source?: string;
9
- medium?: string;
10
- campaign?: string;
11
- term?: string;
12
- content?: string;
13
- };
14
- /**
15
- * Attribution parameters appended to outbound sharing URLs.
16
- *
17
- * Defaults are derived from the V2 Frak context when available:
18
- * - `utmSource`: `"frak"`
19
- * - `utmMedium`: `"referral"`
20
- * - `utmCampaign`: merchantId (`context.m`)
21
- * - `via`: `"frak"`
22
- * - `ref`: clientId (`context.c`)
23
- *
24
- * Fields explicitly set here override the defaults. Existing params on the
25
- * base URL are preserved (gap-fill policy) to respect merchant-provided UTMs.
26
- */
27
- type AttributionParams = {
28
- utmSource?: string;
29
- utmMedium?: string;
30
- utmCampaign?: string;
31
- utmContent?: string;
32
- utmTerm?: string;
33
- via?: string;
34
- ref?: string;
35
- };
36
- /**
37
- * Merchant-level attribution defaults.
38
- *
39
- * Same shape as {@link AttributionParams} minus `utmContent`, because
40
- * `utm_content` describes the specific content/creative being shared and is
41
- * inherently per-call or per-product (never a merchant-wide default).
42
- *
43
- * Used as the shape for both:
44
- * - `FrakWalletSdkConfig.attribution` (SDK-side compile-time defaults)
45
- * - Backend merchant-config attribution (dashboard-driven defaults)
46
- */
47
- type AttributionDefaults = Omit<AttributionParams, "utmContent">;
48
- type TrackArrivalParams = {
49
- /** Sharer wallet address. Accepted in both V1 (legacy) and V2 (authenticated sharer) contexts. */referrerWallet?: Address;
50
- referrerClientId?: string;
51
- referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
52
- referralTimestamp?: number;
53
- };
54
- type TrackArrivalResult = {
55
- success: boolean;
56
- identityGroupId?: string;
57
- referralLinkId?: string;
58
- error?: string;
59
- };
60
- //#endregion
61
- //#region src/types/config.d.ts
62
- /**
63
- * All the currencies available
64
- * @category Config
65
- */
66
- type Currency = "eur" | "usd" | "gbp";
67
- /**
68
- * All the languages available
69
- * @category Config
70
- */
71
- type Language = "fr" | "en";
72
- /**
73
- * Configuration for the Frak Wallet SDK
74
- * @category Config
75
- */
76
- type FrakWalletSdkConfig = {
77
- /**
78
- * The Frak wallet url
79
- * @defaultValue "https://wallet.frak.id"
80
- */
81
- walletUrl?: string;
82
- /**
83
- * Some metadata about your implementation of the Frak SDK
84
- */
85
- metadata: {
86
- /**
87
- * Your application name (will be displayed in a few modals and in SSO)
88
- */
89
- name?: string;
90
- /**
91
- * Your merchant ID from the Frak dashboard (UUID format)
92
- * Used for referral tracking and analytics
93
- * If not provided, will be auto-fetched from the backend using your domain
94
- */
95
- merchantId?: string;
96
- /**
97
- * Language to display in the modal
98
- * If undefined, will default to the browser language
99
- */
100
- lang?: Language;
101
- /**
102
- * The currency to display in the modal
103
- * @defaultValue `"eur"`
104
- */
105
- currency?: Currency;
106
- /**
107
- * The logo URL that will be displayed in a few components
108
- */
109
- logoUrl?: string;
110
- /**
111
- * The homepage link that could be displayed in a few components
112
- */
113
- homepageLink?: string;
114
- };
115
- /**
116
- * Some customization for the modal
117
- */
118
- customizations?: {
119
- /**
120
- * Custom CSS styles to apply to the modals and components
121
- */
122
- css?: `${string}.css`;
123
- /**
124
- * Custom i18n configuration for the modal
125
- */
126
- i18n?: I18nConfig;
127
- };
128
- /**
129
- * The domain name of your application
130
- * @defaultValue window.location.host
131
- */
132
- domain?: string;
133
- /**
134
- * Wait for backend config before rendering components.
135
- * When true (default), components show a spinner until backend config is resolved.
136
- * When false, components render immediately with SDK static config / HTML attributes.
137
- * @defaultValue true
138
- */
139
- waitForBackendConfig?: boolean;
140
- /**
141
- * Default attribution params (UTM / via / ref) appended to outbound
142
- * sharing URLs. Per-call `displaySharingPage` overrides win, then backend
143
- * config, then this SDK-level default. `utm_content` is intentionally
144
- * excluded — it is per-content/per-product, never a merchant-wide default.
145
- */
146
- attribution?: AttributionDefaults;
147
- };
148
- /**
149
- * Custom i18n configuration for the modal
150
- * See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
151
- *
152
- * Available variables
153
- * - `{{ productName }}` : The name of your website (`metadata.name`)
154
- * - `{{ productOrigin }}` : The origin url of your website
155
- * - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
156
- *
157
- * Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
158
- * - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
159
- * - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
160
- *
161
- * @example
162
- * ```ts
163
- * // Multi language config
164
- * const multiI18n = {
165
- * fr: {
166
- * "sdk.modal.title": "Titre de modal",
167
- * "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
168
- * },
169
- * en: "https://example.com/en.json"
170
- * }
171
- *
172
- * // Single language config
173
- * const singleI18n = {
174
- * "sdk.modal.title": "Modal title",
175
- * "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
176
- * }
177
- * ```
178
- *
179
- * @category Config
180
- */
181
- type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
182
- /**
183
- * A localized i18n config (inline objects only — URL-based i18n removed)
184
- * @category Config
185
- */
186
- type LocalizedI18nConfig = {
187
- [key: string]: string;
188
- };
189
- //#endregion
190
- //#region src/types/resolvedConfig.d.ts
191
- /**
192
- * Response from the merchant resolve endpoint
193
- * @category Config
194
- */
195
- type MerchantConfigResponse = {
196
- merchantId: string;
197
- name: string;
198
- domain: string;
199
- allowedDomains: string[];
200
- sdkConfig?: ResolvedSdkConfig;
201
- };
202
- /**
203
- * Resolved placement config from backend
204
- * Translations already flattened: default + lang-specific merged into one record
205
- * @category Config
206
- */
207
- type ResolvedPlacement = {
208
- /** Per-component configuration within this placement */components?: {
209
- buttonShare?: {
210
- text?: string;
211
- noRewardText?: string;
212
- clickAction?: "embedded-wallet" | "share-modal" | "sharing-page";
213
- useReward?: boolean;
214
- css?: string;
215
- };
216
- buttonWallet?: {
217
- position?: "right" | "left";
218
- css?: string;
219
- };
220
- openInApp?: {
221
- text?: string;
222
- css?: string;
223
- };
224
- postPurchase?: {
225
- badgeText?: string;
226
- refereeText?: string;
227
- refereeNoRewardText?: string;
228
- referrerText?: string;
229
- referrerNoRewardText?: string;
230
- ctaText?: string;
231
- ctaNoRewardText?: string;
232
- css?: string;
233
- };
234
- banner?: {
235
- referralTitle?: string;
236
- referralDescription?: string;
237
- referralCta?: string;
238
- inappTitle?: string;
239
- inappDescription?: string;
240
- inappCta?: string;
241
- css?: string;
242
- };
243
- };
244
- targetInteraction?: string; /** Already flattened: default + lang-specific merged into one record */
245
- translations?: Record<string, string>; /** Global placement CSS (applied to modals/listener) */
246
- css?: string;
247
- };
248
- /**
249
- * Resolved SDK config from backend `/resolve` endpoint
250
- * Language resolution and translation merging already applied
251
- * @category Config
252
- */
253
- type ResolvedSdkConfig = {
254
- name?: string;
255
- logoUrl?: string;
256
- homepageLink?: string;
257
- currency?: Currency;
258
- lang?: Language; /** When true, all SDK components should be hidden */
259
- hidden?: boolean;
260
- css?: string;
261
- translations?: Record<string, string>;
262
- placements?: Record<string, ResolvedPlacement>; /** Global component defaults (used when no placement override exists) */
263
- components?: ResolvedPlacement["components"];
264
- /**
265
- * Default attribution params applied when building outbound sharing URLs.
266
- * Per-call overrides win over these backend defaults; `utm_content` is
267
- * intentionally excluded (per-content/per-product, never a merchant default).
268
- */
269
- attribution?: AttributionDefaults;
270
- };
271
- /**
272
- * Internal SDK config store state
273
- * Merged config: backend > SDK static > defaults
274
- * Components subscribe to this reactively
275
- * @category Config
276
- */
277
- type SdkResolvedConfig = {
278
- /** Whether the backend config has been resolved */isResolved: boolean; /** Merchant ID from resolution */
279
- merchantId: string; /** Domain returned by the resolve endpoint */
280
- domain?: string; /** Domains allowed for this merchant (used by iframe trust check) */
281
- allowedDomains?: string[]; /** Whether the resolve returned a backend sdkConfig object */
282
- hasRawSdkConfig?: boolean; /** Merged metadata fields */
283
- name?: string;
284
- logoUrl?: string;
285
- homepageLink?: string;
286
- lang?: Language;
287
- currency?: Currency; /** When true, all SDK components should be hidden */
288
- hidden?: boolean; /** Global CSS from backend config (passed to iframe) */
289
- css?: string; /** Global translations (for reference / component fallback) */
290
- translations?: Record<string, string>; /** Named placements (keyed by placement ID) */
291
- placements?: Record<string, ResolvedPlacement>; /** Global component defaults (fallback for placement-level overrides) */
292
- components?: ResolvedPlacement["components"]; /** Merged attribution defaults: backend > SDK static config */
293
- attribution?: AttributionDefaults;
294
- };
295
- //#endregion
296
- //#region src/types/lifecycle/client.d.ts
297
- /**
298
- * Event related to the iframe lifecycle
299
- * @ignore
300
- */
301
- type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | SsoRedirectCompleteEvent | DeepLinkFailedEvent | ResolvedConfigEvent;
302
- type CustomCssEvent = {
303
- clientLifecycle: "modal-css";
304
- data: {
305
- cssLink: string;
306
- };
307
- };
308
- type CustomI18nEvent = {
309
- clientLifecycle: "modal-i18n";
310
- data: {
311
- i18n: I18nConfig;
312
- };
313
- };
314
- type RestoreBackupEvent = {
315
- clientLifecycle: "restore-backup";
316
- data: {
317
- backup: string;
318
- };
319
- };
320
- type HearbeatEvent = {
321
- clientLifecycle: "heartbeat";
322
- data?: never;
323
- };
324
- type SsoRedirectCompleteEvent = {
325
- clientLifecycle: "sso-redirect-complete";
326
- data: {
327
- compressed: string;
328
- };
329
- };
330
- type DeepLinkFailedEvent = {
331
- clientLifecycle: "deep-link-failed";
332
- data: {
333
- originalUrl: string;
334
- };
335
- };
336
- type ResolvedConfigEvent = {
337
- clientLifecycle: "resolved-config";
338
- data: {
339
- merchantId: string; /** The domain the backend resolved this config for */
340
- domain: string; /** All domains registered for this merchant (for domain proof) */
341
- allowedDomains: string[]; /** Full URL of the parent page (for interaction tracking) */
342
- sourceUrl: string;
343
- /**
344
- * Pending merge token extracted from URL (?fmt= parameter).
345
- * When present, listener should execute identity merge in background.
346
- */
347
- pendingMergeToken?: string;
348
- /**
349
- * Persistent per-origin anonymous id generated on the partner site
350
- * (SDK-side localStorage). Propagated here so the listener can
351
- * set it as an OpenPanel global property and stitch SDK events
352
- * with listener events in the same funnel.
353
- */
354
- sdkAnonymousId?: string;
355
- sdkConfig?: ResolvedSdkConfig;
356
- };
357
- };
358
- //#endregion
359
- //#region src/types/lifecycle/iframe.d.ts
360
- /**
361
- * Event related to the iframe lifecycle
362
- * @ignore
363
- */
364
- type IFrameLifecycleEvent = {
365
- iframeLifecycle: "connected" | "show" | "hide" | "remove-backup";
366
- data?: never;
367
- } | DoBackupEvent | RedirectRequestEvent;
368
- type DoBackupEvent = {
369
- iframeLifecycle: "do-backup";
370
- data: {
371
- backup?: string;
372
- };
373
- };
374
- type RedirectRequestEvent = {
375
- iframeLifecycle: "redirect";
376
- data: {
377
- /**
378
- * The base url to redirect to
379
- * If it contain a query param `u`, the client need will suffix the current url to the base url
380
- */
381
- baseRedirectUrl: string;
382
- /**
383
- * Optional merge token for anonymous identity merging
384
- * When provided, appended as ?fmt= query parameter to the final redirect URL
385
- * Used when redirecting out of social browsers to preserve identity across contexts
386
- */
387
- mergeToken?: string;
388
- /**
389
- * When true, open the URL in a new tab via window.open(_blank)
390
- * instead of navigating the current page.
391
- * Requires the postMessage to include user activation delegation
392
- * (includeUserActivation: true) so Safari allows the popup.
393
- */
394
- openInNewTab?: boolean;
395
- };
396
- };
397
- //#endregion
398
- //#region src/constants/interactionTypes.d.ts
399
- /**
400
- * The supported interaction type keys
401
- *
402
- * - `referral` - User arrived via a referral link
403
- * - `create_referral_link` - User created/shared a referral link
404
- * - `purchase` - User completed a purchase
405
- * - `custom.${string}` - Custom interaction type defined per campaign
406
- *
407
- * @inline
408
- */
409
- type InteractionTypeKey = "referral" | "create_referral_link" | "purchase" | `custom.${string}`;
410
- //#endregion
411
- //#region src/types/rpc/modal/generic.d.ts
412
- /**
413
- * Represent a generic modal step type
414
- * @ignore
415
- * @inline
416
- */
417
- type GenericModalStepType<TKey, TParams, TReturns> = {
418
- key: TKey;
419
- params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
420
- returns: TReturns;
421
- };
422
- /**
423
- * Metadata that can be used to customize a modal step
424
- * @group Modal Display
425
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
426
- */
427
- type ModalStepMetadata = {
428
- metadata?: {
429
- /**
430
- * Custom title for the step
431
- * If none provided, it will use an internationalized text
432
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
433
- */
434
- title?: string;
435
- /**
436
- * Custom description for the step
437
- * If none provided, it will use an internationalized text
438
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
439
- */
440
- description?: string;
441
- /**
442
- * Custom text for the primary action of the step
443
- * If none provided, it will use an internationalized text
444
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
445
- */
446
- primaryActionText?: string;
447
- /**
448
- * Custom text for the secondary action of the step
449
- * If none provided, it will use an internationalized text
450
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
451
- */
452
- secondaryActionText?: string;
453
- };
454
- };
455
- //#endregion
456
- //#region src/types/rpc/modal/final.d.ts
457
- /**
458
- * The final modal step type, could be used to display sharing options or a success reward screen.
459
- *
460
- * **Input**: What type final step to display?
461
- * **Output**: None
462
- *
463
- * @group Modal Display
464
- */
465
- type FinalModalStepType = GenericModalStepType<"final", {
466
- dismissedMetadata?: ModalStepMetadata["metadata"];
467
- action: FinalActionType;
468
- autoSkip?: boolean;
469
- }, object>;
470
- /**
471
- * The different types of final actions we can display in the final step
472
- * @group Modal Display
473
- */
474
- type FinalActionType = {
475
- key: "sharing";
476
- options?: {
477
- /**
478
- * @deprecated Use the top level `config.metadata.i18n` instead
479
- */
480
- popupTitle?: string;
481
- /**
482
- * @deprecated Use the top level `config.metadata.i18n` instead
483
- */
484
- text?: string;
485
- link?: string;
486
- };
487
- } | {
488
- key: "reward";
489
- options?: never;
490
- };
491
- //#endregion
492
- //#region src/types/rpc/sso.d.ts
493
- /**
494
- * SSO Metadata
495
- */
496
- type SsoMetadata = {
497
- /**
498
- * URL to your client, if provided will be displayed in the SSO header
499
- */
500
- logoUrl?: string;
501
- /**
502
- * Link to your homepage, if referenced your app name will contain a link on the sso page
503
- */
504
- homepageLink?: string;
505
- };
506
- /**
507
- * Params for preparing SSO (generating URL)
508
- * Same as OpenSsoParamsType but without openInSameWindow (popup-only operation)
509
- * @group RPC Schema
510
- */
511
- type PrepareSsoParamsType = {
512
- /**
513
- * Redirect URL after the SSO (optional)
514
- */
515
- redirectUrl?: string;
516
- /**
517
- * If the SSO should directly exit after completion
518
- * @defaultValue true
519
- */
520
- directExit?: boolean;
521
- /**
522
- * Language of the SSO page (optional)
523
- * It will default to the current user language (or "en" if unsupported language)
524
- */
525
- lang?: "en" | "fr";
526
- /**
527
- * Custom SSO metadata
528
- */
529
- metadata?: SsoMetadata;
530
- };
531
- /**
532
- * Response after preparing SSO
533
- * @group RPC Schema
534
- */
535
- type PrepareSsoReturnType = {
536
- /**
537
- * The SSO URL that should be opened in a popup
538
- */
539
- ssoUrl: string;
540
- };
541
- /**
542
- * Response after an SSO has been openned
543
- */
544
- type OpenSsoReturnType = {
545
- /**
546
- * Optional wallet address, returned when SSO completes via postMessage
547
- * Note: Only present when SSO flow completes (not immediately on open)
548
- */
549
- wallet?: Hex;
550
- };
551
- /**
552
- * Params to start a SSO
553
- * @group RPC Schema
554
- */
555
- type OpenSsoParamsType = PrepareSsoParamsType & {
556
- /**
557
- * Indicate whether we want todo the flow within the same window context, or if we want to do it with an external popup window openned
558
- * Note: Default true if redirectUrl is present, otherwise, false
559
- */
560
- openInSameWindow?: boolean;
561
- /**
562
- * Custom SSO popup url if user want additionnal customisation
563
- */
564
- ssoPopupUrl?: string;
565
- };
566
- //#endregion
567
- //#region src/types/rpc/modal/login.d.ts
568
- /** @inline */
569
- type LoginWithSso = {
570
- allowSso: true;
571
- ssoMetadata?: SsoMetadata;
572
- };
573
- /** @inline */
574
- type LoginWithoutSso = {
575
- allowSso?: false;
576
- ssoMetadata?: never;
577
- };
578
- /**
579
- * The login step for a Modal
580
- *
581
- * **Input**: Do we allow SSO or not? Is yes then the SSO metadata
582
- * **Output**: The logged in wallet address
583
- *
584
- * @group Modal Display
585
- */
586
- type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
587
- wallet: Address;
588
- webauthnProof?: {
589
- challenge: Hex;
590
- authenticatorResponse: string;
591
- };
592
- }>;
593
- //#endregion
594
- //#region src/types/rpc/modal/siweAuthenticate.d.ts
595
- /**
596
- * Parameters used send a SIWE rpc request
597
- */
598
- type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
599
- expirationTimeTimestamp?: number;
600
- notBeforeTimestamp?: number;
601
- };
602
- /**
603
- * Return type of the Siwe transaction rpc request
604
- * @inline
605
- */
606
- type SiweAuthenticateReturnType = {
607
- signature: Hex;
608
- message: string;
609
- };
610
- /**
611
- * The SIWE authentication step for a Modal
612
- *
613
- * **Input**: SIWE message parameters
614
- * **Output**: SIWE result (message signed and wallet signature)
615
- *
616
- * @group Modal Display
617
- */
618
- type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
619
- siwe: SiweAuthenticationParams;
620
- }, SiweAuthenticateReturnType>;
621
- //#endregion
622
- //#region src/types/rpc/modal/transaction.d.ts
623
- /**
624
- * Generic format representing a tx to be sent
625
- */
626
- type SendTransactionTxType = {
627
- to: Address;
628
- data?: Hex;
629
- value?: Hex;
630
- };
631
- /**
632
- * Return type of the send transaction rpc request
633
- * @inline
634
- */
635
- type SendTransactionReturnType = {
636
- hash: Hex;
637
- };
638
- /**
639
- * The send transaction step for a Modal
640
- *
641
- * **Input**: Either a single tx or an array of tx to be sent
642
- * **Output**: The hash of the tx(s) hash (in case of multiple tx, still returns a single hash because it's bundled on the wallet level)
643
- *
644
- * @group Modal Display
645
- */
646
- type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
647
- tx: SendTransactionTxType | SendTransactionTxType[];
648
- }, SendTransactionReturnType>;
649
- //#endregion
650
- //#region src/types/rpc/displayModal.d.ts
651
- /**
652
- * Generic type of steps we will display in the modal to the end user
653
- * @group Modal Display
654
- */
655
- type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | FinalModalStepType;
656
- /**
657
- * Type for the result of a modal request
658
- * Just the `returns` type of each `ModalStepTypes`
659
- * @typeParam T - The list of modal steps we expect to have in the modal
660
- * @group Modal Display
661
- * @group RPC Schema
662
- */
663
- type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = { [K in T[number]["key"]]: Extract<T[number], {
664
- key: K;
665
- }>["returns"] };
666
- /**
667
- * Type for the RPC input of a modal
668
- * Just the `params` type of each `ModalStepTypes`
669
- * @typeParam T - The list of modal steps we expect to have in the modal
670
- * @group Modal Display
671
- * @group RPC Schema
672
- */
673
- type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = { [K in T[number]["key"]]?: Extract<T[number], {
674
- key: K;
675
- }>["params"] };
676
- /**
677
- * RPC metadata for the modal, used on top level modal configuration
678
- * @group Modal Display
679
- * @group RPC Schema
680
- */
681
- type ModalRpcMetadata = {
682
- header?: {
683
- title?: string;
684
- icon?: string;
685
- };
686
- targetInteraction?: InteractionTypeKey;
687
- /**
688
- * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
689
- */
690
- i18n?: I18nConfig;
691
- } & ({
692
- isDismissible: true;
693
- /**
694
- * @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
695
- */
696
- dismissActionTxt?: string;
697
- } | {
698
- isDismissible?: false;
699
- dismissActionTxt?: never;
700
- });
701
- /**
702
- * Params used to display a modal
703
- * @typeParam T - The list of modal steps we expect to have in the modal
704
- * @group Modal Display
705
- */
706
- type DisplayModalParamsType<T extends ModalStepTypes[]> = {
707
- steps: ModalRpcStepsInput<T>;
708
- metadata?: ModalRpcMetadata;
709
- };
710
- //#endregion
711
- //#region src/types/rpc/displaySharingPage.d.ts
712
- /**
713
- * Product information to display on the sharing page
714
- * @group Sharing Page
715
- */
716
- type SharingPageProduct = {
717
- /**
718
- * The product title / name
719
- */
720
- title: string;
721
- /**
722
- * Optional product image URL
723
- */
724
- imageUrl?: string;
725
- /**
726
- * Optional product-specific sharing link
727
- * When provided and the product is selected, this link is used instead of the default sharing link
728
- */
729
- link?: string;
730
- /**
731
- * Optional `utm_content` value to apply when this product is selected.
732
- * Falls back to the page-level `attribution.utmContent` when omitted.
733
- */
734
- utmContent?: string;
735
- };
736
- /**
737
- * Parameters to display the sharing page
738
- * @group Sharing Page
739
- * @group RPC Schema
740
- */
741
- type DisplaySharingPageParamsType = {
742
- /**
743
- * Products to showcase on the sharing page
744
- * If provided, they will be displayed in a product card section
745
- */
746
- products?: SharingPageProduct[];
747
- /**
748
- * Optional link override for sharing
749
- * If not provided, the sharing link will be generated from the current page URL + merchant context
750
- */
751
- link?: string;
752
- /**
753
- * Optional attribution overrides for the outbound sharing URL.
754
- *
755
- * When provided (even as an empty object), Frak adds standard affiliation
756
- * params (`utm_source=frak`, `utm_medium=referral`, `utm_campaign=<merchantId>`,
757
- * `ref=<clientId>`, `via=frak`) alongside `fCtx`. Existing UTMs on the base
758
- * URL are preserved (gap-fill). Set this to `null` to disable attribution
759
- * params entirely (only `fCtx` is added).
760
- *
761
- * @default {} — defaults applied
762
- */
763
- attribution?: AttributionParams | null;
764
- /**
765
- * Optional metadata overrides for the sharing page
766
- */
767
- metadata?: {
768
- /**
769
- * Logo override for the sharing page header
770
- */
771
- logo?: string;
772
- /**
773
- * Link to the homepage of the calling website
774
- */
775
- homepageLink?: string;
776
- /**
777
- * The target interaction behind this sharing page
778
- */
779
- targetInteraction?: InteractionTypeKey;
780
- /**
781
- * i18n overrides for the sharing page
782
- */
783
- i18n?: I18nConfig;
784
- };
785
- };
786
- /**
787
- * Result of the sharing page display
788
- * @group Sharing Page
789
- * @group RPC Schema
790
- */
791
- type DisplaySharingPageResultType = {
792
- /**
793
- * The action the user took
794
- * - "shared": User used the native share dialog
795
- * - "copied": User copied the link to clipboard
796
- * - "dismissed": User dismissed the sharing page without acting
797
- */
798
- action: "shared" | "copied" | "dismissed";
799
- /**
800
- * The install URL for the Frak app
801
- * Can be used as a fallback to redirect the user to the install page
802
- * from the merchant's top-level page (e.g. via `window.location.href`)
803
- */
804
- installUrl?: string;
805
- };
806
- //#endregion
807
- //#region src/types/rpc/embedded/loggedIn.d.ts
808
- /**
809
- * The different type of action we can have on the embedded view (once the user is logged in)
810
- *
811
- * @group Embedded wallet
812
- */
813
- type EmbeddedViewActionSharing = {
814
- key: "sharing";
815
- /**
816
- * Some sharing options
817
- */
818
- options?: {
819
- /**
820
- * The title that will be displayed on the system popup once the system sharing window is open
821
- * @deprecated Use the top level `config.metadata.i18n` instead
822
- */
823
- popupTitle?: string;
824
- /**
825
- * The text that will be shared alongside the link.
826
- * Can contain the variable `{LINK}` to specify where the link is placed, otherwise it will be added at the end
827
- * @deprecated Use the top level `config.metadata.i18n` instead
828
- */
829
- text?: string;
830
- /**
831
- * The link to be shared (will be suffixed with the Frak sharing context)
832
- */
833
- link?: string;
834
- };
835
- };
836
- /**
837
- * The action to display on the logged out embedded view when the user is referred
838
- *
839
- * @group Embedded wallet
840
- */
841
- type EmbeddedViewActionReferred = {
842
- key: "referred";
843
- /**
844
- * No options for a referred action
845
- */
846
- options?: never;
847
- };
848
- /**
849
- * Some configuration options for the embedded view
850
- *
851
- * @group Embedded wallet
852
- */
853
- type LoggedInEmbeddedView = {
854
- /**
855
- * The main action to display on the logged in embedded view
856
- */
857
- action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
858
- };
859
- //#endregion
860
- //#region src/types/rpc/embedded/loggedOut.d.ts
861
- /**
862
- * The view when a user is logged out
863
- * @group Embedded wallet
864
- */
865
- type LoggedOutEmbeddedView = {
866
- /**
867
- * Metadata option when displaying the embedded view
868
- */
869
- metadata?: {
870
- /**
871
- * The main CTA for the logged out view
872
- * - can include some variable, available ones are:
873
- * - `{REWARD}` -> The maximum reward a user can receive when interacting on your website
874
- * - can be formatted in markdown
875
- *
876
- * If not set, it will default to a internationalized message
877
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
878
- */
879
- text?: string;
880
- /**
881
- * The text that will be displayed on the login button
882
- *
883
- * If not set, it will default to a internationalized message
884
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
885
- */
886
- buttonText?: string;
887
- };
888
- };
889
- //#endregion
890
- //#region src/types/rpc/embedded/index.d.ts
891
- /**
892
- * The params used to display the embedded wallet
893
- *
894
- * @group Embedded wallet
895
- */
896
- type DisplayEmbeddedWalletParamsType = {
897
- /**
898
- * The embedded view to display once the user is logged in
899
- */
900
- loggedIn?: LoggedInEmbeddedView;
901
- /**
902
- * The embedded view to display once the user is logged out
903
- */
904
- loggedOut?: LoggedOutEmbeddedView;
905
- /**
906
- * Some metadata to customize the embedded view
907
- */
908
- metadata?: {
909
- /**
910
- * The logo to display on the embedded wallet
911
- * If undefined, will default to no logo displayed
912
- */
913
- logo?: string;
914
- /**
915
- * Link to the homepage of the calling website
916
- * If undefined, will default to the domain of the calling website
917
- */
918
- homepageLink?: string;
919
- /**
920
- * The target interaction behind this modal
921
- */
922
- targetInteraction?: InteractionTypeKey;
923
- /**
924
- * The position of the component
925
- */
926
- position?: "left" | "right";
927
- /**
928
- * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
929
- */
930
- i18n?: I18nConfig;
931
- };
932
- };
933
- /**
934
- * The result of the display embedded wallet rpc request
935
- *
936
- * @group Embedded wallet
937
- */
938
- type DisplayEmbeddedWalletResultType = {
939
- wallet: Address;
940
- };
941
- //#endregion
942
- //#region src/types/rpc/interaction.d.ts
943
- /**
944
- * Parameters for sending interactions via RPC
945
- *
946
- * Note: merchantId and clientId come from WalletRpcContext
947
- * and are NOT included in the params - they are resolved by the listener
948
- *
949
- * @group RPC Schema
950
- */
951
- type SendInteractionParamsType = {
952
- type: "arrival"; /** Sharer wallet address. Accepted in both wallet-only legacy contexts and merchant-context (V2) contexts. */
953
- referrerWallet?: Address;
954
- referrerClientId?: string;
955
- referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
956
- referralTimestamp?: number;
957
- } | {
958
- type: "sharing"; /** Epoch seconds timestamp matching the V2 context `t` field embedded in the referral link URL, used for backend correlation */
959
- sharingTimestamp?: number; /** Merchant order ID linking this sharing event to a purchase (stays server-side, never in URL) */
960
- purchaseId?: string;
961
- } | {
962
- type: "custom";
963
- customType: string;
964
- data?: Record<string, unknown>;
965
- idempotencyKey?: string;
966
- };
967
- //#endregion
968
- //#region src/types/rpc/merchantInformation.d.ts
969
- /**
970
- * The type for the amount of tokens
971
- */
972
- type TokenAmountType = {
973
- amount: number;
974
- eurAmount: number;
975
- usdAmount: number;
976
- gbpAmount: number;
977
- };
978
- /**
979
- * A tier definition for tiered rewards
980
- */
981
- type RewardTier = {
982
- minValue: number;
983
- maxValue?: number;
984
- amount: TokenAmountType;
985
- };
986
- /**
987
- * Estimated reward amount — discriminated union by payout type
988
- *
989
- * - `fixed`: A known token amount (with fiat equivalents)
990
- * - `percentage`: A percent of a purchase field (e.g. 5% of purchase_amount), with optional min/max caps
991
- * - `tiered`: Amount depends on a field value matching tier brackets
992
- */
993
- type EstimatedReward = {
994
- payoutType: "fixed";
995
- amount: TokenAmountType;
996
- } | {
997
- payoutType: "percentage";
998
- percent: number;
999
- percentOf: string;
1000
- maxAmount?: TokenAmountType;
1001
- minAmount?: TokenAmountType;
1002
- } | {
1003
- payoutType: "tiered";
1004
- tierField: string;
1005
- tiers: RewardTier[];
1006
- };
1007
- /**
1008
- * Response of the `frak_getMerchantInformation` RPC method
1009
- * @group RPC Schema
1010
- */
1011
- type GetMerchantInformationReturnType = {
1012
- /**
1013
- * Current merchant id
1014
- */
1015
- id: string;
1016
- /**
1017
- * Some metadata
1018
- */
1019
- onChainMetadata: {
1020
- /**
1021
- * Name of the merchant on-chain
1022
- */
1023
- name: string;
1024
- /**
1025
- * Domain of the merchant on-chain
1026
- */
1027
- domain: string;
1028
- };
1029
- rewards: {
1030
- token?: Address;
1031
- campaignId: string;
1032
- interactionTypeKey: InteractionTypeKey;
1033
- referrer?: EstimatedReward;
1034
- referee?: EstimatedReward;
1035
- }[];
1036
- };
1037
- //#endregion
1038
- //#region src/types/rpc/userReferralStatus.d.ts
1039
- /**
1040
- * User referral status returned by `frak_getUserReferralStatus`.
1041
- *
1042
- * Generic referral context for the current user on a merchant.
1043
- * Used by components like `<frak-post-purchase>` and `<frak-referred-banner>`
1044
- * to adapt their display based on the user's referral relationship.
1045
- *
1046
- * Returns `null` when the user's identity cannot be resolved
1047
- * (e.g. no clientId and no wallet session).
1048
- *
1049
- * @group RPC Schema
1050
- */
1051
- type UserReferralStatusType = {
1052
- /**
1053
- * Whether the user was referred to this merchant by someone else.
1054
- *
1055
- * `true` means a referral link exists where this user is the referee.
1056
- */
1057
- isReferred: boolean;
1058
- };
1059
- //#endregion
1060
- //#region src/types/rpc/walletStatus.d.ts
1061
- /**
1062
- * RPC Response for the method `frak_listenToWalletStatus`
1063
- * @group RPC Schema
1064
- */
1065
- type WalletStatusReturnType = WalletConnected | WalletNotConnected;
1066
- /**
1067
- * @ignore
1068
- * @inline
1069
- */
1070
- type WalletConnected = {
1071
- key: "connected";
1072
- wallet: Address;
1073
- interactionToken?: string;
1074
- };
1075
- /**
1076
- * @ignore
1077
- * @inline
1078
- */
1079
- type WalletNotConnected = {
1080
- key: "not-connected";
1081
- wallet?: never;
1082
- interactionToken?: never;
1083
- };
1084
- //#endregion
1085
- //#region src/types/rpc.d.ts
1086
- /**
1087
- * RPC interface that's used for the iframe communication
1088
- *
1089
- * Define all the methods available within the iFrame RPC client with response type annotations
1090
- *
1091
- * @group RPC Schema
1092
- *
1093
- * @remarks
1094
- * Each method in the schema now includes a ResponseType field that indicates:
1095
- * - "promise": One-shot request that resolves once
1096
- * - "stream": Streaming request that can emit multiple values
1097
- *
1098
- * ### Methods:
1099
- *
1100
- * #### frak_listenToWalletStatus
1101
- * - Params: None
1102
- * - Returns: {@link WalletStatusReturnType}
1103
- * - Response Type: stream (emits updates when wallet status changes)
1104
- *
1105
- * #### frak_displayModal
1106
- * - Params: [requests: {@link ModalRpcStepsInput}, metadata?: {@link ModalRpcMetadata}, configMetadata: {@link FrakWalletSdkConfig}["metadata"], placement?: string]
1107
- * - Returns: {@link ModalRpcStepsResultType}
1108
- * - Response Type: promise (one-shot)
1109
- *
1110
- * #### frak_sso
1111
- * - Params: [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
1112
- * - Returns: {@link OpenSsoReturnType}
1113
- * - Response Type: promise (one-shot)
1114
- *
1115
- * #### frak_getMerchantInformation
1116
- * - Params: None
1117
- * - Returns: {@link GetMerchantInformationReturnType}
1118
- * - Response Type: promise (one-shot)
1119
- *
1120
- * #### frak_displayEmbeddedWallet
1121
- * - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"], placement?: string]
1122
- * - Returns: {@link DisplayEmbeddedWalletResultType}
1123
- * - Response Type: promise (one-shot)
1124
- *
1125
- * #### frak_displaySharingPage
1126
- * - Params: [request: {@link DisplaySharingPageParamsType}, configMetadata: {@link FrakWalletSdkConfig}["metadata"], placement?: string]
1127
- * - Returns: {@link DisplaySharingPageResultType}
1128
- * - Response Type: promise (one-shot)
1129
- */
1130
- type IFrameRpcSchema = [
1131
- /**
1132
- * Method used to listen to the wallet status
1133
- * This is a streaming method that emits updates when wallet status changes
1134
- */
1135
- {
1136
- Method: "frak_listenToWalletStatus";
1137
- Parameters?: undefined;
1138
- ReturnType: WalletStatusReturnType;
1139
- },
1140
- /**
1141
- * Method to display a modal with the provided steps
1142
- * This is a one-shot request
1143
- */
1144
- {
1145
- Method: "frak_displayModal";
1146
- Parameters: [requests: ModalRpcStepsInput, metadata: ModalRpcMetadata | undefined, configMetadata: FrakWalletSdkConfig["metadata"], placement?: string];
1147
- ReturnType: ModalRpcStepsResultType;
1148
- },
1149
- /**
1150
- * Method to prepare SSO (generate URL for popup)
1151
- * Returns the SSO URL that should be opened in a popup
1152
- * Only used for popup flows (not redirect flows)
1153
- */
1154
- {
1155
- Method: "frak_prepareSso";
1156
- Parameters: [params: PrepareSsoParamsType, name?: string, customCss?: string];
1157
- ReturnType: PrepareSsoReturnType;
1158
- },
1159
- /**
1160
- * Method to open/trigger SSO
1161
- * Either triggers redirect (if openInSameWindow/redirectUrl)
1162
- * Or waits for popup completion (if popup mode)
1163
- * This method handles BOTH redirect and popup flows
1164
- */
1165
- {
1166
- Method: "frak_openSso";
1167
- Parameters: [params: OpenSsoParamsType, name?: string, customCss?: string];
1168
- ReturnType: OpenSsoReturnType;
1169
- },
1170
- /**
1171
- * Method to get current merchant information
1172
- * - Is merchant registered?
1173
- * - Does it have running campaign?
1174
- * - Estimated reward on actions
1175
- * This is a one-shot request
1176
- */
1177
- {
1178
- Method: "frak_getMerchantInformation";
1179
- Parameters?: undefined;
1180
- ReturnType: GetMerchantInformationReturnType;
1181
- },
1182
- /**
1183
- * Method to show the embedded wallet, with potential customization
1184
- * This is a one-shot request
1185
- */
1186
- {
1187
- Method: "frak_displayEmbeddedWallet";
1188
- Parameters: [request: DisplayEmbeddedWalletParamsType, metadata: FrakWalletSdkConfig["metadata"], placement?: string];
1189
- ReturnType: DisplayEmbeddedWalletResultType;
1190
- },
1191
- /**
1192
- * Method to send interactions (arrival, sharing, custom events)
1193
- * Fire-and-forget method - no return value expected
1194
- * merchantId is resolved from context
1195
- * clientId is passed via metadata as safeguard against race conditions
1196
- */
1197
- {
1198
- Method: "frak_sendInteraction";
1199
- Parameters: [interaction: SendInteractionParamsType, metadata?: {
1200
- clientId?: string;
1201
- }];
1202
- ReturnType: undefined;
1203
- },
1204
- /**
1205
- * Method to get the current user's referral status on this merchant.
1206
- * Returns whether the user was referred (has a referral link as referee).
1207
- * Returns null when the user's identity cannot be resolved.
1208
- * This is a one-shot request.
1209
- */
1210
- {
1211
- Method: "frak_getUserReferralStatus";
1212
- Parameters?: undefined;
1213
- ReturnType: UserReferralStatusType | null;
1214
- },
1215
- /**
1216
- * Method to display a sharing page with product info and sharing buttons
1217
- * Resolves on first user action (share/copy) but the page stays visible
1218
- * This is a one-shot request
1219
- */
1220
- {
1221
- Method: "frak_displaySharingPage";
1222
- Parameters: [request: DisplaySharingPageParamsType, configMetadata: FrakWalletSdkConfig["metadata"], placement?: string];
1223
- ReturnType: DisplaySharingPageResultType;
1224
- },
1225
- /**
1226
- * Method to get a merge token for the current anonymous identity.
1227
- * Used by in-app browser redirect flows to preserve identity
1228
- * when switching from a WebView to the system browser.
1229
- * Returns the merge token string, or null if unavailable.
1230
- * This is a one-shot request.
1231
- */
1232
- {
1233
- Method: "frak_getMergeToken";
1234
- Parameters?: undefined;
1235
- ReturnType: string | null;
1236
- }];
1237
- //#endregion
1238
- //#region src/types/transport.d.ts
1239
- /**
1240
- * IFrame transport interface
1241
- */
1242
- type IFrameTransport = {
1243
- /**
1244
- * Wait for the connection to be established
1245
- */
1246
- waitForConnection: Promise<boolean>;
1247
- /**
1248
- * Wait for the setup to be done
1249
- */
1250
- waitForSetup: Promise<void>;
1251
- /**
1252
- * Function used to perform a single request via the iframe transport
1253
- */
1254
- request: RpcClient<IFrameRpcSchema, LifecycleMessage>["request"];
1255
- /**
1256
- * Function used to listen to a request response via the iframe transport
1257
- */
1258
- listenerRequest: RpcClient<IFrameRpcSchema, LifecycleMessage>["listen"];
1259
- /**
1260
- * Function used to destroy the iframe transport
1261
- */
1262
- destroy: () => Promise<void>;
1263
- };
1264
- /**
1265
- * Represent an iframe event
1266
- */
1267
- type FrakLifecycleEvent = IFrameLifecycleEvent | ClientLifecycleEvent;
1268
- //#endregion
1269
- //#region src/types/client.d.ts
1270
- /**
1271
- * Representing a Frak client, used to interact with the Frak Wallet
1272
- */
1273
- type FrakClient = {
1274
- config: FrakWalletSdkConfig;
1275
- debugInfo: {
1276
- formatDebugInfo: (error: Error | unknown | string) => string;
1277
- };
1278
- openPanel?: OpenPanel;
1279
- } & IFrameTransport;
1280
- //#endregion
1281
- //#region src/types/context.d.ts
1282
- /**
1283
- * V1 (legacy) Frak Context — contains only the referrer wallet address.
1284
- * Used for backward compatibility with old sharing links.
1285
- * @ignore
1286
- */
1287
- type FrakContextV1 = {
1288
- /** Referrer wallet address */r: Address;
1289
- };
1290
- /**
1291
- * V2 Frak Context — anonymous-first referral context with optional wallet.
1292
- *
1293
- * Carries merchant context (`m`) and creation timestamp (`t`) unconditionally.
1294
- * Identifies the sharer via either the anonymous clientId (`c`) or, when the
1295
- * sharer is authenticated, the stronger wallet identifier (`w`). A valid V2
1296
- * context MUST contain at least one of `c` or `w`; both may be present when
1297
- * a logged-in user shares a link (best attribution signal).
1298
- *
1299
- * `w` takes precedence as the source of truth because the wallet is bound to
1300
- * the user's WebAuthn credential, survives localStorage clears, and is global
1301
- * across merchants — unlike `c`, which is a per-browser UUID.
1302
- *
1303
- * @ignore
1304
- */
1305
- type FrakContextV2 = {
1306
- /** Version discriminator */v: 2; /** Merchant ID (UUID) */
1307
- m: string; /** Link creation timestamp (epoch seconds) */
1308
- t: number; /** Sharer's anonymous clientId (UUID from localStorage). Optional when `w` is provided. */
1309
- c?: string; /** Sharer's wallet address. Preferred source of truth when the sharer is authenticated. Optional when `c` is provided. */
1310
- w?: Address;
1311
- };
1312
- /**
1313
- * The current Frak Context — union of all versions.
1314
- *
1315
- * - No `v` field → V1 (legacy wallet address)
1316
- * - `v: 2` → V2 (anonymous clientId-based)
1317
- *
1318
- * @ignore
1319
- */
1320
- type FrakContext = FrakContextV1 | FrakContextV2;
1321
- /**
1322
- * Type guard: check if a context is V1 (legacy wallet address).
1323
- * @param ctx - The Frak context to check
1324
- * @returns True if the context is a V1 context
1325
- */
1326
- declare function isV1Context(ctx: FrakContext): ctx is FrakContextV1;
1327
- /**
1328
- * Type guard: check if a context is V2 (anonymous clientId-based).
1329
- * @param ctx - The Frak context to check
1330
- * @returns True if the context is a V2 context
1331
- */
1332
- declare function isV2Context(ctx: FrakContext): ctx is FrakContextV2;
1333
- //#endregion
1334
- //#region src/actions/openSso.d.ts
1335
- declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
1336
- declare const ssoPopupName = "frak-sso";
1337
- /**
1338
- * Function used to open the SSO
1339
- * @param client - The current Frak Client
1340
- * @param args - The SSO parameters
1341
- *
1342
- * @description Two SSO flow modes:
1343
- *
1344
- * **Redirect Mode** (openInSameWindow: true):
1345
- * - Wallet generates URL and triggers redirect
1346
- * - Used when redirectUrl is provided
1347
- *
1348
- * **Popup Mode** (openInSameWindow: false/omitted):
1349
- * - SDK generates URL client-side (or uses provided ssoPopupUrl)
1350
- * - Opens popup synchronously (prevents popup blockers)
1351
- * - Waits for SSO completion via postMessage
1352
- *
1353
- * @example
1354
- * First we build the sso metadata
1355
- * ```ts
1356
- * // Build the metadata
1357
- * const metadata: SsoMetadata = {
1358
- * logoUrl: "https://my-app.com/logo.png",
1359
- * homepageLink: "https://my-app.com",
1360
- * };
1361
- * ```
1362
- *
1363
- * Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
1364
- * :::code-group
1365
- * ```ts [Popup (default)]
1366
- * // Opens in popup, SDK generates URL automatically
1367
- * await openSso(frakConfig, {
1368
- * directExit: true,
1369
- * metadata,
1370
- * });
1371
- * ```
1372
- * ```ts [Redirect]
1373
- * // Opens in same window with redirect
1374
- * await openSso(frakConfig, {
1375
- * redirectUrl: "https://my-app.com/frak-sso",
1376
- * metadata,
1377
- * openInSameWindow: true,
1378
- * });
1379
- * ```
1380
- * ```ts [Custom popup URL]
1381
- * // Advanced: provide custom SSO URL
1382
- * const { ssoUrl } = await prepareSso(frakConfig, { metadata });
1383
- * await openSso(frakConfig, {
1384
- * metadata,
1385
- * ssoPopupUrl: `${ssoUrl}&custom=param`,
1386
- * });
1387
- * ```
1388
- * :::
1389
- */
1390
- declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
1391
- //#endregion
1392
- export { ResolvedPlacement as $, ModalRpcMetadata as A, LoginModalStepType as B, EmbeddedViewActionReferred as C, DisplaySharingPageResultType as D, DisplaySharingPageParamsType as E, SendTransactionReturnType as F, SsoMetadata as G, OpenSsoReturnType as H, SendTransactionTxType as I, ModalStepMetadata as J, FinalActionType as K, SiweAuthenticateModalStepType as L, ModalRpcStepsResultType as M, ModalStepTypes as N, SharingPageProduct as O, SendTransactionModalStepType as P, MerchantConfigResponse as Q, SiweAuthenticateReturnType as R, LoggedOutEmbeddedView as S, LoggedInEmbeddedView as T, PrepareSsoParamsType as U, OpenSsoParamsType as V, PrepareSsoReturnType as W, IFrameLifecycleEvent as X, InteractionTypeKey as Y, ClientLifecycleEvent as Z, RewardTier as _, FrakContextV1 as a, Language as at, DisplayEmbeddedWalletParamsType as b, isV2Context as c, AttributionParams as ct, IFrameTransport as d, UtmParams as dt, ResolvedSdkConfig as et, IFrameRpcSchema as f, GetMerchantInformationReturnType as g, EstimatedReward as h, FrakContext as i, I18nConfig as it, ModalRpcStepsInput as j, DisplayModalParamsType as k, FrakClient as l, TrackArrivalParams as lt, UserReferralStatusType as m, ssoPopupFeatures as n, Currency as nt, FrakContextV2 as o, LocalizedI18nConfig as ot, WalletStatusReturnType as p, FinalModalStepType as q, ssoPopupName as r, FrakWalletSdkConfig as rt, isV1Context as s, AttributionDefaults as st, openSso as t, SdkResolvedConfig as tt, FrakLifecycleEvent as u, TrackArrivalResult as ut, TokenAmountType as v, EmbeddedViewActionSharing as w, DisplayEmbeddedWalletResultType as x, SendInteractionParamsType as y, SiweAuthenticationParams as z };