@frak-labs/core-sdk 1.0.2-beta.64c76510 → 1.0.2-beta.75bb63ae

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 (88) hide show
  1. package/README.md +0 -1
  2. package/package.json +4 -4
  3. package/src/actions/ensureIdentity.ts +3 -3
  4. package/src/actions/openSso.ts +4 -4
  5. package/src/actions/referral/processReferral.test.ts +38 -22
  6. package/src/actions/referral/processReferral.ts +6 -4
  7. package/src/actions/referral/referralInteraction.test.ts +7 -7
  8. package/src/actions/referral/referralInteraction.ts +1 -1
  9. package/src/actions/sendInteraction.ts +1 -1
  10. package/src/actions/trackPurchaseStatus.test.ts +4 -4
  11. package/src/actions/trackPurchaseStatus.ts +3 -3
  12. package/src/actions/wrapper/siweAuthenticate.test.ts +1 -5
  13. package/src/actions/wrapper/siweAuthenticate.ts +25 -1
  14. package/src/clients/createIFrameFrakClient.ts +5 -21
  15. package/src/clients/index.ts +0 -1
  16. package/src/clients/transports/iframeLifecycleManager.test.ts +10 -10
  17. package/src/clients/transports/iframeLifecycleManager.ts +3 -3
  18. package/src/config/index.ts +3 -0
  19. package/src/{utils → config}/sdkConfigStore.ts +1 -1
  20. package/src/{utils/constants.test.ts → constants.test.ts} +1 -6
  21. package/src/context/address.ts +76 -0
  22. package/src/{utils/FrakContext.test.ts → context/frakContext.test.ts} +4 -2
  23. package/src/{utils/FrakContext.ts → context/frakContext.ts} +4 -4
  24. package/src/{utils → context}/frakContextV2Codec.test.ts +1 -1
  25. package/src/{utils → context}/frakContextV2Codec.ts +6 -6
  26. package/src/context/index.ts +6 -0
  27. package/src/index.ts +17 -22
  28. package/src/stubs/rrweb.ts +8 -4
  29. package/src/types/client.ts +0 -3
  30. package/src/types/config.ts +11 -0
  31. package/src/types/index.ts +1 -0
  32. package/src/utils/{deepLinkWithFallback.ts → browser/deepLinkWithFallback.ts} +1 -1
  33. package/src/utils/{inAppBrowser.ts → browser/inAppBrowser.ts} +13 -0
  34. package/src/utils/browser/index.ts +13 -0
  35. package/src/utils/{formatAmount.test.ts → format/formatAmount.test.ts} +1 -1
  36. package/src/utils/{formatAmount.ts → format/formatAmount.ts} +1 -1
  37. package/src/utils/{getCurrencyAmountKey.test.ts → format/getCurrencyAmountKey.test.ts} +2 -2
  38. package/src/utils/{getCurrencyAmountKey.ts → format/getCurrencyAmountKey.ts} +1 -1
  39. package/src/utils/{getSupportedCurrency.test.ts → format/getSupportedCurrency.test.ts} +2 -2
  40. package/src/utils/{getSupportedCurrency.ts → format/getSupportedCurrency.ts} +2 -2
  41. package/src/utils/{getSupportedLocale.test.ts → format/getSupportedLocale.test.ts} +3 -3
  42. package/src/utils/{getSupportedLocale.ts → format/getSupportedLocale.ts} +2 -2
  43. package/src/utils/format/index.ts +4 -0
  44. package/src/utils/{iframeHelper.test.ts → iframe/iframeHelper.test.ts} +3 -3
  45. package/src/utils/{iframeHelper.ts → iframe/iframeHelper.ts} +3 -3
  46. package/src/utils/iframe/index.ts +6 -0
  47. package/src/utils/index.ts +31 -24
  48. package/src/utils/sso/index.ts +6 -0
  49. package/src/utils/{sso.ts → sso/sso.ts} +2 -2
  50. package/cdn/bundle.js +0 -14
  51. package/dist/actions-DihYM-OG.js +0 -1
  52. package/dist/actions-cYbmqewX.cjs +0 -1
  53. package/dist/actions.cjs +0 -1
  54. package/dist/actions.d.cts +0 -3
  55. package/dist/actions.d.ts +0 -3
  56. package/dist/actions.js +0 -1
  57. package/dist/bundle.cjs +0 -1
  58. package/dist/bundle.d.cts +0 -4
  59. package/dist/bundle.d.ts +0 -4
  60. package/dist/bundle.js +0 -1
  61. package/dist/index-BhBuaCRl.d.cts +0 -707
  62. package/dist/index-BsBbSMxk.d.cts +0 -646
  63. package/dist/index-CeX1Tl7W.d.ts +0 -707
  64. package/dist/index-quaxtKRh.d.ts +0 -646
  65. package/dist/index.cjs +0 -1
  66. package/dist/index.d.cts +0 -3
  67. package/dist/index.d.ts +0 -3
  68. package/dist/index.js +0 -1
  69. package/dist/openSso-DyUQew2K.d.ts +0 -1392
  70. package/dist/openSso-rQhLhPbq.d.cts +0 -1392
  71. package/dist/sdkConfigStore-BXzz5PlK.js +0 -1
  72. package/dist/sdkConfigStore-DDL_fjYX.cjs +0 -1
  73. package/dist/src-CMaRNkkJ.cjs +0 -13
  74. package/dist/src-DMFOQMm6.js +0 -13
  75. package/src/clients/DebugInfo.test.ts +0 -418
  76. package/src/clients/DebugInfo.ts +0 -182
  77. package/src/utils/computeLegacyProductId.ts +0 -11
  78. /package/src/{utils → clients}/ssoUrlListener.test.ts +0 -0
  79. /package/src/{utils → clients}/ssoUrlListener.ts +0 -0
  80. /package/src/{utils → config}/backendUrl.test.ts +0 -0
  81. /package/src/{utils → config}/backendUrl.ts +0 -0
  82. /package/src/{utils → config}/clientId.test.ts +0 -0
  83. /package/src/{utils → config}/clientId.ts +0 -0
  84. /package/src/{utils → config}/sdkConfigStore.test.ts +0 -0
  85. /package/src/{utils/constants.ts → constants.ts} +0 -0
  86. /package/src/{utils → context}/mergeAttribution.test.ts +0 -0
  87. /package/src/{utils → context}/mergeAttribution.ts +0 -0
  88. /package/src/utils/{deepLinkWithFallback.test.ts → browser/deepLinkWithFallback.test.ts} +0 -0
@@ -1,646 +0,0 @@
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-DyUQew2K.js";
2
-
3
- //#region src/actions/displayEmbeddedWallet.d.ts
4
- /**
5
- * Function used to display the Frak embedded wallet popup
6
- * @param client - The current Frak Client
7
- * @param params - The parameter used to customise the embedded wallet
8
- * @param placement - Optional placement ID to associate with this display request
9
- * @returns The embedded wallet display result
10
- */
11
- declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType, placement?: string): Promise<DisplayEmbeddedWalletResultType>;
12
- //#endregion
13
- //#region src/actions/displayModal.d.ts
14
- /**
15
- * Function used to display a modal
16
- * @param client - The current Frak Client
17
- * @param args
18
- * @param args.steps - The different steps of the modal
19
- * @param args.metadata - The metadata for the modal (customization, etc)
20
- * @param placement - Optional placement ID to associate with this modal display
21
- * @returns The result of each modal steps
22
- *
23
- * @description This function will display a modal to the user with the provided steps and metadata.
24
- *
25
- * @remarks
26
- * - 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` 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
- * - Steps are automatically reordered in the following sequence:
29
- * 1. `login` (if needed)
30
- * 2. All other steps in the order specified
31
- * 3. `success` (if included, always last)
32
- *
33
- * @example
34
- * Simple sharing modal with steps:
35
- * 1. Login (Skipped if already logged in)
36
- * 2. Display a success message with sharing link option
37
- *
38
- * ```ts
39
- * const results = await displayModal(frakConfig, {
40
- * steps: {
41
- * // Simple login with no SSO, nor customization
42
- * login: { allowSso: false },
43
- * // Success message
44
- * final: {
45
- * action: { key: "reward" },
46
- * // Skip this step, it will be only displayed in the stepper within the modal
47
- * autoSkip: true,
48
- * },
49
- * },
50
- * });
51
- *
52
- * console.log("Login step - wallet", results.login.wallet);
53
- * ```
54
- *
55
- * @example
56
- * A full modal example, with a few customization options, with the steps:
57
- * 1. Login (Skipped if already logged in)
58
- * 2. Authenticate via SIWE
59
- * 3. Send a transaction
60
- * 4. Display a success message with sharing link options
61
- *
62
- * ```ts
63
- * const results = await displayModal(frakConfig, {
64
- * steps: {
65
- * // Login step
66
- * login: {
67
- * allowSso: true,
68
- * ssoMetadata: {
69
- * logoUrl: "https://my-app.com/logo.png",
70
- * homepageLink: "https://my-app.com",
71
- * },
72
- * },
73
- * // Siwe authentication
74
- * siweAuthenticate: {
75
- * siwe: {
76
- * domain: "my-app.com",
77
- * uri: "https://my-app.com/",
78
- * nonce: generateSiweNonce(),
79
- * version: "1",
80
- * },
81
- * },
82
- * // Send batched transaction
83
- * sendTransaction: {
84
- * tx: [
85
- * { to: "0xdeadbeef", data: "0xdeadbeef" },
86
- * { to: "0xdeadbeef", data: "0xdeadbeef" },
87
- * ],
88
- * },
89
- * // Success message with sharing options
90
- * final: {
91
- * action: {
92
- * key: "sharing",
93
- * options: {
94
- * popupTitle: "Share the app",
95
- * text: "Discover my super app website",
96
- * link: "https://my-app.com",
97
- * },
98
- * },
99
- * dismissedMetadata: {
100
- * title: "Dismiss",
101
- * description: "You won't be rewarded for this sharing action",
102
- * },
103
- * },
104
- * },
105
- * metadata: {
106
- * // Header of desktop modals
107
- * header: {
108
- * title: "My-App",
109
- * icon: "https://my-app.com/logo.png",
110
- * },
111
- * // Context that will be present in every modal steps
112
- * context: "My-app overkill flow",
113
- * },
114
- * });
115
- * ```
116
- */
117
- declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, {
118
- steps,
119
- metadata
120
- }: DisplayModalParamsType<T>, placement?: string): Promise<ModalRpcStepsResultType<T>>;
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
156
- //#region src/actions/ensureIdentity.d.ts
157
- /**
158
- * Ensure the current wallet ↔ clientId link exists on the backend.
159
- *
160
- * Called automatically by {@link watchWalletStatus} when a connected wallet
161
- * status is received. Acts as a failsafe: if the primary merge (SSO, pairing,
162
- * login/register) missed or silently failed, this ensures the link is
163
- * eventually established.
164
- *
165
- * The call is:
166
- * - **Idempotent** — if already linked, backend returns immediately
167
- * - **Deduplicated** — only fires once per browser session per merchant
168
- * - **Fire-and-forget** — errors are logged but never thrown
169
- *
170
- * @param interactionToken - The SDK JWT from wallet status (x-wallet-sdk-auth)
171
- *
172
- * @example
173
- * ```ts
174
- * // Usually called automatically via watchWalletStatus side effect.
175
- * // Can also be called manually if needed:
176
- * await ensureIdentity("eyJhbGciOi...");
177
- * ```
178
- */
179
- declare function ensureIdentity(interactionToken: string): Promise<void>;
180
- //#endregion
181
- //#region src/actions/getMerchantInformation.d.ts
182
- /**
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
- *
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.
191
- * @returns The merchant information including available reward tiers
192
- *
193
- * @see {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`} for the return type shape
194
- */
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>;
247
- //#endregion
248
- //#region src/actions/prepareSso.d.ts
249
- /**
250
- * Generate SSO URL without opening popup
251
- *
252
- * This is a **synchronous**, client-side function that generates the SSO URL
253
- * without any RPC calls to the wallet iframe. Use this when you need:
254
- * - Custom URL modifications before opening popup
255
- * - Pre-generation for advanced popup strategies
256
- * - URL inspection/logging before SSO flow
257
- *
258
- * @param client - The current Frak Client
259
- * @param args - The SSO parameters
260
- * @returns Object containing the generated ssoUrl
261
- *
262
- * @example
263
- * ```ts
264
- * // Generate URL for inspection
265
- * const { ssoUrl } = prepareSso(client, {
266
- * metadata: { logoUrl: "..." },
267
- * directExit: true
268
- * });
269
- * console.log("Opening SSO:", ssoUrl);
270
- *
271
- * // Add custom params
272
- * const customUrl = `${ssoUrl}&tracking=abc123`;
273
- * await openSso(client, { metadata, ssoPopupUrl: customUrl });
274
- * ```
275
- *
276
- * @remarks
277
- * For most use cases, just use `openSso()` which handles URL generation automatically.
278
- * Only use `prepareSso()` when you need explicit control over the URL.
279
- */
280
- declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Promise<PrepareSsoReturnType>;
281
- //#endregion
282
- //#region src/actions/referral/processReferral.d.ts
283
- /**
284
- * Options for the referral auto-interaction process.
285
- */
286
- type ProcessReferralOptions = {
287
- /**
288
- * If true, always replace the URL with the current user's referral context
289
- * so the next visitor gets referred by this user.
290
- * @defaultValue false
291
- */
292
- alwaysAppendUrl?: boolean;
293
- /**
294
- * Merchant ID for building the current user's referral context.
295
- * Required when `alwaysAppendUrl` is true and the incoming context is V1.
296
- * For V2 contexts, the merchantId is already embedded in the context.
297
- */
298
- merchantId?: string;
299
- };
300
- /**
301
- * The different states of the referral process.
302
- * @inline
303
- */
304
- type ReferralState = "idle" | "processing" | "success" | "no-referrer" | "self-referral";
305
- /**
306
- * Handle the full referral interaction flow:
307
- *
308
- * 1. Check if the user has been referred (if not, early exit)
309
- * 2. Preflight self-referral check (if yes, early exit)
310
- * 3. Track the arrival event
311
- * 4. Replace the current URL with the user's own referral context
312
- * 5. Return the resulting referral state
313
- *
314
- * @param client - The current Frak Client
315
- * @param args
316
- * @param args.walletStatus - The current user wallet status
317
- * @param args.frakContext - The referral context parsed from the URL
318
- * @param args.options - Options for URL replacement and merchant context
319
- * @returns The referral state
320
- *
321
- * @see {@link @frak-labs/core-sdk!ModalStepTypes} for modal step types
322
- */
323
- declare function processReferral(client: FrakClient, {
324
- walletStatus,
325
- frakContext,
326
- options
327
- }: {
328
- walletStatus?: WalletStatusReturnType;
329
- frakContext?: FrakContext | null;
330
- options?: ProcessReferralOptions;
331
- }): ReferralState;
332
- //#endregion
333
- //#region src/actions/referral/referralInteraction.d.ts
334
- /**
335
- * Function used to handle referral interactions
336
- * @param client - The current Frak Client
337
- * @param args
338
- * @param args.options - Some options for the referral interaction
339
- *
340
- * @returns A promise with the resulting referral state, or undefined in case of an error
341
- *
342
- * @description This function will automatically handle the referral interaction process
343
- *
344
- * @see {@link processReferral} for more details on the automatic referral handling process
345
- */
346
- declare function referralInteraction(client: FrakClient, {
347
- options
348
- }?: {
349
- options?: ProcessReferralOptions;
350
- }): Promise<("idle" | "processing" | "success" | "no-referrer" | "self-referral") | undefined>;
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
372
- //#region src/actions/sendInteraction.d.ts
373
- /**
374
- * Send an interaction to the backend via the listener RPC.
375
- * Fire-and-forget: errors are caught and logged, not thrown.
376
- *
377
- * @param client - The Frak client instance
378
- * @param params - The interaction parameters
379
- *
380
- * @description Sends a user interaction event through the wallet iframe RPC. Supports three interaction types: arrival tracking, sharing events, and custom interactions.
381
- *
382
- * @example
383
- * Track a user arrival with referral attribution:
384
- * ```ts
385
- * await sendInteraction(client, {
386
- * type: "arrival",
387
- * referrerWallet: "0x1234...abcd",
388
- * landingUrl: window.location.href,
389
- * utmSource: "twitter",
390
- * utmMedium: "social",
391
- * utmCampaign: "launch-2026",
392
- * });
393
- * ```
394
- *
395
- * @example
396
- * Track a sharing event:
397
- * ```ts
398
- * await sendInteraction(client, { type: "sharing" });
399
- * ```
400
- *
401
- * @example
402
- * Send a custom interaction:
403
- * ```ts
404
- * await sendInteraction(client, {
405
- * type: "custom",
406
- * customType: "newsletter_signup",
407
- * data: { email: "user@example.com" },
408
- * });
409
- * ```
410
- */
411
- declare function sendInteraction(client: FrakClient, params: SendInteractionParamsType): Promise<void>;
412
- //#endregion
413
- //#region src/actions/trackPurchaseStatus.d.ts
414
- /**
415
- * Function used to track the status of a purchase
416
- * when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
417
- *
418
- * @param args.customerId - The customer id that made the purchase (on your side)
419
- * @param args.orderId - The order id of the purchase (on your side)
420
- * @param args.token - The token of the purchase
421
- * @param args.merchantId - Optional explicit merchant id to use for the tracking request
422
- *
423
- * @description This function will send a request to the backend to listen for the purchase status.
424
- *
425
- * @example
426
- * async function trackPurchase(checkout) {
427
- * const payload = {
428
- * customerId: checkout.order.customer.id,
429
- * orderId: checkout.order.id,
430
- * token: checkout.token,
431
- * merchantId: "your-merchant-id",
432
- * };
433
- *
434
- * await trackPurchaseStatus(payload);
435
- * }
436
- *
437
- * @remarks
438
- * - Merchant id is resolved in this order: explicit `args.merchantId`, then `sdkConfigStore.resolveMerchantId()` (config store → sessionStorage → backend fetch).
439
- * - This function supports anonymous users and will use the `x-frak-client-id` header when available.
440
- * - At least one identity source must exist (`frak-wallet-interaction-token` or `x-frak-client-id`), otherwise the tracking request is skipped.
441
- * - This function will print a warning if used in a non-browser environment or if no identity / merchant id can be resolved.
442
- */
443
- declare function trackPurchaseStatus(args: {
444
- customerId: string | number;
445
- orderId: string | number;
446
- token: string;
447
- merchantId?: string;
448
- }): Promise<void>;
449
- //#endregion
450
- //#region src/actions/watchWalletStatus.d.ts
451
- /**
452
- * Function used to watch the current frak wallet status
453
- * @param client - The current Frak Client
454
- * @param callback - The callback that will receive any wallet status change
455
- * @returns A promise resolving with the initial wallet status
456
- *
457
- * @description This function will return the current wallet status, and will listen to any change in the wallet status.
458
- *
459
- * @example
460
- * await watchWalletStatus(frakConfig, (status: WalletStatusReturnType) => {
461
- * if (status.key === "connected") {
462
- * console.log("Wallet connected:", status.wallet);
463
- * } else {
464
- * console.log("Wallet not connected");
465
- * }
466
- * });
467
- */
468
- declare function watchWalletStatus(client: FrakClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
469
- //#endregion
470
- //#region src/actions/wrapper/modalBuilder.d.ts
471
- /**
472
- * Represent the type of the modal step builder
473
- */
474
- type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
475
- /**
476
- * The current modal params
477
- */
478
- params: DisplayModalParamsType<Steps>;
479
- /**
480
- * Add a send transaction step to the modal
481
- */
482
- sendTx: (options: SendTransactionModalStepType["params"]) => ModalStepBuilder<[...Steps, SendTransactionModalStepType]>;
483
- /**
484
- * Add a final step of type reward to the modal
485
- */
486
- reward: (options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
487
- /**
488
- * Add a final step of type sharing to the modal
489
- */
490
- sharing: (sharingOptions?: Extract<FinalActionType, {
491
- key: "sharing";
492
- }>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
493
- /**
494
- * Display the modal
495
- * @param metadataOverride - Function returning optional metadata to override the current modal metadata
496
- * @param placement - Optional placement ID to associate with this modal display
497
- */
498
- display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined, placement?: string) => Promise<ModalRpcStepsResultType<Steps>>;
499
- };
500
- /**
501
- * Represent the output type of the modal builder
502
- */
503
- type ModalBuilder = ModalStepBuilder<[LoginModalStepType]>;
504
- /**
505
- * Helper to craft Frak modal, and share a base initial config
506
- * @param client - The current Frak Client
507
- * @param args
508
- * @param args.metadata - Common modal metadata (customisation, language etc)
509
- * @param args.login - Login step parameters
510
- *
511
- * @description This function will create a modal builder with the provided metadata and login parameters.
512
- *
513
- * @example
514
- * Here is an example of how to use the `modalBuilder` to create and display a sharing modal:
515
- *
516
- * ```js
517
- * // Create the modal builder
518
- * const modalBuilder = window.FrakSDK.modalBuilder(frakClient, baseModalConfig);
519
- *
520
- * // Configure the information to be shared via the sharing link
521
- * const sharingConfig = {
522
- * popupTitle: "Share this with your friends",
523
- * text: "Discover our product!",
524
- * link: window.location.href,
525
- * };
526
- *
527
- * // Display the sharing modal
528
- * function modalShare() {
529
- * modalBuilder.sharing(sharingConfig).display();
530
- * }
531
- * ```
532
- *
533
- * @see {@link ModalStepTypes} for more info about each modal step types and their parameters
534
- * @see {@link ModalRpcMetadata} for more info about the metadata that can be passed to the modal
535
- * @see {@link ModalRpcStepsResultType} for more info about the result of each modal steps
536
- * @see {@link displayModal} for more info about how the modal is displayed
537
- */
538
- declare function modalBuilder(client: FrakClient, {
539
- metadata,
540
- login
541
- }: {
542
- metadata?: ModalRpcMetadata;
543
- login?: LoginModalStepType["params"];
544
- }): ModalBuilder;
545
- //#endregion
546
- //#region src/actions/wrapper/sendTransaction.d.ts
547
- /**
548
- * Parameters to directly show a modal used to send a transaction
549
- * @inline
550
- */
551
- type SendTransactionParams = {
552
- /**
553
- * The transaction to be sent (either a single tx or multiple ones)
554
- */
555
- tx: SendTransactionModalStepType["params"]["tx"];
556
- /**
557
- * Custom metadata to be passed to the modal
558
- */
559
- metadata?: ModalRpcMetadata;
560
- };
561
- /**
562
- * Function used to send a user transaction, simple wrapper around the displayModal function to ease the send transaction process
563
- * @param client - The current Frak Client
564
- * @param args - The parameters
565
- * @returns The hash of the transaction that was sent in a promise
566
- *
567
- * @description This function will display a modal to the user with the provided transaction and metadata.
568
- *
569
- * @example
570
- * const { hash } = await sendTransaction(frakConfig, {
571
- * tx: {
572
- * to: "0xdeadbeef",
573
- * value: toHex(100n),
574
- * },
575
- * metadata: {
576
- * header: {
577
- * title: "Sending eth",
578
- * },
579
- * context: "Send 100wei to 0xdeadbeef",
580
- * },
581
- * });
582
- * console.log("Transaction hash:", hash);
583
- */
584
- declare function sendTransaction(client: FrakClient, {
585
- tx,
586
- metadata
587
- }: SendTransactionParams): Promise<SendTransactionReturnType>;
588
- //#endregion
589
- //#region src/actions/wrapper/siweAuthenticate.d.ts
590
- /**
591
- * Parameter used to directly show a modal used to authenticate with SIWE
592
- * @inline
593
- */
594
- type SiweAuthenticateModalParams = {
595
- /**
596
- * Partial SIWE params, since we can rebuild them from the SDK if they are empty
597
- *
598
- * If no parameters provider, some fields will be recomputed from the current configuration and environment.
599
- * - `statement` will be set to a default value
600
- * - `nonce` will be generated
601
- * - `uri` will be set to the current domain
602
- * - `version` will be set to "1"
603
- * - `domain` will be set to the current window domain
604
- *
605
- * @default {}
606
- */
607
- siwe?: Partial<SiweAuthenticationParams>;
608
- /**
609
- * Custom metadata to be passed to the modal
610
- */
611
- metadata?: ModalRpcMetadata;
612
- };
613
- /**
614
- * Function used to launch a siwe authentication
615
- * @param client - The current Frak Client
616
- * @param args - The parameters
617
- * @returns The SIWE authentication result (message + signature) in a promise
618
- *
619
- * @description This function will display a modal to the user with the provided SIWE parameters and metadata.
620
- *
621
- * @example
622
- * import { siweAuthenticate } from "@frak-labs/core-sdk/actions";
623
- * import { parseSiweMessage } from "viem/siwe";
624
- *
625
- * const { signature, message } = await siweAuthenticate(frakConfig, {
626
- * siwe: {
627
- * statement: "Sign in to My App",
628
- * domain: "my-app.com",
629
- * expirationTimeTimestamp: Date.now() + 1000 * 60 * 5,
630
- * },
631
- * metadata: {
632
- * header: {
633
- * title: "Sign in",
634
- * },
635
- * context: "Sign in to My App",
636
- * },
637
- * });
638
- * console.log("Parsed final message:", parseSiweMessage(message));
639
- * console.log("Siwe signature:", signature);
640
- */
641
- declare function siweAuthenticate(client: FrakClient, {
642
- siwe,
643
- metadata
644
- }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
645
- //#endregion
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 DELETED
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./sdkConfigStore-DDL_fjYX.cjs`),t=require(`./src-CMaRNkkJ.cjs`);exports.DEEP_LINK_SCHEME=t.b,exports.DebugInfoGatherer=t.r,exports.FrakContextManager=e.n,exports.base64urlDecode=e.h,exports.base64urlEncode=e.g,exports.baseIframeProps=t.c,exports.clearAllCache=e.a,exports.compressJsonToB64=e.m,exports.computeLegacyProductId=e._,exports.createIFrameFrakClient=t.n,exports.createIframe=t.l,exports.decompressJsonFromB64=t.x,exports.findIframeInOpener=t.u,exports.formatAmount=t.f,exports.generateSsoUrl=e.p,exports.getBackendUrl=e.c,exports.getCache=e.o,exports.getClientId=e.v,exports.getCurrencyAmountKey=t.d,exports.getSupportedCurrency=t.m,exports.getSupportedLocale=t.p,exports.isChromiumAndroid=t.g,exports.isFrakDeepLink=t._,exports.isIOS=t.a,exports.isInAppBrowser=t.o,exports.isV1Context=e.r,exports.isV2Context=e.i,exports.locales=t.h,exports.mergeAttribution=t.i,exports.redirectToExternalBrowser=t.s,exports.sdkConfigStore=e.t,exports.setupClient=t.t,exports.ssoPopupFeatures=e.d,exports.ssoPopupName=e.f,exports.toAndroidIntentUrl=t.v,exports.trackEvent=e.l,exports.triggerDeepLinkWithFallback=t.y,exports.withCache=e.s;
package/dist/index.d.cts DELETED
@@ -1,3 +0,0 @@
1
- import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, ct as AttributionParams, d as IFrameTransport, dt as UtmParams, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, lt as TrackArrivalParams, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, st as AttributionDefaults, tt as SdkResolvedConfig, u as FrakLifecycleEvent, ut as TrackArrivalResult, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-rQhLhPbq.cjs";
2
- import { A as getClientId, B as setupClient, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as trackEvent, G as KeyProvider, H as createIFrameFrakClient, I as SdkEventMap, L as SdkHandshakeFailureReason, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as LocalesKey, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as DebugInfoGatherer, W as HashProtectedData, _ as getCurrencyAmountKey, a as generateSsoUrl, b as DeepLinkFallbackOptions, c as mergeAttribution, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as FullSsoParams, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as AppSpecificSsoMetadata, o as sdkConfigStore, p as createIframe, r as CompressedSsoData, s as MergeAttributionInput, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as locales } from "./index-BhBuaCRl.cjs";
3
- export { AppSpecificSsoMetadata, AttributionDefaults, AttributionParams, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, MergeAttributionInput, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkEventMap, SdkHandshakeFailureReason, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, mergeAttribution, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { $ as ResolvedPlacement, A as ModalRpcMetadata, B as LoginModalStepType, C as EmbeddedViewActionReferred, D as DisplaySharingPageResultType, E as DisplaySharingPageParamsType, F as SendTransactionReturnType, G as SsoMetadata, H as OpenSsoReturnType, I as SendTransactionTxType, J as ModalStepMetadata, K as FinalActionType, L as SiweAuthenticateModalStepType, M as ModalRpcStepsResultType, N as ModalStepTypes, O as SharingPageProduct, P as SendTransactionModalStepType, Q as MerchantConfigResponse, R as SiweAuthenticateReturnType, S as LoggedOutEmbeddedView, T as LoggedInEmbeddedView, U as PrepareSsoParamsType, V as OpenSsoParamsType, W as PrepareSsoReturnType, X as IFrameLifecycleEvent, Y as InteractionTypeKey, Z as ClientLifecycleEvent, _ as RewardTier, a as FrakContextV1, at as Language, b as DisplayEmbeddedWalletParamsType, c as isV2Context, ct as AttributionParams, d as IFrameTransport, dt as UtmParams, et as ResolvedSdkConfig, f as IFrameRpcSchema, g as GetMerchantInformationReturnType, h as EstimatedReward, i as FrakContext, it as I18nConfig, j as ModalRpcStepsInput, k as DisplayModalParamsType, l as FrakClient, lt as TrackArrivalParams, m as UserReferralStatusType, n as ssoPopupFeatures, nt as Currency, o as FrakContextV2, ot as LocalizedI18nConfig, p as WalletStatusReturnType, q as FinalModalStepType, r as ssoPopupName, rt as FrakWalletSdkConfig, s as isV1Context, st as AttributionDefaults, tt as SdkResolvedConfig, u as FrakLifecycleEvent, ut as TrackArrivalResult, v as TokenAmountType, w as EmbeddedViewActionSharing, x as DisplayEmbeddedWalletResultType, y as SendInteractionParamsType, z as SiweAuthenticationParams } from "./openSso-DyUQew2K.js";
2
- import { A as getClientId, B as setupClient, C as toAndroidIntentUrl, D as compressJsonToB64, E as decompressJsonFromB64, F as trackEvent, G as KeyProvider, H as createIFrameFrakClient, I as SdkEventMap, L as SdkHandshakeFailureReason, M as getCache, N as withCache, O as base64urlDecode, P as getBackendUrl, R as LocalesKey, S as isFrakDeepLink, T as DEEP_LINK_SCHEME, U as CompressedData, V as DebugInfoGatherer, W as HashProtectedData, _ as getCurrencyAmountKey, a as generateSsoUrl, b as DeepLinkFallbackOptions, c as mergeAttribution, d as redirectToExternalBrowser, f as baseIframeProps, g as getSupportedCurrency, h as getSupportedLocale, i as FullSsoParams, j as clearAllCache, k as base64urlEncode, l as isIOS, m as findIframeInOpener, n as AppSpecificSsoMetadata, o as sdkConfigStore, p as createIframe, r as CompressedSsoData, s as MergeAttributionInput, t as computeLegacyProductId, u as isInAppBrowser, v as formatAmount, w as triggerDeepLinkWithFallback, x as isChromiumAndroid, y as FrakContextManager, z as locales } from "./index-CeX1Tl7W.js";
3
- export { AppSpecificSsoMetadata, AttributionDefaults, AttributionParams, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DEEP_LINK_SCHEME, DebugInfoGatherer, DeepLinkFallbackOptions, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, DisplaySharingPageParamsType, DisplaySharingPageResultType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, EstimatedReward, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakContextV1, FrakContextV2, FrakLifecycleEvent, FrakWalletSdkConfig, FullSsoParams, GetMerchantInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypeKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, MerchantConfigResponse, MergeAttributionInput, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepMetadata, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, ResolvedPlacement, ResolvedSdkConfig, RewardTier, SdkEventMap, SdkHandshakeFailureReason, SdkResolvedConfig, SendInteractionParamsType, SendTransactionModalStepType, SendTransactionReturnType, SendTransactionTxType, SharingPageProduct, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, TrackArrivalParams, TrackArrivalResult, UserReferralStatusType, UtmParams, WalletStatusReturnType, base64urlDecode, base64urlEncode, baseIframeProps, clearAllCache, compressJsonToB64, computeLegacyProductId, createIFrameFrakClient, createIframe, decompressJsonFromB64, findIframeInOpener, formatAmount, generateSsoUrl, getBackendUrl, getCache, getClientId, getCurrencyAmountKey, getSupportedCurrency, getSupportedLocale, isChromiumAndroid, isFrakDeepLink, isIOS, isInAppBrowser, isV1Context, isV2Context, locales, mergeAttribution, redirectToExternalBrowser, sdkConfigStore, setupClient, ssoPopupFeatures, ssoPopupName, toAndroidIntentUrl, trackEvent, triggerDeepLinkWithFallback, withCache };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as g}from"./sdkConfigStore-BXzz5PlK.js";import{_,a as v,b 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,x as I,y as L}from"./src-DMFOQMm6.js";export{y as DEEP_LINK_SCHEME,j as DebugInfoGatherer,u as FrakContextManager,o as base64urlDecode,a as base64urlEncode,b as baseIframeProps,t as clearAllCache,l as compressJsonToB64,e as computeLegacyProductId,O as createIFrameFrakClient,E as createIframe,I as decompressJsonFromB64,P as findIframeInOpener,S as formatAmount,f as generateSsoUrl,n as getBackendUrl,d as getCache,g as getClientId,x as getCurrencyAmountKey,D as getSupportedCurrency,A as getSupportedLocale,C as isChromiumAndroid,_ as isFrakDeepLink,v as isIOS,k as isInAppBrowser,p as isV1Context,s as isV2Context,w as locales,T as mergeAttribution,M as redirectToExternalBrowser,h as sdkConfigStore,N as setupClient,r as ssoPopupFeatures,i as ssoPopupName,F as toAndroidIntentUrl,c as trackEvent,L as triggerDeepLinkWithFallback,m as withCache};