@frak-labs/core-sdk 0.0.19-beta.f259d7fc → 0.1.0-beta.263acd1e

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 (139) 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 -1400
  6. package/dist/actions.d.ts +3 -1400
  7. package/dist/actions.js +1 -1
  8. package/dist/bundle.cjs +1 -13
  9. package/dist/bundle.d.cts +6 -1927
  10. package/dist/bundle.d.ts +6 -1927
  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 -1269
  20. package/dist/index.d.ts +4 -1269
  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 +24 -19
  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.ts +57 -0
  52. package/src/actions/sendInteraction.test.ts +219 -0
  53. package/src/actions/sendInteraction.ts +32 -0
  54. package/src/actions/trackPurchaseStatus.test.ts +287 -0
  55. package/src/actions/trackPurchaseStatus.ts +53 -0
  56. package/src/actions/watchWalletStatus.test.ts +372 -0
  57. package/src/actions/watchWalletStatus.ts +94 -0
  58. package/src/actions/wrapper/modalBuilder.ts +212 -0
  59. package/src/actions/wrapper/sendTransaction.ts +62 -0
  60. package/src/actions/wrapper/siweAuthenticate.ts +94 -0
  61. package/src/bundle.ts +3 -0
  62. package/src/clients/DebugInfo.ts +182 -0
  63. package/src/clients/createIFrameFrakClient.ts +287 -0
  64. package/src/clients/index.ts +3 -0
  65. package/src/clients/setupClient.test.ts +343 -0
  66. package/src/clients/setupClient.ts +73 -0
  67. package/src/clients/transports/iframeLifecycleManager.test.ts +399 -0
  68. package/src/clients/transports/iframeLifecycleManager.ts +90 -0
  69. package/src/constants/interactionTypes.ts +44 -0
  70. package/src/constants/locales.ts +14 -0
  71. package/src/constants/productTypes.ts +33 -0
  72. package/src/index.ts +101 -0
  73. package/src/interactions/index.ts +5 -0
  74. package/src/interactions/pressEncoder.test.ts +215 -0
  75. package/src/interactions/pressEncoder.ts +53 -0
  76. package/src/interactions/purchaseEncoder.test.ts +291 -0
  77. package/src/interactions/purchaseEncoder.ts +99 -0
  78. package/src/interactions/referralEncoder.test.ts +170 -0
  79. package/src/interactions/referralEncoder.ts +47 -0
  80. package/src/interactions/retailEncoder.test.ts +107 -0
  81. package/src/interactions/retailEncoder.ts +37 -0
  82. package/src/interactions/webshopEncoder.test.ts +56 -0
  83. package/src/interactions/webshopEncoder.ts +30 -0
  84. package/src/types/client.ts +14 -0
  85. package/src/types/compression.ts +22 -0
  86. package/src/types/config.ts +111 -0
  87. package/src/types/context.ts +13 -0
  88. package/src/types/index.ts +71 -0
  89. package/src/types/lifecycle/client.ts +46 -0
  90. package/src/types/lifecycle/iframe.ts +35 -0
  91. package/src/types/lifecycle/index.ts +2 -0
  92. package/src/types/rpc/displayModal.ts +84 -0
  93. package/src/types/rpc/embedded/index.ts +68 -0
  94. package/src/types/rpc/embedded/loggedIn.ts +55 -0
  95. package/src/types/rpc/embedded/loggedOut.ts +28 -0
  96. package/src/types/rpc/interaction.ts +43 -0
  97. package/src/types/rpc/modal/final.ts +46 -0
  98. package/src/types/rpc/modal/generic.ts +46 -0
  99. package/src/types/rpc/modal/index.ts +20 -0
  100. package/src/types/rpc/modal/login.ts +32 -0
  101. package/src/types/rpc/modal/openSession.ts +25 -0
  102. package/src/types/rpc/modal/siweAuthenticate.ts +37 -0
  103. package/src/types/rpc/modal/transaction.ts +33 -0
  104. package/src/types/rpc/productInformation.ts +59 -0
  105. package/src/types/rpc/sso.ts +80 -0
  106. package/src/types/rpc/walletStatus.ts +35 -0
  107. package/src/types/rpc.ts +158 -0
  108. package/src/types/transport.ts +34 -0
  109. package/src/utils/FrakContext.test.ts +407 -0
  110. package/src/utils/FrakContext.ts +158 -0
  111. package/src/utils/compression/b64.test.ts +181 -0
  112. package/src/utils/compression/b64.ts +29 -0
  113. package/src/utils/compression/compress.test.ts +123 -0
  114. package/src/utils/compression/compress.ts +11 -0
  115. package/src/utils/compression/decompress.test.ts +145 -0
  116. package/src/utils/compression/decompress.ts +11 -0
  117. package/src/utils/compression/index.ts +3 -0
  118. package/src/utils/computeProductId.test.ts +80 -0
  119. package/src/utils/computeProductId.ts +11 -0
  120. package/src/utils/constants.test.ts +23 -0
  121. package/src/utils/constants.ts +4 -0
  122. package/src/utils/formatAmount.test.ts +113 -0
  123. package/src/utils/formatAmount.ts +18 -0
  124. package/src/utils/getCurrencyAmountKey.test.ts +44 -0
  125. package/src/utils/getCurrencyAmountKey.ts +15 -0
  126. package/src/utils/getSupportedCurrency.test.ts +51 -0
  127. package/src/utils/getSupportedCurrency.ts +14 -0
  128. package/src/utils/getSupportedLocale.test.ts +64 -0
  129. package/src/utils/getSupportedLocale.ts +16 -0
  130. package/src/utils/iframeHelper.test.ts +450 -0
  131. package/src/utils/iframeHelper.ts +143 -0
  132. package/src/utils/index.ts +21 -0
  133. package/src/utils/sso.test.ts +361 -0
  134. package/src/utils/sso.ts +119 -0
  135. package/src/utils/ssoUrlListener.ts +60 -0
  136. package/src/utils/trackEvent.test.ts +162 -0
  137. package/src/utils/trackEvent.ts +26 -0
  138. package/cdn/bundle.js +0 -19
  139. package/cdn/bundle.js.LICENSE.txt +0 -10
package/dist/bundle.d.cts CHANGED
@@ -1,1927 +1,6 @@
1
- import { Address } from 'viem';
2
- import { Hex } from 'viem';
3
- import type { LifecycleMessage } from '@frak-labs/frame-connector';
4
- import type { OpenPanel } from '@openpanel/web';
5
- import type { RpcClient } from '@frak-labs/frame-connector';
6
- import { RpcMessage } from '@frak-labs/frame-connector';
7
- import { RpcResponse } from '@frak-labs/frame-connector';
8
- import type { SiweMessage } from 'viem/siwe';
9
-
10
- /**
11
- * Decode a base64url encoded string
12
- * @param value The value to decode
13
- * @returns The decoded value
14
- */
15
- export declare function base64urlDecode(value: string): Uint8Array;
16
-
17
- /**
18
- * Encode a buffer to a base64url encoded string
19
- * @param buffer The buffer to encode
20
- * @returns The encoded string
21
- */
22
- export declare function base64urlEncode(buffer: Uint8Array): string;
23
-
24
- /**
25
- * Base props for the iframe
26
- * @ignore
27
- */
28
- export declare const baseIframeProps: {
29
- id: string;
30
- name: string;
31
- title: string;
32
- allow: string;
33
- style: {
34
- width: string;
35
- height: string;
36
- border: string;
37
- position: string;
38
- zIndex: number;
39
- top: string;
40
- left: string;
41
- colorScheme: string;
42
- };
43
- };
44
-
45
- /**
46
- * Event related to the iframe lifecycle
47
- * @ignore
48
- */
49
- export declare type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse | SsoRedirectCompleteEvent;
50
-
51
- /**
52
- * Compress the current Frak context
53
- * @param context - The context to be compressed
54
- * @returns A compressed string containing the Frak context
55
- */
56
- declare function compress(context?: Partial<FrakContext>): string | undefined;
57
-
58
- /**
59
- * The received encoded data from a client
60
- * -> The encoded should contain a HashProtectedData once decoded
61
- * @ignore
62
- */
63
- export declare type CompressedData = Uint8Array;
64
-
65
- /**
66
- * Compress json data
67
- * @param data
68
- * @ignore
69
- */
70
- export declare function compressJsonToB64(data: unknown): string;
71
-
72
- /**
73
- * Create the Frak iframe
74
- * @param args
75
- * @param args.walletBaseUrl - Use `config.walletUrl` instead. Will be removed in future versions.
76
- * @param args.config - The configuration object containing iframe options, including the replacement for `walletBaseUrl`.
77
- */
78
- export declare function createIframe({ walletBaseUrl, config, }: {
79
- walletBaseUrl?: string;
80
- config?: FrakWalletSdkConfig;
81
- }): Promise<HTMLIFrameElement | undefined>;
82
-
83
- /**
84
- * Create a new iframe Frak client
85
- * @param args
86
- * @param args.config - The configuration to use for the Frak Wallet SDK
87
- * @param args.iframe - The iframe to use for the communication
88
- * @returns The created Frak Client
89
- *
90
- * @example
91
- * const frakConfig: FrakWalletSdkConfig = {
92
- * metadata: {
93
- * name: "My app title",
94
- * },
95
- * }
96
- * const iframe = await createIframe({ config: frakConfig });
97
- * const client = createIFrameFrakClient({ config: frakConfig, iframe });
98
- */
99
- export declare function createIFrameFrakClient({ config, iframe, }: {
100
- config: FrakWalletSdkConfig;
101
- iframe: HTMLIFrameElement;
102
- }): FrakClient;
103
-
104
- /**
105
- * All the currencies available
106
- * @category Config
107
- */
108
- export declare type Currency = "eur" | "usd" | "gbp";
109
-
110
- declare type CustomCssEvent = {
111
- clientLifecycle: "modal-css";
112
- data: {
113
- cssLink: string;
114
- };
115
- };
116
-
117
- declare type CustomI18nEvent = {
118
- clientLifecycle: "modal-i18n";
119
- data: {
120
- i18n: I18nConfig;
121
- };
122
- };
123
-
124
- /** @ignore */
125
- export declare class DebugInfoGatherer {
126
- private config?;
127
- private iframe?;
128
- private isSetupDone;
129
- private lastResponse;
130
- private lastRequest;
131
- constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
132
- setLastResponse(message: RpcMessage, response: RpcResponse): void;
133
- setLastRequest(event: RpcMessage): void;
134
- updateSetupStatus(status: boolean): void;
135
- private base64Encode;
136
- /**
137
- * Extract information from the iframe status
138
- */
139
- private getIframeStatus;
140
- private getNavigatorInfo;
141
- private gatherDebugInfo;
142
- static empty(): DebugInfoGatherer;
143
- /**
144
- * Format Frak debug information
145
- */
146
- formatDebugInfo(error: Error | unknown | string): string;
147
- }
148
-
149
- /**
150
- * Decompress the given Frak context
151
- * @param context - The raw context to be decompressed into a `FrakContext`
152
- * @returns The decompressed Frak context, or undefined if it fails
153
- */
154
- declare function decompress(context?: string): FrakContext | undefined;
155
-
156
- /**
157
- * Decompress json data
158
- * @param data
159
- * @ignore
160
- */
161
- export declare function decompressJsonFromB64<T>(data: string): T | null;
162
-
163
- /**
164
- * Function used to display the Frak embedded wallet popup
165
- * @param client - The current Frak Client
166
- * @param params - The parameter used to customise the embedded wallet
167
- */
168
- export declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
169
-
170
- /**
171
- * The params used to display the embedded wallet
172
- *
173
- * @group Embedded wallet
174
- */
175
- export declare type DisplayEmbeddedWalletParamsType = {
176
- /**
177
- * The embedded view to display once the user is logged in
178
- */
179
- loggedIn?: LoggedInEmbeddedView;
180
- /**
181
- * The embedded view to display once the user is logged out
182
- */
183
- loggedOut?: LoggedOutEmbeddedView;
184
- /**
185
- * Some metadata to customize the embedded view
186
- */
187
- metadata?: {
188
- /**
189
- * The logo to display on the embedded wallet
190
- * If undefined, will default to no logo displayed
191
- */
192
- logo?: string;
193
- /**
194
- * Link to the homepage of the calling website
195
- * If undefined, will default to the domain of the calling website
196
- */
197
- homepageLink?: string;
198
- /**
199
- * The target interaction behind this modal
200
- */
201
- targetInteraction?: FullInteractionTypesKey;
202
- /**
203
- * The position of the component
204
- */
205
- position?: "left" | "right";
206
- /**
207
- * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
208
- */
209
- i18n?: I18nConfig;
210
- };
211
- };
212
-
213
- /**
214
- * The result of the display embedded wallet rpc request
215
- *
216
- * @group Embedded wallet
217
- */
218
- export declare type DisplayEmbeddedWalletResultType = {
219
- wallet: Address;
220
- };
221
-
222
- /**
223
- * Function used to display a modal
224
- * @param client - The current Frak Client
225
- * @param args
226
- * @param args.steps - The different steps of the modal
227
- * @param args.metadata - The metadata for the modal (customization, etc)
228
- * @returns The result of each modal steps
229
- *
230
- * @description This function will display a modal to the user with the provided steps and metadata.
231
- *
232
- * @remarks
233
- * - The UI of the displayed modal can be configured with the `customCss` property in the `customizations.css` field of the top-level config.
234
- * - 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.
235
- * - Steps are automatically reordered in the following sequence:
236
- * 1. `login` (if needed)
237
- * 2. `openSession` (if needed)
238
- * 3. All other steps in the order specified
239
- * 4. `success` (if included, always last)
240
- *
241
- * @example
242
- * Simple sharing modal with steps:
243
- * 1. Login (Skipped if already logged in)
244
- * 2. Open a session (Skipped if already opened)
245
- * 3. Display a success message with sharing link option
246
- *
247
- * ```ts
248
- * const results = await displayModal(frakConfig, {
249
- * steps: {
250
- * // Simple login with no SSO, nor customization
251
- * login: { allowSso: false },
252
- * // Simple session opening, with no customization
253
- * openSession: {},
254
- * // Success message
255
- * final: {
256
- * action: { key: "reward" },
257
- * // Skip this step, it will be only displayed in the stepper within the modal
258
- * autoSkip: true,
259
- * },
260
- * },
261
- * });
262
- *
263
- * console.log("Login step - wallet", results.login.wallet);
264
- * console.log("Open session step - start + end", {
265
- * start: results.openSession.startTimestamp,
266
- * end: results.openSession.endTimestamp,
267
- * });
268
- * ```
269
- *
270
- * @example
271
- * A full modal example, with a few customization options, with the steps:
272
- * 1. Login (Skipped if already logged in)
273
- * 2. Open a session (Skipped if already opened)
274
- * 3. Authenticate via SIWE
275
- * 4. Send a transaction
276
- * 5. Display a success message with sharing link options
277
- *
278
- * ```ts
279
- * const results = await displayModal(frakConfig, {
280
- * steps: {
281
- * // Login step
282
- * login: {
283
- * allowSso: true,
284
- * ssoMetadata: {
285
- * logoUrl: "https://my-app.com/logo.png",
286
- * homepageLink: "https://my-app.com",
287
- * },
288
- * },
289
- * // Simple session opening, with no customisation
290
- * openSession: {},
291
- * // Siwe authentication
292
- * siweAuthenticate: {
293
- * siwe: {
294
- * domain: "my-app.com",
295
- * uri: "https://my-app.com/",
296
- * nonce: generateSiweNonce(),
297
- * version: "1",
298
- * },
299
- * },
300
- * // Send batched transaction
301
- * sendTransaction: {
302
- * tx: [
303
- * { to: "0xdeadbeef", data: "0xdeadbeef" },
304
- * { to: "0xdeadbeef", data: "0xdeadbeef" },
305
- * ],
306
- * },
307
- * // Success message with sharing options
308
- * final: {
309
- * action: {
310
- * key: "sharing",
311
- * options: {
312
- * popupTitle: "Share the app",
313
- * text: "Discover my super app website",
314
- * link: "https://my-app.com",
315
- * },
316
- * },
317
- * dismissedMetadata: {
318
- * title: "Dismiss",
319
- * description: "You won't be rewarded for this sharing action",
320
- * },
321
- * },
322
- * },
323
- * metadata: {
324
- * // Header of desktop modals
325
- * header: {
326
- * title: "My-App",
327
- * icon: "https://my-app.com/logo.png",
328
- * },
329
- * // Context that will be present in every modal steps
330
- * context: "My-app overkill flow",
331
- * },
332
- * });
333
- * ```
334
- */
335
- export declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, { steps, metadata }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
336
-
337
- /**
338
- * Params used to display a modal
339
- * @typeParam T - The list of modal steps we expect to have in the modal
340
- * @group Modal Display
341
- */
342
- export declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
343
- steps: ModalRpcStepsInput<T>;
344
- metadata?: ModalRpcMetadata;
345
- };
346
-
347
- declare type DoBackupEvent = {
348
- iframeLifecycle: "do-backup";
349
- data: {
350
- backup?: string;
351
- };
352
- };
353
-
354
- /**
355
- * The action to display on the logged out embedded view when the user is referred
356
- *
357
- * @group Embedded wallet
358
- */
359
- export declare type EmbeddedViewActionReferred = {
360
- key: "referred";
361
- /**
362
- * No options for a referred action
363
- */
364
- options?: never;
365
- };
366
-
367
- /**
368
- * The different type of action we can have on the embedded view (once the user is logged in)
369
- *
370
- * @group Embedded wallet
371
- */
372
- export declare type EmbeddedViewActionSharing = {
373
- key: "sharing";
374
- /**
375
- * Some sharing options
376
- */
377
- options?: {
378
- /**
379
- * The title that will be displayed on the system popup once the system sharing window is open
380
- * @deprecated Use the top level `config.metadata.i18n` instead
381
- */
382
- popupTitle?: string;
383
- /**
384
- * The text that will be shared alongside the link.
385
- * Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
386
- * @deprecated Use the top level `config.metadata.i18n` instead
387
- */
388
- text?: string;
389
- /**
390
- * The link to be shared (will be suffixed with the Frak sharing context)
391
- */
392
- link?: string;
393
- };
394
- };
395
-
396
- declare type EventProps = Record<string, unknown>;
397
-
398
- /**
399
- * The different types of final actions we can display in the final step
400
- * @group Modal Display
401
- */
402
- export declare type FinalActionType = {
403
- key: "sharing";
404
- options?: {
405
- /**
406
- * @deprecated Use the top level `config.metadata.i18n` instead
407
- */
408
- popupTitle?: string;
409
- /**
410
- * @deprecated Use the top level `config.metadata.i18n` instead
411
- */
412
- text?: string;
413
- link?: string;
414
- };
415
- } | {
416
- key: "reward";
417
- options?: never;
418
- };
419
-
420
- /**
421
- * The final modal step type, could be used to display sharing options or a success reward screen.
422
- *
423
- * **Input**: What type final step to display?
424
- * **Output**: None
425
- *
426
- * @group Modal Display
427
- */
428
- export declare type FinalModalStepType = GenericModalStepType<"final", {
429
- dismissedMetadata?: ModalStepMetadata["metadata"];
430
- action: FinalActionType;
431
- autoSkip?: boolean;
432
- }, object>;
433
-
434
- export declare function formatAmount(amount: number, currency?: Currency): string;
435
-
436
- /**
437
- * Representing a Frak client, used to interact with the Frak Wallet
438
- */
439
- export declare type FrakClient = {
440
- config: FrakWalletSdkConfig;
441
- debugInfo: {
442
- formatDebugInfo: (error: Error | unknown | string) => string;
443
- };
444
- openPanel?: OpenPanel;
445
- } & IFrameTransport;
446
-
447
- /**
448
- * The current Frak Context
449
- *
450
- * For now, only contain a referrer address.
451
- *
452
- * @ignore
453
- */
454
- export declare type FrakContext = {
455
- r: Address;
456
- };
457
-
458
- /**
459
- * Export our frak context
460
- */
461
- export declare const FrakContextManager: {
462
- compress: typeof compress;
463
- decompress: typeof decompress;
464
- parse: typeof parse;
465
- update: typeof update;
466
- remove: typeof remove;
467
- replaceUrl: typeof replaceUrl;
468
- };
469
-
470
- declare type FrakEvent = "share_button_clicked" | "wallet_button_clicked" | "share_modal_error" | "user_referred";
471
-
472
- /**
473
- * Represent an iframe event
474
- */
475
- export declare type FrakLifecycleEvent = IFrameLifecycleEvent | ClientLifecycleEvent;
476
-
477
- /**
478
- * Configuration for the Frak Wallet SDK
479
- * @category Config
480
- */
481
- export declare type FrakWalletSdkConfig = {
482
- /**
483
- * The Frak wallet url
484
- * @defaultValue "https://wallet.frak.id"
485
- */
486
- walletUrl?: string;
487
- /**
488
- * Some metadata about your implementation of the Frak SDK
489
- */
490
- metadata: {
491
- /**
492
- * Your application name (will be displayed in a few modals and in SSO)
493
- */
494
- name: string;
495
- /**
496
- * Language to display in the modal
497
- * If undefined, will default to the browser language
498
- */
499
- lang?: Language;
500
- /**
501
- * The currency to display in the modal
502
- * @defaultValue `"eur"`
503
- */
504
- currency?: Currency;
505
- /**
506
- * The logo URL that will be displayed in a few components
507
- */
508
- logoUrl?: string;
509
- /**
510
- * The homepage link that could be displayed in a few components
511
- */
512
- homepageLink?: string;
513
- };
514
- /**
515
- * Some customization for the modal
516
- */
517
- customizations?: {
518
- /**
519
- * Custom CSS styles to apply to the modals and components
520
- */
521
- css?: `${string}.css`;
522
- /**
523
- * Custom i18n configuration for the modal
524
- */
525
- i18n?: I18nConfig;
526
- };
527
- /**
528
- * The domain name of your application
529
- * @defaultValue window.location.host
530
- */
531
- domain?: string;
532
- };
533
-
534
- /**
535
- * The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
536
- * @inline
537
- */
538
- export declare type FullInteractionTypesKey = {
539
- [Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
540
- }[keyof typeof interactionTypes];
541
-
542
- /**
543
- * Represent a generic modal step type
544
- * @ignore
545
- * @inline
546
- */
547
- declare type GenericModalStepType<TKey, TParams, TReturns> = {
548
- key: TKey;
549
- params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
550
- returns: TReturns;
551
- };
552
-
553
- /**
554
- * Get the currency amount key for a given currency
555
- * @param currency - The currency to use
556
- * @returns The currency amount key
557
- */
558
- export declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
559
-
560
- /**
561
- * Function used to get the current product information
562
- * @param client - The current Frak Client
563
- * @returns The product information in a promise
564
- */
565
- export declare function getProductInformation(client: FrakClient): Promise<GetProductInformationReturnType>;
566
-
567
- /**
568
- * Response of the `frak_getProductInformation` RPC method
569
- * @group RPC Schema
570
- */
571
- export declare type GetProductInformationReturnType = {
572
- /**
573
- * Current product id
574
- */
575
- id: Hex;
576
- /**
577
- * Some metadata
578
- */
579
- onChainMetadata: {
580
- /**
581
- * Name of the product on-chain
582
- */
583
- name: string;
584
- /**
585
- * Domain of the product on-chain
586
- */
587
- domain: string;
588
- /**
589
- * The supported product types
590
- */
591
- productTypes: ProductTypesKey[];
592
- };
593
- /**
594
- * The max potential reward for the referrer
595
- */
596
- maxReferrer?: TokenAmountType;
597
- /**
598
- * The max potential reward for the referee
599
- */
600
- maxReferee?: TokenAmountType;
601
- /**
602
- * List of all the potentials reward arround this product
603
- */
604
- rewards: {
605
- token: Address;
606
- campaign: Address;
607
- interactionTypeKey: FullInteractionTypesKey;
608
- referrer: TokenAmountType;
609
- referee: TokenAmountType;
610
- }[];
611
- };
612
-
613
- /**
614
- * Get the supported currency for a given currency
615
- * @param currency - The currency to use
616
- * @returns The supported currency
617
- */
618
- export declare function getSupportedCurrency(currency?: Currency): Currency;
619
-
620
- /**
621
- * Get the supported locale for a given currency
622
- * @param currency - The currency to use
623
- * @returns The supported locale
624
- */
625
- export declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
626
-
627
- declare type HandshakeRequestEvent = {
628
- iframeLifecycle: "handshake";
629
- data: {
630
- token: string;
631
- };
632
- };
633
-
634
- declare type HandshakeResponse = {
635
- clientLifecycle: "handshake-response";
636
- data: {
637
- token: string;
638
- currentUrl: string;
639
- };
640
- };
641
-
642
- /**
643
- * The encoded data to send to a client / received by a client
644
- * @ignore
645
- */
646
- export declare type HashProtectedData<DataType> = Readonly<DataType & {
647
- validationHash: string;
648
- }>;
649
-
650
- declare type HearbeatEvent = {
651
- clientLifecycle: "heartbeat";
652
- data?: never;
653
- };
654
-
655
- /**
656
- * Custom i18n configuration for the modal
657
- * See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
658
- *
659
- * Available variables
660
- * - `{{ productName }}` : The name of your website (`metadata.name`)
661
- * - `{{ productOrigin }}` : The origin url of your website
662
- * - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
663
- *
664
- * Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
665
- * - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
666
- * - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
667
- *
668
- * @example
669
- * ```ts
670
- * // Multi language config
671
- * const multiI18n = {
672
- * fr: {
673
- * "sdk.modal.title": "Titre de modal",
674
- * "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
675
- * },
676
- * en: "https://example.com/en.json"
677
- * }
678
- *
679
- * // Single language config
680
- * const singleI18n = {
681
- * "sdk.modal.title": "Modal title",
682
- * "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
683
- * }
684
- * ```
685
- *
686
- * @category Config
687
- */
688
- export declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
689
-
690
- /**
691
- * Event related to the iframe lifecycle
692
- * @ignore
693
- */
694
- export declare type IFrameLifecycleEvent = {
695
- iframeLifecycle: "connected" | "show" | "hide" | "remove-backup";
696
- data?: never;
697
- } | DoBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
698
-
699
- /**
700
- * RPC interface that's used for the iframe communication
701
- *
702
- * Define all the methods available within the iFrame RPC client with response type annotations
703
- *
704
- * @group RPC Schema
705
- *
706
- * @remarks
707
- * Each method in the schema now includes a ResponseType field that indicates:
708
- * - "promise": One-shot request that resolves once
709
- * - "stream": Streaming request that can emit multiple values
710
- *
711
- * ### Methods:
712
- *
713
- * #### frak_listenToWalletStatus
714
- * - Params: None
715
- * - Returns: {@link WalletStatusReturnType}
716
- * - Response Type: stream (emits updates when wallet status changes)
717
- *
718
- * #### frak_displayModal
719
- * - Params: [requests: {@link ModalRpcStepsInput}, metadata?: {@link ModalRpcMetadata}, configMetadata: {@link FrakWalletSdkConfig}["metadata"]]
720
- * - Returns: {@link ModalRpcStepsResultType}
721
- * - Response Type: promise (one-shot)
722
- *
723
- * #### frak_sendInteraction
724
- * - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
725
- * - Returns: {@link SendInteractionReturnType}
726
- * - Response Type: promise (one-shot)
727
- *
728
- * #### frak_sso
729
- * - Params: [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
730
- * - Returns: {@link OpenSsoReturnType}
731
- * - Response Type: promise (one-shot)
732
- *
733
- * #### frak_getProductInformation
734
- * - Params: None
735
- * - Returns: {@link GetProductInformationReturnType}
736
- * - Response Type: promise (one-shot)
737
- *
738
- * #### frak_displayEmbeddedWallet
739
- * - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"]]
740
- * - Returns: {@link DisplayEmbeddedWalletResultType}
741
- * - Response Type: promise (one-shot)
742
- */
743
- export declare type IFrameRpcSchema = [
744
- /**
745
- * Method used to listen to the wallet status
746
- * This is a streaming method that emits updates when wallet status changes
747
- */
748
- {
749
- Method: "frak_listenToWalletStatus";
750
- Parameters?: undefined;
751
- ReturnType: WalletStatusReturnType;
752
- },
753
- /**
754
- * Method to display a modal with the provided steps
755
- * This is a one-shot request
756
- */
757
- {
758
- Method: "frak_displayModal";
759
- Parameters: [
760
- requests: ModalRpcStepsInput,
761
- metadata: ModalRpcMetadata | undefined,
762
- configMetadata: FrakWalletSdkConfig["metadata"]
763
- ];
764
- ReturnType: ModalRpcStepsResultType;
765
- },
766
- /**
767
- * Method to transmit a user interaction
768
- * This is a one-shot request
769
- */
770
- {
771
- Method: "frak_sendInteraction";
772
- Parameters: [
773
- productId: Hex,
774
- interaction: PreparedInteraction,
775
- signature?: Hex
776
- ];
777
- ReturnType: SendInteractionReturnType;
778
- },
779
- /**
780
- * Method to start a SSO
781
- * This is a one-shot request
782
- */
783
- {
784
- Method: "frak_sso";
785
- Parameters: [
786
- params: OpenSsoParamsType,
787
- name: string,
788
- customCss?: string
789
- ];
790
- ReturnType: OpenSsoReturnType;
791
- },
792
- /**
793
- * Method to get current product information's
794
- * - Is product minted?
795
- * - Does it have running campaign?
796
- * - Estimated reward on actions
797
- * This is a one-shot request
798
- */
799
- {
800
- Method: "frak_getProductInformation";
801
- Parameters?: undefined;
802
- ReturnType: GetProductInformationReturnType;
803
- },
804
- /**
805
- * Method to show the embedded wallet, with potential customization
806
- * This is a one-shot request
807
- */
808
- {
809
- Method: "frak_displayEmbeddedWallet";
810
- Parameters: [
811
- request: DisplayEmbeddedWalletParamsType,
812
- metadata: FrakWalletSdkConfig["metadata"]
813
- ];
814
- ReturnType: DisplayEmbeddedWalletResultType;
815
- }
816
- ];
817
-
818
- /**
819
- * IFrame transport interface
820
- */
821
- export declare type IFrameTransport = {
822
- /**
823
- * Wait for the connection to be established
824
- */
825
- waitForConnection: Promise<boolean>;
826
- /**
827
- * Wait for the setup to be done
828
- */
829
- waitForSetup: Promise<void>;
830
- /**
831
- * Function used to perform a single request via the iframe transport
832
- */
833
- request: RpcClient<IFrameRpcSchema, LifecycleMessage>["request"];
834
- /**
835
- * Function used to listen to a request response via the iframe transport
836
- */
837
- listenerRequest: RpcClient<IFrameRpcSchema, LifecycleMessage>["listen"];
838
- /**
839
- * Function used to destroy the iframe transport
840
- */
841
- destroy: () => Promise<void>;
842
- };
843
-
844
- /**
845
- * Each interactions types according to the product types
846
- */
847
- export declare const interactionTypes: {
848
- readonly press: {
849
- readonly openArticle: "0xc0a24ffb";
850
- readonly readArticle: "0xd5bd0fbe";
851
- };
852
- readonly dapp: {
853
- readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
854
- readonly callableVerifiableStorageUpdate: "0xa07da986";
855
- };
856
- readonly webshop: {
857
- readonly open: "0xb311798f";
858
- };
859
- readonly referral: {
860
- readonly referred: "0x010cc3b9";
861
- readonly createLink: "0xb2c0f17c";
862
- };
863
- readonly purchase: {
864
- readonly started: "0xd87e90c3";
865
- readonly completed: "0x8403aeb4";
866
- readonly unsafeCompleted: "0x4d5b14e0";
867
- };
868
- readonly retail: {
869
- readonly customerMeeting: "0x74489004";
870
- };
871
- };
872
-
873
- /**
874
- * The final keys for each interaction types (e.g. `openArticle`) -> interaction type
875
- * @inline
876
- */
877
- export declare type InteractionTypesKey = {
878
- [K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
879
- }[keyof typeof interactionTypes];
880
-
881
- /**
882
- * Represent a key provider used for the hashed and secure compression
883
- * @ignore
884
- */
885
- export declare type KeyProvider<DataType> = (value: DataType) => string[];
886
-
887
- /**
888
- * All the languages available
889
- * @category Config
890
- */
891
- export declare type Language = "fr" | "en";
892
-
893
- /**
894
- * Map the currency to the locale
895
- */
896
- export declare const locales: {
897
- readonly eur: "fr-FR";
898
- readonly usd: "en-US";
899
- readonly gbp: "en-GB";
900
- };
901
-
902
- /**
903
- * The keys for each locales
904
- * @inline
905
- */
906
- export declare type LocalesKey = keyof typeof locales;
907
-
908
- /**
909
- * A localized i18n config
910
- * @category Config
911
- */
912
- export declare type LocalizedI18nConfig = `${string}.css` | {
913
- [key: string]: string;
914
- };
915
-
916
- /**
917
- * Some configuration options for the embedded view
918
- *
919
- * @group Embedded wallet
920
- */
921
- export declare type LoggedInEmbeddedView = {
922
- /**
923
- * The main action to display on the logged in embedded view
924
- */
925
- action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
926
- };
927
-
928
- /**
929
- * The view when a user is logged out
930
- * @group Embedded wallet
931
- */
932
- export declare type LoggedOutEmbeddedView = {
933
- /**
934
- * Metadata option when displaying the embedded view
935
- */
936
- metadata?: {
937
- /**
938
- * The main CTA for the logged out view
939
- * - can include some variable, available ones are:
940
- * - {REWARD} -> The maximum reward a user can receive when interacting on your website
941
- * - can be formatted in markdown
942
- *
943
- * If not set, it will default to a internationalized message
944
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
945
- */
946
- text?: string;
947
- /**
948
- * The text that will be displayed on the login button
949
- *
950
- * If not set, it will default to a internationalized message
951
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
952
- */
953
- buttonText?: string;
954
- };
955
- };
956
-
957
- /**
958
- * The login step for a Modal
959
- *
960
- * **Input**: Do we allow SSO or not? Is yes then the SSO metadata
961
- * **Output**: The logged in wallet address
962
- *
963
- * @group Modal Display
964
- */
965
- export declare type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
966
- wallet: Address;
967
- }>;
968
-
969
- /** @inline */
970
- declare type LoginWithoutSso = {
971
- allowSso?: false;
972
- ssoMetadata?: never;
973
- };
974
-
975
- /** @inline */
976
- declare type LoginWithSso = {
977
- allowSso: true;
978
- ssoMetadata?: SsoMetadata;
979
- };
980
-
981
- /**
982
- * Represent the output type of the modal builder
983
- */
984
- export declare type ModalBuilder = ModalStepBuilder<[
985
- LoginModalStepType,
986
- OpenInteractionSessionModalStepType
987
- ]>;
988
-
989
- /**
990
- * Helper to craft Frak modal, and share a base initial config
991
- * @param client - The current Frak Client
992
- * @param args
993
- * @param args.metadata - Common modal metadata (customisation, language etc)
994
- * @param args.login - Login step parameters
995
- * @param args.openSession - Open session step parameters
996
- *
997
- * @description This function will create a modal builder with the provided metadata, login and open session parameters.
998
- *
999
- * @example
1000
- * Here is an example of how to use the `modalBuilder` to create and display a sharing modal:
1001
- *
1002
- * ```js
1003
- * // Create the modal builder
1004
- * const modalBuilder = window.FrakSDK.modalBuilder(frakClient, baseModalConfig);
1005
- *
1006
- * // Configure the information to be shared via the sharing link
1007
- * const sharingConfig = {
1008
- * popupTitle: "Share this with your friends",
1009
- * text: "Discover our product!",
1010
- * link: window.location.href,
1011
- * };
1012
- *
1013
- * // Display the sharing modal
1014
- * function modalShare() {
1015
- * modalBuilder.sharing(sharingConfig).display();
1016
- * }
1017
- * ```
1018
- *
1019
- * @see {@link ModalStepTypes} for more info about each modal step types and their parameters
1020
- * @see {@link ModalRpcMetadata} for more info about the metadata that can be passed to the modal
1021
- * @see {@link ModalRpcStepsResultType} for more info about the result of each modal steps
1022
- * @see {@link displayModal} for more info about how the modal is displayed
1023
- */
1024
- export declare function modalBuilder(client: FrakClient, { metadata, login, openSession, }: {
1025
- metadata?: ModalRpcMetadata;
1026
- login?: LoginModalStepType["params"];
1027
- openSession?: OpenInteractionSessionModalStepType["params"];
1028
- }): ModalBuilder;
1029
-
1030
- /**
1031
- * RPC metadata for the modal, used on top level modal configuration
1032
- * @group Modal Display
1033
- * @group RPC Schema
1034
- */
1035
- export declare type ModalRpcMetadata = {
1036
- header?: {
1037
- title?: string;
1038
- icon?: string;
1039
- };
1040
- targetInteraction?: FullInteractionTypesKey;
1041
- /**
1042
- * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
1043
- */
1044
- i18n?: I18nConfig;
1045
- } & ({
1046
- isDismissible: true;
1047
- /**
1048
- * @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
1049
- */
1050
- dismissActionTxt?: string;
1051
- } | {
1052
- isDismissible?: false;
1053
- dismissActionTxt?: never;
1054
- });
1055
-
1056
- /**
1057
- * Type for the RPC input of a modal
1058
- * Just the `params` type of each `ModalStepTypes`
1059
- * @typeParam T - The list of modal steps we expect to have in the modal
1060
- * @group Modal Display
1061
- * @group RPC Schema
1062
- */
1063
- export declare type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
1064
- [K in T[number]["key"]]?: Extract<T[number], {
1065
- key: K;
1066
- }>["params"];
1067
- };
1068
-
1069
- /**
1070
- * Type for the result of a modal request
1071
- * Just the `returns` type of each `ModalStepTypes`
1072
- * @typeParam T - The list of modal steps we expect to have in the modal
1073
- * @group Modal Display
1074
- * @group RPC Schema
1075
- */
1076
- export declare type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
1077
- [K in T[number]["key"]]: Extract<T[number], {
1078
- key: K;
1079
- }>["returns"];
1080
- };
1081
-
1082
- /**
1083
- * Represent the type of the modal step builder
1084
- */
1085
- export declare type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
1086
- /**
1087
- * The current modal params
1088
- */
1089
- params: DisplayModalParamsType<Steps>;
1090
- /**
1091
- * Add a send transaction step to the modal
1092
- */
1093
- sendTx: (options: SendTransactionModalStepType["params"]) => ModalStepBuilder<[...Steps, SendTransactionModalStepType]>;
1094
- /**
1095
- * Add a final step of type reward to the modal
1096
- */
1097
- reward: (options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
1098
- /**
1099
- * Add a final step of type sharing to the modal
1100
- */
1101
- sharing: (sharingOptions?: Extract<FinalActionType, {
1102
- key: "sharing";
1103
- }>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
1104
- /**
1105
- * Display the modal
1106
- * @param metadataOverride - Function returning optional metadata to override the current modal metadata
1107
- */
1108
- display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
1109
- };
1110
-
1111
- /**
1112
- * Metadata that can be used to customize a modal step
1113
- * @group Modal Display
1114
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1115
- */
1116
- export declare type ModalStepMetadata = {
1117
- metadata?: {
1118
- /**
1119
- * Custom title for the step
1120
- * If none provided, it will use an internationalized text
1121
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1122
- */
1123
- title?: string;
1124
- /**
1125
- * Custom description for the step
1126
- * If none provided, it will use an internationalized text
1127
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1128
- */
1129
- description?: string;
1130
- /**
1131
- * Custom text for the primary action of the step
1132
- * If none provided, it will use an internationalized text
1133
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1134
- */
1135
- primaryActionText?: string;
1136
- /**
1137
- * Custom text for the secondary action of the step
1138
- * If none provided, it will use an internationalized text
1139
- * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1140
- */
1141
- secondaryActionText?: string;
1142
- };
1143
- };
1144
-
1145
- /**
1146
- * Generic type of steps we will display in the modal to the end user
1147
- * @group Modal Display
1148
- */
1149
- export declare type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
1150
-
1151
- /**
1152
- * The open interaction session step for a Modal
1153
- *
1154
- * **Input**: None
1155
- * **Output**: The interactions session period (start and end timestamp)
1156
- *
1157
- * @group Modal Display
1158
- */
1159
- export declare type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
1160
-
1161
- /**
1162
- * Return type of the open session modal step
1163
- * @inline
1164
- * @ignore
1165
- */
1166
- export declare type OpenInteractionSessionReturnType = {
1167
- startTimestamp: number;
1168
- endTimestamp: number;
1169
- };
1170
-
1171
- /**
1172
- * Function used to open the SSO
1173
- * @param client - The current Frak Client
1174
- * @param args - The SSO parameters
1175
- *
1176
- * @description This function will open the SSO with the provided parameters.
1177
- *
1178
- * @example
1179
- * First we build the sso metadata
1180
- * ```ts
1181
- * // Build the metadata
1182
- * const metadata: SsoMetadata = {
1183
- * logoUrl: "https://my-app.com/logo.png",
1184
- * homepageLink: "https://my-app.com",
1185
- * };
1186
- * ```
1187
- *
1188
- * Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
1189
- * :::code-group
1190
- * ```ts [Direct exit]
1191
- * // Trigger an sso opening with redirection
1192
- * await openSso(frakConfig, {
1193
- * directExit: true,
1194
- * metadata,
1195
- * });
1196
- * ```
1197
- * ```ts [Redirection]
1198
- * // Trigger an sso opening within a popup with direct exit
1199
- * await openSso(frakConfig, {
1200
- * redirectUrl: "https://my-app.com/frak-sso",
1201
- * metadata,
1202
- * });
1203
- * ```
1204
- * ```ts [With tracking]
1205
- * // Trigger an sso with consumeKey for tracking
1206
- * const result = await openSso(frakConfig, {
1207
- * directExit: true,
1208
- * generateConsumeKey: true,
1209
- * metadata,
1210
- * });
1211
- * console.log(result.consumeKey); // Use this to track SSO status
1212
- * ```
1213
- * :::
1214
- */
1215
- export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
1216
-
1217
- /**
1218
- * Params to start a SSO
1219
- * @group RPC Schema
1220
- */
1221
- export declare type OpenSsoParamsType = {
1222
- /**
1223
- * Redirect URL after the SSO (optional)
1224
- */
1225
- redirectUrl?: string;
1226
- /**
1227
- * If the SSO should directly exit after completion
1228
- * @defaultValue true
1229
- */
1230
- directExit?: boolean;
1231
- /**
1232
- * If true, opens SSO in same window instead of popup
1233
- * Defaults to true when redirectUrl is provided, false otherwise
1234
- */
1235
- openInSameWindow?: boolean;
1236
- /**
1237
- * Language of the SSO page (optional)
1238
- * It will default to the current user language (or "en" if unsupported language)
1239
- */
1240
- lang?: "en" | "fr";
1241
- /**
1242
- * Custom SSO metadata
1243
- */
1244
- metadata: SsoMetadata;
1245
- };
1246
-
1247
- /**
1248
- * Response after an SSO has been openned
1249
- */
1250
- export declare type OpenSsoReturnType = {
1251
- /**
1252
- * Optional wallet address, returned when SSO completes via postMessage
1253
- * Note: Only present when SSO flow completes (not immediately on open)
1254
- */
1255
- wallet?: Hex;
1256
- };
1257
-
1258
- /**
1259
- * Parse the current URL into a Frak Context
1260
- * @param args
1261
- * @param args.url - The url to parse
1262
- * @returns The parsed Frak context
1263
- */
1264
- declare function parse({ url }: {
1265
- url: string;
1266
- }): FrakContext | null | undefined;
1267
-
1268
- /**
1269
- * Represent a prepared user interaction, ready to be sent on-chain via the wallet
1270
- */
1271
- export declare type PreparedInteraction = {
1272
- handlerTypeDenominator: Hex;
1273
- interactionData: Hex;
1274
- };
1275
-
1276
- /**
1277
- * Press interactions allow you to track user engagement with articles or other press content on your platform.
1278
- * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
1279
- *
1280
- * :::info
1281
- * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
1282
- * :::
1283
- *
1284
- * @description Encode press related user interactions
1285
- *
1286
- * @group Interactions Encoder
1287
- *
1288
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1289
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1290
- */
1291
- export declare const PressInteractionEncoder: {
1292
- /**
1293
- * Encode an open article interaction
1294
- * @param args
1295
- * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
1296
- */
1297
- openArticle({ articleId }: {
1298
- articleId: Hex;
1299
- }): PreparedInteraction;
1300
- /**
1301
- * Encode a read article interaction
1302
- * @param args
1303
- * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
1304
- */
1305
- readArticle({ articleId }: {
1306
- articleId: Hex;
1307
- }): PreparedInteraction;
1308
- };
1309
-
1310
- /**
1311
- * This function handle all the heavy lifting of the referral interaction process
1312
- * 1. Check if the user has been referred or not (if not, early exit)
1313
- * 2. Then check if the user is logged in or not
1314
- * 2.1 If not logged in, try a soft login, if it fail, display a modal for the user to login
1315
- * 3. Check if that's not a self-referral (if yes, early exit)
1316
- * 4. Check if the user has an interaction session or not
1317
- * 4.1 If not, display a modal for the user to open a session
1318
- * 5. Push the referred interaction
1319
- * 6. Update the current url with the right data
1320
- * 7. Return the resulting referral state
1321
- *
1322
- * If any error occurs during the process, the function will catch it and return an error state
1323
- *
1324
- * @param client - The current Frak Client
1325
- * @param args
1326
- * @param args.walletStatus - The current user wallet status
1327
- * @param args.frakContext - The current frak context
1328
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
1329
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
1330
- * @param args.options - Some options for the referral interaction
1331
- * @returns A promise with the resulting referral state
1332
- *
1333
- * @see {@link displayModal} for more details about the displayed modal
1334
- * @see {@link sendInteraction} for more details on the interaction submission part
1335
- * @see {@link ReferralInteractionEncoder} for more details about the referred interaction
1336
- * @see {@link ModalStepTypes} for more details on each modal steps types
1337
- */
1338
- export declare function processReferral(client: FrakClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
1339
- walletStatus?: WalletStatusReturnType;
1340
- frakContext?: Partial<FrakContext> | null;
1341
- modalConfig?: DisplayEmbeddedWalletParamsType;
1342
- productId?: Hex;
1343
- options?: ProcessReferralOptions;
1344
- }): Promise<ReferralState>;
1345
-
1346
- /**
1347
- * Options for the referral auto-interaction process
1348
- */
1349
- export declare type ProcessReferralOptions = {
1350
- /**
1351
- * If we want to always append the url with the frak context or not
1352
- * @defaultValue false
1353
- */
1354
- alwaysAppendUrl?: boolean;
1355
- };
1356
-
1357
- /**
1358
- * List of the product types per denominator
1359
- */
1360
- export declare const productTypes: {
1361
- dapp: number;
1362
- press: number;
1363
- webshop: number;
1364
- retail: number;
1365
- referral: number;
1366
- purchase: number;
1367
- };
1368
-
1369
- /**
1370
- * The keys for each product types
1371
- * @inline
1372
- */
1373
- export declare type ProductTypesKey = keyof typeof productTypes;
1374
-
1375
- /**
1376
- * Bitmask for each product types
1377
- */
1378
- export declare const productTypesMask: Record<ProductTypesKey, bigint>;
1379
-
1380
- /**
1381
- * Purchase interactions allow you to track user purchases on your platform.
1382
- * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
1383
- *
1384
- * :::info
1385
- * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
1386
- * :::
1387
- *
1388
- * :::note
1389
- * The `purchaseId` is used on both interactions. It can be computed like this:
1390
- *
1391
- * ```ts
1392
- * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
1393
- * ```
1394
- *
1395
- * With:
1396
- * - `productId`: The id of your product, you can find it in the product dashboard.
1397
- * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
1398
- * :::
1399
- *
1400
- * @description Encode purchase related user interactions
1401
- *
1402
- * @group Interactions Encoder
1403
- *
1404
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1405
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1406
- * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
1407
- * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
1408
- * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
1409
- */
1410
- export declare const PurchaseInteractionEncoder: {
1411
- /**
1412
- * Encode a start purchase interaction
1413
- * @param args
1414
- * @param args.purchaseId - The id of the purchase that is being started.
1415
- */
1416
- startPurchase({ purchaseId }: {
1417
- purchaseId: Hex;
1418
- }): PreparedInteraction;
1419
- /**
1420
- * Encode a complete purchase interaction
1421
- * @param args
1422
- * @param args.purchaseId - The id of the purchase that is being completed.
1423
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
1424
- */
1425
- completedPurchase({ purchaseId, proof, }: {
1426
- purchaseId: Hex;
1427
- proof: Hex[];
1428
- }): PreparedInteraction;
1429
- /**
1430
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
1431
- * @param args
1432
- * @param args.purchaseId - The id of the purchase that is being completed.
1433
- */
1434
- unsafeCompletedPurchase({ purchaseId, }: {
1435
- purchaseId: Hex;
1436
- }): PreparedInteraction;
1437
- };
1438
-
1439
- declare type RedirectRequestEvent = {
1440
- iframeLifecycle: "redirect";
1441
- data: {
1442
- /**
1443
- * The base url to redirect to
1444
- * If it contain a query param `u`, the client need will suffix the current url to the base url
1445
- */
1446
- baseRedirectUrl: string;
1447
- };
1448
- };
1449
-
1450
- /**
1451
- * Function used to display a modal
1452
- * @param client - The current Frak Client
1453
- * @param args
1454
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
1455
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
1456
- * @param args.options - Some options for the referral interaction
1457
- *
1458
- * @returns A promise with the resulting referral state, or undefined in case of an error
1459
- *
1460
- * @description This function will automatically handle the referral interaction process
1461
- *
1462
- * @see {@link processReferral} for more details on the automatic referral handling process
1463
- * @see {@link ModalStepTypes} for more details on each modal steps types
1464
- */
1465
- export declare function referralInteraction(client: FrakClient, { productId, modalConfig, options, }?: {
1466
- productId?: Hex;
1467
- modalConfig?: DisplayEmbeddedWalletParamsType;
1468
- options?: ProcessReferralOptions;
1469
- }): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
1470
-
1471
- /**
1472
- * Referral interactions allow you to track user sharing activities.
1473
- * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
1474
- *
1475
- * :::info
1476
- * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
1477
- * :::
1478
- *
1479
- * @description Encode referral related user interactions
1480
- *
1481
- * @group Interactions Encoder
1482
- *
1483
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1484
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1485
- */
1486
- export declare const ReferralInteractionEncoder: {
1487
- /**
1488
- * Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
1489
- */
1490
- createLink(): PreparedInteraction;
1491
- /**
1492
- * Encode a referred interaction
1493
- * @param args
1494
- * @param args.referrer - The Ethereum address of the user who made the referral
1495
- */
1496
- referred({ referrer }: {
1497
- referrer: Address;
1498
- }): PreparedInteraction;
1499
- };
1500
-
1501
- /**
1502
- * The different states of the referral process
1503
- * @inline
1504
- */
1505
- declare type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
1506
-
1507
- /**
1508
- * Remove Frak context from current url
1509
- * @param url - The url to update
1510
- * @returns The new url without the Frak context
1511
- */
1512
- declare function remove(url: string): string;
1513
-
1514
- /**
1515
- * Replace the current url with the given Frak context
1516
- * @param args
1517
- * @param args.url - The url to update
1518
- * @param args.context - The context to update
1519
- */
1520
- declare function replaceUrl({ url: baseUrl, context, }: {
1521
- url?: string;
1522
- context: Partial<FrakContext> | null;
1523
- }): void;
1524
-
1525
- declare type RestoreBackupEvent = {
1526
- clientLifecycle: "restore-backup";
1527
- data: {
1528
- backup: string;
1529
- };
1530
- };
1531
-
1532
- /**
1533
- * Retail interactions allow you to track user activities on your retails products.
1534
- *
1535
- * :::info
1536
- * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
1537
- * :::
1538
- *
1539
- * @description Encode retail related user interactions
1540
- *
1541
- * @group Interactions Encoder
1542
- *
1543
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1544
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1545
- */
1546
- export declare const RetailInteractionEncoder: {
1547
- /**
1548
- * Encode a customer meeting retail interaction
1549
- * @param args
1550
- * @param args.agencyId - The id of the agency that the customer is meeting with
1551
- *
1552
- */
1553
- customerMeeting({ agencyId }: {
1554
- agencyId: Hex;
1555
- }): PreparedInteraction;
1556
- };
1557
-
1558
- /**
1559
- * Function used to send an interaction
1560
- * @param client - The current Frak Client
1561
- * @param args
1562
- *
1563
- * @example
1564
- * const interaction = PressInteractionEncoder.openArticle({
1565
- * articleId: keccak256(toHex("article-slug")),
1566
- * });
1567
- * const { delegationId } = await sendInteraction(frakConfig, {
1568
- * interaction,
1569
- * });
1570
- * console.log("Delegated interaction id", delegationId);
1571
- */
1572
- export declare function sendInteraction(client: FrakClient, { productId, interaction, validation }: SendInteractionParamsType): Promise<SendInteractionReturnType>;
1573
-
1574
- /**
1575
- * Parameters that will be used to send an interaction to the blockchain
1576
- * @inline
1577
- */
1578
- export declare type SendInteractionParamsType = {
1579
- /**
1580
- * The product id where this interaction has been made
1581
- * @defaultValue keccak256(toHex(window.location.host))
1582
- */
1583
- productId?: Hex;
1584
- /**
1585
- * The prepared interaction, built from an Interaction Encoder
1586
- */
1587
- interaction: PreparedInteraction;
1588
- /**
1589
- * A pre-computed interaction signature
1590
- * If none provided, the delegated interaction validator of your product will sign it (you can manage it in the business dashboard)
1591
- *
1592
- * @defaultValue undefined
1593
- */
1594
- validation?: Hex;
1595
- };
1596
-
1597
- /**
1598
- * Return type of the send interaction rpc request
1599
- * @group RPC Schema
1600
- */
1601
- export declare type SendInteractionReturnType = {
1602
- /**
1603
- * The id of the interaction in the interaction pool
1604
- */
1605
- delegationId: string;
1606
- };
1607
-
1608
- /**
1609
- * Function used to send a user transaction, simple wrapper around the displayModal function to ease the send transaction process
1610
- * @param client - The current Frak Client
1611
- * @param args - The parameters
1612
- * @returns The hash of the transaction that was sent in a promise
1613
- *
1614
- * @description This function will display a modal to the user with the provided transaction and metadata.
1615
- *
1616
- * @example
1617
- * const { hash } = await sendTransaction(frakConfig, {
1618
- * tx: {
1619
- * to: "0xdeadbeef",
1620
- * value: toHex(100n),
1621
- * },
1622
- * metadata: {
1623
- * header: {
1624
- * title: "Sending eth",
1625
- * },
1626
- * context: "Send 100wei to 0xdeadbeef",
1627
- * },
1628
- * });
1629
- * console.log("Transaction hash:", hash);
1630
- */
1631
- export declare function sendTransaction(client: FrakClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
1632
-
1633
- /**
1634
- * The send transaction step for a Modal
1635
- *
1636
- * **Input**: Either a single tx or an array of tx to be sent
1637
- * **Output**: The hash of the tx(s) hash (in case of multiple tx, still returns a single hash because it's bundled on the wallet level)
1638
- *
1639
- * @group Modal Display
1640
- */
1641
- export declare type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
1642
- tx: SendTransactionTxType | SendTransactionTxType[];
1643
- }, SendTransactionReturnType>;
1644
-
1645
- /**
1646
- * Parameters to directly show a modal used to send a transaction
1647
- * @inline
1648
- */
1649
- export declare type SendTransactionParams = {
1650
- /**
1651
- * The transaction to be sent (either a single tx or multiple ones)
1652
- */
1653
- tx: SendTransactionModalStepType["params"]["tx"];
1654
- /**
1655
- * Custom metadata to be passed to the modal
1656
- */
1657
- metadata?: ModalRpcMetadata;
1658
- };
1659
-
1660
- /**
1661
- * Return type of the send transaction rpc request
1662
- * @inline
1663
- */
1664
- export declare type SendTransactionReturnType = {
1665
- hash: Hex;
1666
- };
1667
-
1668
- /**
1669
- * Generic format representing a tx to be sent
1670
- */
1671
- export declare type SendTransactionTxType = {
1672
- to: Address;
1673
- data?: Hex;
1674
- value?: Hex;
1675
- };
1676
-
1677
- /**
1678
- * Directly setup the Frak client with an iframe
1679
- * Return when the FrakClient is ready (setup and communication estbalished with the wallet)
1680
- *
1681
- * @param config - The configuration to use for the Frak Wallet SDK
1682
- * @returns a Promise with the Frak Client
1683
- *
1684
- * @example
1685
- * const frakConfig: FrakWalletSdkConfig = {
1686
- * metadata: {
1687
- * name: "My app title",
1688
- * },
1689
- * }
1690
- * const client = await setupClient({ config: frakConfig });
1691
- */
1692
- export declare function setupClient({ config, }: {
1693
- config: FrakWalletSdkConfig;
1694
- }): Promise<FrakClient | undefined>;
1695
-
1696
- /**
1697
- * Function used to launch a siwe authentication
1698
- * @param client - The current Frak Client
1699
- * @param args - The parameters
1700
- * @returns The SIWE authentication result (message + signature) in a promise
1701
- *
1702
- * @description This function will display a modal to the user with the provided SIWE parameters and metadata.
1703
- *
1704
- * @example
1705
- * import { siweAuthenticate } from "@frak-labs/core-sdk/actions";
1706
- * import { parseSiweMessage } from "viem/siwe";
1707
- *
1708
- * const { signature, message } = await siweAuthenticate(frakConfig, {
1709
- * siwe: {
1710
- * statement: "Sign in to My App",
1711
- * domain: "my-app.com",
1712
- * expirationTimeTimestamp: Date.now() + 1000 * 60 * 5,
1713
- * },
1714
- * metadata: {
1715
- * header: {
1716
- * title: "Sign in",
1717
- * },
1718
- * context: "Sign in to My App",
1719
- * },
1720
- * });
1721
- * console.log("Parsed final message:", parseSiweMessage(message));
1722
- * console.log("Siwe signature:", signature);
1723
- */
1724
- export declare function siweAuthenticate(client: FrakClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
1725
-
1726
- /**
1727
- * Parameter used to directly show a modal used to authenticate with SIWE
1728
- * @inline
1729
- */
1730
- export declare type SiweAuthenticateModalParams = {
1731
- /**
1732
- * Partial SIWE params, since we can rebuild them from the SDK if they are empty
1733
- *
1734
- * If no parameters provider, some fields will be recomputed from the current configuration and environment.
1735
- * - `statement` will be set to a default value
1736
- * - `nonce` will be generated
1737
- * - `uri` will be set to the current domain
1738
- * - `version` will be set to "1"
1739
- * - `domain` will be set to the current window domain
1740
- *
1741
- * @default {}
1742
- */
1743
- siwe?: Partial<SiweAuthenticationParams>;
1744
- /**
1745
- * Custom metadata to be passed to the modal
1746
- */
1747
- metadata?: ModalRpcMetadata;
1748
- };
1749
-
1750
- /**
1751
- * The SIWE authentication step for a Modal
1752
- *
1753
- * **Input**: SIWE message parameters
1754
- * **Output**: SIWE result (message signed and wallet signature)
1755
- *
1756
- * @group Modal Display
1757
- */
1758
- export declare type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
1759
- siwe: SiweAuthenticationParams;
1760
- }, SiweAuthenticateReturnType>;
1761
-
1762
- /**
1763
- * Return type of the Siwe transaction rpc request
1764
- * @inline
1765
- */
1766
- export declare type SiweAuthenticateReturnType = {
1767
- signature: Hex;
1768
- message: string;
1769
- };
1770
-
1771
- /**
1772
- * Parameters used send a SIWE rpc request
1773
- */
1774
- export declare type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
1775
- expirationTimeTimestamp?: number;
1776
- notBeforeTimestamp?: number;
1777
- };
1778
-
1779
- /**
1780
- * SSO Metadata
1781
- */
1782
- export declare type SsoMetadata = {
1783
- /**
1784
- * URL to your client, if provided will be displayed in the SSO header
1785
- */
1786
- logoUrl?: string;
1787
- /**
1788
- * Link to your homepage, if referenced your app name will contain a link on the sso page
1789
- */
1790
- homepageLink?: string;
1791
- };
1792
-
1793
- declare type SsoRedirectCompleteEvent = {
1794
- clientLifecycle: "sso-redirect-complete";
1795
- data: {
1796
- compressed: string;
1797
- };
1798
- };
1799
-
1800
- /**
1801
- * The type for the amount of tokens
1802
- */
1803
- export declare type TokenAmountType = {
1804
- amount: number;
1805
- eurAmount: number;
1806
- usdAmount: number;
1807
- gbpAmount: number;
1808
- };
1809
-
1810
- export declare function trackEvent(client: FrakClient | undefined, event: FrakEvent, props?: EventProps): void;
1811
-
1812
- /**
1813
- * Function used to track the status of a purchase
1814
- * when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
1815
- *
1816
- * @param args.customerId - The customer id that made the purchase (on your side)
1817
- * @param args.orderId - The order id of the purchase (on your side)
1818
- * @param args.token - The token of the purchase
1819
- *
1820
- * @description This function will send a request to the backend to listen for the purchase status.
1821
- *
1822
- * @example
1823
- * async function trackPurchase(checkout) {
1824
- * const payload = {
1825
- * customerId: checkout.order.customer.id,
1826
- * orderId: checkout.order.id,
1827
- * token: checkout.token,
1828
- * };
1829
- *
1830
- * await trackPurchaseStatus(payload);
1831
- * }
1832
- *
1833
- * @remarks
1834
- * - The `trackPurchaseStatus` function requires the `frak-wallet-interaction-token` stored in the session storage to authenticate the request.
1835
- * - This function will print a warning if used in a non-browser environment or if the wallet interaction token is not available.
1836
- */
1837
- export declare function trackPurchaseStatus(args: {
1838
- customerId: string | number;
1839
- orderId: string | number;
1840
- token: string;
1841
- }): Promise<void>;
1842
-
1843
- /**
1844
- * Populate the current url with the given Frak context
1845
- * @param args
1846
- * @param args.url - The url to update
1847
- * @param args.context - The context to update
1848
- * @returns The new url with the Frak context
1849
- */
1850
- declare function update({ url, context, }: {
1851
- url?: string;
1852
- context: Partial<FrakContext>;
1853
- }): string | null;
1854
-
1855
- /**
1856
- * @ignore
1857
- * @inline
1858
- */
1859
- declare type WalletConnected = {
1860
- key: "connected";
1861
- wallet: Address;
1862
- interactionToken?: string;
1863
- interactionSession?: {
1864
- startTimestamp: number;
1865
- endTimestamp: number;
1866
- };
1867
- };
1868
-
1869
- /**
1870
- * @ignore
1871
- * @inline
1872
- */
1873
- declare type WalletNotConnected = {
1874
- key: "not-connected";
1875
- wallet?: never;
1876
- interactionToken?: never;
1877
- interactionSession?: never;
1878
- };
1879
-
1880
- /**
1881
- * RPC Response for the method `frak_listenToWalletStatus`
1882
- * @group RPC Schema
1883
- */
1884
- export declare type WalletStatusReturnType = WalletConnected | WalletNotConnected;
1885
-
1886
- /**
1887
- * Function used to watch the current frak wallet status
1888
- * @param client - The current Frak Client
1889
- * @param callback - The callback that will receive any wallet status change
1890
- * @returns A promise resolving with the initial wallet status
1891
- *
1892
- * @description This function will return the current wallet status, and will listen to any change in the wallet status.
1893
- *
1894
- * @example
1895
- * await watchWalletStatus(frakConfig, (status: WalletStatusReturnType) => {
1896
- * if (status.key === "connected") {
1897
- * console.log("Wallet connected:", status.wallet);
1898
- * console.log("Current interaction session:", status.interactionSession);
1899
- * } else {
1900
- * console.log("Wallet not connected");
1901
- * }
1902
- * });
1903
- */
1904
- export declare function watchWalletStatus(client: FrakClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
1905
-
1906
- /**
1907
- * Webshop interactions allow you to track user activities on your webshop.
1908
- *
1909
- * :::info
1910
- * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
1911
- * :::
1912
- *
1913
- * @description Encode webshop related user interactions
1914
- *
1915
- * @group Interactions Encoder
1916
- *
1917
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1918
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1919
- */
1920
- export declare const WebShopInteractionEncoder: {
1921
- /**
1922
- * Encode an open webshop interaction
1923
- */
1924
- open(): PreparedInteraction;
1925
- };
1926
-
1927
- export { }
1
+ import { A as SiweAuthenticateReturnType, B as FinalActionType, C as ModalRpcStepsInput, D as SendTransactionReturnType, E as SendTransactionModalStepType, F as OpenSsoParamsType, G as interactionTypes, H as ModalStepMetadata, I as OpenSsoReturnType, J as Currency, K as IFrameLifecycleEvent, L as PrepareSsoParamsType, M as OpenInteractionSessionModalStepType, N as OpenInteractionSessionReturnType, O as SendTransactionTxType, P as LoginModalStepType, Q as LocalizedI18nConfig, R as PrepareSsoReturnType, S as ModalRpcMetadata, T as ModalStepTypes, U as FullInteractionTypesKey, V as FinalModalStepType, W as InteractionTypesKey, X as I18nConfig, Y as FrakWalletSdkConfig, Z as Language, _ as LoggedOutEmbeddedView, a as FrakClient, b as LoggedInEmbeddedView, c as IFrameRpcSchema, d as TokenAmountType, f as ProductTypesKey, g as DisplayEmbeddedWalletResultType, h as DisplayEmbeddedWalletParamsType, i as FrakContext, j as SiweAuthenticationParams, k as SiweAuthenticateModalStepType, l as WalletStatusReturnType, m as productTypesMask, n as ssoPopupFeatures, o as FrakLifecycleEvent, p as productTypes, q as ClientLifecycleEvent, r as ssoPopupName, s as IFrameTransport, t as openSso, u as GetProductInformationReturnType, v as EmbeddedViewActionReferred, w as ModalRpcStepsResultType, x as DisplayModalParamsType, y as EmbeddedViewActionSharing, z as SsoMetadata } from "./openSso-D--Airj6.cjs";
2
+ import { n as SendInteractionParamsType, r as SendInteractionReturnType, t as PreparedInteraction } from "./interaction-DMJ3ZfaF.cjs";
3
+ import { C as CompressedData, S as createIFrameFrakClient, T as KeyProvider, _ as base64urlEncode, a as generateSsoUrl, b as setupClient, c as findIframeInOpener, d as getCurrencyAmountKey, f as formatAmount, g as base64urlDecode, h as compressJsonToB64, i as FullSsoParams, l as getSupportedLocale, m as decompressJsonFromB64, n as AppSpecificSsoMetadata, o as baseIframeProps, p as FrakContextManager, r as CompressedSsoData, s as createIframe, t as trackEvent, u as getSupportedCurrency, v as LocalesKey, w as HashProtectedData, x as DebugInfoGatherer, y as locales } from "./index-p4FqSp8z.cjs";
4
+ import { _ as displayEmbeddedWallet, a as ModalBuilder, c as watchWalletStatus, d as referralInteraction, f as ProcessReferralOptions, g as displayModal, h as getProductInformation, i as sendTransaction, l as trackPurchaseStatus, m as prepareSso, n as siweAuthenticate, o as ModalStepBuilder, p as processReferral, r as SendTransactionParams, s as modalBuilder, t as SiweAuthenticateModalParams, u as sendInteraction } from "./index-C6FxkWPC.cjs";
5
+ import { a as PressInteractionEncoder, i as PurchaseInteractionEncoder, n as RetailInteractionEncoder, r as ReferralInteractionEncoder, t as WebShopInteractionEncoder } from "./index-zDq-VlKx.cjs";
6
+ export { AppSpecificSsoMetadata, ClientLifecycleEvent, CompressedData, CompressedSsoData, Currency, DebugInfoGatherer, DisplayEmbeddedWalletParamsType, DisplayEmbeddedWalletResultType, DisplayModalParamsType, EmbeddedViewActionReferred, EmbeddedViewActionSharing, FinalActionType, FinalModalStepType, FrakClient, FrakContext, FrakContextManager, FrakLifecycleEvent, FrakWalletSdkConfig, FullInteractionTypesKey, FullSsoParams, GetProductInformationReturnType, HashProtectedData, I18nConfig, IFrameLifecycleEvent, IFrameRpcSchema, IFrameTransport, InteractionTypesKey, KeyProvider, Language, LocalesKey, LocalizedI18nConfig, LoggedInEmbeddedView, LoggedOutEmbeddedView, LoginModalStepType, ModalBuilder, ModalRpcMetadata, ModalRpcStepsInput, ModalRpcStepsResultType, ModalStepBuilder, ModalStepMetadata, ModalStepTypes, OpenInteractionSessionModalStepType, OpenInteractionSessionReturnType, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, PrepareSsoReturnType, PreparedInteraction, PressInteractionEncoder, ProcessReferralOptions, ProductTypesKey, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, SendInteractionParamsType, SendInteractionReturnType, SendTransactionModalStepType, SendTransactionParams, SendTransactionReturnType, SendTransactionTxType, SiweAuthenticateModalParams, SiweAuthenticateModalStepType, SiweAuthenticateReturnType, SiweAuthenticationParams, SsoMetadata, TokenAmountType, WalletStatusReturnType, WebShopInteractionEncoder, base64urlDecode, base64urlEncode, baseIframeProps, compressJsonToB64, createIFrameFrakClient, createIframe, decompressJsonFromB64, displayEmbeddedWallet, displayModal, findIframeInOpener, formatAmount, generateSsoUrl, getCurrencyAmountKey, getProductInformation, getSupportedCurrency, getSupportedLocale, interactionTypes, locales, modalBuilder, openSso, prepareSso, processReferral, productTypes, productTypesMask, referralInteraction, sendInteraction, sendTransaction, setupClient, siweAuthenticate, ssoPopupFeatures, ssoPopupName, trackEvent, trackPurchaseStatus, watchWalletStatus };