@frak-labs/core-sdk 0.2.1-beta.eb3cff34 → 1.0.0-beta.0cd79998
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.js +3 -3
- package/dist/{actions-Dq_uN-wn.js → actions-BMTVobuH.js} +1 -1
- package/dist/{actions-D4aBXbdp.cjs → actions-ukNCM0d7.cjs} +1 -1
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +2 -2
- package/dist/actions.d.ts +2 -2
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +1 -1
- package/dist/bundle.d.cts +4 -4
- package/dist/bundle.d.ts +4 -4
- package/dist/bundle.js +1 -1
- package/dist/{index-BV5D9DsW.d.ts → index-BCwGNRmk.d.cts} +59 -27
- package/dist/{index-Dwmo109y.d.cts → index-BfmJnxzo.d.ts} +59 -27
- package/dist/{index-BphwTmKA.d.cts → index-CVnwk1E_.d.cts} +1 -1
- package/dist/{index-_f8EuN_1.d.ts → index-DZuYiI2M.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{openSso-BwEK2M98.d.cts → openSso-BQ-q-_Y9.d.ts} +92 -4
- package/dist/{openSso-C1Wzl5-i.d.ts → openSso-CMBCbhvP.d.cts} +91 -3
- package/dist/src-Cx0RZEA3.js +13 -0
- package/dist/src-DmYZ4ZLk.cjs +13 -0
- package/dist/trackEvent-B5xo_5K3.cjs +1 -0
- package/dist/trackEvent-DdykyX0U.js +1 -0
- package/package.json +2 -2
- package/src/clients/createIFrameFrakClient.ts +12 -1
- package/src/index.ts +4 -0
- package/src/types/config.ts +9 -0
- package/src/types/index.ts +2 -0
- package/src/types/resolvedConfig.ts +10 -0
- package/src/types/rpc/displaySharingPage.ts +18 -0
- package/src/types/tracking.ts +36 -0
- package/src/utils/FrakContext.test.ts +144 -0
- package/src/utils/FrakContext.ts +67 -1
- package/src/utils/index.ts +4 -0
- package/src/utils/mergeAttribution.test.ts +153 -0
- package/src/utils/mergeAttribution.ts +75 -0
- package/dist/src-B3Dusips.cjs +0 -13
- package/dist/src-CnnhYPyK.js +0 -13
- package/dist/trackEvent-BqJqRZ-u.cjs +0 -1
- package/dist/trackEvent-Bqq4jd6R.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-
|
|
1
|
+
import { G as SsoMetadata, Q as MerchantConfigResponse, U as PrepareSsoParamsType, a as FrakContextV1, at as Language, ct as AttributionParams, i as FrakContext, l as FrakClient, nt as Currency, o as FrakContextV2, rt as FrakWalletSdkConfig, st as AttributionDefaults, tt as SdkResolvedConfig, v as TokenAmountType } from "./openSso-BQ-q-_Y9.js";
|
|
2
|
+
import { Hex } from "viem";
|
|
2
3
|
import { RpcMessage, RpcResponse } from "@frak-labs/frame-connector";
|
|
3
|
-
import { Address, Hex } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/types/compression.d.ts
|
|
6
6
|
/**
|
|
@@ -22,29 +22,6 @@ type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
22
22
|
*/
|
|
23
23
|
type KeyProvider<DataType> = (value: DataType) => string[];
|
|
24
24
|
//#endregion
|
|
25
|
-
//#region src/types/tracking.d.ts
|
|
26
|
-
type UtmParams = {
|
|
27
|
-
source?: string;
|
|
28
|
-
medium?: string;
|
|
29
|
-
campaign?: string;
|
|
30
|
-
term?: string;
|
|
31
|
-
content?: string;
|
|
32
|
-
};
|
|
33
|
-
type TrackArrivalParams = {
|
|
34
|
-
/** @deprecated V1 legacy — use referrerClientId for v2 contexts */referrerWallet?: Address;
|
|
35
|
-
referrerClientId?: string;
|
|
36
|
-
referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
|
|
37
|
-
referralTimestamp?: number;
|
|
38
|
-
landingUrl?: string;
|
|
39
|
-
utmParams?: UtmParams;
|
|
40
|
-
};
|
|
41
|
-
type TrackArrivalResult = {
|
|
42
|
-
success: boolean;
|
|
43
|
-
identityGroupId?: string;
|
|
44
|
-
touchpointId?: string;
|
|
45
|
-
error?: string;
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
25
|
//#region src/clients/createIFrameFrakClient.d.ts
|
|
49
26
|
/**
|
|
50
27
|
* Create a new iframe Frak client
|
|
@@ -320,17 +297,25 @@ declare function parse({
|
|
|
320
297
|
/**
|
|
321
298
|
* Add or replace the `fCtx` query parameter in a URL with the given context.
|
|
322
299
|
*
|
|
300
|
+
* When `attribution` is provided (even as an empty object), standard affiliation
|
|
301
|
+
* params (`utm_source`, `utm_medium`, `utm_campaign`, `ref`, `via`, ...) are
|
|
302
|
+
* also appended using gap-fill semantics: pre-existing params on the URL are
|
|
303
|
+
* preserved, and defaults are derived from the context when applicable.
|
|
304
|
+
*
|
|
323
305
|
* @param args
|
|
324
306
|
* @param args.url - The URL to update
|
|
325
307
|
* @param args.context - The context to embed (V1 or V2)
|
|
308
|
+
* @param args.attribution - Optional attribution overrides. Omit to skip UTM/ref params.
|
|
326
309
|
* @returns The updated URL string, or null on failure
|
|
327
310
|
*/
|
|
328
311
|
declare function update({
|
|
329
312
|
url,
|
|
330
|
-
context
|
|
313
|
+
context,
|
|
314
|
+
attribution
|
|
331
315
|
}: {
|
|
332
316
|
url?: string;
|
|
333
317
|
context: FrakContextV1 | FrakContextV2;
|
|
318
|
+
attribution?: AttributionParams;
|
|
334
319
|
}): string | null;
|
|
335
320
|
/**
|
|
336
321
|
* Remove the `fCtx` query parameter from a URL.
|
|
@@ -483,6 +468,53 @@ declare const isInAppBrowser: boolean;
|
|
|
483
468
|
*/
|
|
484
469
|
declare function redirectToExternalBrowser(targetUrl: string): void;
|
|
485
470
|
//#endregion
|
|
471
|
+
//#region src/utils/mergeAttribution.d.ts
|
|
472
|
+
/**
|
|
473
|
+
* Inputs for {@link mergeAttribution}.
|
|
474
|
+
*/
|
|
475
|
+
type MergeAttributionInput = {
|
|
476
|
+
/**
|
|
477
|
+
* Per-call attribution override passed to actions like `displaySharingPage`.
|
|
478
|
+
*
|
|
479
|
+
* - `null` explicitly disables attribution (no UTM/ref/via params are added).
|
|
480
|
+
* - `undefined` means "no per-call override" — defaults apply if present.
|
|
481
|
+
* - An object (including `{}`) merges field-by-field with defaults.
|
|
482
|
+
*/
|
|
483
|
+
perCall: AttributionParams | null | undefined;
|
|
484
|
+
/**
|
|
485
|
+
* Pre-merged merchant-level defaults (backend config > SDK static config).
|
|
486
|
+
* `utm_content` is intentionally absent from this shape.
|
|
487
|
+
*/
|
|
488
|
+
defaults?: AttributionDefaults;
|
|
489
|
+
/**
|
|
490
|
+
* Per-product `utm_content` override (from the currently selected
|
|
491
|
+
* `SharingPageProduct`). Takes precedence over `perCall.utmContent`.
|
|
492
|
+
*/
|
|
493
|
+
productUtmContent?: string;
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* Merge the three attribution layers into a single {@link AttributionParams}
|
|
497
|
+
* value suitable for `FrakContextManager.update`.
|
|
498
|
+
*
|
|
499
|
+
* Priority per field:
|
|
500
|
+
* 1. `perCall` (wins)
|
|
501
|
+
* 2. `defaults` (merchant-level, backend > SDK static, already pre-merged)
|
|
502
|
+
* 3. Hardcoded fallbacks resolved later by `FrakContextManager`
|
|
503
|
+
*
|
|
504
|
+
* Special rules:
|
|
505
|
+
* - `perCall === null` returns `undefined` (explicit disable: no UTM/ref/via).
|
|
506
|
+
* - `perCall === undefined` (no opinion) yields at least `{}` so `FrakContextManager`
|
|
507
|
+
* applies its hardcoded defaults (utm_source=frak, utm_medium=referral,
|
|
508
|
+
* utm_campaign=<merchantId>, ref=<clientId>, via=frak).
|
|
509
|
+
* - `utm_content` never comes from `defaults`; only `productUtmContent` or
|
|
510
|
+
* `perCall.utmContent` can populate it.
|
|
511
|
+
*/
|
|
512
|
+
declare function mergeAttribution({
|
|
513
|
+
perCall,
|
|
514
|
+
defaults,
|
|
515
|
+
productUtmContent
|
|
516
|
+
}: MergeAttributionInput): AttributionParams | undefined;
|
|
517
|
+
//#endregion
|
|
486
518
|
//#region src/utils/sdkConfigStore.d.ts
|
|
487
519
|
declare const GLOBAL_KEY = "__frakSdkConfig";
|
|
488
520
|
declare global {
|
|
@@ -588,4 +620,4 @@ declare function computeLegacyProductId({
|
|
|
588
620
|
domain?: string;
|
|
589
621
|
}): `0x${string}`;
|
|
590
622
|
//#endregion
|
|
591
|
-
export {
|
|
623
|
+
export { base64urlDecode as A, DebugInfoGatherer as B, isChromiumAndroid as C, DEEP_LINK_SCHEME as D, triggerDeepLinkWithFallback as E, withCache as F, CompressedData as H, getBackendUrl as I, LocalesKey as L, getClientId as M, clearAllCache as N, decompressJsonFromB64 as O, getCache as P, locales as R, DeepLinkFallbackOptions as S, toAndroidIntentUrl as T, HashProtectedData as U, createIFrameFrakClient as V, KeyProvider as W, getSupportedLocale as _, CompressedSsoData as a, formatAmount as b, sdkConfigStore as c, isIOS as d, isInAppBrowser as f, findIframeInOpener as g, createIframe as h, AppSpecificSsoMetadata as i, base64urlEncode as j, compressJsonToB64 as k, MergeAttributionInput as l, baseIframeProps as m, FrakEvent as n, FullSsoParams as o, redirectToExternalBrowser as p, trackEvent as r, generateSsoUrl as s, computeLegacyProductId as t, mergeAttribution as u, getSupportedCurrency as v, isFrakDeepLink as w, FrakContextManager as x, getCurrencyAmountKey as y, setupClient as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-
|
|
1
|
+
import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-CMBCbhvP.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/actions/displayEmbeddedWallet.d.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-
|
|
1
|
+
import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-BQ-q-_Y9.js";
|
|
2
2
|
|
|
3
3
|
//#region src/actions/displayEmbeddedWallet.d.ts
|
|
4
4
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-B5xo_5K3.cjs`),t=require(`./src-DmYZ4ZLk.cjs`);exports.DEEP_LINK_SCHEME=t.b,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.r,exports.base64urlDecode=e.g,exports.base64urlEncode=e._,exports.baseIframeProps=t.c,exports.clearAllCache=e.s,exports.compressJsonToB64=e.h,exports.computeLegacyProductId=e.v,exports.createIFrameFrakClient=t.n,exports.createIframe=t.l,exports.decompressJsonFromB64=e.o,exports.findIframeInOpener=t.u,exports.formatAmount=t.f,exports.generateSsoUrl=e.m,exports.getBackendUrl=e.u,exports.getCache=e.c,exports.getClientId=e.y,exports.getCurrencyAmountKey=t.d,exports.getSupportedCurrency=t.m,exports.getSupportedLocale=t.p,exports.isChromiumAndroid=t.g,exports.isFrakDeepLink=t._,exports.isIOS=t.a,exports.isInAppBrowser=t.o,exports.isV1Context=e.i,exports.isV2Context=e.a,exports.locales=t.h,exports.mergeAttribution=t.i,exports.redirectToExternalBrowser=t.s,exports.sdkConfigStore=e.n,exports.setupClient=t.t,exports.ssoPopupFeatures=e.f,exports.ssoPopupName=e.p,exports.toAndroidIntentUrl=t.v,exports.trackEvent=e.t,exports.triggerDeepLinkWithFallback=t.y,exports.withCache=e.l;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-
|
|
2
|
-
import { A as
|
|
3
|
-
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, ct as AttributionParams, d as IFrameTransport, dt as UtmParams, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, lt as TrackArrivalParams, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, st as AttributionDefaults, tt as SdkResolvedConfig, u as FrakLifecycleEvent, ut as TrackArrivalResult, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-CMBCbhvP.cjs";
|
|
2
|
+
import { A as base64urlDecode, B as DebugInfoGatherer, C as isChromiumAndroid, D as DEEP_LINK_SCHEME, E as triggerDeepLinkWithFallback, F as withCache, H as CompressedData, I as getBackendUrl, L as LocalesKey, M as getClientId, N as clearAllCache, O as decompressJsonFromB64, P as getCache, R as locales, S as DeepLinkFallbackOptions, T as toAndroidIntentUrl, U as HashProtectedData, V as createIFrameFrakClient, W as KeyProvider, _ as getSupportedLocale, a as CompressedSsoData, b as formatAmount, c as sdkConfigStore, d as isIOS, f as isInAppBrowser, g as findIframeInOpener, h as createIframe, i as AppSpecificSsoMetadata, j as base64urlEncode, k as compressJsonToB64, l as MergeAttributionInput, m as baseIframeProps, n as FrakEvent, o as FullSsoParams, p as redirectToExternalBrowser, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as mergeAttribution, v as getSupportedCurrency, w as isFrakDeepLink, x as FrakContextManager, y as getCurrencyAmountKey, z as setupClient } from "./index-BCwGNRmk.cjs";
|
|
3
|
+
export { AppSpecificSsoMetadata, AttributionDefaults, AttributionParams, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, MergeAttributionInput, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, mergeAttribution, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-
|
|
2
|
-
import { A as
|
|
3
|
-
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, ct as AttributionParams, d as IFrameTransport, dt as UtmParams, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, lt as TrackArrivalParams, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, st as AttributionDefaults, tt as SdkResolvedConfig, u as FrakLifecycleEvent, ut as TrackArrivalResult, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-BQ-q-_Y9.js";
|
|
2
|
+
import { A as base64urlDecode, B as DebugInfoGatherer, C as isChromiumAndroid, D as DEEP_LINK_SCHEME, E as triggerDeepLinkWithFallback, F as withCache, H as CompressedData, I as getBackendUrl, L as LocalesKey, M as getClientId, N as clearAllCache, O as decompressJsonFromB64, P as getCache, R as locales, S as DeepLinkFallbackOptions, T as toAndroidIntentUrl, U as HashProtectedData, V as createIFrameFrakClient, W as KeyProvider, _ as getSupportedLocale, a as CompressedSsoData, b as formatAmount, c as sdkConfigStore, d as isIOS, f as isInAppBrowser, g as findIframeInOpener, h as createIframe, i as AppSpecificSsoMetadata, j as base64urlEncode, k as compressJsonToB64, l as MergeAttributionInput, m as baseIframeProps, n as FrakEvent, o as FullSsoParams, p as redirectToExternalBrowser, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as mergeAttribution, v as getSupportedCurrency, w as isFrakDeepLink, x as FrakContextManager, y as getCurrencyAmountKey, z as setupClient } from "./index-BfmJnxzo.js";
|
|
3
|
+
export { AppSpecificSsoMetadata, AttributionDefaults, AttributionParams, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, MergeAttributionInput, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, mergeAttribution, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./trackEvent-
|
|
1
|
+
import{_ as e,a as t,c as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./trackEvent-DdykyX0U.js";import{_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as k,o as A,p as j,r as M,s as N,t as P,u as F,v as I,y as L}from"./src-Cx0RZEA3.js";export{b as DEEP_LINK_SCHEME,M as DebugInfoGatherer,f as FrakContextManager,i as base64urlDecode,e as base64urlEncode,x as baseIframeProps,p as clearAllCache,a as compressJsonToB64,g as computeLegacyProductId,k as createIFrameFrakClient,D as createIframe,u as decompressJsonFromB64,F as findIframeInOpener,C as formatAmount,c as generateSsoUrl,h as getBackendUrl,n as getCache,_ as getClientId,S as getCurrencyAmountKey,O as getSupportedCurrency,j as getSupportedLocale,w as isChromiumAndroid,v as isFrakDeepLink,y as isIOS,A as isInAppBrowser,o as isV1Context,t as isV2Context,T as locales,E as mergeAttribution,N as redirectToExternalBrowser,l as sdkConfigStore,P as setupClient,r as ssoPopupFeatures,d as ssoPopupName,I as toAndroidIntentUrl,m as trackEvent,L as triggerDeepLinkWithFallback,s as withCache};
|
|
@@ -1,8 +1,65 @@
|
|
|
1
|
-
import { OpenPanel } from "@openpanel/web";
|
|
2
|
-
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
3
1
|
import { Address, Hex } from "viem";
|
|
2
|
+
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
3
|
+
import { OpenPanel } from "@openpanel/web";
|
|
4
4
|
import { SiweMessage } from "viem/siwe";
|
|
5
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
|
+
/** @deprecated V1 legacy — use referrerClientId for v2 contexts */referrerWallet?: Address;
|
|
50
|
+
referrerClientId?: string;
|
|
51
|
+
referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
|
|
52
|
+
referralTimestamp?: number;
|
|
53
|
+
landingUrl?: string;
|
|
54
|
+
utmParams?: UtmParams;
|
|
55
|
+
};
|
|
56
|
+
type TrackArrivalResult = {
|
|
57
|
+
success: boolean;
|
|
58
|
+
identityGroupId?: string;
|
|
59
|
+
touchpointId?: string;
|
|
60
|
+
error?: string;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
6
63
|
//#region src/types/config.d.ts
|
|
7
64
|
/**
|
|
8
65
|
* All the currencies available
|
|
@@ -82,6 +139,13 @@ type FrakWalletSdkConfig = {
|
|
|
82
139
|
* @defaultValue true
|
|
83
140
|
*/
|
|
84
141
|
waitForBackendConfig?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Default attribution params (UTM / via / ref) appended to outbound
|
|
144
|
+
* sharing URLs. Per-call `displaySharingPage` overrides win, then backend
|
|
145
|
+
* config, then this SDK-level default. `utm_content` is intentionally
|
|
146
|
+
* excluded — it is per-content/per-product, never a merchant-wide default.
|
|
147
|
+
*/
|
|
148
|
+
attribution?: AttributionDefaults;
|
|
85
149
|
};
|
|
86
150
|
/**
|
|
87
151
|
* Custom i18n configuration for the modal
|
|
@@ -199,6 +263,12 @@ type ResolvedSdkConfig = {
|
|
|
199
263
|
translations?: Record<string, string>;
|
|
200
264
|
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (used when no placement override exists) */
|
|
201
265
|
components?: ResolvedPlacement["components"];
|
|
266
|
+
/**
|
|
267
|
+
* Default attribution params applied when building outbound sharing URLs.
|
|
268
|
+
* Per-call overrides win over these backend defaults; `utm_content` is
|
|
269
|
+
* intentionally excluded (per-content/per-product, never a merchant default).
|
|
270
|
+
*/
|
|
271
|
+
attribution?: AttributionDefaults;
|
|
202
272
|
};
|
|
203
273
|
/**
|
|
204
274
|
* Internal SDK config store state
|
|
@@ -221,7 +291,8 @@ type SdkResolvedConfig = {
|
|
|
221
291
|
css?: string; /** Global translations (for reference / component fallback) */
|
|
222
292
|
translations?: Record<string, string>; /** Named placements (keyed by placement ID) */
|
|
223
293
|
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (fallback for placement-level overrides) */
|
|
224
|
-
components?: ResolvedPlacement["components"];
|
|
294
|
+
components?: ResolvedPlacement["components"]; /** Merged attribution defaults: backend > SDK static config */
|
|
295
|
+
attribution?: AttributionDefaults;
|
|
225
296
|
};
|
|
226
297
|
//#endregion
|
|
227
298
|
//#region src/types/lifecycle/client.d.ts
|
|
@@ -651,6 +722,11 @@ type SharingPageProduct = {
|
|
|
651
722
|
* When provided and the product is selected, this link is used instead of the default sharing link
|
|
652
723
|
*/
|
|
653
724
|
link?: string;
|
|
725
|
+
/**
|
|
726
|
+
* Optional `utm_content` value to apply when this product is selected.
|
|
727
|
+
* Falls back to the page-level `attribution.utmContent` when omitted.
|
|
728
|
+
*/
|
|
729
|
+
utmContent?: string;
|
|
654
730
|
};
|
|
655
731
|
/**
|
|
656
732
|
* Parameters to display the sharing page
|
|
@@ -668,6 +744,18 @@ type DisplaySharingPageParamsType = {
|
|
|
668
744
|
* If not provided, the sharing link will be generated from the current page URL + merchant context
|
|
669
745
|
*/
|
|
670
746
|
link?: string;
|
|
747
|
+
/**
|
|
748
|
+
* Optional attribution overrides for the outbound sharing URL.
|
|
749
|
+
*
|
|
750
|
+
* When provided (even as an empty object), Frak adds standard affiliation
|
|
751
|
+
* params (`utm_source=frak`, `utm_medium=referral`, `utm_campaign=<merchantId>`,
|
|
752
|
+
* `ref=<clientId>`, `via=frak`) alongside `fCtx`. Existing UTMs on the base
|
|
753
|
+
* URL are preserved (gap-fill). Set this to `null` to disable attribution
|
|
754
|
+
* params entirely (only `fCtx` is added).
|
|
755
|
+
*
|
|
756
|
+
* @default {} — defaults applied
|
|
757
|
+
*/
|
|
758
|
+
attribution?: AttributionParams | null;
|
|
671
759
|
/**
|
|
672
760
|
* Optional metadata overrides for the sharing page
|
|
673
761
|
*/
|
|
@@ -1291,4 +1379,4 @@ declare const ssoPopupName = "frak-sso";
|
|
|
1291
1379
|
*/
|
|
1292
1380
|
declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1293
1381
|
//#endregion
|
|
1294
|
-
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, IFrameTransport as d, 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, 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, openSso as t, SdkResolvedConfig as tt, FrakLifecycleEvent as u, TokenAmountType as v, EmbeddedViewActionSharing as w, DisplayEmbeddedWalletResultType as x, SendInteractionParamsType as y, SiweAuthenticationParams as z };
|
|
1382
|
+
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 };
|
|
@@ -1,8 +1,65 @@
|
|
|
1
|
+
import { OpenPanel } from "@openpanel/web";
|
|
1
2
|
import { Address, Hex } from "viem";
|
|
2
3
|
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
3
|
-
import { OpenPanel } from "@openpanel/web";
|
|
4
4
|
import { SiweMessage } from "viem/siwe";
|
|
5
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
|
+
/** @deprecated V1 legacy — use referrerClientId for v2 contexts */referrerWallet?: Address;
|
|
50
|
+
referrerClientId?: string;
|
|
51
|
+
referrerMerchantId?: string; /** Epoch seconds timestamp from the referral link creation */
|
|
52
|
+
referralTimestamp?: number;
|
|
53
|
+
landingUrl?: string;
|
|
54
|
+
utmParams?: UtmParams;
|
|
55
|
+
};
|
|
56
|
+
type TrackArrivalResult = {
|
|
57
|
+
success: boolean;
|
|
58
|
+
identityGroupId?: string;
|
|
59
|
+
touchpointId?: string;
|
|
60
|
+
error?: string;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
6
63
|
//#region src/types/config.d.ts
|
|
7
64
|
/**
|
|
8
65
|
* All the currencies available
|
|
@@ -82,6 +139,13 @@ type FrakWalletSdkConfig = {
|
|
|
82
139
|
* @defaultValue true
|
|
83
140
|
*/
|
|
84
141
|
waitForBackendConfig?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Default attribution params (UTM / via / ref) appended to outbound
|
|
144
|
+
* sharing URLs. Per-call `displaySharingPage` overrides win, then backend
|
|
145
|
+
* config, then this SDK-level default. `utm_content` is intentionally
|
|
146
|
+
* excluded — it is per-content/per-product, never a merchant-wide default.
|
|
147
|
+
*/
|
|
148
|
+
attribution?: AttributionDefaults;
|
|
85
149
|
};
|
|
86
150
|
/**
|
|
87
151
|
* Custom i18n configuration for the modal
|
|
@@ -199,6 +263,12 @@ type ResolvedSdkConfig = {
|
|
|
199
263
|
translations?: Record<string, string>;
|
|
200
264
|
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (used when no placement override exists) */
|
|
201
265
|
components?: ResolvedPlacement["components"];
|
|
266
|
+
/**
|
|
267
|
+
* Default attribution params applied when building outbound sharing URLs.
|
|
268
|
+
* Per-call overrides win over these backend defaults; `utm_content` is
|
|
269
|
+
* intentionally excluded (per-content/per-product, never a merchant default).
|
|
270
|
+
*/
|
|
271
|
+
attribution?: AttributionDefaults;
|
|
202
272
|
};
|
|
203
273
|
/**
|
|
204
274
|
* Internal SDK config store state
|
|
@@ -221,7 +291,8 @@ type SdkResolvedConfig = {
|
|
|
221
291
|
css?: string; /** Global translations (for reference / component fallback) */
|
|
222
292
|
translations?: Record<string, string>; /** Named placements (keyed by placement ID) */
|
|
223
293
|
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (fallback for placement-level overrides) */
|
|
224
|
-
components?: ResolvedPlacement["components"];
|
|
294
|
+
components?: ResolvedPlacement["components"]; /** Merged attribution defaults: backend > SDK static config */
|
|
295
|
+
attribution?: AttributionDefaults;
|
|
225
296
|
};
|
|
226
297
|
//#endregion
|
|
227
298
|
//#region src/types/lifecycle/client.d.ts
|
|
@@ -651,6 +722,11 @@ type SharingPageProduct = {
|
|
|
651
722
|
* When provided and the product is selected, this link is used instead of the default sharing link
|
|
652
723
|
*/
|
|
653
724
|
link?: string;
|
|
725
|
+
/**
|
|
726
|
+
* Optional `utm_content` value to apply when this product is selected.
|
|
727
|
+
* Falls back to the page-level `attribution.utmContent` when omitted.
|
|
728
|
+
*/
|
|
729
|
+
utmContent?: string;
|
|
654
730
|
};
|
|
655
731
|
/**
|
|
656
732
|
* Parameters to display the sharing page
|
|
@@ -668,6 +744,18 @@ type DisplaySharingPageParamsType = {
|
|
|
668
744
|
* If not provided, the sharing link will be generated from the current page URL + merchant context
|
|
669
745
|
*/
|
|
670
746
|
link?: string;
|
|
747
|
+
/**
|
|
748
|
+
* Optional attribution overrides for the outbound sharing URL.
|
|
749
|
+
*
|
|
750
|
+
* When provided (even as an empty object), Frak adds standard affiliation
|
|
751
|
+
* params (`utm_source=frak`, `utm_medium=referral`, `utm_campaign=<merchantId>`,
|
|
752
|
+
* `ref=<clientId>`, `via=frak`) alongside `fCtx`. Existing UTMs on the base
|
|
753
|
+
* URL are preserved (gap-fill). Set this to `null` to disable attribution
|
|
754
|
+
* params entirely (only `fCtx` is added).
|
|
755
|
+
*
|
|
756
|
+
* @default {} — defaults applied
|
|
757
|
+
*/
|
|
758
|
+
attribution?: AttributionParams | null;
|
|
671
759
|
/**
|
|
672
760
|
* Optional metadata overrides for the sharing page
|
|
673
761
|
*/
|
|
@@ -1291,4 +1379,4 @@ declare const ssoPopupName = "frak-sso";
|
|
|
1291
1379
|
*/
|
|
1292
1380
|
declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1293
1381
|
//#endregion
|
|
1294
|
-
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, IFrameTransport as d, 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, 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, openSso as t, SdkResolvedConfig as tt, FrakLifecycleEvent as u, TokenAmountType as v, EmbeddedViewActionSharing as w, DisplayEmbeddedWalletResultType as x, SendInteractionParamsType as y, SiweAuthenticationParams as z };
|
|
1382
|
+
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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{n as e,s as t,y as n}from"./trackEvent-DdykyX0U.js";import{Deferred as r,FrakRpcError as i,RpcErrorCodes as a,createRpcClient as o}from"@frak-labs/frame-connector";import{OpenPanel as s}from"@openpanel/web";const c=`nexus-wallet-backup`,l=`frakwallet://`;function u(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function d(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function f(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=u()&&p(e)?d(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function p(e){return e.startsWith(l)}const m={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function h(e){return e&&e in m?e:`eur`}function g(e){return e?m[e]??m.eur:m.eur}function _(e,t){let n=g(t),r=h(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function v(e){return e?`${e}Amount`:`eurAmount`}const y={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 b({walletBaseUrl:e,config:t}){let r=document.querySelector(`#frak-wallet`);r&&r.remove();let i=document.createElement(`iframe`);i.id=y.id,i.name=y.name,i.allow=y.allow,i.style.zIndex=y.style.zIndex.toString(),x({iframe:i,isVisible:!1});let a=t?.walletUrl??e??`https://wallet.frak.id`,o=n();return i.src=`${a}/listener?clientId=${encodeURIComponent(o)}`,new Promise(e=>{i.addEventListener(`load`,()=>e(i)),document.body.appendChild(i)})}function x({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 S(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 C(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const w=C();function T(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const E=T();function D(e){w&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:w&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function O({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}function k(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 A=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,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(),n=this.getNavigatorInfo(),r=`Unknown`;return e instanceof i?r=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?r=e.message:typeof e==`string`&&(r=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:n?this.base64Encode(n):`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:r}}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 j=(()=>{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 M(e){e?localStorage.setItem(c,e):localStorage.removeItem(c)}function N(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=I(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function P(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 F(e){return e.includes(`/common/social`)}function I(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function L(e,t,n,r,i){if(i){let e=N(t,r);window.open(e,`_blank`);return}if(p(t)){let i=N(t,r);f(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(j&&F(t))P(r);else{let e=N(t,r);window.location.href=e}}function R({iframe:e,targetOrigin:t}){let n=new r;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:M(a.backup);break;case`remove-backup`:localStorage.removeItem(c);break;case`show`:case`hide`:x({iframe:e,isVisible:i===`show`});break;case`redirect`:L(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function z({config:c,iframe:l}){let u=c?.walletUrl??`https://wallet.frak.id`,d=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,f=c.metadata.lang??(d===`en`||d===`fr`?d:void 0),p=c.domain??(typeof window<`u`?window.location.hostname:``);e.setCacheScope(p,f),e.reset();let m=e.isCacheFresh?void 0:e.resolve(c.domain,c.walletUrl,f),h=R({iframe:l,targetOrigin:u}),g=new r,_=new A(c,l);if(!l.contentWindow)throw new i(a.configError,`The iframe does not have a content window`);let v=o({emittingTransport:l.contentWindow,listeningTransport:window,targetOrigin:u,middleware:[{async onRequest(e,t){if(!await h.isConnected)throw new i(a.clientNotConnected,`The iframe provider isn't connected yet`);return await g.promise,t}},{onRequest(e,t){return _.setLastRequest(e),t},onResponse(e,t){return _.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{h.handleEvent(e)}}}),y=B(v,h),b=async()=>{y(),v.cleanup(),l.remove(),t(),e.clearCache(),e.reset()},x;console.log(`[Frak SDK] Initializing OpenPanel`),x=new s({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`1.0.0`,userAnonymousClientId:n()}),!0)}),x.setGlobalProperties({sdkVersion:`1.0.0`,userAnonymousClientId:n()}),x.init();let S=V({config:c,rpcClient:v,lifecycleManager:h,configPromise:m,contextSent:g}).then(()=>_.updateSetupStatus(!0)).catch(e=>{throw g.reject(e),e});return{config:c,debugInfo:_,waitForConnection:h.isConnected,waitForSetup:S,request:v.request,listenerRequest:v.listen,destroy:b,openPanel:x}}function B(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 V({config:t,rpcClient:n,lifecycleManager:r,configPromise:i,contextSent:a}){await r.isConnected,k(n,r.isConnected);let o=new URL(window.location.href),s=o.searchParams.get(`fmt`)??void 0;s&&(o.searchParams.delete(`fmt`),window.history.replaceState({},``,o.toString()));let l=n=>{let r=n?.merchantId??t.metadata.merchantId??``,i=n?.domain??``,a=n?.allowedDomains??[],o=n?.sdkConfig,s=o?.attribution||t.attribution?{...t.attribution,...o?.attribution}:void 0;e.setConfig(o?{isResolved:!0,merchantId:r,domain:i,allowedDomains:a,hasRawSdkConfig:!0,name:o.name??t.metadata.name,logoUrl:o.logoUrl??t.metadata.logoUrl,homepageLink:o.homepageLink??t.metadata.homepageLink,lang:o.lang??t.metadata.lang,currency:o.currency??t.metadata.currency,hidden:o.hidden,css:o.css,translations:o.translations,placements:o.placements,components:o.components,attribution:s}:{isResolved:!0,merchantId:r,domain:i,allowedDomains:a,name:t.metadata.name,logoUrl:t.metadata.logoUrl,homepageLink:t.metadata.homepageLink,lang:t.metadata.lang,currency:t.metadata.currency,attribution:s})},u=!1,d=e=>{let t=u?void 0:s;u=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0;n.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...t&&{pendingMergeToken:t},...r&&{sdkConfig:r}}})};e.isResolved&&(d(e.getConfig()),a.resolve()),i&&(l(await i),d(e.getConfig()),a.resolve());async function f(){let e=t.customizations?.css;e&&n.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:e}})}async function p(){let e=t.customizations?.i18n;e&&n.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:e}})}async function m(){if(typeof window>`u`)return;let e=window.localStorage.getItem(c);e&&n.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}await Promise.allSettled([f(),p(),m()])}async function H({config:e}){let t=U(e),n=await b({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=z({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function U(e){let t=h(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{p as _,w as a,l as b,y as c,v as d,_ as f,u as g,m as h,O as i,b as l,h as m,z as n,E as o,g as p,A as r,D as s,H as t,S as u,d as v,f as y};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const e=require(`./trackEvent-B5xo_5K3.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.y();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(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const y=v();function b(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const x=b();function S(e){y&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:y&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`https://backend.frak.id/common/social?u=${encodeURIComponent(e)}`}function C({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&!(n!==void 0&&n!==``))return;let a={...t,...e??{}},o=n??e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}function w(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 T=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,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 E=(()=>{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 D(e){e?localStorage.setItem(r,e):localStorage.removeItem(r)}function O(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=j(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function k(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 A(e){return e.includes(`/common/social`)}function j(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function M(e,t,n,r,i){if(i){let e=O(t,r);window.open(e,`_blank`);return}if(c(t)){let i=O(t,r);s(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(E&&A(t))k(r);else{let e=O(t,r);window.location.href=e}}function N({iframe:e,targetOrigin:n}){let i=new t.Deferred;return{handleEvent:t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:a,data:o}=t;switch(a){case`connected`:i.resolve(!0);break;case`do-backup`:D(o.backup);break;case`remove-backup`:localStorage.removeItem(r);break;case`show`:case`hide`:g({iframe:e,isVisible:a===`show`});break;case`redirect`:M(e,o.baseRedirectUrl,n,o.mergeToken,o.openInNewTab);break}},isConnected:i.promise}}function P({config:r,iframe:i}){let a=r?.walletUrl??`https://wallet.frak.id`,o=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,s=r.metadata.lang??(o===`en`||o===`fr`?o:void 0),c=r.domain??(typeof window<`u`?window.location.hostname:``);e.n.setCacheScope(c,s),e.n.reset();let l=e.n.isCacheFresh?void 0:e.n.resolve(r.domain,r.walletUrl,s),u=N({iframe:i,targetOrigin:a}),d=new t.Deferred,f=new T(r,i);if(!i.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let p=(0,t.createRpcClient)({emittingTransport:i.contentWindow,listeningTransport:window,targetOrigin:a,middleware:[{async onRequest(e,n){if(!await u.isConnected)throw new t.FrakRpcError(t.RpcErrorCodes.clientNotConnected,`The iframe provider isn't connected yet`);return await d.promise,n}},{onRequest(e,t){return f.setLastRequest(e),t},onResponse(e,t){return f.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{u.handleEvent(e)}}}),m=F(p,u),h=async()=>{m(),p.cleanup(),i.remove(),e.s(),e.n.clearCache(),e.n.reset()},g;console.log(`[Frak SDK] Initializing OpenPanel`),g=new n.OpenPanel({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:t,payload:n})=>(t!==`track`||!n?.properties||`sdkVersion`in n.properties||(n.properties={...n.properties,sdkVersion:`1.0.0`,userAnonymousClientId:e.y()}),!0)}),g.setGlobalProperties({sdkVersion:`1.0.0`,userAnonymousClientId:e.y()}),g.init();let _=I({config:r,rpcClient:p,lifecycleManager:u,configPromise:l,contextSent:d}).then(()=>f.updateSetupStatus(!0)).catch(e=>{throw d.reject(e),e});return{config:r,debugInfo:f,waitForConnection:u.isConnected,waitForSetup:_,request:p.request,listenerRequest:p.listen,destroy:h,openPanel:g}}function F(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 I({config:t,rpcClient:n,lifecycleManager:i,configPromise:a,contextSent:o}){await i.isConnected,w(n,i.isConnected);let s=new URL(window.location.href),c=s.searchParams.get(`fmt`)??void 0;c&&(s.searchParams.delete(`fmt`),window.history.replaceState({},``,s.toString()));let l=n=>{let r=n?.merchantId??t.metadata.merchantId??``,i=n?.domain??``,a=n?.allowedDomains??[],o=n?.sdkConfig,s=o?.attribution||t.attribution?{...t.attribution,...o?.attribution}:void 0;e.n.setConfig(o?{isResolved:!0,merchantId:r,domain:i,allowedDomains:a,hasRawSdkConfig:!0,name:o.name??t.metadata.name,logoUrl:o.logoUrl??t.metadata.logoUrl,homepageLink:o.homepageLink??t.metadata.homepageLink,lang:o.lang??t.metadata.lang,currency:o.currency??t.metadata.currency,hidden:o.hidden,css:o.css,translations:o.translations,placements:o.placements,components:o.components,attribution:s}:{isResolved:!0,merchantId:r,domain:i,allowedDomains:a,name:t.metadata.name,logoUrl:t.metadata.logoUrl,homepageLink:t.metadata.homepageLink,lang:t.metadata.lang,currency:t.metadata.currency,attribution:s})},u=!1,d=e=>{let t=u?void 0:c;u=!0;let r=e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0;n.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...t&&{pendingMergeToken:t},...r&&{sdkConfig:r}}})};e.n.isResolved&&(d(e.n.getConfig()),o.resolve()),a&&(l(await a),d(e.n.getConfig()),o.resolve());async function f(){let e=t.customizations?.css;e&&n.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:e}})}async function p(){let e=t.customizations?.i18n;e&&n.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:e}})}async function m(){if(typeof window>`u`)return;let e=window.localStorage.getItem(r);e&&n.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}await Promise.allSettled([f(),p(),m()])}async function L({config:e}){let t=R(e),n=await h({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=P({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function R(e){let t=u(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return s}});
|
|
@@ -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)?`https://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}var v=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};const y=new v(1024),b=new v(1024),x=3e4,S=new v(1024);async function C(e,{cacheKey:t,cacheTime:n=x}){if(n>0){let e=b.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=S.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=y.get(t);i||(i=e(),y.set(t,i));try{let e=await i;return b.set(t,{data:e,created:Date.now()}),S.delete(t),e}catch(e){throw S.set(t,Date.now()),e}finally{y.delete(t)}}function ee(e){return{clear:()=>{y.delete(e),b.delete(e)},has:(t=x)=>{let n=b.get(e);return n?Date.now()-n.created<t:!1}}}function w(){y.clear(),b.clear(),S.clear()}function T(e){return(0,t.jsonDecode)(s(e))}function E(e){return`r`in e&&!(`v`in e)}function D(e){return`v`in e&&e.v===2}const O=`fCtx`;function k(t){if(t)try{return D(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 A(t){if(!(!t||t.length===0))try{let n=T(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 j({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(O);return t?A(t):null}const M=`frak`;function N(e,t){let n=D(e);return{utm_source:t.utmSource??M,utm_medium:t.utmMedium??`referral`,utm_campaign:t.utmCampaign??(n?e.m:void 0),utm_content:t.utmContent,utm_term:t.utmTerm,via:t.via??M,ref:t.ref??(n?e.c:void 0)}}function te(e,t,n){let r=N(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function P({url:e,context:t,attribution:n}){if(!e)return null;let r=k(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(O,r),te(i,t,n),i.toString()}function F(e){let t=new URL(e);return t.searchParams.delete(O),t.toString()}function I({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?F(n):P({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const L={compress:k,decompress:A,parse:j,update:P,remove:F,replaceUrl:I},R=`__frakSdkConfig`,z=`frak-config-cache`,B=`frak-merchant-id`,V={key:z},H=typeof window<`u`;function U(){return{isResolved:!1,merchantId:``}}let W=null;function G(){if(!H)return null;try{let e=localStorage.getItem(V.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(W=t,t):null}catch{return null}}function K(){return(W??G())?.config}function q(){let e=W??G();return e?Date.now()-e.timestamp<3e4:!1}function J(e){if(!(!H||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(V.key,JSON.stringify(t)),W=t}catch{}}function Y(){if(H){W=null;try{localStorage.removeItem(V.key)}catch{}}}function X(){H&&(window[R]||(window[R]=K()??U()))}X();function Z(){return H?window[R]??U():U()}function Q(e){H&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function ne(e){return e??(H?window.location.hostname:``)}async function re(e,t,n){try{let r=_(t),i=n?`&lang=${encodeURIComponent(n)}`:``,a=await fetch(`${r}/user/merchant/resolve?domain=${encodeURIComponent(e)}${i}`);if(!a.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${a.status}`);return}let o=await a.json();if(H)try{sessionStorage.setItem(B,o.merchantId)}catch{}return o}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const $={getConfig:Z,get isResolved(){return Z().isResolved},get isCacheFresh(){return q()},setCacheScope(e,t){V.key=`${z}:${`${e}:${t??``}`}`,W=null},setConfig(e){if(H&&(window[R]=e),J(e),Q(e),H&&e.merchantId)try{sessionStorage.setItem(B,e.merchantId)}catch{}},reset(){let e=K()??U();H&&(window[R]=e),Q(e)},clearCache(){if(Y(),w(),H)try{sessionStorage.removeItem(B)}catch{}},resolve(e,t,n){let r=ne(e);return r?C(async()=>{let e=await re(r,t,n);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${r}:${n??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Z();if(e.isResolved&&e.merchantId)return e.merchantId;if(H)try{return sessionStorage.getItem(B)??void 0}catch{}},async resolveMerchantId(e,t){return $.getMerchantId()||(await $.resolve(e,t))?.merchantId}};function ie(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 o}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return i}});
|