@frak-labs/core-sdk 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.js +5 -5
- package/cdn/bundle.js.LICENSE.txt +1 -10
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +135 -58
- package/dist/actions.d.ts +135 -58
- package/dist/actions.js +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +171 -46
- package/dist/index.d.ts +171 -46
- package/dist/index.js +2 -2
- package/dist/interactions.cjs +1 -1
- package/package.json +6 -8
package/dist/actions.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ import type { SiweMessage } from 'viem/siwe';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* All the currencies available
|
|
9
|
+
* @category Config
|
|
9
10
|
*/
|
|
10
11
|
declare type Currency = "eur" | "usd" | "gbp";
|
|
11
12
|
|
|
@@ -17,31 +18,31 @@ declare type Currency = "eur" | "usd" | "gbp";
|
|
|
17
18
|
export declare function displayEmbededWallet(client: FrakClient, params: DisplayEmbededWalletParamsType): Promise<void>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* The params used to display the
|
|
21
|
+
* The params used to display the embedded wallet
|
|
21
22
|
*
|
|
22
|
-
* @group
|
|
23
|
+
* @group Embedded wallet
|
|
23
24
|
*/
|
|
24
25
|
declare type DisplayEmbededWalletParamsType = {
|
|
25
26
|
/**
|
|
26
|
-
* The
|
|
27
|
+
* The embedded view to display once the user is logged in
|
|
27
28
|
*/
|
|
28
29
|
loggedIn?: LoggedInEmbededView;
|
|
29
30
|
/**
|
|
30
|
-
* The
|
|
31
|
+
* The embedded view to display once the user is logged out
|
|
31
32
|
*/
|
|
32
33
|
loggedOut?: LoggedOutEmbededView;
|
|
33
34
|
/**
|
|
34
|
-
* Some metadata to
|
|
35
|
+
* Some metadata to customize the embedded view
|
|
35
36
|
*/
|
|
36
37
|
metadata?: {
|
|
37
38
|
/**
|
|
38
|
-
* The logo to display on the
|
|
39
|
+
* The logo to display on the embedded wallet
|
|
39
40
|
* If undefined, will default to no logo displayed
|
|
40
41
|
*/
|
|
41
42
|
logo?: string;
|
|
42
43
|
/**
|
|
43
44
|
* Link to the homepage of the calling website
|
|
44
|
-
* If
|
|
45
|
+
* If undefined, will default to the domain of the calling website
|
|
45
46
|
*/
|
|
46
47
|
homepageLink?: string;
|
|
47
48
|
/**
|
|
@@ -52,6 +53,10 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
52
53
|
* The position of the component
|
|
53
54
|
*/
|
|
54
55
|
position?: "left" | "right";
|
|
56
|
+
/**
|
|
57
|
+
* Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
|
|
58
|
+
*/
|
|
59
|
+
i18n?: I18nConfig;
|
|
55
60
|
};
|
|
56
61
|
};
|
|
57
62
|
|
|
@@ -60,13 +65,13 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
60
65
|
* @param client - The current Frak Client
|
|
61
66
|
* @param args
|
|
62
67
|
* @param args.steps - The different steps of the modal
|
|
63
|
-
* @param args.metadata - The metadata for the modal (
|
|
68
|
+
* @param args.metadata - The metadata for the modal (customization, etc)
|
|
64
69
|
* @returns The result of each modal steps
|
|
65
70
|
*
|
|
66
71
|
* @description This function will display a modal to the user with the provided steps and metadata.
|
|
67
72
|
*
|
|
68
73
|
* @remarks
|
|
69
|
-
* - The UI of the displayed modal can be configured with the `customCss` property in the `
|
|
74
|
+
* - The UI of the displayed modal can be configured with the `customCss` property in the `customizations.css` field of the top-level config.
|
|
70
75
|
* - 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.
|
|
71
76
|
* - Steps are automatically reordered in the following sequence:
|
|
72
77
|
* 1. `login` (if needed)
|
|
@@ -83,9 +88,9 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
83
88
|
* ```ts
|
|
84
89
|
* const results = await displayModal(frakConfig, {
|
|
85
90
|
* steps: {
|
|
86
|
-
* // Simple login with no SSO, nor
|
|
91
|
+
* // Simple login with no SSO, nor customization
|
|
87
92
|
* login: { allowSso: false },
|
|
88
|
-
* // Simple session opening, with no
|
|
93
|
+
* // Simple session opening, with no customization
|
|
89
94
|
* openSession: {},
|
|
90
95
|
* // Success message
|
|
91
96
|
* final: {
|
|
@@ -104,7 +109,7 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
104
109
|
* ```
|
|
105
110
|
*
|
|
106
111
|
* @example
|
|
107
|
-
* A full modal example, with a few
|
|
112
|
+
* A full modal example, with a few customization options, with the steps:
|
|
108
113
|
* 1. Login (Skipped if already logged in)
|
|
109
114
|
* 2. Open a session (Skipped if already opened)
|
|
110
115
|
* 3. Authenticate via SIWE
|
|
@@ -121,16 +126,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
121
126
|
* logoUrl: "https://my-app.com/logo.png",
|
|
122
127
|
* homepageLink: "https://my-app.com",
|
|
123
128
|
* },
|
|
124
|
-
* metadata: {
|
|
125
|
-
* // Modal title on desktop
|
|
126
|
-
* title: "Login on My-App",
|
|
127
|
-
* // Modal description (and yep it accept markdown)
|
|
128
|
-
* description: "## Please login to continue",
|
|
129
|
-
* // Primary button text
|
|
130
|
-
* primaryActionText: "Register",
|
|
131
|
-
* // Secondary button text
|
|
132
|
-
* secondaryActionText: "Login",
|
|
133
|
-
* },
|
|
134
129
|
* },
|
|
135
130
|
* // Simple session opening, with no customisation
|
|
136
131
|
* openSession: {},
|
|
@@ -142,11 +137,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
142
137
|
* nonce: generateSiweNonce(),
|
|
143
138
|
* version: "1",
|
|
144
139
|
* },
|
|
145
|
-
* metadata: {
|
|
146
|
-
* title: "Authenticate with SIWE",
|
|
147
|
-
* description: "Please authenticate with SIWE to continue",
|
|
148
|
-
* primaryActionText: "Authenticate",
|
|
149
|
-
* },
|
|
150
140
|
* },
|
|
151
141
|
* // Send batched transaction
|
|
152
142
|
* sendTransaction: {
|
|
@@ -154,10 +144,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
154
144
|
* { to: "0xdeadbeef", data: "0xdeadbeef" },
|
|
155
145
|
* { to: "0xdeadbeef", data: "0xdeadbeef" },
|
|
156
146
|
* ],
|
|
157
|
-
* metadata: {
|
|
158
|
-
* title: "Send a transaction",
|
|
159
|
-
* description: "Please send a transaction to continue",
|
|
160
|
-
* },
|
|
161
147
|
* },
|
|
162
148
|
* // Success message with sharing options
|
|
163
149
|
* final: {
|
|
@@ -200,9 +186,9 @@ declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
|
200
186
|
};
|
|
201
187
|
|
|
202
188
|
/**
|
|
203
|
-
* The different type of action we can have on the
|
|
189
|
+
* The different type of action we can have on the embedded view (once the user is logged in)
|
|
204
190
|
*
|
|
205
|
-
* @group
|
|
191
|
+
* @group Embedded wallet
|
|
206
192
|
*/
|
|
207
193
|
declare type EmbededViewAction = {
|
|
208
194
|
key: "sharing";
|
|
@@ -212,11 +198,13 @@ declare type EmbededViewAction = {
|
|
|
212
198
|
options?: {
|
|
213
199
|
/**
|
|
214
200
|
* The title that will be displayed on the system popup once the system sharing window is open
|
|
201
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
215
202
|
*/
|
|
216
203
|
popupTitle?: string;
|
|
217
204
|
/**
|
|
218
205
|
* The text that will be shared alongside the link.
|
|
219
206
|
* Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
|
|
207
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
220
208
|
*/
|
|
221
209
|
text?: string;
|
|
222
210
|
/**
|
|
@@ -261,7 +249,13 @@ declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameter
|
|
|
261
249
|
declare type FinalActionType = {
|
|
262
250
|
key: "sharing";
|
|
263
251
|
options?: {
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
254
|
+
*/
|
|
264
255
|
popupTitle?: string;
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
258
|
+
*/
|
|
265
259
|
text?: string;
|
|
266
260
|
link?: string;
|
|
267
261
|
};
|
|
@@ -298,13 +292,16 @@ declare type FrakClient = {
|
|
|
298
292
|
* The current Frak Context
|
|
299
293
|
*
|
|
300
294
|
* For now, only contain a referrer address.
|
|
295
|
+
*
|
|
296
|
+
* @ignore
|
|
301
297
|
*/
|
|
302
298
|
declare type FrakContext = {
|
|
303
299
|
r: Address;
|
|
304
300
|
};
|
|
305
301
|
|
|
306
302
|
/**
|
|
307
|
-
* Configuration for the
|
|
303
|
+
* Configuration for the Frak Wallet SDK
|
|
304
|
+
* @category Config
|
|
308
305
|
*/
|
|
309
306
|
declare type FrakWalletSdkConfig = {
|
|
310
307
|
/**
|
|
@@ -320,20 +317,37 @@ declare type FrakWalletSdkConfig = {
|
|
|
320
317
|
* Your application name (will be displayed in a few modals and in SSO)
|
|
321
318
|
*/
|
|
322
319
|
name: string;
|
|
323
|
-
/**
|
|
324
|
-
* Custom CSS styles to apply to the modals and components
|
|
325
|
-
*/
|
|
326
|
-
css?: string;
|
|
327
320
|
/**
|
|
328
321
|
* Language to display in the modal
|
|
329
322
|
* If undefined, will default to the browser language
|
|
330
323
|
*/
|
|
331
|
-
lang?:
|
|
324
|
+
lang?: Language;
|
|
332
325
|
/**
|
|
333
326
|
* The currency to display in the modal
|
|
334
327
|
* @defaultValue `"eur"`
|
|
335
328
|
*/
|
|
336
329
|
currency?: Currency;
|
|
330
|
+
/**
|
|
331
|
+
* The logo URL that will be displayed in a few components
|
|
332
|
+
*/
|
|
333
|
+
logoUrl?: string;
|
|
334
|
+
/**
|
|
335
|
+
* The homepage link that could be displayed in a few components
|
|
336
|
+
*/
|
|
337
|
+
homepageLink?: string;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* Some customization for the modal
|
|
341
|
+
*/
|
|
342
|
+
customizations?: {
|
|
343
|
+
/**
|
|
344
|
+
* Custom CSS styles to apply to the modals and components
|
|
345
|
+
*/
|
|
346
|
+
css?: `${string}.css`;
|
|
347
|
+
/**
|
|
348
|
+
* Custom i18n configuration for the modal
|
|
349
|
+
*/
|
|
350
|
+
i18n?: I18nConfig;
|
|
337
351
|
};
|
|
338
352
|
/**
|
|
339
353
|
* The domain name of your application
|
|
@@ -414,6 +428,41 @@ declare type GetProductInformationReturnType = {
|
|
|
414
428
|
}[];
|
|
415
429
|
};
|
|
416
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Custom i18n configuration for the modal
|
|
433
|
+
* See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
|
|
434
|
+
*
|
|
435
|
+
* Available variables
|
|
436
|
+
* - `{{ productName }}` : The name of your website (`metadata.name`)
|
|
437
|
+
* - `{{ productOrigin }}` : The origin url of your website
|
|
438
|
+
* - `{{ 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)
|
|
439
|
+
*
|
|
440
|
+
* Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
|
|
441
|
+
* - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
|
|
442
|
+
* - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```ts
|
|
446
|
+
* // Multi language config
|
|
447
|
+
* const multiI18n = {
|
|
448
|
+
* fr: {
|
|
449
|
+
* "sdk.modal.title": "Titre de modal",
|
|
450
|
+
* "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
|
|
451
|
+
* },
|
|
452
|
+
* en: "https://example.com/en.json"
|
|
453
|
+
* }
|
|
454
|
+
*
|
|
455
|
+
* // Single language config
|
|
456
|
+
* const singleI18n = {
|
|
457
|
+
* "sdk.modal.title": "Modal title",
|
|
458
|
+
* "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
|
|
459
|
+
* }
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* @category Config
|
|
463
|
+
*/
|
|
464
|
+
declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
|
|
465
|
+
|
|
417
466
|
/**
|
|
418
467
|
* RPC interface that's used for the iframe communication
|
|
419
468
|
*
|
|
@@ -464,7 +513,8 @@ declare type IFrameRpcSchema = [
|
|
|
464
513
|
Method: "frak_displayModal";
|
|
465
514
|
Parameters: [
|
|
466
515
|
requests: ModalRpcStepsInput,
|
|
467
|
-
metadata:
|
|
516
|
+
metadata: ModalRpcMetadata | undefined,
|
|
517
|
+
configMetadata: FrakWalletSdkConfig["metadata"]
|
|
468
518
|
];
|
|
469
519
|
ReturnType: ModalRpcStepsResultType;
|
|
470
520
|
},
|
|
@@ -505,12 +555,12 @@ declare type IFrameRpcSchema = [
|
|
|
505
555
|
ReturnType: GetProductInformationReturnType;
|
|
506
556
|
},
|
|
507
557
|
/**
|
|
508
|
-
* Method to show the
|
|
558
|
+
* Method to show the embedded wallet, with potential customization
|
|
509
559
|
*/
|
|
510
560
|
{
|
|
511
561
|
Method: "frak_displayEmbededWallet";
|
|
512
562
|
Parameters: [
|
|
513
|
-
DisplayEmbededWalletParamsType,
|
|
563
|
+
request: DisplayEmbededWalletParamsType,
|
|
514
564
|
metadata: FrakWalletSdkConfig["metadata"]
|
|
515
565
|
];
|
|
516
566
|
ReturnType: undefined;
|
|
@@ -572,6 +622,12 @@ declare const interactionTypes: {
|
|
|
572
622
|
};
|
|
573
623
|
};
|
|
574
624
|
|
|
625
|
+
/**
|
|
626
|
+
* All the languages available
|
|
627
|
+
* @category Config
|
|
628
|
+
*/
|
|
629
|
+
declare type Language = "fr" | "en";
|
|
630
|
+
|
|
575
631
|
/**
|
|
576
632
|
* Type used for a listening request
|
|
577
633
|
* @inline
|
|
@@ -579,13 +635,21 @@ declare const interactionTypes: {
|
|
|
579
635
|
declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
580
636
|
|
|
581
637
|
/**
|
|
582
|
-
*
|
|
638
|
+
* A localized i18n config
|
|
639
|
+
* @category Config
|
|
640
|
+
*/
|
|
641
|
+
declare type LocalizedI18nConfig = `${string}.css` | {
|
|
642
|
+
[key: string]: string;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Some configuration options for the embedded view
|
|
583
647
|
*
|
|
584
|
-
* @group
|
|
648
|
+
* @group Embedded wallet
|
|
585
649
|
*/
|
|
586
650
|
declare type LoggedInEmbededView = {
|
|
587
651
|
/**
|
|
588
|
-
* The main action to display on the logged in
|
|
652
|
+
* The main action to display on the logged in embedded view
|
|
589
653
|
* If none specified, the user will see his wallet with the activation button
|
|
590
654
|
*/
|
|
591
655
|
action?: EmbededViewAction;
|
|
@@ -593,26 +657,28 @@ declare type LoggedInEmbededView = {
|
|
|
593
657
|
|
|
594
658
|
/**
|
|
595
659
|
* The view when a user is logged out
|
|
596
|
-
* @group
|
|
660
|
+
* @group Embedded wallet
|
|
597
661
|
*/
|
|
598
662
|
declare type LoggedOutEmbededView = {
|
|
599
663
|
/**
|
|
600
|
-
* Metadata option when displaying the
|
|
664
|
+
* Metadata option when displaying the embedded view
|
|
601
665
|
*/
|
|
602
666
|
metadata?: {
|
|
603
667
|
/**
|
|
604
668
|
* The main CTA for the logged out view
|
|
605
669
|
* - can include some variable, available ones are:
|
|
606
|
-
* - {REWARD} -> The maximum reward a user can receive when
|
|
670
|
+
* - {REWARD} -> The maximum reward a user can receive when interacting on your website
|
|
607
671
|
* - can be formatted in markdown
|
|
608
672
|
*
|
|
609
|
-
* If not
|
|
673
|
+
* If not set, it will default to a internationalized message
|
|
674
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
610
675
|
*/
|
|
611
676
|
text?: string;
|
|
612
677
|
/**
|
|
613
678
|
* The text that will be displayed on the login button
|
|
614
679
|
*
|
|
615
|
-
* If not set, it will default to a
|
|
680
|
+
* If not set, it will default to a internationalized message
|
|
681
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
616
682
|
*/
|
|
617
683
|
buttonText?: string;
|
|
618
684
|
};
|
|
@@ -639,7 +705,7 @@ declare type LoginWithoutSso = {
|
|
|
639
705
|
/** @inline */
|
|
640
706
|
declare type LoginWithSso = {
|
|
641
707
|
allowSso: true;
|
|
642
|
-
ssoMetadata
|
|
708
|
+
ssoMetadata?: SsoMetadata;
|
|
643
709
|
};
|
|
644
710
|
|
|
645
711
|
/**
|
|
@@ -701,10 +767,16 @@ declare type ModalRpcMetadata = {
|
|
|
701
767
|
title?: string;
|
|
702
768
|
icon?: string;
|
|
703
769
|
};
|
|
704
|
-
context?: string;
|
|
705
770
|
targetInteraction?: FullInteractionTypesKey;
|
|
771
|
+
/**
|
|
772
|
+
* Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
|
|
773
|
+
*/
|
|
774
|
+
i18n?: I18nConfig;
|
|
706
775
|
} & ({
|
|
707
776
|
isDismissible: true;
|
|
777
|
+
/**
|
|
778
|
+
* @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
|
|
779
|
+
*/
|
|
708
780
|
dismissActionTxt?: string;
|
|
709
781
|
} | {
|
|
710
782
|
isDismissible?: false;
|
|
@@ -767,29 +839,34 @@ export declare type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepT
|
|
|
767
839
|
};
|
|
768
840
|
|
|
769
841
|
/**
|
|
770
|
-
* Metadata that can be used to
|
|
842
|
+
* Metadata that can be used to customize a modal step
|
|
771
843
|
* @group Modal Display
|
|
844
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
772
845
|
*/
|
|
773
846
|
declare type ModalStepMetadata = {
|
|
774
847
|
metadata?: {
|
|
775
848
|
/**
|
|
776
849
|
* Custom title for the step
|
|
777
|
-
* If none provided, it will use an
|
|
850
|
+
* If none provided, it will use an internationalized text
|
|
851
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
778
852
|
*/
|
|
779
853
|
title?: string;
|
|
780
854
|
/**
|
|
781
855
|
* Custom description for the step
|
|
782
|
-
* If none provided, it will use an
|
|
856
|
+
* If none provided, it will use an internationalized text
|
|
857
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
783
858
|
*/
|
|
784
859
|
description?: string;
|
|
785
860
|
/**
|
|
786
861
|
* Custom text for the primary action of the step
|
|
787
|
-
* If none provided, it will use an
|
|
862
|
+
* If none provided, it will use an internationalized text
|
|
863
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
788
864
|
*/
|
|
789
865
|
primaryActionText?: string;
|
|
790
866
|
/**
|
|
791
867
|
* Custom text for the secondary action of the step
|
|
792
|
-
* If none provided, it will use an
|
|
868
|
+
* If none provided, it will use an internationalized text
|
|
869
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
793
870
|
*/
|
|
794
871
|
secondaryActionText?: string;
|
|
795
872
|
};
|
|
@@ -850,7 +927,7 @@ declare type OpenInteractionSessionReturnType = {
|
|
|
850
927
|
* ```ts [Redirection]
|
|
851
928
|
* // Trigger an sso opening within a popup with direct exit
|
|
852
929
|
* await openSso(frakConfig, {
|
|
853
|
-
* redirectUrl: "https://my-app.com/
|
|
930
|
+
* redirectUrl: "https://my-app.com/frak-sso",
|
|
854
931
|
* metadata,
|
|
855
932
|
* });
|
|
856
933
|
* ```
|