@frak-labs/core-sdk 1.0.2 → 1.1.0-beta.53162c2d

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 (96) hide show
  1. package/README.md +0 -1
  2. package/cdn/bundle.js +1 -14
  3. package/dist/actions-BVbAHcBk.cjs +1 -0
  4. package/dist/actions-dH5NFCj1.js +1 -0
  5. package/dist/actions.cjs +1 -1
  6. package/dist/actions.d.cts +2 -2
  7. package/dist/actions.d.ts +2 -2
  8. package/dist/actions.js +1 -1
  9. package/dist/bundle.cjs +1 -1
  10. package/dist/bundle.d.cts +4 -4
  11. package/dist/bundle.d.ts +4 -4
  12. package/dist/bundle.js +1 -1
  13. package/dist/frakContext-CTKalP6g.js +1 -0
  14. package/dist/frakContext-_b-_uwgd.cjs +1 -0
  15. package/dist/{index-DzVPSUQq.d.ts → index-5JycXTk0.d.cts} +248 -352
  16. package/dist/{index-quaxtKRh.d.ts → index-BD1gOEIo.d.ts} +1 -1
  17. package/dist/{index-BsBbSMxk.d.cts → index-C2xfJCUg.d.cts} +1 -1
  18. package/dist/{index-s1vE3jLz.d.cts → index-RNzVfwrP.d.ts} +248 -352
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +3 -3
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +1 -1
  23. package/dist/{openSso-DyUQew2K.d.ts → openSso-CtDyvXLM.d.ts} +19 -20
  24. package/dist/{openSso-rQhLhPbq.d.cts → openSso-DIBN_iiz.d.cts} +18 -19
  25. package/dist/src-CDfF2FOa.cjs +1 -0
  26. package/dist/src-DFiac-zk.js +1 -0
  27. package/package.json +4 -4
  28. package/src/actions/ensureIdentity.ts +3 -3
  29. package/src/actions/openSso.ts +13 -6
  30. package/src/actions/referral/processReferral.test.ts +38 -22
  31. package/src/actions/referral/processReferral.ts +6 -4
  32. package/src/actions/referral/referralInteraction.test.ts +7 -7
  33. package/src/actions/referral/referralInteraction.ts +1 -1
  34. package/src/actions/sendInteraction.ts +1 -1
  35. package/src/actions/trackPurchaseStatus.test.ts +4 -4
  36. package/src/actions/trackPurchaseStatus.ts +3 -3
  37. package/src/actions/wrapper/siweAuthenticate.test.ts +1 -5
  38. package/src/actions/wrapper/siweAuthenticate.ts +25 -1
  39. package/src/clients/createIFrameFrakClient.ts +5 -21
  40. package/src/clients/index.ts +0 -1
  41. package/src/clients/transports/iframeLifecycleManager.test.ts +10 -10
  42. package/src/clients/transports/iframeLifecycleManager.ts +3 -3
  43. package/src/config/index.ts +3 -0
  44. package/src/{utils → config}/sdkConfigStore.ts +1 -1
  45. package/src/{utils/constants.test.ts → constants.test.ts} +1 -6
  46. package/src/constants.ts +15 -0
  47. package/src/context/address.ts +76 -0
  48. package/src/{utils/FrakContext.test.ts → context/frakContext.test.ts} +4 -2
  49. package/src/{utils/FrakContext.ts → context/frakContext.ts} +4 -4
  50. package/src/{utils → context}/frakContextV2Codec.test.ts +1 -1
  51. package/src/{utils → context}/frakContextV2Codec.ts +6 -6
  52. package/src/context/index.ts +6 -0
  53. package/src/index.ts +17 -22
  54. package/src/stubs/rrweb.ts +8 -4
  55. package/src/types/client.ts +0 -3
  56. package/src/types/config.ts +11 -0
  57. package/src/types/index.ts +1 -0
  58. package/src/types/rpc/sso.ts +6 -2
  59. package/src/utils/{deepLinkWithFallback.ts → browser/deepLinkWithFallback.ts} +10 -5
  60. package/src/utils/{inAppBrowser.ts → browser/inAppBrowser.ts} +13 -0
  61. package/src/utils/browser/index.ts +13 -0
  62. package/src/utils/{formatAmount.test.ts → format/formatAmount.test.ts} +1 -1
  63. package/src/utils/{formatAmount.ts → format/formatAmount.ts} +1 -1
  64. package/src/utils/{getCurrencyAmountKey.test.ts → format/getCurrencyAmountKey.test.ts} +2 -2
  65. package/src/utils/{getCurrencyAmountKey.ts → format/getCurrencyAmountKey.ts} +1 -1
  66. package/src/utils/{getSupportedCurrency.test.ts → format/getSupportedCurrency.test.ts} +2 -2
  67. package/src/utils/{getSupportedCurrency.ts → format/getSupportedCurrency.ts} +2 -2
  68. package/src/utils/{getSupportedLocale.test.ts → format/getSupportedLocale.test.ts} +3 -3
  69. package/src/utils/{getSupportedLocale.ts → format/getSupportedLocale.ts} +2 -2
  70. package/src/utils/format/index.ts +4 -0
  71. package/src/utils/{iframeHelper.test.ts → iframe/iframeHelper.test.ts} +3 -3
  72. package/src/utils/{iframeHelper.ts → iframe/iframeHelper.ts} +3 -3
  73. package/src/utils/iframe/index.ts +6 -0
  74. package/src/utils/index.ts +31 -24
  75. package/src/utils/sso/index.ts +6 -0
  76. package/src/utils/{sso.ts → sso/sso.ts} +2 -2
  77. package/dist/actions-DihYM-OG.js +0 -1
  78. package/dist/actions-cYbmqewX.cjs +0 -1
  79. package/dist/sdkConfigStore-BXzz5PlK.js +0 -1
  80. package/dist/sdkConfigStore-DDL_fjYX.cjs +0 -1
  81. package/dist/src-CfxklqLh.cjs +0 -13
  82. package/dist/src-VDUSvqqt.js +0 -13
  83. package/src/clients/DebugInfo.test.ts +0 -418
  84. package/src/clients/DebugInfo.ts +0 -182
  85. package/src/utils/computeLegacyProductId.ts +0 -11
  86. package/src/utils/constants.ts +0 -9
  87. /package/src/{utils → clients}/ssoUrlListener.test.ts +0 -0
  88. /package/src/{utils → clients}/ssoUrlListener.ts +0 -0
  89. /package/src/{utils → config}/backendUrl.test.ts +0 -0
  90. /package/src/{utils → config}/backendUrl.ts +0 -0
  91. /package/src/{utils → config}/clientId.test.ts +0 -0
  92. /package/src/{utils → config}/clientId.ts +0 -0
  93. /package/src/{utils → config}/sdkConfigStore.test.ts +0 -0
  94. /package/src/{utils → context}/mergeAttribution.test.ts +0 -0
  95. /package/src/{utils → context}/mergeAttribution.ts +0 -0
  96. /package/src/utils/{deepLinkWithFallback.test.ts → browser/deepLinkWithFallback.test.ts} +0 -0
@@ -7,8 +7,5 @@ import type { IFrameTransport } from "./transport";
7
7
  */
8
8
  export type FrakClient = {
9
9
  config: FrakWalletSdkConfig;
10
- debugInfo: {
11
- formatDebugInfo: (error: Error | unknown | string) => string;
12
- };
13
10
  openPanel?: OpenPanel;
14
11
  } & IFrameTransport;
@@ -87,6 +87,11 @@ export type FrakWalletSdkConfig = {
87
87
  * excluded — it is per-content/per-product, never a merchant-wide default.
88
88
  */
89
89
  attribution?: AttributionDefaults;
90
+ /**
91
+ * Preload specific UI views inside the listener iframe for better UX.
92
+ * Default: ["sharing"]
93
+ */
94
+ preload?: ListenerPreloadOption[];
90
95
  };
91
96
 
92
97
  /**
@@ -126,6 +131,12 @@ export type I18nConfig =
126
131
  | Record<Language, LocalizedI18nConfig>
127
132
  | LocalizedI18nConfig;
128
133
 
134
+ /**
135
+ * Options for preloading the listener UI
136
+ * @category Config
137
+ */
138
+ export type ListenerPreloadOption = "modal" | "sharing";
139
+
129
140
  /**
130
141
  * A localized i18n config (inline objects only — URL-based i18n removed)
131
142
  * @category Config
@@ -12,6 +12,7 @@ export type {
12
12
  FrakWalletSdkConfig,
13
13
  I18nConfig,
14
14
  Language,
15
+ ListenerPreloadOption,
15
16
  LocalizedI18nConfig,
16
17
  } from "./config";
17
18
  // Utils
@@ -25,8 +25,12 @@ export type PrepareSsoParamsType = {
25
25
  */
26
26
  redirectUrl?: string;
27
27
  /**
28
- * If the SSO should directly exit after completion
29
- * @defaultValue true
28
+ * If the SSO should directly exit (close the popup) after completion.
29
+ *
30
+ * Defaults to `true` when `redirectUrl` is omitted, `false` otherwise.
31
+ * The default is applied by {@link @frak-labs/core-sdk!actions.openSso | `openSso()`}
32
+ * before the SSO URL is generated and by the wallet SSO route as a fallback
33
+ * for older SDK callers.
30
34
  */
31
35
  directExit?: boolean;
32
36
  /**
@@ -1,4 +1,4 @@
1
- import { DEEP_LINK_SCHEME } from "./constants";
1
+ import { DEEP_LINK_SCHEME } from "../../constants";
2
2
 
3
3
  /**
4
4
  * Options for deep link with fallback
@@ -24,7 +24,7 @@ export function isChromiumAndroid(): boolean {
24
24
  }
25
25
 
26
26
  /**
27
- * Convert a frakwallet:// deep link to an Android intent:// URL.
27
+ * Convert a Frak deep link to an Android intent:// URL.
28
28
  *
29
29
  * Intent URLs let Chromium browsers open the app directly without
30
30
  * showing the "Continue to app?" confirmation bar.
@@ -35,12 +35,17 @@ export function isChromiumAndroid(): boolean {
35
35
  * Without `package`, Chrome simply does nothing when the app is
36
36
  * missing, allowing the fallback mechanism to fire correctly.
37
37
  *
38
- * Format: intent://path#Intent;scheme=frakwallet;end
38
+ * The scheme is derived from `DEEP_LINK_SCHEME` so the dev variant
39
+ * (`frakwallet-dev://`) routes to the dev app shell, not prod.
40
+ *
41
+ * Format: intent://path#Intent;scheme=<scheme>;end
39
42
  */
43
+ const DEEP_LINK_SCHEME_NAME = DEEP_LINK_SCHEME.replace("://", "");
44
+
40
45
  export function toAndroidIntentUrl(deepLink: string): string {
41
- // Extract everything after "frakwallet://"
46
+ // Extract everything after the scheme (e.g. "frakwallet://" or "frakwallet-dev://")
42
47
  const path = deepLink.slice(DEEP_LINK_SCHEME.length);
43
- return `intent://${path}#Intent;scheme=frakwallet;end`;
48
+ return `intent://${path}#Intent;scheme=${DEEP_LINK_SCHEME_NAME};end`;
44
49
  }
45
50
 
46
51
  /**
@@ -16,6 +16,19 @@ function checkIsIOS(): boolean {
16
16
  */
17
17
  export const isIOS: boolean = checkIsIOS();
18
18
 
19
+ /**
20
+ * Check if the current device is a mobile device (iOS, iPadOS, Android,
21
+ * webOS, BlackBerry, IEMobile, Opera Mini). Reuses {@link isIOS} so the
22
+ * iPadOS-13+ Macintosh heuristic stays in one place.
23
+ */
24
+ export function isMobile(): boolean {
25
+ if (typeof navigator === "undefined") return false;
26
+ if (isIOS) return true;
27
+ return /Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(
28
+ navigator.userAgent
29
+ );
30
+ }
31
+
19
32
  /**
20
33
  * Check if the current browser is a social media in-app browser
21
34
  * (Instagram, Facebook WebView).
@@ -0,0 +1,13 @@
1
+ export {
2
+ type DeepLinkFallbackOptions,
3
+ isChromiumAndroid,
4
+ isFrakDeepLink,
5
+ toAndroidIntentUrl,
6
+ triggerDeepLinkWithFallback,
7
+ } from "./deepLinkWithFallback";
8
+ export {
9
+ isInAppBrowser,
10
+ isIOS,
11
+ isMobile,
12
+ redirectToExternalBrowser,
13
+ } from "./inAppBrowser";
@@ -3,7 +3,7 @@
3
3
  * Tests currency formatting with proper locale support
4
4
  */
5
5
 
6
- import { describe, expect, it } from "../../tests/vitest-fixtures";
6
+ import { describe, expect, it } from "../../../tests/vitest-fixtures";
7
7
  import { formatAmount } from "./formatAmount";
8
8
 
9
9
  describe("formatAmount", () => {
@@ -1,4 +1,4 @@
1
- import type { Currency } from "../types";
1
+ import type { Currency } from "../../types";
2
2
  import { getSupportedCurrency } from "./getSupportedCurrency";
3
3
  import { getSupportedLocale } from "./getSupportedLocale";
4
4
 
@@ -3,8 +3,8 @@
3
3
  * Tests currency amount key generation
4
4
  */
5
5
 
6
- import { describe, expect, it } from "../../tests/vitest-fixtures";
7
- import type { Currency } from "../types";
6
+ import { describe, expect, it } from "../../../tests/vitest-fixtures";
7
+ import type { Currency } from "../../types";
8
8
  import { getCurrencyAmountKey } from "./getCurrencyAmountKey";
9
9
 
10
10
  describe("getCurrencyAmountKey", () => {
@@ -1,4 +1,4 @@
1
- import type { Currency, TokenAmountType } from "../types";
1
+ import type { Currency, TokenAmountType } from "../../types";
2
2
 
3
3
  /**
4
4
  * Get the currency amount key for a given currency
@@ -3,8 +3,8 @@
3
3
  * Tests currency validation and fallback behavior
4
4
  */
5
5
 
6
- import { describe, expect, it } from "../../tests/vitest-fixtures";
7
- import type { Currency } from "../types";
6
+ import { describe, expect, it } from "../../../tests/vitest-fixtures";
7
+ import type { Currency } from "../../types";
8
8
  import { getSupportedCurrency } from "./getSupportedCurrency";
9
9
 
10
10
  describe("getSupportedCurrency", () => {
@@ -1,5 +1,5 @@
1
- import { locales } from "../constants/locales";
2
- import type { Currency } from "../types";
1
+ import { locales } from "../../constants/locales";
2
+ import type { Currency } from "../../types";
3
3
 
4
4
  /**
5
5
  * Get the supported currency for a given currency
@@ -3,9 +3,9 @@
3
3
  * Tests locale resolution from currency
4
4
  */
5
5
 
6
- import { describe, expect, it } from "../../tests/vitest-fixtures";
7
- import { locales } from "../constants/locales";
8
- import type { Currency } from "../types";
6
+ import { describe, expect, it } from "../../../tests/vitest-fixtures";
7
+ import { locales } from "../../constants/locales";
8
+ import type { Currency } from "../../types";
9
9
  import { getSupportedLocale } from "./getSupportedLocale";
10
10
 
11
11
  describe("getSupportedLocale", () => {
@@ -1,5 +1,5 @@
1
- import { type LocalesKey, locales } from "../constants/locales";
2
- import type { Currency } from "../types";
1
+ import { type LocalesKey, locales } from "../../constants/locales";
2
+ import type { Currency } from "../../types";
3
3
 
4
4
  /**
5
5
  * Get the supported locale for a given currency
@@ -0,0 +1,4 @@
1
+ export { formatAmount } from "./formatAmount";
2
+ export { getCurrencyAmountKey } from "./getCurrencyAmountKey";
3
+ export { getSupportedCurrency } from "./getSupportedCurrency";
4
+ export { getSupportedLocale } from "./getSupportedLocale";
@@ -1,6 +1,6 @@
1
1
  import { vi } from "vitest";
2
2
 
3
- vi.mock("./clientId", () => ({
3
+ vi.mock("../../config/clientId", () => ({
4
4
  getClientId: vi.fn(() => "mock-client-id-for-test"),
5
5
  }));
6
6
 
@@ -15,8 +15,8 @@ import {
15
15
  describe,
16
16
  expect,
17
17
  it,
18
- } from "../../tests/vitest-fixtures";
19
- import type { FrakWalletSdkConfig } from "../types";
18
+ } from "../../../tests/vitest-fixtures";
19
+ import type { FrakWalletSdkConfig } from "../../types";
20
20
  import {
21
21
  baseIframeProps,
22
22
  changeIframeVisibility,
@@ -1,6 +1,6 @@
1
- import type { FrakWalletSdkConfig } from "../types";
2
- import { getBackendUrl } from "./backendUrl";
3
- import { getClientId } from "./clientId";
1
+ import { getBackendUrl } from "../../config/backendUrl";
2
+ import { getClientId } from "../../config/clientId";
3
+ import type { FrakWalletSdkConfig } from "../../types";
4
4
 
5
5
  /**
6
6
  * Base props for the iframe
@@ -0,0 +1,6 @@
1
+ export {
2
+ baseIframeProps,
3
+ changeIframeVisibility,
4
+ createIframe,
5
+ findIframeInOpener,
6
+ } from "./iframeHelper";
@@ -1,42 +1,49 @@
1
+ // Generic, framework-agnostic utilities. Stateful concerns (config store,
2
+ // client identifiers) live in `src/config/`; URL/binary codecs for the
3
+ // referral context live in `src/context/`; SSO URL listener belongs to the
4
+ // iframe client lifecycle in `src/clients/`. Keep this surface narrow.
1
5
  export { Deferred } from "@frak-labs/frame-connector";
6
+
7
+ // Analytics
2
8
  export { trackEvent } from "./analytics";
3
- export { getBackendUrl } from "./backendUrl";
4
- export { clearAllCache, getCache, withCache } from "./cache";
5
- export { getClientId } from "./clientId";
6
- export { base64urlDecode, base64urlEncode } from "./compression/b64";
7
- export { compressJsonToB64 } from "./compression/compress";
8
- export { decompressJsonFromB64 } from "./compression/decompress";
9
- export { DEEP_LINK_SCHEME } from "./constants";
9
+ // Browser / deep linking
10
10
  export {
11
11
  type DeepLinkFallbackOptions,
12
12
  isChromiumAndroid,
13
13
  isFrakDeepLink,
14
14
  toAndroidIntentUrl,
15
15
  triggerDeepLinkWithFallback,
16
- } from "./deepLinkWithFallback";
17
- export { FrakContextManager } from "./FrakContext";
18
- export { formatAmount } from "./formatAmount";
19
- export { getCurrencyAmountKey } from "./getCurrencyAmountKey";
20
- export { getSupportedCurrency } from "./getSupportedCurrency";
21
- export { getSupportedLocale } from "./getSupportedLocale";
22
- export {
23
- baseIframeProps,
24
- createIframe,
25
- findIframeInOpener,
26
- } from "./iframeHelper";
16
+ } from "./browser/deepLinkWithFallback";
27
17
  export {
28
18
  isInAppBrowser,
29
19
  isIOS,
20
+ isMobile,
30
21
  redirectToExternalBrowser,
31
- } from "./inAppBrowser";
22
+ } from "./browser/inAppBrowser";
23
+ // Cache
24
+ export { clearAllCache, getCache, withCache } from "./cache";
25
+ // Compression / encoding
26
+ export { base64urlDecode, base64urlEncode } from "./compression/b64";
27
+ export { compressJsonToB64 } from "./compression/compress";
28
+ export { decompressJsonFromB64 } from "./compression/decompress";
29
+
30
+ // Formatting / i18n
31
+ export { formatAmount } from "./format/formatAmount";
32
+ export { getCurrencyAmountKey } from "./format/getCurrencyAmountKey";
33
+ export { getSupportedCurrency } from "./format/getSupportedCurrency";
34
+ export { getSupportedLocale } from "./format/getSupportedLocale";
35
+
36
+ // Iframe DOM helpers
32
37
  export {
33
- type MergeAttributionInput,
34
- mergeAttribution,
35
- } from "./mergeAttribution";
36
- export { sdkConfigStore } from "./sdkConfigStore";
38
+ baseIframeProps,
39
+ createIframe,
40
+ findIframeInOpener,
41
+ } from "./iframe/iframeHelper";
42
+
43
+ // SSO URL builder
37
44
  export {
38
45
  type AppSpecificSsoMetadata,
39
46
  type CompressedSsoData,
40
47
  type FullSsoParams,
41
48
  generateSsoUrl,
42
- } from "./sso";
49
+ } from "./sso/sso";
@@ -0,0 +1,6 @@
1
+ export {
2
+ type AppSpecificSsoMetadata,
3
+ type CompressedSsoData,
4
+ type FullSsoParams,
5
+ generateSsoUrl,
6
+ } from "./sso";
@@ -1,6 +1,6 @@
1
1
  import type { Hex } from "viem";
2
- import type { PrepareSsoParamsType, SsoMetadata } from "../types";
3
- import { compressJsonToB64 } from "./compression/compress";
2
+ import type { PrepareSsoParamsType, SsoMetadata } from "../../types";
3
+ import { compressJsonToB64 } from "../compression/compress";
4
4
 
5
5
  export type AppSpecificSsoMetadata = SsoMetadata & {
6
6
  name?: string;
@@ -1 +0,0 @@
1
- import{c as e,i as t,l as n,n as r,r as i,s as a,t as o,v as s}from"./sdkConfigStore-BXzz5PlK.js";import{isAddressEqual as c}from"viem";import{Deferred as l}from"@frak-labs/frame-connector";import{generateSiweNonce as u}from"viem/siwe";async function d(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function f(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function p(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function m(t){if(typeof window>`u`)return;let n=s();if(!n)return;let r=await o.resolveMerchantId();if(!r)return;let i=`frak-identity-ensured-${r}`;if(!window.sessionStorage.getItem(i))try{let a=e();(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 h(e,t){return a(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function g(e,t){return a(()=>e.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}async function _(e,t){return a(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function v(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function y(e,t){try{await e.request({method:`frak_sendInteraction`,params:[t,{clientId:s()}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function b(e,r,a){return t(r)?(n(e,`user_referred_started`,{referrerClientId:r.c,referrerWallet:r.w,walletStatus:a?.key}),y(e,{type:`arrival`,referrerClientId:r.c,referrerMerchantId:r.m,referrerWallet:r.w,referralTimestamp:r.t}),!0):i(r)?(n(e,`user_referred_started`,{referrer:r.r,walletStatus:a?.key}),y(e,{type:`arrival`,referrerWallet:r.r}),!0):!1}function x(e,t){let n=s();return!n&&!t?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...n?{c:n}:{},...t?{w:t}:{}}}function S(e,n){return t(e)?e.w&&n?.wallet?c(e.w,n.wallet):e.c?s()===e.c:!1:i(e)&&n?.wallet?c(e.r,n.wallet):!1}function C(e,{walletStatus:i,frakContext:a,options:o}){if(!a)return`no-referrer`;if(S(a,i))return`self-referral`;if(!b(e,a,i))return`no-referrer`;let s=t(a)?a.m:o?.merchantId,c=o?.alwaysAppendUrl&&s?x(s,i?.wallet):null;return r.replaceUrl({url:window.location?.href,context:c}),n(e,`user_referred_completed`,{status:`success`}),`success`}async function w(e,{options:t}={}){let n=r.parse({url:window.location.href}),i=await O(e);try{return C(e,{walletStatus:i,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const T=`frak:referral-success`;async function E(e){try{await w(e)===`success`&&window.dispatchEvent(new Event(T))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function D(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=s();if(!n&&!r){console.warn(`[Frak] No identity found, skipping purchase check`);return}let i=t.merchantId??await o.resolveMerchantId();if(!i){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let a={Accept:`application/json`,"Content-Type":`application/json`};n&&(a[`x-wallet-sdk-auth`]=n),r&&(a[`x-frak-client-id`]=r);let c=e();await fetch(`${c}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:i})})}function O(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(k(e,t),t));let n=new l,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{k(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function k(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),m(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function A(e,{metadata:t,login:n}){return j(e,{steps:{login:n??{}},metadata:t})}function j(e,t){function n(n){return j(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return j(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return j(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function a(n,r){return n&&(t.metadata=n(t.metadata??{})),await f(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:a}}async function M(e,{tx:t,metadata:n}){return(await f(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function N(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 f(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??u(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}export{f as _,D as a,w as c,v as d,_ as f,p as g,m as h,O as i,C as l,h as m,M as n,T as o,g as p,A as r,E as s,N as t,y as u,d as v};
@@ -1 +0,0 @@
1
- const e=require(`./sdkConfigStore-DDL_fjYX.cjs`);let t=require(`viem`),n=require(`@frak-labs/frame-connector`),r=require(`viem/siwe`);async function i(e,t,n){return await e.request({method:`frak_displayEmbeddedWallet`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function a(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function o(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function s(t){if(typeof window>`u`)return;let n=e.v();if(!n)return;let r=await e.t.resolveMerchantId();if(!r)return;let i=`frak-identity-ensured-${r}`;if(!window.sessionStorage.getItem(i))try{let a=e.c();(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 c(t,n){return e.s(()=>t.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:n?.cacheTime})}async function l(t,n){return e.s(()=>t.request({method:`frak_getMergeToken`}),{cacheKey:`frak_getMergeToken`,cacheTime:n?.cacheTime})}async function u(t,n){return e.s(()=>t.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:n?.cacheTime})}async function d(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function f(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 p(t,n,r){return e.i(n)?(e.l(t,`user_referred_started`,{referrerClientId:n.c,referrerWallet:n.w,walletStatus:r?.key}),f(t,{type:`arrival`,referrerClientId:n.c,referrerMerchantId:n.m,referrerWallet:n.w,referralTimestamp:n.t}),!0):e.r(n)?(e.l(t,`user_referred_started`,{referrer:n.r,walletStatus:r?.key}),f(t,{type:`arrival`,referrerWallet:n.r}),!0):!1}function m(t,n){let r=e.v();return!r&&!n?null:{v:2,m:t,t:Math.floor(Date.now()/1e3),...r?{c:r}:{},...n?{w:n}:{}}}function h(n,r){return e.i(n)?n.w&&r?.wallet?(0,t.isAddressEqual)(n.w,r.wallet):n.c?e.v()===n.c:!1:e.r(n)&&r?.wallet?(0,t.isAddressEqual)(n.r,r.wallet):!1}function g(t,{walletStatus:n,frakContext:r,options:i}){if(!r)return`no-referrer`;if(h(r,n))return`self-referral`;if(!p(t,r,n))return`no-referrer`;let a=e.i(r)?r.m:i?.merchantId,o=i?.alwaysAppendUrl&&a?m(a,n?.wallet):null;return e.n.replaceUrl({url:window.location?.href,context:o}),e.l(t,`user_referred_completed`,{status:`success`}),`success`}async function _(t,{options:n}={}){let r=e.n.parse({url:window.location.href}),i=await x(t);try{return g(t,{walletStatus:i,frakContext:r,options:n})}catch(e){console.warn(`Error processing referral`,{error:e})}}const v=`frak:referral-success`;async function y(e){try{await _(e)===`success`&&window.dispatchEvent(new Event(v))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function b(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=t.merchantId??await e.t.resolveMerchantId();if(!i){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let a={Accept:`application/json`,"Content-Type":`application/json`};n&&(a[`x-wallet-sdk-auth`]=n),r&&(a[`x-frak-client-id`]=r);let o=e.c();await fetch(`${o}/user/track/purchase`,{method:`POST`,headers:a,body:JSON.stringify({customerId:t.customerId,orderId:t.orderId,token:t.token,merchantId:i})})}function x(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(S(e,t),t));let r=new n.Deferred,i=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},n=>{S(e,n),t(n),i||=(r.resolve(n),!0)}),r.promise}function S(e,t){typeof window>`u`||(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),s(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function C(e,{metadata:t,login:n}){return w(e,{steps:{login:n??{}},metadata:t})}function w(e,t){function n(n){return w(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return w(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}function i(n,r){return w(e,{...t,steps:{...t.steps,final:{...r,action:{key:`sharing`,options:n}}}})}async function o(n,r){return n&&(t.metadata=n(t.metadata??{})),await a(e,t,r)}return{params:t,sendTx:n,reward:r,sharing:i,display:o}}async function T(e,{tx:t,metadata:n}){return(await a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}async function E(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,`_`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return u}}),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 x}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return i}});
@@ -1 +0,0 @@
1
- import{bytesToHex as e,hexToBytes as t,isAddress as n,keccak256 as r,toHex as i}from"viem";import{jsonEncode as a}from"@frak-labs/frame-connector";const o=`frak-client-id`;function s(){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 c(){if(typeof window>`u`||!window.localStorage)return console.warn(`[Frak SDK] No Window / localStorage available to save the clientId`),s();let e=localStorage.getItem(o);return e||(e=s(),localStorage.setItem(o,e)),e}function l({domain:e}={}){return r(i((e??window.location.host).replace(`www.`,``)))}function u(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function d(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 f(e){return u(a(e))}function p(e,t,n,r,i,a){let o=f(m({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 m(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 h=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,g=`frak-sso`;async function ee(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??p(i??`https://wallet.frak.id`,t,l(),n.name,c(),r?.css),o=window.open(a,g,h);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]})??{}}function te(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)}}const _=`https://backend.frak.id`;function ne(e){return e.includes(`localhost:3000`)||e.includes(`localhost:3010`)}function v(e){return ne(e)?`https://localhost:3030`:e.includes(`wallet-dev.frak.id`)||e.includes(`wallet.gcp-dev.frak.id`)?`https://backend.gcp-dev.frak.id`:_}function y(e){if(e)return v(e);if(typeof window<`u`){let e=window.FrakSetup?.client?.config?.walletUrl;if(e)return v(e)}return _}var b=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 x=new b(1024),S=new b(1024),C=3e4,w=new b(1024);async function T(e,{cacheKey:t,cacheTime:n=C}){if(n>0){let e=S.get(t);if(e&&Date.now()-e.created<n)return e.data}let r=w.get(t);if(r&&Date.now()-r<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let i=x.get(t);i||(i=e(),x.set(t,i));try{let e=await i;return S.set(t,{data:e,created:Date.now()}),w.delete(t),e}catch(e){throw w.set(t,Date.now()),e}finally{x.delete(t)}}function E(e){return{clear:()=>{x.delete(e),S.delete(e)},has:(t=C)=>{let n=S.get(e);return n?Date.now()-n.created<t:!1}}}function D(){x.clear(),S.clear(),w.clear()}function re(e){return`r`in e&&!(`v`in e)}function O(e){return`v`in e&&e.v===2}const k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){return typeof e==`string`&&k.test(e)}function j(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function M(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function ie(e){if(!A(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let r=typeof e.c==`string`&&e.c.length>0,i=typeof e.w==`string`&&n(e.w);if(!r&&!i||r&&!A(e.c))return null;let a=new Uint8Array(21+(r?16:0)+(i?20:0)),o=new DataView(a.buffer,a.byteOffset,a.byteLength),s=0;return a[s++]=2|(r?16:0)|(i?32:0),a.set(j(e.m),s),s+=16,o.setUint32(s,e.t,!1),s+=4,r&&(a.set(j(e.c),s),s+=16),i&&(a.set(t(e.w),s),s+=20),a}function ae(t){if(t.length<21)return null;let r=t[0];if((r&15)!=2||r&192)return null;let i=(r&16)!=0,a=(r&32)!=0;if(!i&&!a)return null;let o=21+(i?16:0)+(a?20:0);if(t.length!==o)return null;let s=1,c=M(t.subarray(s,s+16));s+=16;let l=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(s,!1);s+=4;let u={v:2,m:c,t:l};if(i&&(u.c=M(t.subarray(s,s+16)),s+=16),a){let r=e(t.subarray(s,s+20),{size:20});if(!n(r))return null;u.w=r,s+=20}return u}const N=`fCtx`;function P(e){if(e)try{if(O(e)){let t=ie(e);return t?u(t):void 0}return u(t(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function F(t){if(!(!t||t.length===0))try{let r=d(t);if(r.length!==20)return ae(r)||void 0;let i=e(r,{size:20});if(n(i))return{r:i}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function I({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(N);return t?F(t):null}const L=`frak`;function oe(e,t){let n=O(e);return{utm_source:t.utmSource??L,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??L,ref:t.ref??(n?e.c:void 0)}}function se(e,t,n){let r=oe(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function R({url:e,context:t,attribution:n}){if(!e)return null;let r=P(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(N,r),se(i,t,n),i.toString()}function z(e){let t=new URL(e);return t.searchParams.delete(N),t.toString()}function ce({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?z(n):R({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const B={compress:P,decompress:F,parse:I,update:R,remove:z,replaceUrl:ce},V=`__frakSdkConfig`,H=`frak-config-cache`,U=`frak-merchant-id`,W={key:H},G=typeof window<`u`;function K(){return{isResolved:!1,merchantId:``}}let q=null;function J(){if(!G)return null;try{let e=localStorage.getItem(W.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(q=t,t):null}catch{return null}}function Y(){return(q??J())?.config}function le(){let e=q??J();return e?Date.now()-e.timestamp<3e4:!1}function ue(e){if(!(!G||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(W.key,JSON.stringify(t)),q=t}catch{}}function X(){if(G){q=null;try{localStorage.removeItem(W.key)}catch{}}}function de(){G&&(window[V]||(window[V]=Y()??K()))}de();function Z(){return G?window[V]??K():K()}function Q(e){G&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function fe(e){return e??(G?window.location.hostname:``)}async function pe(e,t,n){try{let r=y(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(G)try{sessionStorage.setItem(U,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 le()},setCacheScope(e,t){W.key=`${H}:${`${e}:${t??``}`}`,q=null},setConfig(e){if(G&&(window[V]=e),ue(e),Q(e),G&&e.merchantId)try{sessionStorage.setItem(U,e.merchantId)}catch{}},reset(){let e=Y()??K();G&&(window[V]=e),Q(e)},clearCache(){if(X(),D(),G)try{sessionStorage.removeItem(U)}catch{}},resolve(e,t,n){let r=fe(e);return r?T(async()=>{let e=await pe(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(G)try{return sessionStorage.getItem(U)??void 0}catch{}},async resolveMerchantId(e,t){return $.getMerchantId()||(await $.resolve(e,t))?.merchantId}};export{l as _,D as a,y as c,h as d,g as f,u as g,d as h,O as i,te as l,f as m,B as n,E as o,p,re as r,T as s,$ as t,ee as u,c as v};
@@ -1 +0,0 @@
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 ee(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]})??{}}function p(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)}}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 w(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 T(){y.clear(),b.clear(),S.clear()}function te(e){return`r`in e&&!(`v`in e)}function E(e){return`v`in e&&e.v===2}const D=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function O(e){return typeof e==`string`&&D.test(e)}function k(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function A(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function j(t){if(!O(t.m)||!Number.isInteger(t.t)||t.t<0||t.t>4294967295)return null;let n=typeof t.c==`string`&&t.c.length>0,r=typeof t.w==`string`&&(0,e.isAddress)(t.w);if(!n&&!r||n&&!O(t.c))return null;let i=new Uint8Array(21+(n?16:0)+(r?20:0)),a=new DataView(i.buffer,i.byteOffset,i.byteLength),o=0;return i[o++]=2|(n?16:0)|(r?32:0),i.set(k(t.m),o),o+=16,a.setUint32(o,t.t,!1),o+=4,n&&(i.set(k(t.c),o),o+=16),r&&(i.set((0,e.hexToBytes)(t.w),o),o+=20),i}function ne(t){if(t.length<21)return null;let n=t[0];if((n&15)!=2||n&192)return null;let r=(n&16)!=0,i=(n&32)!=0;if(!r&&!i)return null;let a=21+(r?16:0)+(i?20:0);if(t.length!==a)return null;let o=1,s=A(t.subarray(o,o+16));o+=16;let c=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(o,!1);o+=4;let l={v:2,m:s,t:c};if(r&&(l.c=A(t.subarray(o,o+16)),o+=16),i){let n=(0,e.bytesToHex)(t.subarray(o,o+20),{size:20});if(!(0,e.isAddress)(n))return null;l.w=n,o+=20}return l}const M=`fCtx`;function N(t){if(t)try{if(E(t)){let e=j(t);return e?o(e):void 0}return o((0,e.hexToBytes)(t.r))}catch(e){console.error(`Error compressing Frak context`,{e,context:t})}}function P(t){if(!(!t||t.length===0))try{let n=s(t);if(n.length!==20)return ne(n)||void 0;let r=(0,e.bytesToHex)(n,{size:20});if((0,e.isAddress)(r))return{r}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function F({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(M);return t?P(t):null}const I=`frak`;function L(e,t){let n=E(e);return{utm_source:t.utmSource??I,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??I,ref:t.ref??(n?e.c:void 0)}}function R(e,t,n){let r=L(t,n??{});for(let[t,n]of Object.entries(r))n===void 0||n===``||e.searchParams.has(t)||e.searchParams.set(t,n)}function z({url:e,context:t,attribution:n}){if(!e)return null;let r=N(t);if(!r)return null;let i=new URL(e);return i.searchParams.set(M,r),R(i,t,n),i.toString()}function B(e){let t=new URL(e);return t.searchParams.delete(M),t.toString()}function re({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?B(n):z({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const V={compress:N,decompress:P,parse:F,update:z,remove:B,replaceUrl:re},H=`__frakSdkConfig`,U=`frak-config-cache`,W=`frak-merchant-id`,G={key:U},K=typeof window<`u`;function q(){return{isResolved:!1,merchantId:``}}let J=null;function Y(){if(!K)return null;try{let e=localStorage.getItem(G.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(J=t,t):null}catch{return null}}function X(){return(J??Y())?.config}function ie(){let e=J??Y();return e?Date.now()-e.timestamp<3e4:!1}function ae(e){if(!(!K||!e.isResolved))try{let t={config:e,timestamp:Date.now()};localStorage.setItem(G.key,JSON.stringify(t)),J=t}catch{}}function oe(){if(K){J=null;try{localStorage.removeItem(G.key)}catch{}}}function se(){K&&(window[H]||(window[H]=X()??q()))}se();function Z(){return K?window[H]??q():q()}function Q(e){K&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function ce(e){return e??(K?window.location.hostname:``)}async function le(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(K)try{sessionStorage.setItem(W,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 ie()},setCacheScope(e,t){G.key=`${U}:${`${e}:${t??``}`}`,J=null},setConfig(e){if(K&&(window[H]=e),ae(e),Q(e),K&&e.merchantId)try{sessionStorage.setItem(W,e.merchantId)}catch{}},reset(){let e=X()??q();K&&(window[H]=e),Q(e)},clearCache(){if(oe(),T(),K)try{sessionStorage.removeItem(W)}catch{}},resolve(e,t,n){let r=ce(e);return r?C(async()=>{let e=await le(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(K)try{return sessionStorage.getItem(W)??void 0}catch{}},async resolveMerchantId(e,t){return $.getMerchantId()||(await $.resolve(e,t))?.merchantId}};Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _}}),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 E}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return i}});
@@ -1,13 +0,0 @@
1
- const e=require(`./sdkConfigStore-DDL_fjYX.cjs`);let t=require(`@frak-labs/frame-connector`),n=require(`@openpanel/web`);function r(n){return(0,t.jsonDecode)(e.h(n))}const i=`nexus-wallet-backup`,a=`frakwallet://`;function o(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function s(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function c(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=o()&&l(e)?s(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function l(e){return e.startsWith(a)}const u={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function d(e){return e&&e in u?e:`eur`}function f(e){return e?u[e]??u.eur:u.eur}function p(e,t){let n=f(t),r=d(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function m(e){return e?`${e}Amount`:`eurAmount`}const h={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 g({walletBaseUrl:t,config:n}){let r=document.querySelector(`#frak-wallet`);r&&r.remove();let i=document.createElement(`iframe`);i.id=h.id,i.name=h.name,i.allow=h.allow,i.style.zIndex=h.style.zIndex.toString(),_({iframe:i,isVisible:!1});let a=n?.walletUrl??t??`https://wallet.frak.id`,o=e.v();return y(a),y(e.c(a)),i.src=`${a}/listener?clientId=${encodeURIComponent(o)}`,new Promise(e=>{i.addEventListener(`load`,()=>e(i)),document.body.appendChild(i)})}function _({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 v(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 y(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}function b(){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 x=b();function S(){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 C=S();function w(e){x&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:x&&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 T({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 E(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 D=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 O=(()=>{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 k(e){e?localStorage.setItem(i,e):localStorage.removeItem(i)}function A(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=N(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function j(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 M(e){return e.includes(`/common/social`)}function N(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 P(e,t,n,r,i){if(i){let e=A(t,r);window.open(e,`_blank`);return}if(l(t)){let i=A(t,r);c(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(O&&M(t))j(r);else{let e=A(t,r);window.location.href=e}}function F({iframe:e,targetOrigin:n}){let r=new t.Deferred;return{handleEvent:t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:a,data:o}=t;switch(a){case`connected`:r.resolve(!0);break;case`do-backup`:k(o.backup);break;case`remove-backup`:localStorage.removeItem(i);break;case`show`:case`hide`:_({iframe:e,isVisible:a===`show`});break;case`redirect`:P(e,o.baseRedirectUrl,n,o.mergeToken,o.openInNewTab);break}},isConnected:r.promise}}function I({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.t.setCacheScope(c,s),e.t.reset();let l=e.t.isCacheFresh?void 0:e.t.resolve(r.domain,r.walletUrl,s),u=F({iframe:i,targetOrigin:a}),d=new t.Deferred,f=Date.now(),p=new D(r,i);if(!i.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let m=(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 p.setLastRequest(e),t},onResponse(e,t){return p.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{u.handleEvent(e)}}}),h=L(m,u),g=async()=>{h(),m.cleanup(),i.remove(),e.a(),e.t.clearCache(),e.t.reset()},_;{console.log(`[Frak SDK] Initializing OpenPanel`),_=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:`1.0.2`,userAnonymousClientId:e.v()}),!0)}),_.setGlobalProperties({sdkVersion:`1.0.2`,userAnonymousClientId:e.v()}),_.init(),_.track(`sdk_initialized`,{sdkVersion:`1.0.2`});let t=!1,r=setTimeout(()=>{t||(t=!0,_?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);u.isConnected.then(()=>{t||(t=!0,clearTimeout(r),_?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-f}))}).catch(()=>{t||(t=!0,clearTimeout(r),_?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let v=R({config:r,rpcClient:m,lifecycleManager:u,configPromise:l,contextSent:d,openPanel:_}).then(()=>p.updateSetupStatus(!0)).catch(e=>{throw d.reject(e),e});return{config:r,debugInfo:p,waitForConnection:u.isConnected,waitForSetup:v,request:m.request,listenerRequest:m.listen,destroy:g,openPanel:_}}function L(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),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 R({config:t,rpcClient:n,lifecycleManager:r,configPromise:a,contextSent:o,openPanel:s}){await r.isConnected,E(n,r.isConnected);let c=new URL(window.location.href),l=c.searchParams.get(`fmt`)??void 0;l&&(c.searchParams.delete(`fmt`),window.history.replaceState({},``,c.toString()));let u=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.t.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})},d=!1,f=t=>{let r=d?void 0:l;d=!0;let i=t.hasRawSdkConfig?{name:t.name,logoUrl:t.logoUrl,homepageLink:t.homepageLink,lang:t.lang,currency:t.currency,hidden:t.hidden,css:t.css,translations:t.translations,placements:t.placements,attribution:t.attribution}:t.attribution?{attribution:t.attribution}:void 0,a=e.v();if(s){let e=s.global??{};s.setGlobalProperties({...e,merchantId:t.merchantId,domain:t.domain??``})}n.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:t.merchantId,domain:t.domain??``,allowedDomains:t.allowedDomains??[],sourceUrl:window.location.href,...a&&{sdkAnonymousId:a},...r&&{pendingMergeToken:r},...i&&{sdkConfig:i}}})};e.t.isResolved&&(f(e.t.getConfig()),o.resolve()),a&&(u(await a),f(e.t.getConfig()),o.resolve());async function p(){let e=t.customizations?.css;e&&n.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:e}})}async function m(){let e=t.customizations?.i18n;e&&n.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:e}})}async function h(){if(typeof window>`u`)return;let e=window.localStorage.getItem(i);e&&n.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([p(),m(),h()])).some(e=>e.status===`rejected`)&&s?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}async function z({config:e}){let t=B(e),n=await g({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=I({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function B(e){let t=d(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return c}});
@@ -1,13 +0,0 @@
1
- import{a as e,c as t,h as n,t as r,v as i}from"./sdkConfigStore-BXzz5PlK.js";import{Deferred as a,FrakRpcError as o,RpcErrorCodes as s,createRpcClient as c,jsonDecode as l}from"@frak-labs/frame-connector";import{OpenPanel as u}from"@openpanel/web";function d(e){return l(n(e))}const f=`nexus-wallet-backup`,p=`frakwallet://`;function m(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}function h(e){return`intent://${e.slice(13)}#Intent;scheme=frakwallet;end`}function g(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=m()&&_(e)?h(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function _(e){return e.startsWith(p)}const v={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function y(e){return e&&e in v?e:`eur`}function b(e){return e?v[e]??v.eur:v.eur}function x(e,t){let n=b(t),r=y(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function S(e){return e?`${e}Amount`:`eurAmount`}const C={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 w({walletBaseUrl:e,config:n}){let r=document.querySelector(`#frak-wallet`);r&&r.remove();let a=document.createElement(`iframe`);a.id=C.id,a.name=C.name,a.allow=C.allow,a.style.zIndex=C.style.zIndex.toString(),T({iframe:a,isVisible:!1});let o=n?.walletUrl??e??`https://wallet.frak.id`,s=i();return D(o),D(t(o)),a.src=`${o}/listener?clientId=${encodeURIComponent(s)}`,new Promise(e=>{a.addEventListener(`load`,()=>e(a)),document.body.appendChild(a)})}function T({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(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 D(e){if(!(typeof document>`u`))try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}function O(){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 k=O();function A(){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 j=A();function M(e){k&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:k&&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 N({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 P(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 F=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 o?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 I=(()=>{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 L(e){e?localStorage.setItem(f,e):localStorage.removeItem(f)}function R(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=V(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function z(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 B(e){return e.includes(`/common/social`)}function V(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 H(e,t,n,r,i){if(i){let e=R(t,r);window.open(e,`_blank`);return}if(_(t)){let i=R(t,r);g(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(I&&B(t))z(r);else{let e=R(t,r);window.location.href=e}}function U({iframe:e,targetOrigin:t}){let n=new a;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`:L(a.backup);break;case`remove-backup`:localStorage.removeItem(f);break;case`show`:case`hide`:T({iframe:e,isVisible:i===`show`});break;case`redirect`:H(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab);break}},isConnected:n.promise}}function W({config:t,iframe:n}){let l=t?.walletUrl??`https://wallet.frak.id`,d=typeof navigator<`u`?navigator.language?.split(`-`)[0]:void 0,f=t.metadata.lang??(d===`en`||d===`fr`?d:void 0),p=t.domain??(typeof window<`u`?window.location.hostname:``);r.setCacheScope(p,f),r.reset();let m=r.isCacheFresh?void 0:r.resolve(t.domain,t.walletUrl,f),h=U({iframe:n,targetOrigin:l}),g=new a,_=Date.now(),v=new F(t,n);if(!n.contentWindow)throw new o(s.configError,`The iframe does not have a content window`);let y=c({emittingTransport:n.contentWindow,listeningTransport:window,targetOrigin:l,middleware:[{async onRequest(e,t){if(!await h.isConnected)throw new o(s.clientNotConnected,`The iframe provider isn't connected yet`);return await g.promise,t}},{onRequest(e,t){return v.setLastRequest(e),t},onResponse(e,t){return v.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{h.handleEvent(e)}}}),b=G(y,h),x=async()=>{b(),y.cleanup(),n.remove(),e(),r.clearCache(),r.reset()},S;{console.log(`[Frak SDK] Initializing OpenPanel`),S=new u({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,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.2`,userAnonymousClientId:i()}),!0)}),S.setGlobalProperties({sdkVersion:`1.0.2`,userAnonymousClientId:i()}),S.init(),S.track(`sdk_initialized`,{sdkVersion:`1.0.2`});let e=!1,t=setTimeout(()=>{e||(e=!0,S?.track(`sdk_iframe_handshake_failed`,{reason:`timeout`}))},3e4);h.isConnected.then(()=>{e||(e=!0,clearTimeout(t),S?.track(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-_}))}).catch(()=>{e||(e=!0,clearTimeout(t),S?.track(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}let C=K({config:t,rpcClient:y,lifecycleManager:h,configPromise:m,contextSent:g,openPanel:S}).then(()=>v.updateSetupStatus(!0)).catch(e=>{throw g.reject(e),e});return{config:t,debugInfo:v,waitForConnection:h.isConnected,waitForSetup:C,request:y.request,listenerRequest:y.listen,destroy:x,openPanel:S}}function G(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),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 K({config:e,rpcClient:t,lifecycleManager:n,configPromise:a,contextSent:o,openPanel:s}){await n.isConnected,P(t,n.isConnected);let c=new URL(window.location.href),l=c.searchParams.get(`fmt`)??void 0;l&&(c.searchParams.delete(`fmt`),window.history.replaceState({},``,c.toString()));let u=t=>{let n=t?.merchantId??e.metadata.merchantId??``,i=t?.domain??``,a=t?.allowedDomains??[],o=t?.sdkConfig,s=o?.attribution||e.attribution?{...e.attribution,...o?.attribution}:void 0;r.setConfig(o?{isResolved:!0,merchantId:n,domain:i,allowedDomains:a,hasRawSdkConfig:!0,name:o.name??e.metadata.name,logoUrl:o.logoUrl??e.metadata.logoUrl,homepageLink:o.homepageLink??e.metadata.homepageLink,lang:o.lang??e.metadata.lang,currency:o.currency??e.metadata.currency,hidden:o.hidden,css:o.css,translations:o.translations,placements:o.placements,components:o.components,attribution:s}:{isResolved:!0,merchantId:n,domain:i,allowedDomains:a,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:s})},d=!1,p=e=>{let n=d?void 0:l;d=!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,a=i();if(s){let t=s.global??{};s.setGlobalProperties({...t,merchantId:e.merchantId,domain:e.domain??``})}t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:window.location.href,...a&&{sdkAnonymousId:a},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r}}})};r.isResolved&&(p(r.getConfig()),o.resolve()),a&&(u(await a),p(r.getConfig()),o.resolve());async function m(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function h(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function g(){if(typeof window>`u`)return;let e=window.localStorage.getItem(f);e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}(await Promise.allSettled([m(),h(),g()])).some(e=>e.status===`rejected`)&&s?.track(`sdk_iframe_handshake_failed`,{reason:`asset_push`})}async function q({config:e}){let t=J(e),n=await w({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=W({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function J(e){let t=y(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{_,k as a,p as b,C as c,S as d,x as f,m as g,v as h,N as i,w as l,y as m,W as n,j as o,b as p,F as r,M as s,q as t,E as u,h as v,d as x,g as y};