@frak-labs/core-sdk 0.2.1 → 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/README.md +1 -2
- package/cdn/bundle.js +3 -3
- package/dist/actions-BMTVobuH.js +1 -0
- package/dist/actions-ukNCM0d7.cjs +1 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +3 -3
- package/dist/actions.d.ts +3 -3
- 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/{computeLegacyProductId-b5cUWdAm.d.ts → index-BCwGNRmk.d.cts} +144 -58
- package/dist/{computeLegacyProductId-CCAZvLa5.d.cts → index-BfmJnxzo.d.ts} +144 -58
- package/dist/{siweAuthenticate-CnCZ7mok.d.ts → index-CVnwk1E_.d.cts} +122 -8
- package/dist/{siweAuthenticate-CVigMOxz.d.cts → index-DZuYiI2M.d.ts} +122 -8
- 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-B0g7-807.d.cts → openSso-BQ-q-_Y9.d.ts} +373 -46
- package/dist/{openSso-CMzwvaCa.d.ts → openSso-CMBCbhvP.d.cts} +372 -45
- 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 +12 -13
- package/src/actions/displayEmbeddedWallet.ts +6 -2
- package/src/actions/displayModal.ts +6 -2
- package/src/actions/displaySharingPage.ts +49 -0
- package/src/actions/ensureIdentity.ts +2 -2
- package/src/actions/getMerchantInformation.test.ts +13 -1
- package/src/actions/getMerchantInformation.ts +20 -5
- package/src/actions/getMergeToken.ts +33 -0
- package/src/actions/getUserReferralStatus.ts +42 -0
- package/src/actions/index.ts +8 -1
- package/src/actions/referral/setupReferral.test.ts +79 -0
- package/src/actions/referral/setupReferral.ts +32 -0
- package/src/actions/trackPurchaseStatus.test.ts +32 -20
- package/src/actions/trackPurchaseStatus.ts +3 -5
- package/src/actions/wrapper/modalBuilder.test.ts +4 -2
- package/src/actions/wrapper/modalBuilder.ts +6 -8
- package/src/clients/createIFrameFrakClient.ts +162 -27
- package/src/clients/transports/iframeLifecycleManager.test.ts +14 -94
- package/src/clients/transports/iframeLifecycleManager.ts +35 -53
- package/src/index.ts +21 -4
- package/src/stubs/rrweb.ts +9 -0
- package/src/types/config.ts +19 -3
- package/src/types/index.ts +15 -1
- package/src/types/lifecycle/client.ts +22 -27
- package/src/types/lifecycle/iframe.ts +7 -8
- package/src/types/resolvedConfig.ts +138 -0
- package/src/types/rpc/displaySharingPage.ts +100 -0
- package/src/types/rpc/embedded/index.ts +1 -1
- package/src/types/rpc/interaction.ts +4 -0
- package/src/types/rpc/userReferralStatus.ts +20 -0
- package/src/types/rpc.ts +54 -5
- 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/backendUrl.test.ts +2 -2
- package/src/utils/backendUrl.ts +1 -1
- package/src/utils/cache/index.ts +7 -0
- package/src/utils/cache/lruMap.test.ts +55 -0
- package/src/utils/cache/lruMap.ts +38 -0
- package/src/utils/cache/withCache.test.ts +168 -0
- package/src/utils/cache/withCache.ts +124 -0
- package/src/utils/inAppBrowser.ts +60 -0
- package/src/utils/index.ts +10 -4
- package/src/utils/mergeAttribution.test.ts +153 -0
- package/src/utils/mergeAttribution.ts +75 -0
- package/src/utils/sdkConfigStore.test.ts +405 -0
- package/src/utils/sdkConfigStore.ts +263 -0
- package/src/utils/sso.ts +3 -7
- package/dist/setupClient-BduY6Sym.cjs +0 -13
- package/dist/setupClient-ftmdQ-I8.js +0 -13
- package/dist/siweAuthenticate-BWmI2_TN.cjs +0 -1
- package/dist/siweAuthenticate-zczqxm0a.js +0 -1
- package/dist/trackEvent-CeLFVzZn.js +0 -1
- package/dist/trackEvent-Ew5r5zfI.cjs +0 -1
- package/src/utils/merchantId.test.ts +0 -653
- package/src/utils/merchantId.ts +0 -143
package/src/index.ts
CHANGED
|
@@ -12,6 +12,8 @@ export { type LocalesKey, locales } from "./constants/locales";
|
|
|
12
12
|
|
|
13
13
|
// Types
|
|
14
14
|
export type {
|
|
15
|
+
AttributionDefaults,
|
|
16
|
+
AttributionParams,
|
|
15
17
|
ClientLifecycleEvent,
|
|
16
18
|
CompressedData,
|
|
17
19
|
Currency,
|
|
@@ -19,6 +21,9 @@ export type {
|
|
|
19
21
|
DisplayEmbeddedWalletParamsType,
|
|
20
22
|
DisplayEmbeddedWalletResultType,
|
|
21
23
|
DisplayModalParamsType,
|
|
24
|
+
// RPC Sharing page
|
|
25
|
+
DisplaySharingPageParamsType,
|
|
26
|
+
DisplaySharingPageResultType,
|
|
22
27
|
EmbeddedViewActionReferred,
|
|
23
28
|
EmbeddedViewActionSharing,
|
|
24
29
|
EstimatedReward,
|
|
@@ -47,6 +52,7 @@ export type {
|
|
|
47
52
|
LoggedInEmbeddedView,
|
|
48
53
|
LoggedOutEmbeddedView,
|
|
49
54
|
LoginModalStepType,
|
|
55
|
+
MerchantConfigResponse,
|
|
50
56
|
ModalRpcMetadata,
|
|
51
57
|
ModalRpcStepsInput,
|
|
52
58
|
ModalRpcStepsResultType,
|
|
@@ -58,12 +64,16 @@ export type {
|
|
|
58
64
|
OpenSsoReturnType,
|
|
59
65
|
PrepareSsoParamsType,
|
|
60
66
|
PrepareSsoReturnType,
|
|
67
|
+
ResolvedPlacement,
|
|
68
|
+
ResolvedSdkConfig,
|
|
61
69
|
RewardTier,
|
|
70
|
+
SdkResolvedConfig,
|
|
62
71
|
// RPC Interaction
|
|
63
72
|
SendInteractionParamsType,
|
|
64
73
|
SendTransactionModalStepType,
|
|
65
74
|
SendTransactionReturnType,
|
|
66
75
|
SendTransactionTxType,
|
|
76
|
+
SharingPageProduct,
|
|
67
77
|
SiweAuthenticateModalStepType,
|
|
68
78
|
SiweAuthenticateReturnType,
|
|
69
79
|
SiweAuthenticationParams,
|
|
@@ -72,8 +82,9 @@ export type {
|
|
|
72
82
|
// Tracking
|
|
73
83
|
TrackArrivalParams,
|
|
74
84
|
TrackArrivalResult,
|
|
75
|
-
UtmParams,
|
|
76
85
|
// Rpc
|
|
86
|
+
UserReferralStatusType,
|
|
87
|
+
UtmParams,
|
|
77
88
|
WalletStatusReturnType,
|
|
78
89
|
} from "./types";
|
|
79
90
|
export { isV1Context, isV2Context } from "./types";
|
|
@@ -84,7 +95,7 @@ export {
|
|
|
84
95
|
base64urlEncode,
|
|
85
96
|
baseIframeProps,
|
|
86
97
|
type CompressedSsoData,
|
|
87
|
-
|
|
98
|
+
clearAllCache,
|
|
88
99
|
compressJsonToB64,
|
|
89
100
|
createIframe,
|
|
90
101
|
DEEP_LINK_SCHEME,
|
|
@@ -93,20 +104,26 @@ export {
|
|
|
93
104
|
FrakContextManager,
|
|
94
105
|
type FrakEvent,
|
|
95
106
|
type FullSsoParams,
|
|
96
|
-
fetchMerchantId,
|
|
97
107
|
findIframeInOpener,
|
|
98
108
|
formatAmount,
|
|
99
109
|
generateSsoUrl,
|
|
100
110
|
getBackendUrl,
|
|
111
|
+
getCache,
|
|
101
112
|
getClientId,
|
|
102
113
|
getCurrencyAmountKey,
|
|
103
114
|
getSupportedCurrency,
|
|
104
115
|
getSupportedLocale,
|
|
105
116
|
isChromiumAndroid,
|
|
106
117
|
isFrakDeepLink,
|
|
107
|
-
|
|
118
|
+
isInAppBrowser,
|
|
119
|
+
isIOS,
|
|
120
|
+
type MergeAttributionInput,
|
|
121
|
+
mergeAttribution,
|
|
122
|
+
redirectToExternalBrowser,
|
|
123
|
+
sdkConfigStore,
|
|
108
124
|
toAndroidIntentUrl,
|
|
109
125
|
trackEvent,
|
|
110
126
|
triggerDeepLinkWithFallback,
|
|
127
|
+
withCache,
|
|
111
128
|
} from "./utils";
|
|
112
129
|
export { computeLegacyProductId } from "./utils/computeLegacyProductId";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub for rrweb. The @openpanel/web package statically imports `record` from
|
|
3
|
+
* rrweb even when session replay is disabled. This stub replaces the module so
|
|
4
|
+
* that rrweb is not included in the bundle.
|
|
5
|
+
* @see https://github.com/Openpanel-dev/openpanel/issues/336
|
|
6
|
+
*/
|
|
7
|
+
export function record() {
|
|
8
|
+
return () => {};
|
|
9
|
+
}
|
package/src/types/config.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AttributionDefaults } from "./tracking";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* All the currencies available
|
|
3
5
|
* @category Config
|
|
@@ -27,7 +29,7 @@ export type FrakWalletSdkConfig = {
|
|
|
27
29
|
/**
|
|
28
30
|
* Your application name (will be displayed in a few modals and in SSO)
|
|
29
31
|
*/
|
|
30
|
-
name
|
|
32
|
+
name?: string;
|
|
31
33
|
/**
|
|
32
34
|
* Your merchant ID from the Frak dashboard (UUID format)
|
|
33
35
|
* Used for referral tracking and analytics
|
|
@@ -71,6 +73,20 @@ export type FrakWalletSdkConfig = {
|
|
|
71
73
|
* @defaultValue window.location.host
|
|
72
74
|
*/
|
|
73
75
|
domain?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Wait for backend config before rendering components.
|
|
78
|
+
* When true (default), components show a spinner until backend config is resolved.
|
|
79
|
+
* When false, components render immediately with SDK static config / HTML attributes.
|
|
80
|
+
* @defaultValue true
|
|
81
|
+
*/
|
|
82
|
+
waitForBackendConfig?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Default attribution params (UTM / via / ref) appended to outbound
|
|
85
|
+
* sharing URLs. Per-call `displaySharingPage` overrides win, then backend
|
|
86
|
+
* config, then this SDK-level default. `utm_content` is intentionally
|
|
87
|
+
* excluded — it is per-content/per-product, never a merchant-wide default.
|
|
88
|
+
*/
|
|
89
|
+
attribution?: AttributionDefaults;
|
|
74
90
|
};
|
|
75
91
|
|
|
76
92
|
/**
|
|
@@ -111,7 +127,7 @@ export type I18nConfig =
|
|
|
111
127
|
| LocalizedI18nConfig;
|
|
112
128
|
|
|
113
129
|
/**
|
|
114
|
-
* A localized i18n config
|
|
130
|
+
* A localized i18n config (inline objects only — URL-based i18n removed)
|
|
115
131
|
* @category Config
|
|
116
132
|
*/
|
|
117
|
-
export type LocalizedI18nConfig =
|
|
133
|
+
export type LocalizedI18nConfig = { [key: string]: string };
|
package/src/types/index.ts
CHANGED
|
@@ -17,11 +17,16 @@ export type {
|
|
|
17
17
|
// Utils
|
|
18
18
|
export type { FrakContext, FrakContextV1, FrakContextV2 } from "./context";
|
|
19
19
|
export { isV1Context, isV2Context } from "./context";
|
|
20
|
-
|
|
21
20
|
export type {
|
|
22
21
|
ClientLifecycleEvent,
|
|
23
22
|
IFrameLifecycleEvent,
|
|
24
23
|
} from "./lifecycle";
|
|
24
|
+
export type {
|
|
25
|
+
MerchantConfigResponse,
|
|
26
|
+
ResolvedPlacement,
|
|
27
|
+
ResolvedSdkConfig,
|
|
28
|
+
SdkResolvedConfig,
|
|
29
|
+
} from "./resolvedConfig";
|
|
25
30
|
export type { IFrameRpcSchema } from "./rpc";
|
|
26
31
|
// Modal related
|
|
27
32
|
export type {
|
|
@@ -31,6 +36,12 @@ export type {
|
|
|
31
36
|
ModalRpcStepsResultType,
|
|
32
37
|
ModalStepTypes,
|
|
33
38
|
} from "./rpc/displayModal";
|
|
39
|
+
// Sharing page related
|
|
40
|
+
export type {
|
|
41
|
+
DisplaySharingPageParamsType,
|
|
42
|
+
DisplaySharingPageResultType,
|
|
43
|
+
SharingPageProduct,
|
|
44
|
+
} from "./rpc/displaySharingPage";
|
|
34
45
|
export type {
|
|
35
46
|
DisplayEmbeddedWalletParamsType,
|
|
36
47
|
DisplayEmbeddedWalletResultType,
|
|
@@ -65,9 +76,12 @@ export type {
|
|
|
65
76
|
PrepareSsoReturnType,
|
|
66
77
|
SsoMetadata,
|
|
67
78
|
} from "./rpc/sso";
|
|
79
|
+
export type { UserReferralStatusType } from "./rpc/userReferralStatus";
|
|
68
80
|
export type { WalletStatusReturnType } from "./rpc/walletStatus";
|
|
69
81
|
// Tracking
|
|
70
82
|
export type {
|
|
83
|
+
AttributionDefaults,
|
|
84
|
+
AttributionParams,
|
|
71
85
|
TrackArrivalParams,
|
|
72
86
|
TrackArrivalResult,
|
|
73
87
|
UtmParams,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { I18nConfig } from "../config";
|
|
2
|
+
import type { ResolvedSdkConfig } from "../resolvedConfig";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Event related to the iframe lifecycle
|
|
@@ -9,9 +10,9 @@ export type ClientLifecycleEvent =
|
|
|
9
10
|
| CustomI18nEvent
|
|
10
11
|
| RestoreBackupEvent
|
|
11
12
|
| HearbeatEvent
|
|
12
|
-
| HandshakeResponse
|
|
13
13
|
| SsoRedirectCompleteEvent
|
|
14
|
-
| DeepLinkFailedEvent
|
|
14
|
+
| DeepLinkFailedEvent
|
|
15
|
+
| ResolvedConfigEvent;
|
|
15
16
|
|
|
16
17
|
type CustomCssEvent = {
|
|
17
18
|
clientLifecycle: "modal-css";
|
|
@@ -33,31 +34,6 @@ type HearbeatEvent = {
|
|
|
33
34
|
data?: never;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
type HandshakeResponse = {
|
|
37
|
-
clientLifecycle: "handshake-response";
|
|
38
|
-
data: {
|
|
39
|
-
token: string;
|
|
40
|
-
currentUrl: string;
|
|
41
|
-
/**
|
|
42
|
-
* Pending merge token extracted from URL (?fmt= parameter)
|
|
43
|
-
* When present, listener should execute identity merge in background
|
|
44
|
-
* URL is cleaned after handshake response is sent
|
|
45
|
-
*/
|
|
46
|
-
pendingMergeToken?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Client ID for identity tracking (belt & suspenders fallback)
|
|
49
|
-
* Primary delivery is via iframe URL query param; handshake is backup for SSR
|
|
50
|
-
*/
|
|
51
|
-
clientId?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Explicit domain from SDK config (FrakWalletSdkConfig.domain)
|
|
54
|
-
* When present, listener should prefer this over URL-derived domain
|
|
55
|
-
* for merchant resolution (handles proxied/tunneled environments)
|
|
56
|
-
*/
|
|
57
|
-
configDomain?: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
37
|
type SsoRedirectCompleteEvent = {
|
|
62
38
|
clientLifecycle: "sso-redirect-complete";
|
|
63
39
|
data: { compressed: string };
|
|
@@ -67,3 +43,22 @@ type DeepLinkFailedEvent = {
|
|
|
67
43
|
clientLifecycle: "deep-link-failed";
|
|
68
44
|
data: { originalUrl: string };
|
|
69
45
|
};
|
|
46
|
+
|
|
47
|
+
type ResolvedConfigEvent = {
|
|
48
|
+
clientLifecycle: "resolved-config";
|
|
49
|
+
data: {
|
|
50
|
+
merchantId: string;
|
|
51
|
+
/** The domain the backend resolved this config for */
|
|
52
|
+
domain: string;
|
|
53
|
+
/** All domains registered for this merchant (for domain proof) */
|
|
54
|
+
allowedDomains: string[];
|
|
55
|
+
/** Full URL of the parent page (for interaction tracking) */
|
|
56
|
+
sourceUrl: string;
|
|
57
|
+
/**
|
|
58
|
+
* Pending merge token extracted from URL (?fmt= parameter).
|
|
59
|
+
* When present, listener should execute identity merge in background.
|
|
60
|
+
*/
|
|
61
|
+
pendingMergeToken?: string;
|
|
62
|
+
sdkConfig?: ResolvedSdkConfig;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -8,7 +8,6 @@ export type IFrameLifecycleEvent =
|
|
|
8
8
|
data?: never;
|
|
9
9
|
}
|
|
10
10
|
| DoBackupEvent
|
|
11
|
-
| HandshakeRequestEvent
|
|
12
11
|
| RedirectRequestEvent;
|
|
13
12
|
|
|
14
13
|
type DoBackupEvent = {
|
|
@@ -16,13 +15,6 @@ type DoBackupEvent = {
|
|
|
16
15
|
data: { backup?: string };
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
type HandshakeRequestEvent = {
|
|
20
|
-
iframeLifecycle: "handshake";
|
|
21
|
-
data: {
|
|
22
|
-
token: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
18
|
type RedirectRequestEvent = {
|
|
27
19
|
iframeLifecycle: "redirect";
|
|
28
20
|
data: {
|
|
@@ -37,5 +29,12 @@ type RedirectRequestEvent = {
|
|
|
37
29
|
* Used when redirecting out of social browsers to preserve identity across contexts
|
|
38
30
|
*/
|
|
39
31
|
mergeToken?: string;
|
|
32
|
+
/**
|
|
33
|
+
* When true, open the URL in a new tab via window.open(_blank)
|
|
34
|
+
* instead of navigating the current page.
|
|
35
|
+
* Requires the postMessage to include user activation delegation
|
|
36
|
+
* (includeUserActivation: true) so Safari allows the popup.
|
|
37
|
+
*/
|
|
38
|
+
openInNewTab?: boolean;
|
|
40
39
|
};
|
|
41
40
|
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Currency, Language } from "./config";
|
|
2
|
+
import type { AttributionDefaults } from "./tracking";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Response from the merchant resolve endpoint
|
|
6
|
+
* @category Config
|
|
7
|
+
*/
|
|
8
|
+
export type MerchantConfigResponse = {
|
|
9
|
+
merchantId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
domain: string;
|
|
12
|
+
allowedDomains: string[];
|
|
13
|
+
sdkConfig?: ResolvedSdkConfig;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolved placement config from backend
|
|
18
|
+
* Translations already flattened: default + lang-specific merged into one record
|
|
19
|
+
* @category Config
|
|
20
|
+
*/
|
|
21
|
+
export type ResolvedPlacement = {
|
|
22
|
+
/** Per-component configuration within this placement */
|
|
23
|
+
components?: {
|
|
24
|
+
buttonShare?: {
|
|
25
|
+
text?: string;
|
|
26
|
+
noRewardText?: string;
|
|
27
|
+
clickAction?: "embedded-wallet" | "share-modal" | "sharing-page";
|
|
28
|
+
useReward?: boolean;
|
|
29
|
+
css?: string;
|
|
30
|
+
};
|
|
31
|
+
buttonWallet?: {
|
|
32
|
+
position?: "right" | "left";
|
|
33
|
+
css?: string;
|
|
34
|
+
};
|
|
35
|
+
openInApp?: {
|
|
36
|
+
text?: string;
|
|
37
|
+
css?: string;
|
|
38
|
+
};
|
|
39
|
+
postPurchase?: {
|
|
40
|
+
badgeText?: string;
|
|
41
|
+
refereeText?: string;
|
|
42
|
+
refereeNoRewardText?: string;
|
|
43
|
+
referrerText?: string;
|
|
44
|
+
referrerNoRewardText?: string;
|
|
45
|
+
ctaText?: string;
|
|
46
|
+
ctaNoRewardText?: string;
|
|
47
|
+
css?: string;
|
|
48
|
+
};
|
|
49
|
+
banner?: {
|
|
50
|
+
referralTitle?: string;
|
|
51
|
+
referralDescription?: string;
|
|
52
|
+
referralCta?: string;
|
|
53
|
+
inappTitle?: string;
|
|
54
|
+
inappDescription?: string;
|
|
55
|
+
inappCta?: string;
|
|
56
|
+
css?: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
targetInteraction?: string;
|
|
60
|
+
/** Already flattened: default + lang-specific merged into one record */
|
|
61
|
+
translations?: Record<string, string>;
|
|
62
|
+
/** Global placement CSS (applied to modals/listener) */
|
|
63
|
+
css?: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Resolved SDK config from backend `/resolve` endpoint
|
|
68
|
+
* Language resolution and translation merging already applied
|
|
69
|
+
* @category Config
|
|
70
|
+
*/
|
|
71
|
+
export type ResolvedSdkConfig = {
|
|
72
|
+
name?: string;
|
|
73
|
+
logoUrl?: string;
|
|
74
|
+
homepageLink?: string;
|
|
75
|
+
currency?: Currency;
|
|
76
|
+
lang?: Language;
|
|
77
|
+
/** When true, all SDK components should be hidden */
|
|
78
|
+
hidden?: boolean;
|
|
79
|
+
css?: string;
|
|
80
|
+
translations?: Record<string, string>;
|
|
81
|
+
placements?: Record<string, ResolvedPlacement>;
|
|
82
|
+
/** Global component defaults (used when no placement override exists) */
|
|
83
|
+
components?: ResolvedPlacement["components"];
|
|
84
|
+
/**
|
|
85
|
+
* Default attribution params applied when building outbound sharing URLs.
|
|
86
|
+
* Per-call overrides win over these backend defaults; `utm_content` is
|
|
87
|
+
* intentionally excluded (per-content/per-product, never a merchant default).
|
|
88
|
+
*/
|
|
89
|
+
attribution?: AttributionDefaults;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Internal SDK config store state
|
|
94
|
+
* Merged config: backend > SDK static > defaults
|
|
95
|
+
* Components subscribe to this reactively
|
|
96
|
+
* @category Config
|
|
97
|
+
*/
|
|
98
|
+
export type SdkResolvedConfig = {
|
|
99
|
+
/** Whether the backend config has been resolved */
|
|
100
|
+
isResolved: boolean;
|
|
101
|
+
|
|
102
|
+
/** Merchant ID from resolution */
|
|
103
|
+
merchantId: string;
|
|
104
|
+
|
|
105
|
+
/** Domain returned by the resolve endpoint */
|
|
106
|
+
domain?: string;
|
|
107
|
+
|
|
108
|
+
/** Domains allowed for this merchant (used by iframe trust check) */
|
|
109
|
+
allowedDomains?: string[];
|
|
110
|
+
|
|
111
|
+
/** Whether the resolve returned a backend sdkConfig object */
|
|
112
|
+
hasRawSdkConfig?: boolean;
|
|
113
|
+
|
|
114
|
+
/** Merged metadata fields */
|
|
115
|
+
name?: string;
|
|
116
|
+
logoUrl?: string;
|
|
117
|
+
homepageLink?: string;
|
|
118
|
+
lang?: Language;
|
|
119
|
+
currency?: Currency;
|
|
120
|
+
|
|
121
|
+
/** When true, all SDK components should be hidden */
|
|
122
|
+
hidden?: boolean;
|
|
123
|
+
|
|
124
|
+
/** Global CSS from backend config (passed to iframe) */
|
|
125
|
+
css?: string;
|
|
126
|
+
|
|
127
|
+
/** Global translations (for reference / component fallback) */
|
|
128
|
+
translations?: Record<string, string>;
|
|
129
|
+
|
|
130
|
+
/** Named placements (keyed by placement ID) */
|
|
131
|
+
placements?: Record<string, ResolvedPlacement>;
|
|
132
|
+
|
|
133
|
+
/** Global component defaults (fallback for placement-level overrides) */
|
|
134
|
+
components?: ResolvedPlacement["components"];
|
|
135
|
+
|
|
136
|
+
/** Merged attribution defaults: backend > SDK static config */
|
|
137
|
+
attribution?: AttributionDefaults;
|
|
138
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { InteractionTypeKey } from "../../constants/interactionTypes";
|
|
2
|
+
import type { I18nConfig } from "../config";
|
|
3
|
+
import type { AttributionParams } from "../tracking";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Product information to display on the sharing page
|
|
7
|
+
* @group Sharing Page
|
|
8
|
+
*/
|
|
9
|
+
export type SharingPageProduct = {
|
|
10
|
+
/**
|
|
11
|
+
* The product title / name
|
|
12
|
+
*/
|
|
13
|
+
title: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional product image URL
|
|
16
|
+
*/
|
|
17
|
+
imageUrl?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional product-specific sharing link
|
|
20
|
+
* When provided and the product is selected, this link is used instead of the default sharing link
|
|
21
|
+
*/
|
|
22
|
+
link?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional `utm_content` value to apply when this product is selected.
|
|
25
|
+
* Falls back to the page-level `attribution.utmContent` when omitted.
|
|
26
|
+
*/
|
|
27
|
+
utmContent?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parameters to display the sharing page
|
|
32
|
+
* @group Sharing Page
|
|
33
|
+
* @group RPC Schema
|
|
34
|
+
*/
|
|
35
|
+
export type DisplaySharingPageParamsType = {
|
|
36
|
+
/**
|
|
37
|
+
* Products to showcase on the sharing page
|
|
38
|
+
* If provided, they will be displayed in a product card section
|
|
39
|
+
*/
|
|
40
|
+
products?: SharingPageProduct[];
|
|
41
|
+
/**
|
|
42
|
+
* Optional link override for sharing
|
|
43
|
+
* If not provided, the sharing link will be generated from the current page URL + merchant context
|
|
44
|
+
*/
|
|
45
|
+
link?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Optional attribution overrides for the outbound sharing URL.
|
|
48
|
+
*
|
|
49
|
+
* When provided (even as an empty object), Frak adds standard affiliation
|
|
50
|
+
* params (`utm_source=frak`, `utm_medium=referral`, `utm_campaign=<merchantId>`,
|
|
51
|
+
* `ref=<clientId>`, `via=frak`) alongside `fCtx`. Existing UTMs on the base
|
|
52
|
+
* URL are preserved (gap-fill). Set this to `null` to disable attribution
|
|
53
|
+
* params entirely (only `fCtx` is added).
|
|
54
|
+
*
|
|
55
|
+
* @default {} — defaults applied
|
|
56
|
+
*/
|
|
57
|
+
attribution?: AttributionParams | null;
|
|
58
|
+
/**
|
|
59
|
+
* Optional metadata overrides for the sharing page
|
|
60
|
+
*/
|
|
61
|
+
metadata?: {
|
|
62
|
+
/**
|
|
63
|
+
* Logo override for the sharing page header
|
|
64
|
+
*/
|
|
65
|
+
logo?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Link to the homepage of the calling website
|
|
68
|
+
*/
|
|
69
|
+
homepageLink?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The target interaction behind this sharing page
|
|
72
|
+
*/
|
|
73
|
+
targetInteraction?: InteractionTypeKey;
|
|
74
|
+
/**
|
|
75
|
+
* i18n overrides for the sharing page
|
|
76
|
+
*/
|
|
77
|
+
i18n?: I18nConfig;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Result of the sharing page display
|
|
83
|
+
* @group Sharing Page
|
|
84
|
+
* @group RPC Schema
|
|
85
|
+
*/
|
|
86
|
+
export type DisplaySharingPageResultType = {
|
|
87
|
+
/**
|
|
88
|
+
* The action the user took
|
|
89
|
+
* - "shared": User used the native share dialog
|
|
90
|
+
* - "copied": User copied the link to clipboard
|
|
91
|
+
* - "dismissed": User dismissed the sharing page without acting
|
|
92
|
+
*/
|
|
93
|
+
action: "shared" | "copied" | "dismissed";
|
|
94
|
+
/**
|
|
95
|
+
* The install URL for the Frak app
|
|
96
|
+
* Can be used as a fallback to redirect the user to the install page
|
|
97
|
+
* from the merchant's top-level page (e.g. via `window.location.href`)
|
|
98
|
+
*/
|
|
99
|
+
installUrl?: string;
|
|
100
|
+
};
|
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
import type { LoggedOutEmbeddedView } from "./loggedOut";
|
|
10
10
|
|
|
11
11
|
export type {
|
|
12
|
+
EmbeddedViewActionReferred,
|
|
12
13
|
EmbeddedViewActionSharing,
|
|
13
14
|
LoggedInEmbeddedView,
|
|
14
15
|
LoggedOutEmbeddedView,
|
|
15
|
-
EmbeddedViewActionReferred,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -26,6 +26,10 @@ export type SendInteractionParamsType =
|
|
|
26
26
|
}
|
|
27
27
|
| {
|
|
28
28
|
type: "sharing";
|
|
29
|
+
/** Epoch seconds timestamp matching the V2 context `t` field embedded in the referral link URL, used for backend correlation */
|
|
30
|
+
sharingTimestamp?: number;
|
|
31
|
+
/** Merchant order ID linking this sharing event to a purchase (stays server-side, never in URL) */
|
|
32
|
+
purchaseId?: string;
|
|
29
33
|
}
|
|
30
34
|
| {
|
|
31
35
|
type: "custom";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User referral status returned by `frak_getUserReferralStatus`.
|
|
3
|
+
*
|
|
4
|
+
* Generic referral context for the current user on a merchant.
|
|
5
|
+
* Used by components like `<frak-post-purchase>` and `<frak-referred-banner>`
|
|
6
|
+
* to adapt their display based on the user's referral relationship.
|
|
7
|
+
*
|
|
8
|
+
* Returns `null` when the user's identity cannot be resolved
|
|
9
|
+
* (e.g. no clientId and no wallet session).
|
|
10
|
+
*
|
|
11
|
+
* @group RPC Schema
|
|
12
|
+
*/
|
|
13
|
+
export type UserReferralStatusType = {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the user was referred to this merchant by someone else.
|
|
16
|
+
*
|
|
17
|
+
* `true` means a referral link exists where this user is the referee.
|
|
18
|
+
*/
|
|
19
|
+
isReferred: boolean;
|
|
20
|
+
};
|