@frak-labs/core-sdk 0.2.0 → 0.2.1

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 (43) hide show
  1. package/cdn/bundle.js +3 -3
  2. package/dist/actions.cjs +1 -1
  3. package/dist/actions.d.cts +2 -2
  4. package/dist/actions.d.ts +2 -2
  5. package/dist/actions.js +1 -1
  6. package/dist/bundle.cjs +1 -1
  7. package/dist/bundle.d.cts +4 -4
  8. package/dist/bundle.d.ts +4 -4
  9. package/dist/bundle.js +1 -1
  10. package/dist/{computeLegacyProductId-Raks6FXg.d.cts → computeLegacyProductId-CCAZvLa5.d.cts} +45 -46
  11. package/dist/{computeLegacyProductId-BkyJ4rEY.d.ts → computeLegacyProductId-b5cUWdAm.d.ts} +45 -46
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +1 -1
  16. package/dist/{openSso-BCJGchIb.d.cts → openSso-B0g7-807.d.cts} +40 -7
  17. package/dist/{openSso-DG-_9CED.d.ts → openSso-CMzwvaCa.d.ts} +40 -7
  18. package/dist/setupClient-BduY6Sym.cjs +13 -0
  19. package/dist/setupClient-ftmdQ-I8.js +13 -0
  20. package/dist/siweAuthenticate-BWmI2_TN.cjs +1 -0
  21. package/dist/{siweAuthenticate-Btem4QHs.d.ts → siweAuthenticate-CVigMOxz.d.cts} +28 -32
  22. package/dist/{siweAuthenticate-BH7Dn7nZ.d.cts → siweAuthenticate-CnCZ7mok.d.ts} +28 -32
  23. package/dist/siweAuthenticate-zczqxm0a.js +1 -0
  24. package/dist/trackEvent-CeLFVzZn.js +1 -0
  25. package/dist/trackEvent-Ew5r5zfI.cjs +1 -0
  26. package/package.json +1 -1
  27. package/src/actions/referral/processReferral.test.ts +109 -125
  28. package/src/actions/referral/processReferral.ts +134 -180
  29. package/src/actions/referral/referralInteraction.test.ts +3 -5
  30. package/src/actions/referral/referralInteraction.ts +2 -7
  31. package/src/index.ts +3 -0
  32. package/src/types/context.ts +48 -6
  33. package/src/types/index.ts +2 -1
  34. package/src/types/rpc/interaction.ts +5 -0
  35. package/src/types/tracking.ts +5 -34
  36. package/src/utils/FrakContext.test.ts +270 -186
  37. package/src/utils/FrakContext.ts +78 -56
  38. package/dist/setupClient-CQrMDGyZ.js +0 -13
  39. package/dist/setupClient-Ccv3XxwL.cjs +0 -13
  40. package/dist/siweAuthenticate-BJHbtty4.js +0 -1
  41. package/dist/siweAuthenticate-Cwj3HP0m.cjs +0 -1
  42. package/dist/trackEvent-M2RLTQ2p.js +0 -1
  43. package/dist/trackEvent-T_R9ER2S.cjs +0 -1
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-BCJGchIb.cjs";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-Raks6FXg.cjs";
3
- export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
1
+ import { A as SendTransactionModalStepType, B as PrepareSsoReturnType, C as EmbeddedViewActionSharing, D as ModalRpcStepsInput, E as ModalRpcMetadata, F as SiweAuthenticationParams, G as InteractionTypeKey, H as FinalActionType, I as LoginModalStepType, J as Currency, K as IFrameLifecycleEvent, L as OpenSsoParamsType, M as SendTransactionTxType, N as SiweAuthenticateModalStepType, O as ModalRpcStepsResultType, P as SiweAuthenticateReturnType, Q as LocalizedI18nConfig, R as OpenSsoReturnType, S as EmbeddedViewActionReferred, T as DisplayModalParamsType, U as FinalModalStepType, V as SsoMetadata, W as ModalStepMetadata, X as I18nConfig, Y as FrakWalletSdkConfig, Z as Language, _ as TokenAmountType, a as FrakContextV1, b as DisplayEmbeddedWalletResultType, c as isV2Context, d as IFrameTransport, f as IFrameRpcSchema, g as RewardTier, h as GetMerchantInformationReturnType, i as FrakContext, j as SendTransactionReturnType, k as ModalStepTypes, l as FrakClient, m as EstimatedReward, n as ssoPopupFeatures, o as FrakContextV2, p as WalletStatusReturnType, q as ClientLifecycleEvent, r as ssoPopupName, s as isV1Context, u as FrakLifecycleEvent, v as SendInteractionParamsType, w as LoggedInEmbeddedView, x as LoggedOutEmbeddedView, y as DisplayEmbeddedWalletParamsType, z as PrepareSsoParamsType } from "./openSso-B0g7-807.cjs";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-CCAZvLa5.cjs";
3
+ export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakContextV1, type FrakContextV2, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isV1Context, isV2Context, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as SiweAuthenticateReturnType, B as ModalStepMetadata, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, G as FrakWalletSdkConfig, H as IFrameLifecycleEvent, I as PrepareSsoReturnType, J as LocalizedI18nConfig, K as I18nConfig, L as SsoMetadata, M as LoginModalStepType, N as OpenSsoParamsType, O as SendTransactionTxType, P as OpenSsoReturnType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, U as ClientLifecycleEvent, V as InteractionTypeKey, W as Currency, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as GetMerchantInformationReturnType, f as RewardTier, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as SendInteractionParamsType, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as TokenAmountType, q as Language, r as ssoPopupName, s as IFrameTransport, u as EstimatedReward, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as FinalModalStepType } from "./openSso-DG-_9CED.js";
2
- import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-BkyJ4rEY.js";
3
- export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
1
+ import { A as SendTransactionModalStepType, B as PrepareSsoReturnType, C as EmbeddedViewActionSharing, D as ModalRpcStepsInput, E as ModalRpcMetadata, F as SiweAuthenticationParams, G as InteractionTypeKey, H as FinalActionType, I as LoginModalStepType, J as Currency, K as IFrameLifecycleEvent, L as OpenSsoParamsType, M as SendTransactionTxType, N as SiweAuthenticateModalStepType, O as ModalRpcStepsResultType, P as SiweAuthenticateReturnType, Q as LocalizedI18nConfig, R as OpenSsoReturnType, S as EmbeddedViewActionReferred, T as DisplayModalParamsType, U as FinalModalStepType, V as SsoMetadata, W as ModalStepMetadata, X as I18nConfig, Y as FrakWalletSdkConfig, Z as Language, _ as TokenAmountType, a as FrakContextV1, b as DisplayEmbeddedWalletResultType, c as isV2Context, d as IFrameTransport, f as IFrameRpcSchema, g as RewardTier, h as GetMerchantInformationReturnType, i as FrakContext, j as SendTransactionReturnType, k as ModalStepTypes, l as FrakClient, m as EstimatedReward, n as ssoPopupFeatures, o as FrakContextV2, p as WalletStatusReturnType, q as ClientLifecycleEvent, r as ssoPopupName, s as isV1Context, u as FrakLifecycleEvent, v as SendInteractionParamsType, w as LoggedInEmbeddedView, x as LoggedOutEmbeddedView, y as DisplayEmbeddedWalletParamsType, z as PrepareSsoParamsType } from "./openSso-CMzwvaCa.js";
2
+ import { A as getBackendUrl, B as HashProtectedData, C as triggerDeepLinkWithFallback, D as base64urlDecode, E as compressJsonToB64, F as createIFrameFrakClient, I as TrackArrivalParams, L as TrackArrivalResult, M as locales, N as setupClient, O as base64urlEncode, P as DebugInfoGatherer, R as UtmParams, S as toAndroidIntentUrl, T as decompressJsonFromB64, V as KeyProvider, _ as formatAmount, a as CompressedSsoData, b as isChromiumAndroid, c as clearMerchantIdCache, d as baseIframeProps, f as createIframe, g as getCurrencyAmountKey, h as getSupportedCurrency, i as AppSpecificSsoMetadata, j as LocalesKey, k as getClientId, l as fetchMerchantId, m as getSupportedLocale, n as FrakEvent, o as FullSsoParams, p as findIframeInOpener, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as resolveMerchantId, v as FrakContextManager, w as DEEP_LINK_SCHEME, x as isFrakDeepLink, y as DeepLinkFallbackOptions, z as CompressedData } from "./computeLegacyProductId-b5cUWdAm.js";
3
+ export { type AppSpecificSsoMetadata, type ClientLifecycleEvent, type CompressedData, type CompressedSsoData, type Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, type DeepLinkFallbackOptions, type DisplayEmbeddedWalletParamsType, type DisplayEmbeddedWalletResultType, type DisplayModalParamsType, type EmbeddedViewActionReferred, type EmbeddedViewActionSharing, type EstimatedReward, type FinalActionType, type FinalModalStepType, type FrakClient, type FrakContext, FrakContextManager, type FrakContextV1, type FrakContextV2, type FrakEvent, type FrakLifecycleEvent, type FrakWalletSdkConfig, type FullSsoParams, type GetMerchantInformationReturnType, type HashProtectedData, type I18nConfig, type IFrameLifecycleEvent, type IFrameRpcSchema, type IFrameTransport, type InteractionTypeKey, type KeyProvider, type Language, type LocalesKey, type LocalizedI18nConfig, type LoggedInEmbeddedView, type LoggedOutEmbeddedView, type LoginModalStepType, type ModalRpcMetadata, type ModalRpcStepsInput, type ModalRpcStepsResultType, type ModalStepMetadata, type ModalStepTypes, type OpenSsoParamsType, type OpenSsoReturnType, type PrepareSsoParamsType, type PrepareSsoReturnType, type RewardTier, type SendInteractionParamsType, type SendTransactionModalStepType, type SendTransactionReturnType, type SendTransactionTxType, type SiweAuthenticateModalStepType, type SiweAuthenticateReturnType, type SiweAuthenticationParams, type SsoMetadata, type TokenAmountType, type TrackArrivalParams, type TrackArrivalResult, type UtmParams, type WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearMerchantIdCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, fetchMerchantId, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isV1Context, isV2Context, locales, resolveMerchantId, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p}from"./trackEvent-M2RLTQ2p.js";import{_ as m,a as h,c as g,d as _,f as v,g as y,h as b,i as x,l as S,m as C,n as w,o as T,p as E,r as D,s as O,t as k,u as A}from"./setupClient-CQrMDGyZ.js";export{y as DEEP_LINK_SCHEME,D as DebugInfoGatherer,e as FrakContextManager,r as base64urlDecode,u as base64urlEncode,x as baseIframeProps,c as clearMerchantIdCache,n as compressJsonToB64,s as computeLegacyProductId,w as createIFrameFrakClient,h as createIframe,m as decompressJsonFromB64,d as fetchMerchantId,T as findIframeInOpener,g as formatAmount,p as generateSsoUrl,l as getBackendUrl,i as getClientId,O as getCurrencyAmountKey,A as getSupportedCurrency,S as getSupportedLocale,v as isChromiumAndroid,E as isFrakDeepLink,_ as locales,a as resolveMerchantId,k as setupClient,t as ssoPopupFeatures,o as ssoPopupName,C as toAndroidIntentUrl,f as trackEvent,b as triggerDeepLinkWithFallback};
1
+ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as g}from"./trackEvent-CeLFVzZn.js";import{a as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,t as j,u as M}from"./setupClient-ftmdQ-I8.js";export{x as DEEP_LINK_SCHEME,k as DebugInfoGatherer,t as FrakContextManager,o as base64urlDecode,a as base64urlEncode,C as baseIframeProps,u as clearMerchantIdCache,l as compressJsonToB64,e as computeLegacyProductId,E as createIFrameFrakClient,_ as createIframe,n as decompressJsonFromB64,p as fetchMerchantId,D as findIframeInOpener,v as formatAmount,f as generateSsoUrl,c as getBackendUrl,g as getClientId,A as getCurrencyAmountKey,M as getSupportedCurrency,w as getSupportedLocale,b as isChromiumAndroid,O as isFrakDeepLink,d as isV1Context,m as isV2Context,y as locales,s as resolveMerchantId,j as setupClient,r as ssoPopupFeatures,i as ssoPopupName,T as toAndroidIntentUrl,h as trackEvent,S as triggerDeepLinkWithFallback};
@@ -679,8 +679,11 @@ type DisplayEmbeddedWalletResultType = {
679
679
  * @group RPC Schema
680
680
  */
681
681
  type SendInteractionParamsType = {
682
- type: "arrival";
682
+ type: "arrival"; /** @deprecated V1 legacy — use referrerClientId for v2 */
683
683
  referrerWallet?: Address;
684
+ referrerClientId?: string;
685
+ referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
686
+ referralTimestamp?: number;
684
687
  landingUrl?: string;
685
688
  utmSource?: string;
686
689
  utmMedium?: string;
@@ -951,15 +954,45 @@ type FrakClient = {
951
954
  //#endregion
952
955
  //#region src/types/context.d.ts
953
956
  /**
954
- * The current Frak Context
957
+ * V1 (legacy) Frak Context — contains only the referrer wallet address.
958
+ * Used for backward compatibility with old sharing links.
959
+ * @ignore
960
+ */
961
+ type FrakContextV1 = {
962
+ /** Referrer wallet address */r: Address;
963
+ };
964
+ /**
965
+ * V2 Frak Context — anonymous-first referral context.
966
+ * Contains the sharer's clientId, merchantId, and link creation timestamp.
967
+ * @ignore
968
+ */
969
+ type FrakContextV2 = {
970
+ /** Version discriminator */v: 2; /** Sharer's anonymous clientId (UUID from localStorage) */
971
+ c: string; /** Merchant ID (UUID) */
972
+ m: string; /** Link creation timestamp (epoch seconds) */
973
+ t: number;
974
+ };
975
+ /**
976
+ * The current Frak Context — union of all versions.
955
977
  *
956
- * For now, only contain a referrer address.
978
+ * - No `v` field V1 (legacy wallet address)
979
+ * - `v: 2` → V2 (anonymous clientId-based)
957
980
  *
958
981
  * @ignore
959
982
  */
960
- type FrakContext = {
961
- r: Address;
962
- };
983
+ type FrakContext = FrakContextV1 | FrakContextV2;
984
+ /**
985
+ * Type guard: check if a context is V1 (legacy wallet address).
986
+ * @param ctx - The Frak context to check
987
+ * @returns True if the context is a V1 context
988
+ */
989
+ declare function isV1Context(ctx: FrakContext): ctx is FrakContextV1;
990
+ /**
991
+ * Type guard: check if a context is V2 (anonymous clientId-based).
992
+ * @param ctx - The Frak context to check
993
+ * @returns True if the context is a V2 context
994
+ */
995
+ declare function isV2Context(ctx: FrakContext): ctx is FrakContextV2;
963
996
  //#endregion
964
997
  //#region src/actions/openSso.d.ts
965
998
  declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
@@ -1019,4 +1052,4 @@ declare const ssoPopupName = "frak-sso";
1019
1052
  */
1020
1053
  declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
1021
1054
  //#endregion
1022
- export { SiweAuthenticateReturnType as A, ModalStepMetadata as B, ModalRpcStepsInput as C, SendTransactionReturnType as D, SendTransactionModalStepType as E, PrepareSsoParamsType as F, FrakWalletSdkConfig as G, IFrameLifecycleEvent as H, PrepareSsoReturnType as I, LocalizedI18nConfig as J, I18nConfig as K, SsoMetadata as L, LoginModalStepType as M, OpenSsoParamsType as N, SendTransactionTxType as O, OpenSsoReturnType as P, FinalActionType as R, ModalRpcMetadata as S, ModalStepTypes as T, ClientLifecycleEvent as U, InteractionTypeKey as V, Currency as W, LoggedOutEmbeddedView as _, FrakClient as a, LoggedInEmbeddedView as b, IFrameRpcSchema as c, GetMerchantInformationReturnType as d, RewardTier as f, DisplayEmbeddedWalletResultType as g, DisplayEmbeddedWalletParamsType as h, FrakContext as i, SiweAuthenticationParams as j, SiweAuthenticateModalStepType as k, WalletStatusReturnType as l, SendInteractionParamsType as m, ssoPopupFeatures as n, FrakLifecycleEvent as o, TokenAmountType as p, Language as q, ssoPopupName as r, IFrameTransport as s, openSso as t, EstimatedReward as u, EmbeddedViewActionReferred as v, ModalRpcStepsResultType as w, DisplayModalParamsType as x, EmbeddedViewActionSharing as y, FinalModalStepType as z };
1055
+ export { SendTransactionModalStepType as A, PrepareSsoReturnType as B, EmbeddedViewActionSharing as C, ModalRpcStepsInput as D, ModalRpcMetadata as E, SiweAuthenticationParams as F, InteractionTypeKey as G, FinalActionType as H, LoginModalStepType as I, Currency as J, IFrameLifecycleEvent as K, OpenSsoParamsType as L, SendTransactionTxType as M, SiweAuthenticateModalStepType as N, ModalRpcStepsResultType as O, SiweAuthenticateReturnType as P, LocalizedI18nConfig as Q, OpenSsoReturnType as R, EmbeddedViewActionReferred as S, DisplayModalParamsType as T, FinalModalStepType as U, SsoMetadata as V, ModalStepMetadata as W, I18nConfig as X, FrakWalletSdkConfig as Y, Language as Z, TokenAmountType as _, FrakContextV1 as a, DisplayEmbeddedWalletResultType as b, isV2Context as c, IFrameTransport as d, IFrameRpcSchema as f, RewardTier as g, GetMerchantInformationReturnType as h, FrakContext as i, SendTransactionReturnType as j, ModalStepTypes as k, FrakClient as l, EstimatedReward as m, ssoPopupFeatures as n, FrakContextV2 as o, WalletStatusReturnType as p, ClientLifecycleEvent as q, ssoPopupName as r, isV1Context as s, openSso as t, FrakLifecycleEvent as u, SendInteractionParamsType as v, LoggedInEmbeddedView as w, LoggedOutEmbeddedView as x, DisplayEmbeddedWalletParamsType as y, PrepareSsoParamsType as z };
@@ -679,8 +679,11 @@ type DisplayEmbeddedWalletResultType = {
679
679
  * @group RPC Schema
680
680
  */
681
681
  type SendInteractionParamsType = {
682
- type: "arrival";
682
+ type: "arrival"; /** @deprecated V1 legacy — use referrerClientId for v2 */
683
683
  referrerWallet?: Address;
684
+ referrerClientId?: string;
685
+ referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
686
+ referralTimestamp?: number;
684
687
  landingUrl?: string;
685
688
  utmSource?: string;
686
689
  utmMedium?: string;
@@ -951,15 +954,45 @@ type FrakClient = {
951
954
  //#endregion
952
955
  //#region src/types/context.d.ts
953
956
  /**
954
- * The current Frak Context
957
+ * V1 (legacy) Frak Context — contains only the referrer wallet address.
958
+ * Used for backward compatibility with old sharing links.
959
+ * @ignore
960
+ */
961
+ type FrakContextV1 = {
962
+ /** Referrer wallet address */r: Address;
963
+ };
964
+ /**
965
+ * V2 Frak Context — anonymous-first referral context.
966
+ * Contains the sharer's clientId, merchantId, and link creation timestamp.
967
+ * @ignore
968
+ */
969
+ type FrakContextV2 = {
970
+ /** Version discriminator */v: 2; /** Sharer's anonymous clientId (UUID from localStorage) */
971
+ c: string; /** Merchant ID (UUID) */
972
+ m: string; /** Link creation timestamp (epoch seconds) */
973
+ t: number;
974
+ };
975
+ /**
976
+ * The current Frak Context — union of all versions.
955
977
  *
956
- * For now, only contain a referrer address.
978
+ * - No `v` field V1 (legacy wallet address)
979
+ * - `v: 2` → V2 (anonymous clientId-based)
957
980
  *
958
981
  * @ignore
959
982
  */
960
- type FrakContext = {
961
- r: Address;
962
- };
983
+ type FrakContext = FrakContextV1 | FrakContextV2;
984
+ /**
985
+ * Type guard: check if a context is V1 (legacy wallet address).
986
+ * @param ctx - The Frak context to check
987
+ * @returns True if the context is a V1 context
988
+ */
989
+ declare function isV1Context(ctx: FrakContext): ctx is FrakContextV1;
990
+ /**
991
+ * Type guard: check if a context is V2 (anonymous clientId-based).
992
+ * @param ctx - The Frak context to check
993
+ * @returns True if the context is a V2 context
994
+ */
995
+ declare function isV2Context(ctx: FrakContext): ctx is FrakContextV2;
963
996
  //#endregion
964
997
  //#region src/actions/openSso.d.ts
965
998
  declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
@@ -1019,4 +1052,4 @@ declare const ssoPopupName = "frak-sso";
1019
1052
  */
1020
1053
  declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
1021
1054
  //#endregion
1022
- export { SiweAuthenticateReturnType as A, ModalStepMetadata as B, ModalRpcStepsInput as C, SendTransactionReturnType as D, SendTransactionModalStepType as E, PrepareSsoParamsType as F, FrakWalletSdkConfig as G, IFrameLifecycleEvent as H, PrepareSsoReturnType as I, LocalizedI18nConfig as J, I18nConfig as K, SsoMetadata as L, LoginModalStepType as M, OpenSsoParamsType as N, SendTransactionTxType as O, OpenSsoReturnType as P, FinalActionType as R, ModalRpcMetadata as S, ModalStepTypes as T, ClientLifecycleEvent as U, InteractionTypeKey as V, Currency as W, LoggedOutEmbeddedView as _, FrakClient as a, LoggedInEmbeddedView as b, IFrameRpcSchema as c, GetMerchantInformationReturnType as d, RewardTier as f, DisplayEmbeddedWalletResultType as g, DisplayEmbeddedWalletParamsType as h, FrakContext as i, SiweAuthenticationParams as j, SiweAuthenticateModalStepType as k, WalletStatusReturnType as l, SendInteractionParamsType as m, ssoPopupFeatures as n, FrakLifecycleEvent as o, TokenAmountType as p, Language as q, ssoPopupName as r, IFrameTransport as s, openSso as t, EstimatedReward as u, EmbeddedViewActionReferred as v, ModalRpcStepsResultType as w, DisplayModalParamsType as x, EmbeddedViewActionSharing as y, FinalModalStepType as z };
1055
+ export { SendTransactionModalStepType as A, PrepareSsoReturnType as B, EmbeddedViewActionSharing as C, ModalRpcStepsInput as D, ModalRpcMetadata as E, SiweAuthenticationParams as F, InteractionTypeKey as G, FinalActionType as H, LoginModalStepType as I, Currency as J, IFrameLifecycleEvent as K, OpenSsoParamsType as L, SendTransactionTxType as M, SiweAuthenticateModalStepType as N, ModalRpcStepsResultType as O, SiweAuthenticateReturnType as P, LocalizedI18nConfig as Q, OpenSsoReturnType as R, EmbeddedViewActionReferred as S, DisplayModalParamsType as T, FinalModalStepType as U, SsoMetadata as V, ModalStepMetadata as W, I18nConfig as X, FrakWalletSdkConfig as Y, Language as Z, TokenAmountType as _, FrakContextV1 as a, DisplayEmbeddedWalletResultType as b, isV2Context as c, IFrameTransport as d, IFrameRpcSchema as f, RewardTier as g, GetMerchantInformationReturnType as h, FrakContext as i, SendTransactionReturnType as j, ModalStepTypes as k, FrakClient as l, EstimatedReward as m, ssoPopupFeatures as n, FrakContextV2 as o, WalletStatusReturnType as p, ClientLifecycleEvent as q, ssoPopupName as r, isV1Context as s, openSso as t, FrakLifecycleEvent as u, SendInteractionParamsType as v, LoggedInEmbeddedView as w, LoggedOutEmbeddedView as x, DisplayEmbeddedWalletParamsType as y, PrepareSsoParamsType as z };
@@ -0,0 +1,13 @@
1
+ const e=require(`./trackEvent-Ew5r5zfI.cjs`);let t=require(`@frak-labs/frame-connector`),n=require(`@openpanel/web`);const r=`nexus-wallet-backup`,i=`frakwallet://`;function a(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function o(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function s(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let s=a()&&c(e)?o(e):e;window.location.href=s,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function c(e){return e.startsWith(i)}const l={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function u(e){return e&&e in l?e:`eur`}function d(e){return e?l[e]??l.eur:l.eur}function f(e,t){let n=d(t),r=u(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function p(e){return e?`${e}Amount`:`eurAmount`}const m={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function h({walletBaseUrl:t,config:n}){let r=document.querySelector(`#frak-wallet`);r&&r.remove();let i=document.createElement(`iframe`);i.id=m.id,i.name=m.name,i.allow=m.allow,i.style.zIndex=m.style.zIndex.toString(),g({iframe:i,isVisible:!1});let a=n?.walletUrl??t??`https://wallet.frak.id`,o=e.v();return i.src=`${a}/listener?clientId=${encodeURIComponent(o)}`,new Promise(e=>{i.addEventListener(`load`,()=>e(i)),document.body.appendChild(i)})}function g({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function _(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function v(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var y=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let n=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof t.FrakRpcError?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:n?this.base64Encode(n):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
+ Debug Information:
3
+ -----------------
4
+ Timestamp: ${t.timestamp}
5
+ URL: ${t.encodedUrl}
6
+ Config: ${t.encodedConfig}
7
+ Navigator Info: ${t.navigatorInfo}
8
+ IFrame Status: ${t.iframeStatus}
9
+ Last Request: ${t.lastRequest}
10
+ Last Response: ${t.lastResponse}
11
+ Client Status: ${t.clientStatus}
12
+ Error: ${t.error}
13
+ `.trim()}};const b=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function x(e){e?localStorage.setItem(r,e):localStorage.removeItem(r)}function S(t,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;t.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,pendingMergeToken:o,configDomain:i,clientId:e.v()}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function C(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function w(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function T(e){return e.includes(`/common/social`)}function E(e,t,n,r){if(c(t)){let i=C(t,r);s(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(b&&T(t))w(r);else{let e=C(t,r);window.location.href=e}}function D({iframe:e,targetOrigin:n,configDomain:i}){let a=new t.Deferred;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:o,data:s}=t;switch(o){case`connected`:a.resolve(!0);break;case`do-backup`:x(s.backup);break;case`remove-backup`:localStorage.removeItem(r);break;case`show`:case`hide`:g({iframe:e,isVisible:o===`show`});break;case`handshake`:S(e,s.token,n,i);break;case`redirect`:E(e,s.baseRedirectUrl,n,s.mergeToken);break}},isConnected:a.promise}}function O({config:r,iframe:i}){let a=r?.walletUrl??`https://wallet.frak.id`,o=D({iframe:i,targetOrigin:a,configDomain:r.domain}),s=new y(r,i);if(!i.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let c=(0,t.createRpcClient)({emittingTransport:i.contentWindow,listeningTransport:window,targetOrigin:a,middleware:[{async onRequest(e,n){if(!await o.isConnected)throw new t.FrakRpcError(t.RpcErrorCodes.clientNotConnected,`The iframe provider isn't connected yet`);return n}},{onRequest(e,t){return s.setLastRequest(e),t},onResponse(e,t){return s.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await o.handleEvent(e)}}}),l=k(c,o),u=async()=>{l(),c.cleanup(),i.remove()},d;console.log(`[Frak SDK] Initializing OpenPanel`),d=new n.OpenPanel({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:t,payload:n})=>(t!==`track`||!n?.properties||`sdkVersion`in n.properties||(n.properties={...n.properties,sdkVersion:`0.2.1`,userAnonymousClientId:e.v()}),!0)}),d.setGlobalProperties({sdkVersion:`0.2.1`,userAnonymousClientId:e.v()}),d.init();let f=A({config:r,rpcClient:c,lifecycleManager:o}).then(()=>s.updateSetupStatus(!0));return{config:r,debugInfo:s,waitForConnection:o.isConnected,waitForSetup:f,request:c.request,listenerRequest:c.listen,destroy:u,openPanel:d}}function k(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function A({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,v(t,n.isConnected);async function i(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function a(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function o(){if(typeof window>`u`)return;let e=window.localStorage.getItem(r);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([i(),a(),o()])}async function j({config:e}){let t=M(e),n=await h({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=O({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function M(e){let t=u(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return u}});
@@ -0,0 +1,13 @@
1
+ import{v as e}from"./trackEvent-CeLFVzZn.js";import{Deferred as t,FrakRpcError as n,RpcErrorCodes as r,createRpcClient as i}from"@frak-labs/frame-connector";import{OpenPanel as a}from"@openpanel/web";const o=`nexus-wallet-backup`,s=`frakwallet://`;function c(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function l(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function u(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=c()&&d(e)?l(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function d(e){return e.startsWith(s)}const f={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function p(e){return e&&e in f?e:`eur`}function m(e){return e?f[e]??f.eur:f.eur}function h(e,t){let n=m(t),r=p(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function g(e){return e?`${e}Amount`:`eurAmount`}const _={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function v({walletBaseUrl:t,config:n}){let r=document.querySelector(`#frak-wallet`);r&&r.remove();let i=document.createElement(`iframe`);i.id=_.id,i.name=_.name,i.allow=_.allow,i.style.zIndex=_.style.zIndex.toString(),y({iframe:i,isVisible:!1});let a=n?.walletUrl??t??`https://wallet.frak.id`,o=e();return i.src=`${a}/listener?clientId=${encodeURIComponent(o)}`,new Promise(e=>{i.addEventListener(`load`,()=>e(i)),document.body.appendChild(i)})}function y({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function b(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function x(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var S=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof n?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
+ Debug Information:
3
+ -----------------
4
+ Timestamp: ${t.timestamp}
5
+ URL: ${t.encodedUrl}
6
+ Config: ${t.encodedConfig}
7
+ Navigator Info: ${t.navigatorInfo}
8
+ IFrame Status: ${t.iframeStatus}
9
+ Last Request: ${t.lastRequest}
10
+ Last Response: ${t.lastResponse}
11
+ Client Status: ${t.clientStatus}
12
+ Error: ${t.error}
13
+ `.trim()}};const C=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1))return!1;let t=e.toLowerCase();return t.includes(`instagram`)||t.includes(`fban`)||t.includes(`fbav`)||t.includes(`facebook`)})();function w(e){e?localStorage.setItem(o,e):localStorage.removeItem(o)}function T(t,n,r,i){let a=new URL(window.location.href),o=a.searchParams.get(`fmt`)??void 0;t.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:n,currentUrl:window.location.href,pendingMergeToken:o,configDomain:i,clientId:e()}},r),o&&(a.searchParams.delete(`fmt`),window.history.replaceState({},``,a.toString()))}function E(e,t){try{let n=new URL(e);return n.searchParams.has(`u`)?(n.searchParams.delete(`u`),n.searchParams.append(`u`,window.location.href),t&&n.searchParams.append(`fmt`,t),n.toString()):e}catch{return e}}function D(e){let t=new URL(window.location.href);e&&t.searchParams.set(`fmt`,e);let n=t.protocol===`http:`?`x-safari-http`:`x-safari-https`;window.location.href=`${n}://${t.host}${t.pathname}${t.search}${t.hash}`}function O(e){return e.includes(`/common/social`)}function k(e,t,n,r){if(d(t)){let i=E(t,r);u(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(C&&O(t))D(r);else{let e=E(t,r);window.location.href=e}}function A({iframe:e,targetOrigin:n,configDomain:r}){let i=new t;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:a,data:s}=t;switch(a){case`connected`:i.resolve(!0);break;case`do-backup`:w(s.backup);break;case`remove-backup`:localStorage.removeItem(o);break;case`show`:case`hide`:y({iframe:e,isVisible:a===`show`});break;case`handshake`:T(e,s.token,n,r);break;case`redirect`:k(e,s.baseRedirectUrl,n,s.mergeToken);break}},isConnected:i.promise}}function j({config:t,iframe:o}){let s=t?.walletUrl??`https://wallet.frak.id`,c=A({iframe:o,targetOrigin:s,configDomain:t.domain}),l=new S(t,o);if(!o.contentWindow)throw new n(r.configError,`The iframe does not have a content window`);let u=i({emittingTransport:o.contentWindow,listeningTransport:window,targetOrigin:s,middleware:[{async onRequest(e,t){if(!await c.isConnected)throw new n(r.clientNotConnected,`The iframe provider isn't connected yet`);return t}},{onRequest(e,t){return l.setLastRequest(e),t},onResponse(e,t){return l.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await c.handleEvent(e)}}}),d=M(u,c),f=async()=>{d(),u.cleanup(),o.remove()},p;console.log(`[Frak SDK] Initializing OpenPanel`),p=new a({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:t,payload:n})=>(t!==`track`||!n?.properties||`sdkVersion`in n.properties||(n.properties={...n.properties,sdkVersion:`0.2.1`,userAnonymousClientId:e()}),!0)}),p.setGlobalProperties({sdkVersion:`0.2.1`,userAnonymousClientId:e()}),p.init();let m=N({config:t,rpcClient:u,lifecycleManager:c}).then(()=>l.updateSetupStatus(!0));return{config:t,debugInfo:l,waitForConnection:c.isConnected,waitForSetup:m,request:u.request,listenerRequest:u.listen,destroy:f,openPanel:p}}function M(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function N({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,x(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(o);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}async function P({config:e}){let t=F(e),n=await v({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=j({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function F(e){let t=p(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{v as a,h as c,f as d,c as f,s as g,u as h,_ as i,m as l,l as m,j as n,b as o,d as p,S as r,g as s,P as t,p as u};
@@ -0,0 +1 @@
1
+ const e=require(`./trackEvent-Ew5r5zfI.cjs`);let t=require(`viem`),n=require(`@frak-labs/frame-connector`),r=require(`viem/siwe`);async function i(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function a(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function o(t){if(typeof window>`u`)return;let n=e.v();if(!n)return;let r=await e.r();if(!r)return;let i=`frak-identity-ensured-${r}`;if(!window.sessionStorage.getItem(i))try{let a=e.l();(await fetch(`${a}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":t,"x-frak-client-id":n},body:JSON.stringify({merchantId:r})})).ok&&window.sessionStorage.setItem(i,`1`)}catch{}}async function s(e){return await e.request({method:`frak_getMerchantInformation`})}async function c(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function l(t,n){try{await t.request({method:`frak_sendInteraction`,params:[n,{clientId:e.v()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,n.type)}}function u(t,n,r){let i=typeof window<`u`?window.location.href:void 0;return e.s(n)?(e.t(t,`user_referred_started`,{properties:{referrerClientId:n.c,walletStatus:r?.key}}),l(t,{type:`arrival`,referrerClientId:n.c,referrerMerchantId:n.m,referralTimestamp:n.t,landingUrl:i}),!0):e.o(n)?(e.t(t,`user_referred_started`,{properties:{referrer:n.r,walletStatus:r?.key}}),l(t,{type:`arrival`,referrerWallet:n.r,landingUrl:i}),!0):!1}function d(t){let n=e.v();return n?{v:2,c:n,m:t,t:Math.floor(Date.now()/1e3)}:null}function f(n,r){return e.s(n)?e.v()===n.c:e.o(n)&&r?.wallet?(0,t.isAddressEqual)(n.r,r.wallet):!1}function p(t,{walletStatus:n,frakContext:r,options:i}){if(!r)return`no-referrer`;if(f(r,n))return`self-referral`;if(!u(t,r,n))return`no-referrer`;let a=e.s(r)?r.m:i?.merchantId,o=i?.alwaysAppendUrl&&a?d(a):null;return e.a.replaceUrl({url:window.location?.href,context:o}),e.t(t,`user_referred_completed`,{properties:{status:`success`}}),`success`}async function m(t,{options:n}={}){let r=e.a.parse({url:window.location.href}),i=await g(t);try{return p(t,{walletStatus:i,frakContext:r,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function h(t){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let n=window.sessionStorage.getItem(`frak-wallet-interaction-token`),r=e.v();if(!n&&!r){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=window.sessionStorage.getItem(`frak-merchant-id`),a=t.merchantId??i??await e.r();if(!a){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let o={Accept:`application/json`,"Content-Type":`application/json`};n&&(o[`x-wallet-sdk-auth`]=n),r&&(o[`x-frak-client-id`]=r);let s=e.l();await fetch(`${s}/user/track/purchase`,{method:`POST`,headers:o,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:a})})}function g(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(_(e,t),t));let r=new n.Deferred,i=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},n=>{_(e,n),t(n),i||=(r.resolve(n),!0)}),r.promise}function _(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),o(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function v(e,{metadata:t,login:n}){return y(e,{steps:{login:n??{}},metadata:t})}function y(e,t){function n(n){return y(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return y(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return y(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n){return n&&(t.metadata=n(t.metadata??{})),await a(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:o}}async function b(e,{tx:t,metadata:n}){return(await a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function x(e,{siwe:t,metadata:n}){let i=e.config?.domain??window.location.host,o=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await a(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:o,nonce:t?.nonce??(0,r.generateSiweNonce)(),uri:t?.uri??`https://${i}`,version:t?.version??`1`,domain:i}}}})).siweAuthenticate}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return s}});
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-DG-_9CED.js";
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";
2
2
 
3
3
  //#region src/actions/displayEmbeddedWallet.d.ts
4
4
  /**
@@ -188,61 +188,60 @@ declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Pro
188
188
  //#endregion
189
189
  //#region src/actions/referral/processReferral.d.ts
190
190
  /**
191
- * The different states of the referral process
192
- * @inline
193
- */
194
- type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "error" | "no-referrer" | "self-referral";
195
- /**
196
- * Options for the referral auto-interaction process
191
+ * Options for the referral auto-interaction process.
197
192
  */
198
193
  type ProcessReferralOptions = {
199
194
  /**
200
- * If we want to always append the url with the frak context or not
195
+ * If true, always replace the URL with the current user's referral context
196
+ * so the next visitor gets referred by this user.
201
197
  * @defaultValue false
202
198
  */
203
199
  alwaysAppendUrl?: boolean;
200
+ /**
201
+ * Merchant ID for building the current user's referral context.
202
+ * Required when `alwaysAppendUrl` is true and the incoming context is V1.
203
+ * For V2 contexts, the merchantId is already embedded in the context.
204
+ */
205
+ merchantId?: string;
204
206
  };
205
207
  /**
206
- * This function handle all the heavy lifting of the referral interaction process
207
- * 1. Check if the user has been referred or not (if not, early exit)
208
- * 2. Then check if the user is logged in or not
209
- * 2.1 If not logged in, try a soft login, if it fail, display a modal for the user to login
210
- * 3. Check if that's not a self-referral (if yes, early exit)
211
- * 4. Track the referral event
212
- * 5. Update the current url with the right data
213
- * 6. Return the resulting referral state
208
+ * The different states of the referral process.
209
+ * @inline
210
+ */
211
+ type ReferralState = "idle" | "processing" | "success" | "no-referrer" | "self-referral";
212
+ /**
213
+ * Handle the full referral interaction flow:
214
214
  *
215
- * If any error occurs during the process, the function will catch it and return an error state
215
+ * 1. Check if the user has been referred (if not, early exit)
216
+ * 2. Preflight self-referral check (if yes, early exit)
217
+ * 3. Track the arrival event
218
+ * 4. Replace the current URL with the user's own referral context
219
+ * 5. Return the resulting referral state
216
220
  *
217
221
  * @param client - The current Frak Client
218
222
  * @param args
219
223
  * @param args.walletStatus - The current user wallet status
220
- * @param args.frakContext - The current frak context
221
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
222
- * @param args.options - Some options for the referral interaction
223
- * @returns A promise with the resulting referral state
224
+ * @param args.frakContext - The referral context parsed from the URL
225
+ * @param args.options - Options for URL replacement and merchant context
226
+ * @returns The referral state
224
227
  *
225
- * @see {@link displayModal} for more details about the displayed modal
226
- * @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
228
+ * @see {@link @frak-labs/core-sdk!ModalStepTypes} for modal step types
227
229
  */
228
230
  declare function processReferral(client: FrakClient, {
229
231
  walletStatus,
230
232
  frakContext,
231
- modalConfig,
232
233
  options
233
234
  }: {
234
235
  walletStatus?: WalletStatusReturnType;
235
- frakContext?: Partial<FrakContext> | null;
236
- modalConfig?: DisplayEmbeddedWalletParamsType;
236
+ frakContext?: FrakContext | null;
237
237
  options?: ProcessReferralOptions;
238
- }): Promise<ReferralState>;
238
+ }): ReferralState;
239
239
  //#endregion
240
240
  //#region src/actions/referral/referralInteraction.d.ts
241
241
  /**
242
242
  * Function used to handle referral interactions
243
243
  * @param client - The current Frak Client
244
244
  * @param args
245
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
246
245
  * @param args.options - Some options for the referral interaction
247
246
  *
248
247
  * @returns A promise with the resulting referral state, or undefined in case of an error
@@ -250,15 +249,12 @@ declare function processReferral(client: FrakClient, {
250
249
  * @description This function will automatically handle the referral interaction process
251
250
  *
252
251
  * @see {@link processReferral} for more details on the automatic referral handling process
253
- * @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
254
252
  */
255
253
  declare function referralInteraction(client: FrakClient, {
256
- modalConfig,
257
254
  options
258
255
  }?: {
259
- modalConfig?: DisplayEmbeddedWalletParamsType;
260
256
  options?: ProcessReferralOptions;
261
- }): Promise<("no-referrer" | "self-referral" | "success" | "idle" | "processing" | "no-wallet" | "error") | undefined>;
257
+ }): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
262
258
  //#endregion
263
259
  //#region src/actions/sendInteraction.d.ts
264
260
  /**
@@ -1,4 +1,4 @@
1
- import { A as SiweAuthenticateReturnType, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as PrepareSsoParamsType, I as PrepareSsoReturnType, M as LoginModalStepType, R as FinalActionType, S as ModalRpcMetadata, T as ModalStepTypes, a as FrakClient, d as GetMerchantInformationReturnType, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, m as SendInteractionParamsType, w as ModalRpcStepsResultType, x as DisplayModalParamsType, z as FinalModalStepType } from "./openSso-BCJGchIb.cjs";
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-CMzwvaCa.js";
2
2
 
3
3
  //#region src/actions/displayEmbeddedWallet.d.ts
4
4
  /**
@@ -188,61 +188,60 @@ declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Pro
188
188
  //#endregion
189
189
  //#region src/actions/referral/processReferral.d.ts
190
190
  /**
191
- * The different states of the referral process
192
- * @inline
193
- */
194
- type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "error" | "no-referrer" | "self-referral";
195
- /**
196
- * Options for the referral auto-interaction process
191
+ * Options for the referral auto-interaction process.
197
192
  */
198
193
  type ProcessReferralOptions = {
199
194
  /**
200
- * If we want to always append the url with the frak context or not
195
+ * If true, always replace the URL with the current user's referral context
196
+ * so the next visitor gets referred by this user.
201
197
  * @defaultValue false
202
198
  */
203
199
  alwaysAppendUrl?: boolean;
200
+ /**
201
+ * Merchant ID for building the current user's referral context.
202
+ * Required when `alwaysAppendUrl` is true and the incoming context is V1.
203
+ * For V2 contexts, the merchantId is already embedded in the context.
204
+ */
205
+ merchantId?: string;
204
206
  };
205
207
  /**
206
- * This function handle all the heavy lifting of the referral interaction process
207
- * 1. Check if the user has been referred or not (if not, early exit)
208
- * 2. Then check if the user is logged in or not
209
- * 2.1 If not logged in, try a soft login, if it fail, display a modal for the user to login
210
- * 3. Check if that's not a self-referral (if yes, early exit)
211
- * 4. Track the referral event
212
- * 5. Update the current url with the right data
213
- * 6. Return the resulting referral state
208
+ * The different states of the referral process.
209
+ * @inline
210
+ */
211
+ type ReferralState = "idle" | "processing" | "success" | "no-referrer" | "self-referral";
212
+ /**
213
+ * Handle the full referral interaction flow:
214
214
  *
215
- * If any error occurs during the process, the function will catch it and return an error state
215
+ * 1. Check if the user has been referred (if not, early exit)
216
+ * 2. Preflight self-referral check (if yes, early exit)
217
+ * 3. Track the arrival event
218
+ * 4. Replace the current URL with the user's own referral context
219
+ * 5. Return the resulting referral state
216
220
  *
217
221
  * @param client - The current Frak Client
218
222
  * @param args
219
223
  * @param args.walletStatus - The current user wallet status
220
- * @param args.frakContext - The current frak context
221
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
222
- * @param args.options - Some options for the referral interaction
223
- * @returns A promise with the resulting referral state
224
+ * @param args.frakContext - The referral context parsed from the URL
225
+ * @param args.options - Options for URL replacement and merchant context
226
+ * @returns The referral state
224
227
  *
225
- * @see {@link displayModal} for more details about the displayed modal
226
- * @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
228
+ * @see {@link @frak-labs/core-sdk!ModalStepTypes} for modal step types
227
229
  */
228
230
  declare function processReferral(client: FrakClient, {
229
231
  walletStatus,
230
232
  frakContext,
231
- modalConfig,
232
233
  options
233
234
  }: {
234
235
  walletStatus?: WalletStatusReturnType;
235
- frakContext?: Partial<FrakContext> | null;
236
- modalConfig?: DisplayEmbeddedWalletParamsType;
236
+ frakContext?: FrakContext | null;
237
237
  options?: ProcessReferralOptions;
238
- }): Promise<ReferralState>;
238
+ }): ReferralState;
239
239
  //#endregion
240
240
  //#region src/actions/referral/referralInteraction.d.ts
241
241
  /**
242
242
  * Function used to handle referral interactions
243
243
  * @param client - The current Frak Client
244
244
  * @param args
245
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
246
245
  * @param args.options - Some options for the referral interaction
247
246
  *
248
247
  * @returns A promise with the resulting referral state, or undefined in case of an error
@@ -250,15 +249,12 @@ declare function processReferral(client: FrakClient, {
250
249
  * @description This function will automatically handle the referral interaction process
251
250
  *
252
251
  * @see {@link processReferral} for more details on the automatic referral handling process
253
- * @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
254
252
  */
255
253
  declare function referralInteraction(client: FrakClient, {
256
- modalConfig,
257
254
  options
258
255
  }?: {
259
- modalConfig?: DisplayEmbeddedWalletParamsType;
260
256
  options?: ProcessReferralOptions;
261
- }): Promise<("no-referrer" | "self-referral" | "success" | "idle" | "processing" | "no-wallet" | "error") | undefined>;
257
+ }): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
262
258
  //#endregion
263
259
  //#region src/actions/sendInteraction.d.ts
264
260
  /**
@@ -0,0 +1 @@
1
+ import{a as e,l as t,o as n,r,s as i,t as a,v as o}from"./trackEvent-CeLFVzZn.js";import{isAddressEqual as s}from"viem";import{Deferred as c}from"@frak-labs/frame-connector";import{generateSiweNonce as l}from"viem/siwe";async function u(e,t){return await e.request({method:`frak_displayEmbeddedWallet`,params:[t,e.config.metadata]})}async function d(e,{steps:t,metadata:n}){return await e.request({method:`frak_displayModal`,params:[t,n,e.config.metadata]})}async function f(e){if(typeof window>`u`)return;let n=o();if(!n)return;let i=await r();if(!i)return;let a=`frak-identity-ensured-${i}`;if(!window.sessionStorage.getItem(a))try{let r=t();(await fetch(`${r}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":n},body:JSON.stringify({merchantId:i})})).ok&&window.sessionStorage.setItem(a,`1`)}catch{}}async function p(e){return await e.request({method:`frak_getMerchantInformation`})}async function m(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function h(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:o()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function g(e,t,r){let o=typeof window<`u`?window.location.href:void 0;return i(t)?(a(e,`user_referred_started`,{properties:{referrerClientId:t.c,walletStatus:r?.key}}),h(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referralTimestamp:t.t,landingUrl:o}),!0):n(t)?(a(e,`user_referred_started`,{properties:{referrer:t.r,walletStatus:r?.key}}),h(e,{type:`arrival`,referrerWallet:t.r,landingUrl:o}),!0):!1}function _(e){let t=o();return t?{v:2,c:t,m:e,t:Math.floor(Date.now()/1e3)}:null}function v(e,t){return i(e)?o()===e.c:n(e)&&t?.wallet?s(e.r,t.wallet):!1}function y(t,{walletStatus:n,frakContext:r,options:o}){if(!r)return`no-referrer`;if(v(r,n))return`self-referral`;if(!g(t,r,n))return`no-referrer`;let s=i(r)?r.m:o?.merchantId,c=o?.alwaysAppendUrl&&s?_(s):null;return e.replaceUrl({url:window.location?.href,context:c}),a(t,`user_referred_completed`,{properties:{status:`success`}}),`success`}async function b(t,{options:n}={}){let r=e.parse({url:window.location.href}),i=await S(t);try{return y(t,{walletStatus:i,frakContext:r,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}async function x(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let n=window.sessionStorage.getItem(`frak-wallet-interaction-token`),i=o();if(!n&&!i){console.warn(`[Frak] No identity found, skipping purchase check`);return}let a=window.sessionStorage.getItem(`frak-merchant-id`),s=e.merchantId??a??await r();if(!s){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let c={Accept:`application/json`,"Content-Type":`application/json`};n&&(c[`x-wallet-sdk-auth`]=n),i&&(c[`x-frak-client-id`]=i);let l=t();await fetch(`${l}/user/track/purchase`,{method:`POST`,headers:c,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:s})})}function S(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(C(e,t),t));let n=new c,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{C(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function C(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),f(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function w(e,{metadata:t,login:n}){return T(e,{steps:{login:n??{}},metadata:t})}function T(e,t){function n(n){return T(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return T(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return T(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n){return n&&(t.metadata=n(t.metadata??{})),await d(e,t)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function E(e,{tx:t,metadata:n}){return(await d(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function D(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await d(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??l(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{x as a,h as c,f as d,d as f,S as i,m as l,E as n,b as o,u as p,w as r,y as s,D as t,p as u};
@@ -0,0 +1 @@
1
+ import{bytesToHex as e,hexToBytes as t,isAddress as n,keccak256 as r,toHex as i}from"viem";import{jsonDecode as a,jsonEncode as o}from"@frak-labs/frame-connector";const s=`frak-client-id`;function c(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function l(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),c();let e=localStorage.getItem(s);return e||(e=c(),localStorage.setItem(s,e)),e}function u({domain:e}={}){return r(i((e??window.location.host).replace(`www.`,``)))}function d(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function f(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function p(e){return d(o(e))}function m(e,t,n,r,i,a){let o=p(h({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function h(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const g=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,_=`frak-sso`;async function v(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let a=t.ssoPopupUrl??m(i??`https://wallet.frak.id`,t,u(),n.name,l(),r?.css),o=window.open(a,_,g);if(!o)throw Error(`Popup was blocked. Please allow popups for this site.`);return o.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const y=`https://backend.frak.id`;function b(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function x(e){return b(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:y}function S(e){if(e)return x(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return x(e)}return y}function C(e){return a(f(e))}function w(e){return`r`in e&&!(`v`in e)}function T(e){return`v`in e&&e.v===2}const E=`fCtx`;function D(e){if(e)try{return T(e)?!e.c||!e.m||!e.t?void 0:p({v:2,c:e.c,m:e.m,t:e.t}):d(t(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function O(t){if(!(!t||t.length===0))try{let r=C(t);if(r&&typeof r==`object`&&r.v===2)return r.c&&r.m&&r.t?{v:2,c:r.c,m:r.m,t:r.t}:void 0;let i=e(f(t),{size:20});if(n(i))return{r:i}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function k({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(E);return t?O(t):null}function A({url:e,context:t}){if(!e)return null;let n=D(t);if(!n)return null;let r=new URL(e);return r.searchParams.set(E,n),r.toString()}function j(e){let t=new URL(e);return t.searchParams.delete(E),t.toString()}function M({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?j(n):A({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const N={compress:D,decompress:O,parse:k,update:A,remove:j,replaceUrl:M},P=`frak-merchant-id`;let F,I;async function L(e,t){if(F)return F;if(typeof window<`u`){let e=window.sessionStorage.getItem(P);if(e)return F=e,e}if(I)return I;I=R(e,t);let n=await I;return I=void 0,n}async function R(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=S(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return F=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(P,i.merchantId),F}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function z(){F=void 0,I=void 0,typeof window<`u`&&window.sessionStorage.removeItem(P)}async function B(e,t){return e.metadata?.merchantId?e.metadata.merchantId:L(void 0,t)}function V(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}export{u as _,N as a,C as c,g as d,_ as f,d as g,f as h,B as i,S as l,p as m,z as n,w as o,m as p,L as r,T as s,V as t,v as u,l as v};
@@ -0,0 +1 @@
1
+ let e=require(`viem`),t=require(`@frak-labs/frame-connector`);const n=`frak-client-id`;function r(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function i(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),r();let e=localStorage.getItem(n);return e||(e=r(),localStorage.setItem(n,e)),e}function a({domain:t}={}){return(0,e.keccak256)((0,e.toHex)((t??window.location.host).replace(`www.`,``)))}function o(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function s(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function c(e){return o((0,t.jsonEncode)(e))}function l(e,t,n,r,i,a){let o=c(u({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i})),s=new URL(e);return s.pathname=`/sso`,s.searchParams.set(`p`,o),s.toString()}function u(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const d=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,f=`frak-sso`;async function p(e,t){let{metadata:n,customizations:r,walletUrl:o}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let s=t.ssoPopupUrl??l(o??`https://wallet.frak.id`,t,a(),n.name,i(),r?.css),c=window.open(s,f,d);if(!c)throw Error(`Popup was blocked. Please allow popups for this site.`);return c.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const m=`https://backend.frak.id`;function h(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function g(e){return h(e)?`http://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:m}function _(e){if(e)return g(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return g(e)}return m}function v(e){return(0,t.jsonDecode)(s(e))}function y(e){return`r`in e&&!(`v`in e)}function b(e){return`v`in e&&e.v===2}const x=`fCtx`;function S(t){if(t)try{return b(t)?!t.c||!t.m||!t.t?void 0:c({v:2,c:t.c,m:t.m,t:t.t}):o((0,e.hexToBytes)(t.r))}catch(e){console.error(`Error compressing Frak context`,{e,context:t})}}function C(t){if(!(!t||t.length===0))try{let n=v(t);if(n&&typeof n==`object`&&n.v===2)return n.c&&n.m&&n.t?{v:2,c:n.c,m:n.m,t:n.t}:void 0;let r=(0,e.bytesToHex)(s(t),{size:20});if((0,e.isAddress)(r))return{r}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function w({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(x);return t?C(t):null}function T({url:e,context:t}){if(!e)return null;let n=S(t);if(!n)return null;let r=new URL(e);return r.searchParams.set(x,n),r.toString()}function E(e){let t=new URL(e);return t.searchParams.delete(x),t.toString()}function D({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?E(n):T({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const O={compress:S,decompress:C,parse:w,update:T,remove:E,replaceUrl:D},k=`frak-merchant-id`;let A,j;async function M(e,t){if(A)return A;if(typeof window<`u`){let e=window.sessionStorage.getItem(k);if(e)return A=e,e}if(j)return j;j=N(e,t);let n=await j;return j=void 0,n}async function N(e,t){let n=e??(typeof window<`u`?window.location.hostname:``);if(n)try{let e=_(t),r=await fetch(`${e}/user/merchant/resolve?domain=${encodeURIComponent(n)}`);if(!r.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${n}: ${r.status}`);return}let i=await r.json();return A=i.merchantId,typeof window<`u`&&window.sessionStorage.setItem(k,i.merchantId),A}catch(e){console.warn(`[Frak SDK] Failed to fetch merchantId:`,e);return}}function P(){A=void 0,j=void 0,typeof window<`u`&&window.sessionStorage.removeItem(k)}async function F(e,t){return e.metadata?.merchantId?e.metadata.merchantId:M(void 0,t)}function I(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return i}});
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.2.0",
14
+ "version": "0.2.1",
15
15
  "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",