@frak-labs/core-sdk 0.2.1-beta.d2556d47 → 0.2.1-beta.eb3cff34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.js +3 -55
- package/dist/actions-D4aBXbdp.cjs +1 -0
- package/dist/actions-Dq_uN-wn.js +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-BP-ciVsp.d.cts → index-BV5D9DsW.d.ts} +71 -3
- package/dist/{siweAuthenticate-yITE-iKh.d.cts → index-BphwTmKA.d.cts} +115 -4
- package/dist/{computeLegacyProductId-DiJd7RNo.d.ts → index-Dwmo109y.d.cts} +71 -3
- package/dist/{siweAuthenticate-CDCsp8EJ.d.ts → index-_f8EuN_1.d.ts} +115 -4
- 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-B8v3Vtnh.d.ts → openSso-BwEK2M98.d.cts} +174 -7
- package/dist/{openSso-n_B4LSuW.d.cts → openSso-C1Wzl5-i.d.ts} +174 -7
- package/dist/src-B3Dusips.cjs +13 -0
- package/dist/src-CnnhYPyK.js +13 -0
- package/dist/trackEvent-BqJqRZ-u.cjs +1 -0
- package/dist/trackEvent-Bqq4jd6R.js +1 -0
- package/package.json +9 -10
- package/src/actions/displaySharingPage.ts +49 -0
- 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/clients/createIFrameFrakClient.ts +5 -2
- package/src/clients/transports/iframeLifecycleManager.test.ts +14 -14
- package/src/clients/transports/iframeLifecycleManager.ts +35 -9
- package/src/index.ts +12 -1
- package/src/stubs/rrweb.ts +9 -0
- package/src/types/index.ts +7 -0
- package/src/types/lifecycle/iframe.ts +7 -0
- package/src/types/resolvedConfig.ts +26 -2
- package/src/types/rpc/displaySharingPage.ts +82 -0
- package/src/types/rpc/embedded/index.ts +1 -1
- package/src/types/rpc/userReferralStatus.ts +20 -0
- package/src/types/rpc.ts +47 -0
- 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 +6 -0
- package/src/utils/sdkConfigStore.ts +21 -35
- package/dist/setupClient-Dr_UYfTD.cjs +0 -13
- package/dist/setupClient-TuhDjVJx.js +0 -13
- package/dist/siweAuthenticate-0UPcUqI1.js +0 -1
- package/dist/siweAuthenticate-CfQibjZR.cjs +0 -1
- package/dist/trackEvent-5j5kkOCj.js +0 -1
- package/dist/trackEvent-B2uom25e.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ModalRpcMetadata, B as LoginModalStepType, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, K as FinalActionType, M as ModalRpcStepsResultType, N as ModalStepTypes, P as SendTransactionModalStepType, R as SiweAuthenticateReturnType, U as PrepareSsoParamsType, W as PrepareSsoReturnType, b as DisplayEmbeddedWalletParamsType, g as GetMerchantInformationReturnType, i as FrakContext, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, p as WalletStatusReturnType, q as FinalModalStepType, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-C1Wzl5-i.js";
|
|
2
2
|
|
|
3
3
|
//#region src/actions/displayEmbeddedWallet.d.ts
|
|
4
4
|
/**
|
|
@@ -119,6 +119,40 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
|
|
|
119
119
|
metadata
|
|
120
120
|
}: DisplayModalParamsType<T>, placement?: string): Promise<ModalRpcStepsResultType<T>>;
|
|
121
121
|
//#endregion
|
|
122
|
+
//#region src/actions/displaySharingPage.d.ts
|
|
123
|
+
/**
|
|
124
|
+
* Function used to display a sharing page
|
|
125
|
+
* @param client - The current Frak Client
|
|
126
|
+
* @param params - The parameters to customize the sharing page (products, link override, metadata)
|
|
127
|
+
* @param placement - Optional placement ID to associate with this display request
|
|
128
|
+
* @returns The result indicating the user's action (shared, copied, or dismissed)
|
|
129
|
+
*
|
|
130
|
+
* @description This function will display a full-page sharing UI to the user,
|
|
131
|
+
* showing product info, estimated rewards, sharing steps, FAQ, and share/copy buttons.
|
|
132
|
+
* The sharing link is generated from the user's wallet context + merchant info.
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* - The promise resolves on the first user action (share or copy) but the page stays visible
|
|
136
|
+
* - The user can continue to share/copy multiple times after the initial resolution
|
|
137
|
+
* - Dismissing the page after a share/copy action is a no-op (promise already resolved)
|
|
138
|
+
* - If the user dismisses without any action, the promise resolves with `{ action: "dismissed" }`
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const result = await displaySharingPage(frakClient, {
|
|
143
|
+
* products: [
|
|
144
|
+
* {
|
|
145
|
+
* title: "Babies camel cuir velours bout carré",
|
|
146
|
+
* imageUrl: "https://example.com/product.jpg",
|
|
147
|
+
* },
|
|
148
|
+
* ],
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* console.log("User action:", result.action); // "shared" | "copied" | "dismissed"
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
declare function displaySharingPage(client: FrakClient, params: DisplaySharingPageParamsType, placement?: string): Promise<DisplaySharingPageResultType>;
|
|
155
|
+
//#endregion
|
|
122
156
|
//#region src/actions/ensureIdentity.d.ts
|
|
123
157
|
/**
|
|
124
158
|
* Ensure the current wallet ↔ clientId link exists on the backend.
|
|
@@ -146,13 +180,70 @@ declare function ensureIdentity(interactionToken: string): Promise<void>;
|
|
|
146
180
|
//#endregion
|
|
147
181
|
//#region src/actions/getMerchantInformation.d.ts
|
|
148
182
|
/**
|
|
149
|
-
* Fetch the current merchant information (name, rewards, tiers) from the wallet iframe
|
|
183
|
+
* Fetch the current merchant information (name, rewards, tiers) from the wallet iframe.
|
|
184
|
+
*
|
|
185
|
+
* Results are cached in memory for 30 seconds by default. Concurrent calls
|
|
186
|
+
* while a request is in-flight are deduplicated automatically.
|
|
187
|
+
*
|
|
150
188
|
* @param client - The current Frak Client
|
|
189
|
+
* @param options - Optional cache configuration
|
|
190
|
+
* @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
|
|
151
191
|
* @returns The merchant information including available reward tiers
|
|
152
192
|
*
|
|
153
193
|
* @see {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`} for the return type shape
|
|
154
194
|
*/
|
|
155
|
-
declare function getMerchantInformation(client: FrakClient
|
|
195
|
+
declare function getMerchantInformation(client: FrakClient, options?: {
|
|
196
|
+
cacheTime?: number;
|
|
197
|
+
}): Promise<GetMerchantInformationReturnType>;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/actions/getMergeToken.d.ts
|
|
200
|
+
/**
|
|
201
|
+
* Fetch a merge token for the current anonymous identity.
|
|
202
|
+
*
|
|
203
|
+
* Used by in-app browser redirect flows to preserve identity
|
|
204
|
+
* when switching from a WebView to the system browser.
|
|
205
|
+
* The token is appended as `?fmt=` to the redirect URL.
|
|
206
|
+
*
|
|
207
|
+
* Results are cached in memory for 30 seconds by default. Concurrent calls
|
|
208
|
+
* while a request is in-flight are deduplicated automatically.
|
|
209
|
+
*
|
|
210
|
+
* @param client - The current Frak Client
|
|
211
|
+
* @param options - Optional cache configuration
|
|
212
|
+
* @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
|
|
213
|
+
* @returns The merge token string, or null if unavailable
|
|
214
|
+
*/
|
|
215
|
+
declare function getMergeToken(client: FrakClient, options?: {
|
|
216
|
+
cacheTime?: number;
|
|
217
|
+
}): Promise<string | null>;
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/actions/getUserReferralStatus.d.ts
|
|
220
|
+
/**
|
|
221
|
+
* Fetch the current user's referral status on the current merchant.
|
|
222
|
+
*
|
|
223
|
+
* The listener resolves the user's identity (via clientId or wallet session)
|
|
224
|
+
* and checks whether a referral link exists where the user is the referee.
|
|
225
|
+
*
|
|
226
|
+
* Results are cached in memory for 30 seconds by default. Concurrent calls
|
|
227
|
+
* while a request is in-flight are deduplicated automatically.
|
|
228
|
+
*
|
|
229
|
+
* Returns `null` when the user's identity cannot be resolved.
|
|
230
|
+
*
|
|
231
|
+
* @param client - The current Frak Client
|
|
232
|
+
* @param options - Optional cache configuration
|
|
233
|
+
* @param options.cacheTime - Time in ms to cache the result. Default: 30_000 (30s). Set to 0 to disable.
|
|
234
|
+
* @returns The user's referral status, or `null` if identity cannot be resolved
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const status = await getUserReferralStatus(client);
|
|
239
|
+
* if (status?.isReferred) {
|
|
240
|
+
* console.log("User was referred to this merchant");
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
declare function getUserReferralStatus(client: FrakClient, options?: {
|
|
245
|
+
cacheTime?: number;
|
|
246
|
+
}): Promise<UserReferralStatusType | null>;
|
|
156
247
|
//#endregion
|
|
157
248
|
//#region src/actions/prepareSso.d.ts
|
|
158
249
|
/**
|
|
@@ -258,6 +349,26 @@ declare function referralInteraction(client: FrakClient, {
|
|
|
258
349
|
options?: ProcessReferralOptions;
|
|
259
350
|
}): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
|
|
260
351
|
//#endregion
|
|
352
|
+
//#region src/actions/referral/setupReferral.d.ts
|
|
353
|
+
/**
|
|
354
|
+
* Custom event name dispatched on successful referral processing.
|
|
355
|
+
*
|
|
356
|
+
* Fired once per page load when a valid referral context is found in the URL
|
|
357
|
+
* and successfully tracked. Consumers (e.g. `<frak-banner>`) listen for this
|
|
358
|
+
* to display a referral success message.
|
|
359
|
+
*/
|
|
360
|
+
declare const REFERRAL_SUCCESS_EVENT = "frak:referral-success";
|
|
361
|
+
/**
|
|
362
|
+
* Process referral context and emit a DOM event on success.
|
|
363
|
+
*
|
|
364
|
+
* - Calls {@link referralInteraction} to detect and track any referral in the URL
|
|
365
|
+
* - On `"success"`, dispatches a bare {@link REFERRAL_SUCCESS_EVENT} on `window`
|
|
366
|
+
* - Silently swallows errors (fire-and-forget during SDK init)
|
|
367
|
+
*
|
|
368
|
+
* @param client - The initialized Frak client
|
|
369
|
+
*/
|
|
370
|
+
declare function setupReferral(client: FrakClient): Promise<void>;
|
|
371
|
+
//#endregion
|
|
261
372
|
//#region src/actions/sendInteraction.d.ts
|
|
262
373
|
/**
|
|
263
374
|
* Send an interaction to the backend via the listener RPC.
|
|
@@ -532,4 +643,4 @@ declare function siweAuthenticate(client: FrakClient, {
|
|
|
532
643
|
metadata
|
|
533
644
|
}: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
|
|
534
645
|
//#endregion
|
|
535
|
-
export { displayModal as _, ModalBuilder as a, watchWalletStatus as c,
|
|
646
|
+
export { displayEmbeddedWallet as C, displayModal as S, getUserReferralStatus as _, ModalBuilder as a, ensureIdentity as b, watchWalletStatus as c, REFERRAL_SUCCESS_EVENT as d, setupReferral as f, prepareSso as g, processReferral as h, sendTransaction as i, trackPurchaseStatus as l, ProcessReferralOptions as m, siweAuthenticate as n, ModalStepBuilder as o, referralInteraction as p, SendTransactionParams as r, modalBuilder as s, SiweAuthenticateModalParams as t, sendInteraction as u, getMergeToken as v, displaySharingPage as x, getMerchantInformation as y };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trackEvent-BqJqRZ-u.cjs`),t=require(`./src-B3Dusips.cjs`);exports.DEEP_LINK_SCHEME=t.y,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.r,exports.base64urlDecode=e.g,exports.base64urlEncode=e._,exports.baseIframeProps=t.s,exports.clearAllCache=e.s,exports.compressJsonToB64=e.h,exports.computeLegacyProductId=e.v,exports.createIFrameFrakClient=t.n,exports.createIframe=t.c,exports.decompressJsonFromB64=e.o,exports.findIframeInOpener=t.l,exports.formatAmount=t.d,exports.generateSsoUrl=e.m,exports.getBackendUrl=e.u,exports.getCache=e.c,exports.getClientId=e.y,exports.getCurrencyAmountKey=t.u,exports.getSupportedCurrency=t.p,exports.getSupportedLocale=t.f,exports.isChromiumAndroid=t.h,exports.isFrakDeepLink=t.g,exports.isIOS=t.i,exports.isInAppBrowser=t.a,exports.isV1Context=e.i,exports.isV2Context=e.a,exports.locales=t.m,exports.redirectToExternalBrowser=t.o,exports.sdkConfigStore=e.n,exports.setupClient=t.t,exports.ssoPopupFeatures=e.f,exports.ssoPopupName=e.p,exports.toAndroidIntentUrl=t._,exports.trackEvent=e.t,exports.triggerDeepLinkWithFallback=t.v,exports.withCache=e.l;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { A as
|
|
3
|
-
export {
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-BwEK2M98.cjs";
|
|
2
|
+
import { A as getClientId, B as TrackArrivalParams, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as LocalesKey, G as KeyProvider, H as UtmParams, I as locales, L as setupClient, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as DebugInfoGatherer, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as TrackArrivalResult, W as HashProtectedData, _ as getCurrencyAmountKey, a as CompressedSsoData, b as DeepLinkFallbackOptions, c as sdkConfigStore, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as AppSpecificSsoMetadata, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as FrakEvent, o as FullSsoParams, p as createIframe, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as createIFrameFrakClient } from "./index-Dwmo109y.cjs";
|
|
3
|
+
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { A as
|
|
3
|
-
export {
|
|
1
|
+
import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, d as IFrameTransport, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, tt as SdkResolvedConfig, u as FrakLifecycleEvent, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-C1Wzl5-i.js";
|
|
2
|
+
import { A as getClientId, B as TrackArrivalParams, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as LocalesKey, G as KeyProvider, H as UtmParams, I as locales, L as setupClient, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as DebugInfoGatherer, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as TrackArrivalResult, W as HashProtectedData, _ as getCurrencyAmountKey, a as CompressedSsoData, b as DeepLinkFallbackOptions, c as sdkConfigStore, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as AppSpecificSsoMetadata, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as FrakEvent, o as FullSsoParams, p as createIframe, r as trackEvent, s as generateSsoUrl, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as createIFrameFrakClient } from "./index-BV5D9DsW.js";
|
|
3
|
+
export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakEvent, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,a as t,c as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./trackEvent-Bqq4jd6R.js";import{_ as v,a as y,c as b,d as x,f as S,g as C,h as w,i as T,l as E,m as D,n as O,o as k,p as A,r as j,s as M,t as N,u as P,v as F,y as I}from"./src-CnnhYPyK.js";export{I as DEEP_LINK_SCHEME,j as DebugInfoGatherer,f as FrakContextManager,i as base64urlDecode,e as base64urlEncode,M as baseIframeProps,p as clearAllCache,a as compressJsonToB64,g as computeLegacyProductId,O as createIFrameFrakClient,b as createIframe,u as decompressJsonFromB64,E as findIframeInOpener,x as formatAmount,c as generateSsoUrl,h as getBackendUrl,n as getCache,_ as getClientId,P as getCurrencyAmountKey,A as getSupportedCurrency,S as getSupportedLocale,w as isChromiumAndroid,C as isFrakDeepLink,T as isIOS,y as isInAppBrowser,o as isV1Context,t as isV2Context,D as locales,k as redirectToExternalBrowser,l as sdkConfigStore,N as setupClient,r as ssoPopupFeatures,d as ssoPopupName,v as toAndroidIntentUrl,m as trackEvent,F as triggerDeepLinkWithFallback,s as withCache};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Address, Hex } from "viem";
|
|
2
|
-
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
3
1
|
import { OpenPanel } from "@openpanel/web";
|
|
2
|
+
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
3
|
+
import { Address, Hex } from "viem";
|
|
4
4
|
import { SiweMessage } from "viem/siwe";
|
|
5
5
|
|
|
6
6
|
//#region src/types/config.d.ts
|
|
@@ -147,18 +147,37 @@ type ResolvedPlacement = {
|
|
|
147
147
|
buttonShare?: {
|
|
148
148
|
text?: string;
|
|
149
149
|
noRewardText?: string;
|
|
150
|
-
clickAction?: "embedded-wallet" | "share-modal";
|
|
150
|
+
clickAction?: "embedded-wallet" | "share-modal" | "sharing-page";
|
|
151
151
|
useReward?: boolean;
|
|
152
152
|
css?: string;
|
|
153
153
|
};
|
|
154
154
|
buttonWallet?: {
|
|
155
|
-
position?: "
|
|
155
|
+
position?: "right" | "left";
|
|
156
156
|
css?: string;
|
|
157
157
|
};
|
|
158
158
|
openInApp?: {
|
|
159
159
|
text?: string;
|
|
160
160
|
css?: string;
|
|
161
161
|
};
|
|
162
|
+
postPurchase?: {
|
|
163
|
+
badgeText?: string;
|
|
164
|
+
refereeText?: string;
|
|
165
|
+
refereeNoRewardText?: string;
|
|
166
|
+
referrerText?: string;
|
|
167
|
+
referrerNoRewardText?: string;
|
|
168
|
+
ctaText?: string;
|
|
169
|
+
ctaNoRewardText?: string;
|
|
170
|
+
css?: string;
|
|
171
|
+
};
|
|
172
|
+
banner?: {
|
|
173
|
+
referralTitle?: string;
|
|
174
|
+
referralDescription?: string;
|
|
175
|
+
referralCta?: string;
|
|
176
|
+
inappTitle?: string;
|
|
177
|
+
inappDescription?: string;
|
|
178
|
+
inappCta?: string;
|
|
179
|
+
css?: string;
|
|
180
|
+
};
|
|
162
181
|
};
|
|
163
182
|
targetInteraction?: string; /** Already flattened: default + lang-specific merged into one record */
|
|
164
183
|
translations?: Record<string, string>; /** Global placement CSS (applied to modals/listener) */
|
|
@@ -178,7 +197,8 @@ type ResolvedSdkConfig = {
|
|
|
178
197
|
hidden?: boolean;
|
|
179
198
|
css?: string;
|
|
180
199
|
translations?: Record<string, string>;
|
|
181
|
-
placements?: Record<string, ResolvedPlacement>;
|
|
200
|
+
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (used when no placement override exists) */
|
|
201
|
+
components?: ResolvedPlacement["components"];
|
|
182
202
|
};
|
|
183
203
|
/**
|
|
184
204
|
* Internal SDK config store state
|
|
@@ -200,7 +220,8 @@ type SdkResolvedConfig = {
|
|
|
200
220
|
hidden?: boolean; /** Global CSS from backend config (passed to iframe) */
|
|
201
221
|
css?: string; /** Global translations (for reference / component fallback) */
|
|
202
222
|
translations?: Record<string, string>; /** Named placements (keyed by placement ID) */
|
|
203
|
-
placements?: Record<string, ResolvedPlacement>;
|
|
223
|
+
placements?: Record<string, ResolvedPlacement>; /** Global component defaults (fallback for placement-level overrides) */
|
|
224
|
+
components?: ResolvedPlacement["components"];
|
|
204
225
|
};
|
|
205
226
|
//#endregion
|
|
206
227
|
//#region src/types/lifecycle/client.d.ts
|
|
@@ -288,6 +309,13 @@ type RedirectRequestEvent = {
|
|
|
288
309
|
* Used when redirecting out of social browsers to preserve identity across contexts
|
|
289
310
|
*/
|
|
290
311
|
mergeToken?: string;
|
|
312
|
+
/**
|
|
313
|
+
* When true, open the URL in a new tab via window.open(_blank)
|
|
314
|
+
* instead of navigating the current page.
|
|
315
|
+
* Requires the postMessage to include user activation delegation
|
|
316
|
+
* (includeUserActivation: true) so Safari allows the popup.
|
|
317
|
+
*/
|
|
318
|
+
openInNewTab?: boolean;
|
|
291
319
|
};
|
|
292
320
|
};
|
|
293
321
|
//#endregion
|
|
@@ -604,6 +632,85 @@ type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
|
604
632
|
metadata?: ModalRpcMetadata;
|
|
605
633
|
};
|
|
606
634
|
//#endregion
|
|
635
|
+
//#region src/types/rpc/displaySharingPage.d.ts
|
|
636
|
+
/**
|
|
637
|
+
* Product information to display on the sharing page
|
|
638
|
+
* @group Sharing Page
|
|
639
|
+
*/
|
|
640
|
+
type SharingPageProduct = {
|
|
641
|
+
/**
|
|
642
|
+
* The product title / name
|
|
643
|
+
*/
|
|
644
|
+
title: string;
|
|
645
|
+
/**
|
|
646
|
+
* Optional product image URL
|
|
647
|
+
*/
|
|
648
|
+
imageUrl?: string;
|
|
649
|
+
/**
|
|
650
|
+
* Optional product-specific sharing link
|
|
651
|
+
* When provided and the product is selected, this link is used instead of the default sharing link
|
|
652
|
+
*/
|
|
653
|
+
link?: string;
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* Parameters to display the sharing page
|
|
657
|
+
* @group Sharing Page
|
|
658
|
+
* @group RPC Schema
|
|
659
|
+
*/
|
|
660
|
+
type DisplaySharingPageParamsType = {
|
|
661
|
+
/**
|
|
662
|
+
* Products to showcase on the sharing page
|
|
663
|
+
* If provided, they will be displayed in a product card section
|
|
664
|
+
*/
|
|
665
|
+
products?: SharingPageProduct[];
|
|
666
|
+
/**
|
|
667
|
+
* Optional link override for sharing
|
|
668
|
+
* If not provided, the sharing link will be generated from the current page URL + merchant context
|
|
669
|
+
*/
|
|
670
|
+
link?: string;
|
|
671
|
+
/**
|
|
672
|
+
* Optional metadata overrides for the sharing page
|
|
673
|
+
*/
|
|
674
|
+
metadata?: {
|
|
675
|
+
/**
|
|
676
|
+
* Logo override for the sharing page header
|
|
677
|
+
*/
|
|
678
|
+
logo?: string;
|
|
679
|
+
/**
|
|
680
|
+
* Link to the homepage of the calling website
|
|
681
|
+
*/
|
|
682
|
+
homepageLink?: string;
|
|
683
|
+
/**
|
|
684
|
+
* The target interaction behind this sharing page
|
|
685
|
+
*/
|
|
686
|
+
targetInteraction?: InteractionTypeKey;
|
|
687
|
+
/**
|
|
688
|
+
* i18n overrides for the sharing page
|
|
689
|
+
*/
|
|
690
|
+
i18n?: I18nConfig;
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* Result of the sharing page display
|
|
695
|
+
* @group Sharing Page
|
|
696
|
+
* @group RPC Schema
|
|
697
|
+
*/
|
|
698
|
+
type DisplaySharingPageResultType = {
|
|
699
|
+
/**
|
|
700
|
+
* The action the user took
|
|
701
|
+
* - "shared": User used the native share dialog
|
|
702
|
+
* - "copied": User copied the link to clipboard
|
|
703
|
+
* - "dismissed": User dismissed the sharing page without acting
|
|
704
|
+
*/
|
|
705
|
+
action: "shared" | "copied" | "dismissed";
|
|
706
|
+
/**
|
|
707
|
+
* The install URL for the Frak app
|
|
708
|
+
* Can be used as a fallback to redirect the user to the install page
|
|
709
|
+
* from the merchant's top-level page (e.g. via `window.location.href`)
|
|
710
|
+
*/
|
|
711
|
+
installUrl?: string;
|
|
712
|
+
};
|
|
713
|
+
//#endregion
|
|
607
714
|
//#region src/types/rpc/embedded/loggedIn.d.ts
|
|
608
715
|
/**
|
|
609
716
|
* The different type of action we can have on the embedded view (once the user is logged in)
|
|
@@ -841,6 +948,28 @@ type GetMerchantInformationReturnType = {
|
|
|
841
948
|
}[];
|
|
842
949
|
};
|
|
843
950
|
//#endregion
|
|
951
|
+
//#region src/types/rpc/userReferralStatus.d.ts
|
|
952
|
+
/**
|
|
953
|
+
* User referral status returned by `frak_getUserReferralStatus`.
|
|
954
|
+
*
|
|
955
|
+
* Generic referral context for the current user on a merchant.
|
|
956
|
+
* Used by components like `<frak-post-purchase>` and `<frak-referred-banner>`
|
|
957
|
+
* to adapt their display based on the user's referral relationship.
|
|
958
|
+
*
|
|
959
|
+
* Returns `null` when the user's identity cannot be resolved
|
|
960
|
+
* (e.g. no clientId and no wallet session).
|
|
961
|
+
*
|
|
962
|
+
* @group RPC Schema
|
|
963
|
+
*/
|
|
964
|
+
type UserReferralStatusType = {
|
|
965
|
+
/**
|
|
966
|
+
* Whether the user was referred to this merchant by someone else.
|
|
967
|
+
*
|
|
968
|
+
* `true` means a referral link exists where this user is the referee.
|
|
969
|
+
*/
|
|
970
|
+
isReferred: boolean;
|
|
971
|
+
};
|
|
972
|
+
//#endregion
|
|
844
973
|
//#region src/types/rpc/walletStatus.d.ts
|
|
845
974
|
/**
|
|
846
975
|
* RPC Response for the method `frak_listenToWalletStatus`
|
|
@@ -905,6 +1034,11 @@ type WalletNotConnected = {
|
|
|
905
1034
|
* - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"], placement?: string]
|
|
906
1035
|
* - Returns: {@link DisplayEmbeddedWalletResultType}
|
|
907
1036
|
* - Response Type: promise (one-shot)
|
|
1037
|
+
*
|
|
1038
|
+
* #### frak_displaySharingPage
|
|
1039
|
+
* - Params: [request: {@link DisplaySharingPageParamsType}, configMetadata: {@link FrakWalletSdkConfig}["metadata"], placement?: string]
|
|
1040
|
+
* - Returns: {@link DisplaySharingPageResultType}
|
|
1041
|
+
* - Response Type: promise (one-shot)
|
|
908
1042
|
*/
|
|
909
1043
|
type IFrameRpcSchema = [
|
|
910
1044
|
/**
|
|
@@ -979,6 +1113,39 @@ type IFrameRpcSchema = [
|
|
|
979
1113
|
clientId?: string;
|
|
980
1114
|
}];
|
|
981
1115
|
ReturnType: undefined;
|
|
1116
|
+
},
|
|
1117
|
+
/**
|
|
1118
|
+
* Method to get the current user's referral status on this merchant.
|
|
1119
|
+
* Returns whether the user was referred (has a referral link as referee).
|
|
1120
|
+
* Returns null when the user's identity cannot be resolved.
|
|
1121
|
+
* This is a one-shot request.
|
|
1122
|
+
*/
|
|
1123
|
+
{
|
|
1124
|
+
Method: "frak_getUserReferralStatus";
|
|
1125
|
+
Parameters?: undefined;
|
|
1126
|
+
ReturnType: UserReferralStatusType | null;
|
|
1127
|
+
},
|
|
1128
|
+
/**
|
|
1129
|
+
* Method to display a sharing page with product info and sharing buttons
|
|
1130
|
+
* Resolves on first user action (share/copy) but the page stays visible
|
|
1131
|
+
* This is a one-shot request
|
|
1132
|
+
*/
|
|
1133
|
+
{
|
|
1134
|
+
Method: "frak_displaySharingPage";
|
|
1135
|
+
Parameters: [request: DisplaySharingPageParamsType, configMetadata: FrakWalletSdkConfig["metadata"], placement?: string];
|
|
1136
|
+
ReturnType: DisplaySharingPageResultType;
|
|
1137
|
+
},
|
|
1138
|
+
/**
|
|
1139
|
+
* Method to get a merge token for the current anonymous identity.
|
|
1140
|
+
* Used by in-app browser redirect flows to preserve identity
|
|
1141
|
+
* when switching from a WebView to the system browser.
|
|
1142
|
+
* Returns the merge token string, or null if unavailable.
|
|
1143
|
+
* This is a one-shot request.
|
|
1144
|
+
*/
|
|
1145
|
+
{
|
|
1146
|
+
Method: "frak_getMergeToken";
|
|
1147
|
+
Parameters?: undefined;
|
|
1148
|
+
ReturnType: string | null;
|
|
982
1149
|
}];
|
|
983
1150
|
//#endregion
|
|
984
1151
|
//#region src/types/transport.d.ts
|
|
@@ -1124,4 +1291,4 @@ declare const ssoPopupName = "frak-sso";
|
|
|
1124
1291
|
*/
|
|
1125
1292
|
declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1126
1293
|
//#endregion
|
|
1127
|
-
export {
|
|
1294
|
+
export { ResolvedPlacement as $, ModalRpcMetadata as A, LoginModalStepType as B, EmbeddedViewActionReferred as C, DisplaySharingPageResultType as D, DisplaySharingPageParamsType as E, SendTransactionReturnType as F, SsoMetadata as G, OpenSsoReturnType as H, SendTransactionTxType as I, ModalStepMetadata as J, FinalActionType as K, SiweAuthenticateModalStepType as L, ModalRpcStepsResultType as M, ModalStepTypes as N, SharingPageProduct as O, SendTransactionModalStepType as P, MerchantConfigResponse as Q, SiweAuthenticateReturnType as R, LoggedOutEmbeddedView as S, LoggedInEmbeddedView as T, PrepareSsoParamsType as U, OpenSsoParamsType as V, PrepareSsoReturnType as W, IFrameLifecycleEvent as X, InteractionTypeKey as Y, ClientLifecycleEvent as Z, RewardTier as _, FrakContextV1 as a, Language as at, DisplayEmbeddedWalletParamsType as b, isV2Context as c, IFrameTransport as d, ResolvedSdkConfig as et, IFrameRpcSchema as f, GetMerchantInformationReturnType as g, EstimatedReward as h, FrakContext as i, I18nConfig as it, ModalRpcStepsInput as j, DisplayModalParamsType as k, FrakClient as l, UserReferralStatusType as m, ssoPopupFeatures as n, Currency as nt, FrakContextV2 as o, LocalizedI18nConfig as ot, WalletStatusReturnType as p, FinalModalStepType as q, ssoPopupName as r, FrakWalletSdkConfig as rt, isV1Context as s, openSso as t, SdkResolvedConfig as tt, FrakLifecycleEvent as u, TokenAmountType as v, EmbeddedViewActionSharing as w, DisplayEmbeddedWalletResultType as x, SendInteractionParamsType as y, SiweAuthenticationParams as z };
|