@frak-labs/core-sdk 0.1.0-beta.afa252b0 → 0.1.0-beta.c7e026e5

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 (143) hide show
  1. package/cdn/bundle.iife.js +14 -0
  2. package/dist/actions-CEEObPYc.js +1 -0
  3. package/dist/actions-DbQhWYx8.cjs +1 -0
  4. package/dist/actions.cjs +1 -1
  5. package/dist/actions.d.cts +3 -1481
  6. package/dist/actions.d.ts +3 -1481
  7. package/dist/actions.js +1 -1
  8. package/dist/bundle.cjs +1 -13
  9. package/dist/bundle.d.cts +6 -2087
  10. package/dist/bundle.d.ts +6 -2087
  11. package/dist/bundle.js +1 -13
  12. package/dist/index-7OZ39x1U.d.ts +195 -0
  13. package/dist/index-C6FxkWPC.d.cts +511 -0
  14. package/dist/index-UFX7xCg3.d.ts +351 -0
  15. package/dist/index-d8xS4ryI.d.ts +511 -0
  16. package/dist/index-p4FqSp8z.d.cts +351 -0
  17. package/dist/index-zDq-VlKx.d.cts +195 -0
  18. package/dist/index.cjs +1 -13
  19. package/dist/index.d.cts +4 -1387
  20. package/dist/index.d.ts +4 -1387
  21. package/dist/index.js +1 -13
  22. package/dist/interaction-DMJ3ZfaF.d.cts +45 -0
  23. package/dist/interaction-KX1h9a7V.d.ts +45 -0
  24. package/dist/interactions-DnfM3oe0.js +1 -0
  25. package/dist/interactions-EIXhNLf6.cjs +1 -0
  26. package/dist/interactions.cjs +1 -1
  27. package/dist/interactions.d.cts +2 -182
  28. package/dist/interactions.d.ts +2 -182
  29. package/dist/interactions.js +1 -1
  30. package/dist/openSso-D--Airj6.d.cts +1018 -0
  31. package/dist/openSso-DsKJ4y0j.d.ts +1018 -0
  32. package/dist/productTypes-BUkXJKZ7.cjs +1 -0
  33. package/dist/productTypes-CGb1MmBF.js +1 -0
  34. package/dist/src-B_xO0AR6.cjs +13 -0
  35. package/dist/src-D2d52OZa.js +13 -0
  36. package/dist/trackEvent-CHnYa85W.js +1 -0
  37. package/dist/trackEvent-GuQm_1Nm.cjs +1 -0
  38. package/package.json +23 -18
  39. package/src/actions/displayEmbeddedWallet.test.ts +194 -0
  40. package/src/actions/displayEmbeddedWallet.ts +20 -0
  41. package/src/actions/displayModal.test.ts +387 -0
  42. package/src/actions/displayModal.ts +131 -0
  43. package/src/actions/getProductInformation.test.ts +133 -0
  44. package/src/actions/getProductInformation.ts +14 -0
  45. package/src/actions/index.ts +29 -0
  46. package/src/actions/openSso.test.ts +407 -0
  47. package/src/actions/openSso.ts +116 -0
  48. package/src/actions/prepareSso.test.ts +223 -0
  49. package/src/actions/prepareSso.ts +48 -0
  50. package/src/actions/referral/processReferral.ts +230 -0
  51. package/src/actions/referral/referralInteraction.test.ts +153 -0
  52. package/src/actions/referral/referralInteraction.ts +57 -0
  53. package/src/actions/sendInteraction.test.ts +219 -0
  54. package/src/actions/sendInteraction.ts +32 -0
  55. package/src/actions/trackPurchaseStatus.test.ts +287 -0
  56. package/src/actions/trackPurchaseStatus.ts +53 -0
  57. package/src/actions/watchWalletStatus.test.ts +372 -0
  58. package/src/actions/watchWalletStatus.ts +94 -0
  59. package/src/actions/wrapper/modalBuilder.test.ts +253 -0
  60. package/src/actions/wrapper/modalBuilder.ts +212 -0
  61. package/src/actions/wrapper/sendTransaction.test.ts +164 -0
  62. package/src/actions/wrapper/sendTransaction.ts +62 -0
  63. package/src/actions/wrapper/siweAuthenticate.test.ts +290 -0
  64. package/src/actions/wrapper/siweAuthenticate.ts +94 -0
  65. package/src/bundle.ts +3 -0
  66. package/src/clients/DebugInfo.ts +182 -0
  67. package/src/clients/createIFrameFrakClient.ts +287 -0
  68. package/src/clients/index.ts +3 -0
  69. package/src/clients/setupClient.test.ts +343 -0
  70. package/src/clients/setupClient.ts +73 -0
  71. package/src/clients/transports/iframeLifecycleManager.test.ts +399 -0
  72. package/src/clients/transports/iframeLifecycleManager.ts +90 -0
  73. package/src/constants/interactionTypes.ts +44 -0
  74. package/src/constants/locales.ts +14 -0
  75. package/src/constants/productTypes.ts +33 -0
  76. package/src/index.ts +101 -0
  77. package/src/interactions/index.ts +5 -0
  78. package/src/interactions/pressEncoder.test.ts +215 -0
  79. package/src/interactions/pressEncoder.ts +53 -0
  80. package/src/interactions/purchaseEncoder.test.ts +291 -0
  81. package/src/interactions/purchaseEncoder.ts +99 -0
  82. package/src/interactions/referralEncoder.test.ts +170 -0
  83. package/src/interactions/referralEncoder.ts +47 -0
  84. package/src/interactions/retailEncoder.test.ts +107 -0
  85. package/src/interactions/retailEncoder.ts +37 -0
  86. package/src/interactions/webshopEncoder.test.ts +56 -0
  87. package/src/interactions/webshopEncoder.ts +30 -0
  88. package/src/types/client.ts +14 -0
  89. package/src/types/compression.ts +22 -0
  90. package/src/types/config.ts +111 -0
  91. package/src/types/context.ts +13 -0
  92. package/src/types/index.ts +71 -0
  93. package/src/types/lifecycle/client.ts +46 -0
  94. package/src/types/lifecycle/iframe.ts +35 -0
  95. package/src/types/lifecycle/index.ts +2 -0
  96. package/src/types/rpc/displayModal.ts +84 -0
  97. package/src/types/rpc/embedded/index.ts +68 -0
  98. package/src/types/rpc/embedded/loggedIn.ts +55 -0
  99. package/src/types/rpc/embedded/loggedOut.ts +28 -0
  100. package/src/types/rpc/interaction.ts +43 -0
  101. package/src/types/rpc/modal/final.ts +46 -0
  102. package/src/types/rpc/modal/generic.ts +46 -0
  103. package/src/types/rpc/modal/index.ts +20 -0
  104. package/src/types/rpc/modal/login.ts +32 -0
  105. package/src/types/rpc/modal/openSession.ts +25 -0
  106. package/src/types/rpc/modal/siweAuthenticate.ts +37 -0
  107. package/src/types/rpc/modal/transaction.ts +33 -0
  108. package/src/types/rpc/productInformation.ts +59 -0
  109. package/src/types/rpc/sso.ts +80 -0
  110. package/src/types/rpc/walletStatus.ts +35 -0
  111. package/src/types/rpc.ts +158 -0
  112. package/src/types/transport.ts +34 -0
  113. package/src/utils/FrakContext.test.ts +407 -0
  114. package/src/utils/FrakContext.ts +158 -0
  115. package/src/utils/compression/b64.test.ts +181 -0
  116. package/src/utils/compression/b64.ts +29 -0
  117. package/src/utils/compression/compress.test.ts +123 -0
  118. package/src/utils/compression/compress.ts +11 -0
  119. package/src/utils/compression/decompress.test.ts +145 -0
  120. package/src/utils/compression/decompress.ts +11 -0
  121. package/src/utils/compression/index.ts +3 -0
  122. package/src/utils/computeProductId.test.ts +80 -0
  123. package/src/utils/computeProductId.ts +11 -0
  124. package/src/utils/constants.test.ts +23 -0
  125. package/src/utils/constants.ts +4 -0
  126. package/src/utils/formatAmount.test.ts +113 -0
  127. package/src/utils/formatAmount.ts +18 -0
  128. package/src/utils/getCurrencyAmountKey.test.ts +44 -0
  129. package/src/utils/getCurrencyAmountKey.ts +15 -0
  130. package/src/utils/getSupportedCurrency.test.ts +51 -0
  131. package/src/utils/getSupportedCurrency.ts +14 -0
  132. package/src/utils/getSupportedLocale.test.ts +64 -0
  133. package/src/utils/getSupportedLocale.ts +16 -0
  134. package/src/utils/iframeHelper.test.ts +450 -0
  135. package/src/utils/iframeHelper.ts +143 -0
  136. package/src/utils/index.ts +21 -0
  137. package/src/utils/sso.test.ts +361 -0
  138. package/src/utils/sso.ts +119 -0
  139. package/src/utils/ssoUrlListener.ts +60 -0
  140. package/src/utils/trackEvent.test.ts +162 -0
  141. package/src/utils/trackEvent.ts +26 -0
  142. package/cdn/bundle.js +0 -19
  143. package/cdn/bundle.js.LICENSE.txt +0 -10
@@ -0,0 +1,511 @@
1
+ import { A as SiweAuthenticateReturnType, B as FinalActionType, D as SendTransactionReturnType, E as SendTransactionModalStepType, L as PrepareSsoParamsType, M as OpenInteractionSessionModalStepType, P as LoginModalStepType, R as PrepareSsoReturnType, S as ModalRpcMetadata, T as ModalStepTypes, V as FinalModalStepType, a as FrakClient, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, l as WalletStatusReturnType, u as GetProductInformationReturnType, w as ModalRpcStepsResultType, x as DisplayModalParamsType } from "./openSso-DsKJ4y0j.js";
2
+ import { n as SendInteractionParamsType, r as SendInteractionReturnType } from "./interaction-KX1h9a7V.js";
3
+ import { Hex } from "viem";
4
+
5
+ //#region src/actions/displayEmbeddedWallet.d.ts
6
+
7
+ /**
8
+ * Function used to display the Frak embedded wallet popup
9
+ * @param client - The current Frak Client
10
+ * @param params - The parameter used to customise the embedded wallet
11
+ */
12
+ declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
13
+ //#endregion
14
+ //#region src/actions/displayModal.d.ts
15
+ /**
16
+ * Function used to display a modal
17
+ * @param client - The current Frak Client
18
+ * @param args
19
+ * @param args.steps - The different steps of the modal
20
+ * @param args.metadata - The metadata for the modal (customization, etc)
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` and `openSession` steps will be automatically skipped if the user is already logged in or has an active session. It's safe to include these steps in all cases to ensure proper user state.
28
+ * - Steps are automatically reordered in the following sequence:
29
+ * 1. `login` (if needed)
30
+ * 2. `openSession` (if needed)
31
+ * 3. All other steps in the order specified
32
+ * 4. `success` (if included, always last)
33
+ *
34
+ * @example
35
+ * Simple sharing modal with steps:
36
+ * 1. Login (Skipped if already logged in)
37
+ * 2. Open a session (Skipped if already opened)
38
+ * 3. Display a success message with sharing link option
39
+ *
40
+ * ```ts
41
+ * const results = await displayModal(frakConfig, {
42
+ * steps: {
43
+ * // Simple login with no SSO, nor customization
44
+ * login: { allowSso: false },
45
+ * // Simple session opening, with no customization
46
+ * openSession: {},
47
+ * // Success message
48
+ * final: {
49
+ * action: { key: "reward" },
50
+ * // Skip this step, it will be only displayed in the stepper within the modal
51
+ * autoSkip: true,
52
+ * },
53
+ * },
54
+ * });
55
+ *
56
+ * 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
+ * ```
62
+ *
63
+ * @example
64
+ * A full modal example, with a few customization options, with the steps:
65
+ * 1. Login (Skipped if already logged in)
66
+ * 2. Open a session (Skipped if already opened)
67
+ * 3. Authenticate via SIWE
68
+ * 4. Send a transaction
69
+ * 5. Display a success message with sharing link options
70
+ *
71
+ * ```ts
72
+ * const results = await displayModal(frakConfig, {
73
+ * steps: {
74
+ * // Login step
75
+ * login: {
76
+ * allowSso: true,
77
+ * ssoMetadata: {
78
+ * logoUrl: "https://my-app.com/logo.png",
79
+ * homepageLink: "https://my-app.com",
80
+ * },
81
+ * },
82
+ * // Simple session opening, with no customisation
83
+ * openSession: {},
84
+ * // Siwe authentication
85
+ * siweAuthenticate: {
86
+ * siwe: {
87
+ * domain: "my-app.com",
88
+ * uri: "https://my-app.com/",
89
+ * nonce: generateSiweNonce(),
90
+ * version: "1",
91
+ * },
92
+ * },
93
+ * // Send batched transaction
94
+ * sendTransaction: {
95
+ * tx: [
96
+ * { to: "0xdeadbeef", data: "0xdeadbeef" },
97
+ * { to: "0xdeadbeef", data: "0xdeadbeef" },
98
+ * ],
99
+ * },
100
+ * // Success message with sharing options
101
+ * final: {
102
+ * action: {
103
+ * key: "sharing",
104
+ * options: {
105
+ * popupTitle: "Share the app",
106
+ * text: "Discover my super app website",
107
+ * link: "https://my-app.com",
108
+ * },
109
+ * },
110
+ * dismissedMetadata: {
111
+ * title: "Dismiss",
112
+ * description: "You won't be rewarded for this sharing action",
113
+ * },
114
+ * },
115
+ * },
116
+ * metadata: {
117
+ * // Header of desktop modals
118
+ * header: {
119
+ * title: "My-App",
120
+ * icon: "https://my-app.com/logo.png",
121
+ * },
122
+ * // Context that will be present in every modal steps
123
+ * context: "My-app overkill flow",
124
+ * },
125
+ * });
126
+ * ```
127
+ */
128
+ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, {
129
+ steps,
130
+ metadata
131
+ }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
132
+ //#endregion
133
+ //#region src/actions/getProductInformation.d.ts
134
+ /**
135
+ * Function used to get the current product information
136
+ * @param client - The current Frak Client
137
+ * @returns The product information in a promise
138
+ */
139
+ declare function getProductInformation(client: FrakClient): Promise<GetProductInformationReturnType>;
140
+ //#endregion
141
+ //#region src/actions/prepareSso.d.ts
142
+ /**
143
+ * Generate SSO URL without opening popup
144
+ *
145
+ * This is a **synchronous**, client-side function that generates the SSO URL
146
+ * without any RPC calls to the wallet iframe. Use this when you need:
147
+ * - Custom URL modifications before opening popup
148
+ * - Pre-generation for advanced popup strategies
149
+ * - URL inspection/logging before SSO flow
150
+ *
151
+ * @param client - The current Frak Client
152
+ * @param args - The SSO parameters
153
+ * @returns Object containing the generated ssoUrl
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * // Generate URL for inspection
158
+ * const { ssoUrl } = prepareSso(client, {
159
+ * metadata: { logoUrl: "..." },
160
+ * directExit: true
161
+ * });
162
+ * console.log("Opening SSO:", ssoUrl);
163
+ *
164
+ * // Add custom params
165
+ * const customUrl = `${ssoUrl}&tracking=abc123`;
166
+ * await openSso(client, { metadata, ssoPopupUrl: customUrl });
167
+ * ```
168
+ *
169
+ * @remarks
170
+ * For most use cases, just use `openSso()` which handles URL generation automatically.
171
+ * Only use `prepareSso()` when you need explicit control over the URL.
172
+ */
173
+ declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Promise<PrepareSsoReturnType>;
174
+ //#endregion
175
+ //#region src/actions/referral/processReferral.d.ts
176
+ /**
177
+ * The different states of the referral process
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
183
+ */
184
+ type ProcessReferralOptions = {
185
+ /**
186
+ * If we want to always append the url with the frak context or not
187
+ * @defaultValue false
188
+ */
189
+ alwaysAppendUrl?: boolean;
190
+ };
191
+ /**
192
+ * This function handle all the heavy lifting of the referral interaction process
193
+ * 1. Check if the user has been referred or not (if not, early exit)
194
+ * 2. Then check if the user is logged in or not
195
+ * 2.1 If not logged in, try a soft login, if it fail, display a modal for the user to login
196
+ * 3. Check if that's not a self-referral (if yes, early exit)
197
+ * 4. Check if the user has an interaction session or not
198
+ * 4.1 If not, display a modal for the user to open a session
199
+ * 5. Push the referred interaction
200
+ * 6. Update the current url with the right data
201
+ * 7. Return the resulting referral state
202
+ *
203
+ * If any error occurs during the process, the function will catch it and return an error state
204
+ *
205
+ * @param client - The current Frak Client
206
+ * @param args
207
+ * @param args.walletStatus - The current user wallet status
208
+ * @param args.frakContext - The current frak context
209
+ * @param args.modalConfig - The modal configuration to display if the user is not logged in
210
+ * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
211
+ * @param args.options - Some options for the referral interaction
212
+ * @returns A promise with the resulting referral state
213
+ *
214
+ * @see {@link displayModal} for more details about the displayed modal
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
218
+ */
219
+ declare function processReferral(client: FrakClient, {
220
+ walletStatus,
221
+ frakContext,
222
+ modalConfig,
223
+ productId,
224
+ options
225
+ }: {
226
+ walletStatus?: WalletStatusReturnType;
227
+ frakContext?: Partial<FrakContext> | null;
228
+ modalConfig?: DisplayEmbeddedWalletParamsType;
229
+ productId?: Hex;
230
+ options?: ProcessReferralOptions;
231
+ }): Promise<ReferralState>;
232
+ //#endregion
233
+ //#region src/actions/referral/referralInteraction.d.ts
234
+ /**
235
+ * Function used to display a modal
236
+ * @param client - The current Frak Client
237
+ * @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
+ * @param args.options - Some options for the referral interaction
241
+ *
242
+ * @returns A promise with the resulting referral state, or undefined in case of an error
243
+ *
244
+ * @description This function will automatically handle the referral interaction process
245
+ *
246
+ * @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
+ */
249
+ declare function referralInteraction(client: FrakClient, {
250
+ productId,
251
+ modalConfig,
252
+ options
253
+ }?: {
254
+ productId?: Hex;
255
+ modalConfig?: DisplayEmbeddedWalletParamsType;
256
+ options?: ProcessReferralOptions;
257
+ }): Promise<("no-referrer" | "self-referral" | "success" | "idle" | "processing" | "no-wallet" | "no-session" | "error") | undefined>;
258
+ //#endregion
259
+ //#region src/actions/sendInteraction.d.ts
260
+ /**
261
+ * Function used to send an interaction
262
+ * @param client - The current Frak Client
263
+ * @param args
264
+ *
265
+ * @example
266
+ * const interaction = PressInteractionEncoder.openArticle({
267
+ * articleId: keccak256(toHex("article-slug")),
268
+ * });
269
+ * const { delegationId } = await sendInteraction(frakConfig, {
270
+ * interaction,
271
+ * });
272
+ * console.log("Delegated interaction id", delegationId);
273
+ */
274
+ declare function sendInteraction(client: FrakClient, {
275
+ productId,
276
+ interaction,
277
+ validation
278
+ }: SendInteractionParamsType): Promise<SendInteractionReturnType>;
279
+ //#endregion
280
+ //#region src/actions/trackPurchaseStatus.d.ts
281
+ /**
282
+ * Function used to track the status of a purchase
283
+ * when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
284
+ *
285
+ * @param args.customerId - The customer id that made the purchase (on your side)
286
+ * @param args.orderId - The order id of the purchase (on your side)
287
+ * @param args.token - The token of the purchase
288
+ *
289
+ * @description This function will send a request to the backend to listen for the purchase status.
290
+ *
291
+ * @example
292
+ * async function trackPurchase(checkout) {
293
+ * const payload = {
294
+ * customerId: checkout.order.customer.id,
295
+ * orderId: checkout.order.id,
296
+ * token: checkout.token,
297
+ * };
298
+ *
299
+ * await trackPurchaseStatus(payload);
300
+ * }
301
+ *
302
+ * @remarks
303
+ * - The `trackPurchaseStatus` function requires the `frak-wallet-interaction-token` stored in the session storage to authenticate the request.
304
+ * - This function will print a warning if used in a non-browser environment or if the wallet interaction token is not available.
305
+ */
306
+ declare function trackPurchaseStatus(args: {
307
+ customerId: string | number;
308
+ orderId: string | number;
309
+ token: string;
310
+ }): Promise<void>;
311
+ //#endregion
312
+ //#region src/actions/watchWalletStatus.d.ts
313
+ /**
314
+ * Function used to watch the current frak wallet status
315
+ * @param client - The current Frak Client
316
+ * @param callback - The callback that will receive any wallet status change
317
+ * @returns A promise resolving with the initial wallet status
318
+ *
319
+ * @description This function will return the current wallet status, and will listen to any change in the wallet status.
320
+ *
321
+ * @example
322
+ * await watchWalletStatus(frakConfig, (status: WalletStatusReturnType) => {
323
+ * if (status.key === "connected") {
324
+ * console.log("Wallet connected:", status.wallet);
325
+ * console.log("Current interaction session:", status.interactionSession);
326
+ * } else {
327
+ * console.log("Wallet not connected");
328
+ * }
329
+ * });
330
+ */
331
+ declare function watchWalletStatus(client: FrakClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
332
+ //#endregion
333
+ //#region src/actions/wrapper/modalBuilder.d.ts
334
+ /**
335
+ * Represent the type of the modal step builder
336
+ */
337
+ type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
338
+ /**
339
+ * The current modal params
340
+ */
341
+ params: DisplayModalParamsType<Steps>;
342
+ /**
343
+ * Add a send transaction step to the modal
344
+ */
345
+ sendTx: (options: SendTransactionModalStepType["params"]) => ModalStepBuilder<[...Steps, SendTransactionModalStepType]>;
346
+ /**
347
+ * Add a final step of type reward to the modal
348
+ */
349
+ reward: (options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
350
+ /**
351
+ * Add a final step of type sharing to the modal
352
+ */
353
+ sharing: (sharingOptions?: Extract<FinalActionType, {
354
+ key: "sharing";
355
+ }>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
356
+ /**
357
+ * Display the modal
358
+ * @param metadataOverride - Function returning optional metadata to override the current modal metadata
359
+ */
360
+ display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
361
+ };
362
+ /**
363
+ * Represent the output type of the modal builder
364
+ */
365
+ type ModalBuilder = ModalStepBuilder<[LoginModalStepType, OpenInteractionSessionModalStepType]>;
366
+ /**
367
+ * Helper to craft Frak modal, and share a base initial config
368
+ * @param client - The current Frak Client
369
+ * @param args
370
+ * @param args.metadata - Common modal metadata (customisation, language etc)
371
+ * @param args.login - Login step parameters
372
+ * @param args.openSession - Open session step parameters
373
+ *
374
+ * @description This function will create a modal builder with the provided metadata, login and open session parameters.
375
+ *
376
+ * @example
377
+ * Here is an example of how to use the `modalBuilder` to create and display a sharing modal:
378
+ *
379
+ * ```js
380
+ * // Create the modal builder
381
+ * const modalBuilder = window.FrakSDK.modalBuilder(frakClient, baseModalConfig);
382
+ *
383
+ * // Configure the information to be shared via the sharing link
384
+ * const sharingConfig = {
385
+ * popupTitle: "Share this with your friends",
386
+ * text: "Discover our product!",
387
+ * link: window.location.href,
388
+ * };
389
+ *
390
+ * // Display the sharing modal
391
+ * function modalShare() {
392
+ * modalBuilder.sharing(sharingConfig).display();
393
+ * }
394
+ * ```
395
+ *
396
+ * @see {@link ModalStepTypes} for more info about each modal step types and their parameters
397
+ * @see {@link ModalRpcMetadata} for more info about the metadata that can be passed to the modal
398
+ * @see {@link ModalRpcStepsResultType} for more info about the result of each modal steps
399
+ * @see {@link displayModal} for more info about how the modal is displayed
400
+ */
401
+ declare function modalBuilder(client: FrakClient, {
402
+ metadata,
403
+ login,
404
+ openSession
405
+ }: {
406
+ metadata?: ModalRpcMetadata;
407
+ login?: LoginModalStepType["params"];
408
+ openSession?: OpenInteractionSessionModalStepType["params"];
409
+ }): ModalBuilder;
410
+ //#endregion
411
+ //#region src/actions/wrapper/sendTransaction.d.ts
412
+ /**
413
+ * Parameters to directly show a modal used to send a transaction
414
+ * @inline
415
+ */
416
+ type SendTransactionParams = {
417
+ /**
418
+ * The transaction to be sent (either a single tx or multiple ones)
419
+ */
420
+ tx: SendTransactionModalStepType["params"]["tx"];
421
+ /**
422
+ * Custom metadata to be passed to the modal
423
+ */
424
+ metadata?: ModalRpcMetadata;
425
+ };
426
+ /**
427
+ * Function used to send a user transaction, simple wrapper around the displayModal function to ease the send transaction process
428
+ * @param client - The current Frak Client
429
+ * @param args - The parameters
430
+ * @returns The hash of the transaction that was sent in a promise
431
+ *
432
+ * @description This function will display a modal to the user with the provided transaction and metadata.
433
+ *
434
+ * @example
435
+ * const { hash } = await sendTransaction(frakConfig, {
436
+ * tx: {
437
+ * to: "0xdeadbeef",
438
+ * value: toHex(100n),
439
+ * },
440
+ * metadata: {
441
+ * header: {
442
+ * title: "Sending eth",
443
+ * },
444
+ * context: "Send 100wei to 0xdeadbeef",
445
+ * },
446
+ * });
447
+ * console.log("Transaction hash:", hash);
448
+ */
449
+ declare function sendTransaction(client: FrakClient, {
450
+ tx,
451
+ metadata
452
+ }: SendTransactionParams): Promise<SendTransactionReturnType>;
453
+ //#endregion
454
+ //#region src/actions/wrapper/siweAuthenticate.d.ts
455
+ /**
456
+ * Parameter used to directly show a modal used to authenticate with SIWE
457
+ * @inline
458
+ */
459
+ type SiweAuthenticateModalParams = {
460
+ /**
461
+ * Partial SIWE params, since we can rebuild them from the SDK if they are empty
462
+ *
463
+ * If no parameters provider, some fields will be recomputed from the current configuration and environment.
464
+ * - `statement` will be set to a default value
465
+ * - `nonce` will be generated
466
+ * - `uri` will be set to the current domain
467
+ * - `version` will be set to "1"
468
+ * - `domain` will be set to the current window domain
469
+ *
470
+ * @default {}
471
+ */
472
+ siwe?: Partial<SiweAuthenticationParams>;
473
+ /**
474
+ * Custom metadata to be passed to the modal
475
+ */
476
+ metadata?: ModalRpcMetadata;
477
+ };
478
+ /**
479
+ * Function used to launch a siwe authentication
480
+ * @param client - The current Frak Client
481
+ * @param args - The parameters
482
+ * @returns The SIWE authentication result (message + signature) in a promise
483
+ *
484
+ * @description This function will display a modal to the user with the provided SIWE parameters and metadata.
485
+ *
486
+ * @example
487
+ * import { siweAuthenticate } from "@frak-labs/core-sdk/actions";
488
+ * import { parseSiweMessage } from "viem/siwe";
489
+ *
490
+ * const { signature, message } = await siweAuthenticate(frakConfig, {
491
+ * siwe: {
492
+ * statement: "Sign in to My App",
493
+ * domain: "my-app.com",
494
+ * expirationTimeTimestamp: Date.now() + 1000 * 60 * 5,
495
+ * },
496
+ * metadata: {
497
+ * header: {
498
+ * title: "Sign in",
499
+ * },
500
+ * context: "Sign in to My App",
501
+ * },
502
+ * });
503
+ * console.log("Parsed final message:", parseSiweMessage(message));
504
+ * console.log("Siwe signature:", signature);
505
+ */
506
+ declare function siweAuthenticate(client: FrakClient, {
507
+ siwe,
508
+ metadata
509
+ }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
510
+ //#endregion
511
+ export { displayEmbeddedWallet as _, ModalBuilder as a, watchWalletStatus as c, referralInteraction as d, ProcessReferralOptions as f, displayModal as g, getProductInformation 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 };