@frak-labs/core-sdk 0.1.1 → 0.2.0-beta.7898df5b
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 +58 -0
- package/cdn/bundle.js +14 -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 -6
- package/dist/bundle.d.ts +4 -6
- package/dist/bundle.js +1 -1
- package/dist/computeLegacyProductId-CCAZvLa5.d.cts +537 -0
- package/dist/computeLegacyProductId-b5cUWdAm.d.ts +537 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -1
- package/dist/{openSso-D--Airj6.d.cts → openSso-B0g7-807.d.cts} +173 -136
- package/dist/{openSso-DsKJ4y0j.d.ts → openSso-CMzwvaCa.d.ts} +173 -136
- package/dist/setupClient-BICl5fdX.js +13 -0
- package/dist/setupClient-nl8Dhh4V.cjs +13 -0
- package/dist/siweAuthenticate-BWmI2_TN.cjs +1 -0
- package/dist/{index-d8xS4ryI.d.ts → siweAuthenticate-CVigMOxz.d.cts} +113 -92
- package/dist/{index-C6FxkWPC.d.cts → siweAuthenticate-CnCZ7mok.d.ts} +113 -92
- package/dist/siweAuthenticate-zczqxm0a.js +1 -0
- package/dist/trackEvent-CeLFVzZn.js +1 -0
- package/dist/trackEvent-Ew5r5zfI.cjs +1 -0
- package/package.json +11 -22
- package/src/actions/displayEmbeddedWallet.ts +1 -0
- package/src/actions/displayModal.test.ts +12 -11
- package/src/actions/displayModal.ts +7 -18
- package/src/actions/ensureIdentity.ts +68 -0
- package/src/actions/{getProductInformation.test.ts → getMerchantInformation.test.ts} +33 -50
- package/src/actions/getMerchantInformation.ts +16 -0
- package/src/actions/index.ts +3 -2
- package/src/actions/openSso.ts +4 -2
- package/src/actions/referral/processReferral.test.ts +117 -242
- package/src/actions/referral/processReferral.ts +134 -204
- package/src/actions/referral/referralInteraction.test.ts +4 -12
- package/src/actions/referral/referralInteraction.ts +3 -13
- package/src/actions/sendInteraction.ts +46 -22
- package/src/actions/trackPurchaseStatus.test.ts +354 -141
- package/src/actions/trackPurchaseStatus.ts +48 -11
- package/src/actions/watchWalletStatus.ts +2 -3
- package/src/actions/wrapper/modalBuilder.test.ts +0 -14
- package/src/actions/wrapper/modalBuilder.ts +3 -12
- package/src/bundle.ts +0 -1
- package/src/clients/createIFrameFrakClient.ts +10 -5
- package/src/clients/transports/iframeLifecycleManager.test.ts +163 -4
- package/src/clients/transports/iframeLifecycleManager.ts +172 -33
- package/src/constants/interactionTypes.ts +12 -41
- package/src/index.ts +27 -16
- package/src/types/config.ts +6 -0
- package/src/types/context.ts +48 -6
- package/src/types/index.ts +15 -11
- package/src/types/lifecycle/client.ts +24 -1
- package/src/types/lifecycle/iframe.ts +6 -0
- package/src/types/rpc/displayModal.ts +2 -4
- package/src/types/rpc/embedded/index.ts +2 -2
- package/src/types/rpc/interaction.ts +31 -39
- package/src/types/rpc/merchantInformation.ts +77 -0
- package/src/types/rpc/modal/index.ts +0 -4
- package/src/types/rpc/modal/login.ts +5 -1
- package/src/types/rpc/walletStatus.ts +1 -7
- package/src/types/rpc.ts +22 -30
- package/src/types/tracking.ts +31 -0
- package/src/utils/FrakContext.test.ts +270 -186
- package/src/utils/FrakContext.ts +78 -56
- package/src/utils/backendUrl.test.ts +83 -0
- package/src/utils/backendUrl.ts +62 -0
- package/src/utils/clientId.test.ts +41 -0
- package/src/utils/clientId.ts +43 -0
- package/src/utils/compression/compress.test.ts +1 -1
- package/src/utils/compression/compress.ts +2 -2
- package/src/utils/compression/decompress.test.ts +8 -4
- package/src/utils/compression/decompress.ts +2 -2
- package/src/utils/{computeProductId.ts → computeLegacyProductId.ts} +2 -2
- package/src/utils/constants.ts +5 -0
- package/src/utils/deepLinkWithFallback.test.ts +243 -0
- package/src/utils/deepLinkWithFallback.ts +103 -0
- package/src/utils/formatAmount.ts +6 -0
- package/src/utils/iframeHelper.test.ts +18 -5
- package/src/utils/iframeHelper.ts +10 -3
- package/src/utils/index.ts +16 -1
- package/src/utils/merchantId.test.ts +653 -0
- package/src/utils/merchantId.ts +143 -0
- package/src/utils/sso.ts +18 -11
- package/src/utils/trackEvent.test.ts +23 -5
- package/src/utils/trackEvent.ts +13 -0
- package/cdn/bundle.iife.js +0 -14
- package/dist/actions-B5j-i1p0.cjs +0 -1
- package/dist/actions-q090Z0oR.js +0 -1
- package/dist/index-7OZ39x1U.d.ts +0 -195
- package/dist/index-CRsQWnTs.d.cts +0 -351
- package/dist/index-Ck1hudEi.d.ts +0 -351
- package/dist/index-zDq-VlKx.d.cts +0 -195
- package/dist/interaction-DMJ3ZfaF.d.cts +0 -45
- package/dist/interaction-KX1h9a7V.d.ts +0 -45
- package/dist/interactions-DnfM3oe0.js +0 -1
- package/dist/interactions-EIXhNLf6.cjs +0 -1
- package/dist/interactions.cjs +0 -1
- package/dist/interactions.d.cts +0 -2
- package/dist/interactions.d.ts +0 -2
- package/dist/interactions.js +0 -1
- package/dist/productTypes-BUkXJKZ7.cjs +0 -1
- package/dist/productTypes-CGb1MmBF.js +0 -1
- package/dist/src-1LQ4eLq5.js +0 -13
- package/dist/src-hW71KjPN.cjs +0 -13
- package/dist/trackEvent-CHnYa85W.js +0 -1
- package/dist/trackEvent-GuQm_1Nm.cjs +0 -1
- package/src/actions/getProductInformation.ts +0 -14
- package/src/actions/openSso.test.ts +0 -407
- package/src/actions/sendInteraction.test.ts +0 -219
- package/src/constants/interactionTypes.test.ts +0 -128
- package/src/constants/productTypes.test.ts +0 -130
- package/src/constants/productTypes.ts +0 -33
- package/src/interactions/index.ts +0 -5
- package/src/interactions/pressEncoder.test.ts +0 -215
- package/src/interactions/pressEncoder.ts +0 -53
- package/src/interactions/purchaseEncoder.test.ts +0 -291
- package/src/interactions/purchaseEncoder.ts +0 -99
- package/src/interactions/referralEncoder.test.ts +0 -170
- package/src/interactions/referralEncoder.ts +0 -47
- package/src/interactions/retailEncoder.test.ts +0 -107
- package/src/interactions/retailEncoder.ts +0 -37
- package/src/interactions/webshopEncoder.test.ts +0 -56
- package/src/interactions/webshopEncoder.ts +0 -30
- package/src/types/rpc/modal/openSession.ts +0 -25
- package/src/types/rpc/productInformation.ts +0 -59
- package/src/utils/computeProductId.test.ts +0 -80
- package/src/utils/sso.test.ts +0 -361
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { n as SendInteractionParamsType, r as SendInteractionReturnType } from "./interaction-KX1h9a7V.js";
|
|
3
|
-
import { Hex } from "viem";
|
|
1
|
+
import { A as SendTransactionModalStepType, B as PrepareSsoReturnType, E as ModalRpcMetadata, F as SiweAuthenticationParams, H as FinalActionType, I as LoginModalStepType, O as ModalRpcStepsResultType, P as SiweAuthenticateReturnType, T as DisplayModalParamsType, U as FinalModalStepType, b as DisplayEmbeddedWalletResultType, h as GetMerchantInformationReturnType, i as FrakContext, j as SendTransactionReturnType, k as ModalStepTypes, l as FrakClient, p as WalletStatusReturnType, v as SendInteractionParamsType, y as DisplayEmbeddedWalletParamsType, z as PrepareSsoParamsType } from "./openSso-B0g7-807.cjs";
|
|
4
2
|
|
|
5
3
|
//#region src/actions/displayEmbeddedWallet.d.ts
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* Function used to display the Frak embedded wallet popup
|
|
9
6
|
* @param client - The current Frak Client
|
|
10
7
|
* @param params - The parameter used to customise the embedded wallet
|
|
8
|
+
* @returns The embedded wallet display result
|
|
11
9
|
*/
|
|
12
10
|
declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
|
|
13
11
|
//#endregion
|
|
@@ -24,26 +22,22 @@ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbedd
|
|
|
24
22
|
*
|
|
25
23
|
* @remarks
|
|
26
24
|
* - The UI of the displayed modal can be configured with the `customCss` property in the `customizations.css` field of the top-level config.
|
|
27
|
-
* - The `login`
|
|
25
|
+
* - The `login` step will be automatically skipped if the user is already logged in. It's safe to include this step in all cases to ensure proper user state.
|
|
28
26
|
* - Steps are automatically reordered in the following sequence:
|
|
29
27
|
* 1. `login` (if needed)
|
|
30
|
-
* 2.
|
|
31
|
-
* 3.
|
|
32
|
-
* 4. `success` (if included, always last)
|
|
28
|
+
* 2. All other steps in the order specified
|
|
29
|
+
* 3. `success` (if included, always last)
|
|
33
30
|
*
|
|
34
31
|
* @example
|
|
35
32
|
* Simple sharing modal with steps:
|
|
36
33
|
* 1. Login (Skipped if already logged in)
|
|
37
|
-
* 2.
|
|
38
|
-
* 3. Display a success message with sharing link option
|
|
34
|
+
* 2. Display a success message with sharing link option
|
|
39
35
|
*
|
|
40
36
|
* ```ts
|
|
41
37
|
* const results = await displayModal(frakConfig, {
|
|
42
38
|
* steps: {
|
|
43
39
|
* // Simple login with no SSO, nor customization
|
|
44
40
|
* login: { allowSso: false },
|
|
45
|
-
* // Simple session opening, with no customization
|
|
46
|
-
* openSession: {},
|
|
47
41
|
* // Success message
|
|
48
42
|
* final: {
|
|
49
43
|
* action: { key: "reward" },
|
|
@@ -54,19 +48,14 @@ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbedd
|
|
|
54
48
|
* });
|
|
55
49
|
*
|
|
56
50
|
* console.log("Login step - wallet", results.login.wallet);
|
|
57
|
-
* console.log("Open session step - start + end", {
|
|
58
|
-
* start: results.openSession.startTimestamp,
|
|
59
|
-
* end: results.openSession.endTimestamp,
|
|
60
|
-
* });
|
|
61
51
|
* ```
|
|
62
52
|
*
|
|
63
53
|
* @example
|
|
64
54
|
* A full modal example, with a few customization options, with the steps:
|
|
65
55
|
* 1. Login (Skipped if already logged in)
|
|
66
|
-
* 2.
|
|
67
|
-
* 3.
|
|
68
|
-
* 4.
|
|
69
|
-
* 5. Display a success message with sharing link options
|
|
56
|
+
* 2. Authenticate via SIWE
|
|
57
|
+
* 3. Send a transaction
|
|
58
|
+
* 4. Display a success message with sharing link options
|
|
70
59
|
*
|
|
71
60
|
* ```ts
|
|
72
61
|
* const results = await displayModal(frakConfig, {
|
|
@@ -79,8 +68,6 @@ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbedd
|
|
|
79
68
|
* homepageLink: "https://my-app.com",
|
|
80
69
|
* },
|
|
81
70
|
* },
|
|
82
|
-
* // Simple session opening, with no customisation
|
|
83
|
-
* openSession: {},
|
|
84
71
|
* // Siwe authentication
|
|
85
72
|
* siweAuthenticate: {
|
|
86
73
|
* siwe: {
|
|
@@ -130,13 +117,40 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
|
|
|
130
117
|
metadata
|
|
131
118
|
}: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
|
|
132
119
|
//#endregion
|
|
133
|
-
//#region src/actions/
|
|
120
|
+
//#region src/actions/ensureIdentity.d.ts
|
|
134
121
|
/**
|
|
135
|
-
*
|
|
122
|
+
* Ensure the current wallet ↔ clientId link exists on the backend.
|
|
123
|
+
*
|
|
124
|
+
* Called automatically by {@link watchWalletStatus} when a connected wallet
|
|
125
|
+
* status is received. Acts as a failsafe: if the primary merge (SSO, pairing,
|
|
126
|
+
* login/register) missed or silently failed, this ensures the link is
|
|
127
|
+
* eventually established.
|
|
128
|
+
*
|
|
129
|
+
* The call is:
|
|
130
|
+
* - **Idempotent** — if already linked, backend returns immediately
|
|
131
|
+
* - **Deduplicated** — only fires once per browser session per merchant
|
|
132
|
+
* - **Fire-and-forget** — errors are logged but never thrown
|
|
133
|
+
*
|
|
134
|
+
* @param interactionToken - The SDK JWT from wallet status (x-wallet-sdk-auth)
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* // Usually called automatically via watchWalletStatus side effect.
|
|
139
|
+
* // Can also be called manually if needed:
|
|
140
|
+
* await ensureIdentity("eyJhbGciOi...");
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function ensureIdentity(interactionToken: string): Promise<void>;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/actions/getMerchantInformation.d.ts
|
|
146
|
+
/**
|
|
147
|
+
* Fetch the current merchant information (name, rewards, tiers) from the wallet iframe
|
|
136
148
|
* @param client - The current Frak Client
|
|
137
|
-
* @returns The
|
|
149
|
+
* @returns The merchant information including available reward tiers
|
|
150
|
+
*
|
|
151
|
+
* @see {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`} for the return type shape
|
|
138
152
|
*/
|
|
139
|
-
declare function
|
|
153
|
+
declare function getMerchantInformation(client: FrakClient): Promise<GetMerchantInformationReturnType>;
|
|
140
154
|
//#endregion
|
|
141
155
|
//#region src/actions/prepareSso.d.ts
|
|
142
156
|
/**
|
|
@@ -174,69 +188,60 @@ declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Pro
|
|
|
174
188
|
//#endregion
|
|
175
189
|
//#region src/actions/referral/processReferral.d.ts
|
|
176
190
|
/**
|
|
177
|
-
*
|
|
178
|
-
* @inline
|
|
179
|
-
*/
|
|
180
|
-
type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
|
|
181
|
-
/**
|
|
182
|
-
* Options for the referral auto-interaction process
|
|
191
|
+
* Options for the referral auto-interaction process.
|
|
183
192
|
*/
|
|
184
193
|
type ProcessReferralOptions = {
|
|
185
194
|
/**
|
|
186
|
-
* If
|
|
195
|
+
* If true, always replace the URL with the current user's referral context
|
|
196
|
+
* so the next visitor gets referred by this user.
|
|
187
197
|
* @defaultValue false
|
|
188
198
|
*/
|
|
189
199
|
alwaysAppendUrl?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Merchant ID for building the current user's referral context.
|
|
202
|
+
* Required when `alwaysAppendUrl` is true and the incoming context is V1.
|
|
203
|
+
* For V2 contexts, the merchantId is already embedded in the context.
|
|
204
|
+
*/
|
|
205
|
+
merchantId?: string;
|
|
190
206
|
};
|
|
191
207
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
208
|
+
* The different states of the referral process.
|
|
209
|
+
* @inline
|
|
210
|
+
*/
|
|
211
|
+
type ReferralState = "idle" | "processing" | "success" | "no-referrer" | "self-referral";
|
|
212
|
+
/**
|
|
213
|
+
* Handle the full referral interaction flow:
|
|
214
|
+
*
|
|
215
|
+
* 1. Check if the user has been referred (if not, early exit)
|
|
216
|
+
* 2. Preflight self-referral check (if yes, early exit)
|
|
217
|
+
* 3. Track the arrival event
|
|
218
|
+
* 4. Replace the current URL with the user's own referral context
|
|
219
|
+
* 5. Return the resulting referral state
|
|
204
220
|
*
|
|
205
221
|
* @param client - The current Frak Client
|
|
206
222
|
* @param args
|
|
207
223
|
* @param args.walletStatus - The current user wallet status
|
|
208
|
-
* @param args.frakContext - The
|
|
209
|
-
* @param args.
|
|
210
|
-
* @
|
|
211
|
-
* @param args.options - Some options for the referral interaction
|
|
212
|
-
* @returns A promise with the resulting referral state
|
|
224
|
+
* @param args.frakContext - The referral context parsed from the URL
|
|
225
|
+
* @param args.options - Options for URL replacement and merchant context
|
|
226
|
+
* @returns The referral state
|
|
213
227
|
*
|
|
214
|
-
* @see {@link
|
|
215
|
-
* @see {@link sendInteraction} for more details on the interaction submission part
|
|
216
|
-
* @see {@link ReferralInteractionEncoder} for more details about the referred interaction
|
|
217
|
-
* @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
|
|
228
|
+
* @see {@link @frak-labs/core-sdk!ModalStepTypes} for modal step types
|
|
218
229
|
*/
|
|
219
230
|
declare function processReferral(client: FrakClient, {
|
|
220
231
|
walletStatus,
|
|
221
232
|
frakContext,
|
|
222
|
-
modalConfig,
|
|
223
|
-
productId,
|
|
224
233
|
options
|
|
225
234
|
}: {
|
|
226
235
|
walletStatus?: WalletStatusReturnType;
|
|
227
|
-
frakContext?:
|
|
228
|
-
modalConfig?: DisplayEmbeddedWalletParamsType;
|
|
229
|
-
productId?: Hex;
|
|
236
|
+
frakContext?: FrakContext | null;
|
|
230
237
|
options?: ProcessReferralOptions;
|
|
231
|
-
}):
|
|
238
|
+
}): ReferralState;
|
|
232
239
|
//#endregion
|
|
233
240
|
//#region src/actions/referral/referralInteraction.d.ts
|
|
234
241
|
/**
|
|
235
|
-
* Function used to
|
|
242
|
+
* Function used to handle referral interactions
|
|
236
243
|
* @param client - The current Frak Client
|
|
237
244
|
* @param args
|
|
238
|
-
* @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
|
|
239
|
-
* @param args.modalConfig - The modal configuration to display if the user is not logged in
|
|
240
245
|
* @param args.options - Some options for the referral interaction
|
|
241
246
|
*
|
|
242
247
|
* @returns A promise with the resulting referral state, or undefined in case of an error
|
|
@@ -244,38 +249,53 @@ declare function processReferral(client: FrakClient, {
|
|
|
244
249
|
* @description This function will automatically handle the referral interaction process
|
|
245
250
|
*
|
|
246
251
|
* @see {@link processReferral} for more details on the automatic referral handling process
|
|
247
|
-
* @see {@link @frak-labs/core-sdk!ModalStepTypes} for more details on each modal steps types
|
|
248
252
|
*/
|
|
249
253
|
declare function referralInteraction(client: FrakClient, {
|
|
250
|
-
productId,
|
|
251
|
-
modalConfig,
|
|
252
254
|
options
|
|
253
255
|
}?: {
|
|
254
|
-
productId?: Hex;
|
|
255
|
-
modalConfig?: DisplayEmbeddedWalletParamsType;
|
|
256
256
|
options?: ProcessReferralOptions;
|
|
257
|
-
}): Promise<("
|
|
257
|
+
}): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
|
|
258
258
|
//#endregion
|
|
259
259
|
//#region src/actions/sendInteraction.d.ts
|
|
260
260
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
261
|
+
* Send an interaction to the backend via the listener RPC.
|
|
262
|
+
* Fire-and-forget: errors are caught and logged, not thrown.
|
|
263
|
+
*
|
|
264
|
+
* @param client - The Frak client instance
|
|
265
|
+
* @param params - The interaction parameters
|
|
266
|
+
*
|
|
267
|
+
* @description Sends a user interaction event through the wallet iframe RPC. Supports three interaction types: arrival tracking, sharing events, and custom interactions.
|
|
264
268
|
*
|
|
265
269
|
* @example
|
|
266
|
-
*
|
|
267
|
-
*
|
|
270
|
+
* Track a user arrival with referral attribution:
|
|
271
|
+
* ```ts
|
|
272
|
+
* await sendInteraction(client, {
|
|
273
|
+
* type: "arrival",
|
|
274
|
+
* referrerWallet: "0x1234...abcd",
|
|
275
|
+
* landingUrl: window.location.href,
|
|
276
|
+
* utmSource: "twitter",
|
|
277
|
+
* utmMedium: "social",
|
|
278
|
+
* utmCampaign: "launch-2026",
|
|
268
279
|
* });
|
|
269
|
-
*
|
|
270
|
-
*
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* Track a sharing event:
|
|
284
|
+
* ```ts
|
|
285
|
+
* await sendInteraction(client, { type: "sharing" });
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* Send a custom interaction:
|
|
290
|
+
* ```ts
|
|
291
|
+
* await sendInteraction(client, {
|
|
292
|
+
* type: "custom",
|
|
293
|
+
* customType: "newsletter_signup",
|
|
294
|
+
* data: { email: "user@example.com" },
|
|
271
295
|
* });
|
|
272
|
-
*
|
|
296
|
+
* ```
|
|
273
297
|
*/
|
|
274
|
-
declare function sendInteraction(client: FrakClient,
|
|
275
|
-
productId,
|
|
276
|
-
interaction,
|
|
277
|
-
validation
|
|
278
|
-
}: SendInteractionParamsType): Promise<SendInteractionReturnType>;
|
|
298
|
+
declare function sendInteraction(client: FrakClient, params: SendInteractionParamsType): Promise<void>;
|
|
279
299
|
//#endregion
|
|
280
300
|
//#region src/actions/trackPurchaseStatus.d.ts
|
|
281
301
|
/**
|
|
@@ -285,6 +305,7 @@ declare function sendInteraction(client: FrakClient, {
|
|
|
285
305
|
* @param args.customerId - The customer id that made the purchase (on your side)
|
|
286
306
|
* @param args.orderId - The order id of the purchase (on your side)
|
|
287
307
|
* @param args.token - The token of the purchase
|
|
308
|
+
* @param args.merchantId - Optional explicit merchant id to use for the tracking request
|
|
288
309
|
*
|
|
289
310
|
* @description This function will send a request to the backend to listen for the purchase status.
|
|
290
311
|
*
|
|
@@ -294,19 +315,23 @@ declare function sendInteraction(client: FrakClient, {
|
|
|
294
315
|
* customerId: checkout.order.customer.id,
|
|
295
316
|
* orderId: checkout.order.id,
|
|
296
317
|
* token: checkout.token,
|
|
318
|
+
* merchantId: "your-merchant-id",
|
|
297
319
|
* };
|
|
298
320
|
*
|
|
299
321
|
* await trackPurchaseStatus(payload);
|
|
300
322
|
* }
|
|
301
323
|
*
|
|
302
324
|
* @remarks
|
|
303
|
-
* -
|
|
304
|
-
* - This function
|
|
325
|
+
* - Merchant id is resolved in this order: explicit `args.merchantId`, `frak-merchant-id` from session storage, then `fetchMerchantId()`.
|
|
326
|
+
* - This function supports anonymous users and will use the `x-frak-client-id` header when available.
|
|
327
|
+
* - At least one identity source must exist (`frak-wallet-interaction-token` or `x-frak-client-id`), otherwise the tracking request is skipped.
|
|
328
|
+
* - This function will print a warning if used in a non-browser environment or if no identity / merchant id can be resolved.
|
|
305
329
|
*/
|
|
306
330
|
declare function trackPurchaseStatus(args: {
|
|
307
331
|
customerId: string | number;
|
|
308
332
|
orderId: string | number;
|
|
309
333
|
token: string;
|
|
334
|
+
merchantId?: string;
|
|
310
335
|
}): Promise<void>;
|
|
311
336
|
//#endregion
|
|
312
337
|
//#region src/actions/watchWalletStatus.d.ts
|
|
@@ -322,7 +347,6 @@ declare function trackPurchaseStatus(args: {
|
|
|
322
347
|
* await watchWalletStatus(frakConfig, (status: WalletStatusReturnType) => {
|
|
323
348
|
* if (status.key === "connected") {
|
|
324
349
|
* console.log("Wallet connected:", status.wallet);
|
|
325
|
-
* console.log("Current interaction session:", status.interactionSession);
|
|
326
350
|
* } else {
|
|
327
351
|
* console.log("Wallet not connected");
|
|
328
352
|
* }
|
|
@@ -362,16 +386,15 @@ type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
|
362
386
|
/**
|
|
363
387
|
* Represent the output type of the modal builder
|
|
364
388
|
*/
|
|
365
|
-
type ModalBuilder = ModalStepBuilder<[LoginModalStepType
|
|
389
|
+
type ModalBuilder = ModalStepBuilder<[LoginModalStepType]>;
|
|
366
390
|
/**
|
|
367
391
|
* Helper to craft Frak modal, and share a base initial config
|
|
368
392
|
* @param client - The current Frak Client
|
|
369
393
|
* @param args
|
|
370
394
|
* @param args.metadata - Common modal metadata (customisation, language etc)
|
|
371
395
|
* @param args.login - Login step parameters
|
|
372
|
-
* @param args.openSession - Open session step parameters
|
|
373
396
|
*
|
|
374
|
-
* @description This function will create a modal builder with the provided metadata
|
|
397
|
+
* @description This function will create a modal builder with the provided metadata and login parameters.
|
|
375
398
|
*
|
|
376
399
|
* @example
|
|
377
400
|
* Here is an example of how to use the `modalBuilder` to create and display a sharing modal:
|
|
@@ -400,12 +423,10 @@ type ModalBuilder = ModalStepBuilder<[LoginModalStepType, OpenInteractionSession
|
|
|
400
423
|
*/
|
|
401
424
|
declare function modalBuilder(client: FrakClient, {
|
|
402
425
|
metadata,
|
|
403
|
-
login
|
|
404
|
-
openSession
|
|
426
|
+
login
|
|
405
427
|
}: {
|
|
406
428
|
metadata?: ModalRpcMetadata;
|
|
407
429
|
login?: LoginModalStepType["params"];
|
|
408
|
-
openSession?: OpenInteractionSessionModalStepType["params"];
|
|
409
430
|
}): ModalBuilder;
|
|
410
431
|
//#endregion
|
|
411
432
|
//#region src/actions/wrapper/sendTransaction.d.ts
|
|
@@ -508,4 +529,4 @@ declare function siweAuthenticate(client: FrakClient, {
|
|
|
508
529
|
metadata
|
|
509
530
|
}: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
|
|
510
531
|
//#endregion
|
|
511
|
-
export {
|
|
532
|
+
export { displayModal as _, ModalBuilder as a, watchWalletStatus as c, referralInteraction as d, ProcessReferralOptions as f, ensureIdentity as g, getMerchantInformation as h, sendTransaction as i, trackPurchaseStatus as l, prepareSso as m, siweAuthenticate as n, ModalStepBuilder as o, processReferral as p, SendTransactionParams as r, modalBuilder as s, SiweAuthenticateModalParams as t, sendInteraction as u, displayEmbeddedWallet as v };
|