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

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