@frak-labs/core-sdk 0.0.19-beta.f259d7fc → 0.1.0-beta.263acd1e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.iife.js +14 -0
- package/dist/actions-CEEObPYc.js +1 -0
- package/dist/actions-DbQhWYx8.cjs +1 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +3 -1400
- package/dist/actions.d.ts +3 -1400
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +1 -13
- package/dist/bundle.d.cts +6 -1927
- package/dist/bundle.d.ts +6 -1927
- package/dist/bundle.js +1 -13
- package/dist/index-7OZ39x1U.d.ts +195 -0
- package/dist/index-C6FxkWPC.d.cts +511 -0
- package/dist/index-UFX7xCg3.d.ts +351 -0
- package/dist/index-d8xS4ryI.d.ts +511 -0
- package/dist/index-p4FqSp8z.d.cts +351 -0
- package/dist/index-zDq-VlKx.d.cts +195 -0
- package/dist/index.cjs +1 -13
- package/dist/index.d.cts +4 -1269
- package/dist/index.d.ts +4 -1269
- package/dist/index.js +1 -13
- package/dist/interaction-DMJ3ZfaF.d.cts +45 -0
- package/dist/interaction-KX1h9a7V.d.ts +45 -0
- package/dist/interactions-DnfM3oe0.js +1 -0
- package/dist/interactions-EIXhNLf6.cjs +1 -0
- package/dist/interactions.cjs +1 -1
- package/dist/interactions.d.cts +2 -182
- package/dist/interactions.d.ts +2 -182
- package/dist/interactions.js +1 -1
- package/dist/openSso-D--Airj6.d.cts +1018 -0
- package/dist/openSso-DsKJ4y0j.d.ts +1018 -0
- package/dist/productTypes-BUkXJKZ7.cjs +1 -0
- package/dist/productTypes-CGb1MmBF.js +1 -0
- package/dist/src-B_xO0AR6.cjs +13 -0
- package/dist/src-D2d52OZa.js +13 -0
- package/dist/trackEvent-CHnYa85W.js +1 -0
- package/dist/trackEvent-GuQm_1Nm.cjs +1 -0
- package/package.json +24 -19
- package/src/actions/displayEmbeddedWallet.test.ts +194 -0
- package/src/actions/displayEmbeddedWallet.ts +20 -0
- package/src/actions/displayModal.test.ts +387 -0
- package/src/actions/displayModal.ts +131 -0
- package/src/actions/getProductInformation.test.ts +133 -0
- package/src/actions/getProductInformation.ts +14 -0
- package/src/actions/index.ts +29 -0
- package/src/actions/openSso.test.ts +407 -0
- package/src/actions/openSso.ts +116 -0
- package/src/actions/prepareSso.test.ts +223 -0
- package/src/actions/prepareSso.ts +48 -0
- package/src/actions/referral/processReferral.ts +230 -0
- package/src/actions/referral/referralInteraction.ts +57 -0
- package/src/actions/sendInteraction.test.ts +219 -0
- package/src/actions/sendInteraction.ts +32 -0
- package/src/actions/trackPurchaseStatus.test.ts +287 -0
- package/src/actions/trackPurchaseStatus.ts +53 -0
- package/src/actions/watchWalletStatus.test.ts +372 -0
- package/src/actions/watchWalletStatus.ts +94 -0
- package/src/actions/wrapper/modalBuilder.ts +212 -0
- package/src/actions/wrapper/sendTransaction.ts +62 -0
- package/src/actions/wrapper/siweAuthenticate.ts +94 -0
- package/src/bundle.ts +3 -0
- package/src/clients/DebugInfo.ts +182 -0
- package/src/clients/createIFrameFrakClient.ts +287 -0
- package/src/clients/index.ts +3 -0
- package/src/clients/setupClient.test.ts +343 -0
- package/src/clients/setupClient.ts +73 -0
- package/src/clients/transports/iframeLifecycleManager.test.ts +399 -0
- package/src/clients/transports/iframeLifecycleManager.ts +90 -0
- package/src/constants/interactionTypes.ts +44 -0
- package/src/constants/locales.ts +14 -0
- package/src/constants/productTypes.ts +33 -0
- package/src/index.ts +101 -0
- package/src/interactions/index.ts +5 -0
- package/src/interactions/pressEncoder.test.ts +215 -0
- package/src/interactions/pressEncoder.ts +53 -0
- package/src/interactions/purchaseEncoder.test.ts +291 -0
- package/src/interactions/purchaseEncoder.ts +99 -0
- package/src/interactions/referralEncoder.test.ts +170 -0
- package/src/interactions/referralEncoder.ts +47 -0
- package/src/interactions/retailEncoder.test.ts +107 -0
- package/src/interactions/retailEncoder.ts +37 -0
- package/src/interactions/webshopEncoder.test.ts +56 -0
- package/src/interactions/webshopEncoder.ts +30 -0
- package/src/types/client.ts +14 -0
- package/src/types/compression.ts +22 -0
- package/src/types/config.ts +111 -0
- package/src/types/context.ts +13 -0
- package/src/types/index.ts +71 -0
- package/src/types/lifecycle/client.ts +46 -0
- package/src/types/lifecycle/iframe.ts +35 -0
- package/src/types/lifecycle/index.ts +2 -0
- package/src/types/rpc/displayModal.ts +84 -0
- package/src/types/rpc/embedded/index.ts +68 -0
- package/src/types/rpc/embedded/loggedIn.ts +55 -0
- package/src/types/rpc/embedded/loggedOut.ts +28 -0
- package/src/types/rpc/interaction.ts +43 -0
- package/src/types/rpc/modal/final.ts +46 -0
- package/src/types/rpc/modal/generic.ts +46 -0
- package/src/types/rpc/modal/index.ts +20 -0
- package/src/types/rpc/modal/login.ts +32 -0
- package/src/types/rpc/modal/openSession.ts +25 -0
- package/src/types/rpc/modal/siweAuthenticate.ts +37 -0
- package/src/types/rpc/modal/transaction.ts +33 -0
- package/src/types/rpc/productInformation.ts +59 -0
- package/src/types/rpc/sso.ts +80 -0
- package/src/types/rpc/walletStatus.ts +35 -0
- package/src/types/rpc.ts +158 -0
- package/src/types/transport.ts +34 -0
- package/src/utils/FrakContext.test.ts +407 -0
- package/src/utils/FrakContext.ts +158 -0
- package/src/utils/compression/b64.test.ts +181 -0
- package/src/utils/compression/b64.ts +29 -0
- package/src/utils/compression/compress.test.ts +123 -0
- package/src/utils/compression/compress.ts +11 -0
- package/src/utils/compression/decompress.test.ts +145 -0
- package/src/utils/compression/decompress.ts +11 -0
- package/src/utils/compression/index.ts +3 -0
- package/src/utils/computeProductId.test.ts +80 -0
- package/src/utils/computeProductId.ts +11 -0
- package/src/utils/constants.test.ts +23 -0
- package/src/utils/constants.ts +4 -0
- package/src/utils/formatAmount.test.ts +113 -0
- package/src/utils/formatAmount.ts +18 -0
- package/src/utils/getCurrencyAmountKey.test.ts +44 -0
- package/src/utils/getCurrencyAmountKey.ts +15 -0
- package/src/utils/getSupportedCurrency.test.ts +51 -0
- package/src/utils/getSupportedCurrency.ts +14 -0
- package/src/utils/getSupportedLocale.test.ts +64 -0
- package/src/utils/getSupportedLocale.ts +16 -0
- package/src/utils/iframeHelper.test.ts +450 -0
- package/src/utils/iframeHelper.ts +143 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/sso.test.ts +361 -0
- package/src/utils/sso.ts +119 -0
- package/src/utils/ssoUrlListener.ts +60 -0
- package/src/utils/trackEvent.test.ts +162 -0
- package/src/utils/trackEvent.ts +26 -0
- package/cdn/bundle.js +0 -19
- package/cdn/bundle.js.LICENSE.txt +0 -10
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
import { r as SendInteractionReturnType, t as PreparedInteraction } from "./interaction-DMJ3ZfaF.cjs";
|
|
2
|
+
import { OpenPanel } from "@openpanel/web";
|
|
3
|
+
import { LifecycleMessage, RpcClient } from "@frak-labs/frame-connector";
|
|
4
|
+
import { Address, Hex } from "viem";
|
|
5
|
+
import { SiweMessage } from "viem/siwe";
|
|
6
|
+
|
|
7
|
+
//#region src/types/config.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* All the currencies available
|
|
10
|
+
* @category Config
|
|
11
|
+
*/
|
|
12
|
+
type Currency = "eur" | "usd" | "gbp";
|
|
13
|
+
/**
|
|
14
|
+
* All the languages available
|
|
15
|
+
* @category Config
|
|
16
|
+
*/
|
|
17
|
+
type Language = "fr" | "en";
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for the Frak Wallet SDK
|
|
20
|
+
* @category Config
|
|
21
|
+
*/
|
|
22
|
+
type FrakWalletSdkConfig = {
|
|
23
|
+
/**
|
|
24
|
+
* The Frak wallet url
|
|
25
|
+
* @defaultValue "https://wallet.frak.id"
|
|
26
|
+
*/
|
|
27
|
+
walletUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Some metadata about your implementation of the Frak SDK
|
|
30
|
+
*/
|
|
31
|
+
metadata: {
|
|
32
|
+
/**
|
|
33
|
+
* Your application name (will be displayed in a few modals and in SSO)
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* Language to display in the modal
|
|
38
|
+
* If undefined, will default to the browser language
|
|
39
|
+
*/
|
|
40
|
+
lang?: Language;
|
|
41
|
+
/**
|
|
42
|
+
* The currency to display in the modal
|
|
43
|
+
* @defaultValue `"eur"`
|
|
44
|
+
*/
|
|
45
|
+
currency?: Currency;
|
|
46
|
+
/**
|
|
47
|
+
* The logo URL that will be displayed in a few components
|
|
48
|
+
*/
|
|
49
|
+
logoUrl?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The homepage link that could be displayed in a few components
|
|
52
|
+
*/
|
|
53
|
+
homepageLink?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Some customization for the modal
|
|
57
|
+
*/
|
|
58
|
+
customizations?: {
|
|
59
|
+
/**
|
|
60
|
+
* Custom CSS styles to apply to the modals and components
|
|
61
|
+
*/
|
|
62
|
+
css?: `${string}.css`;
|
|
63
|
+
/**
|
|
64
|
+
* Custom i18n configuration for the modal
|
|
65
|
+
*/
|
|
66
|
+
i18n?: I18nConfig;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The domain name of your application
|
|
70
|
+
* @defaultValue window.location.host
|
|
71
|
+
*/
|
|
72
|
+
domain?: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Custom i18n configuration for the modal
|
|
76
|
+
* See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
|
|
77
|
+
*
|
|
78
|
+
* Available variables
|
|
79
|
+
* - `{{ productName }}` : The name of your website (`metadata.name`)
|
|
80
|
+
* - `{{ productOrigin }}` : The origin url of your website
|
|
81
|
+
* - `{{ 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)
|
|
82
|
+
*
|
|
83
|
+
* Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
|
|
84
|
+
* - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
|
|
85
|
+
* - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* // Multi language config
|
|
90
|
+
* const multiI18n = {
|
|
91
|
+
* fr: {
|
|
92
|
+
* "sdk.modal.title": "Titre de modal",
|
|
93
|
+
* "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
|
|
94
|
+
* },
|
|
95
|
+
* en: "https://example.com/en.json"
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* // Single language config
|
|
99
|
+
* const singleI18n = {
|
|
100
|
+
* "sdk.modal.title": "Modal title",
|
|
101
|
+
* "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @category Config
|
|
106
|
+
*/
|
|
107
|
+
type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
|
|
108
|
+
/**
|
|
109
|
+
* A localized i18n config
|
|
110
|
+
* @category Config
|
|
111
|
+
*/
|
|
112
|
+
type LocalizedI18nConfig = `${string}.css` | {
|
|
113
|
+
[key: string]: string;
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/types/lifecycle/client.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* Event related to the iframe lifecycle
|
|
119
|
+
* @ignore
|
|
120
|
+
*/
|
|
121
|
+
type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse | SsoRedirectCompleteEvent;
|
|
122
|
+
type CustomCssEvent = {
|
|
123
|
+
clientLifecycle: "modal-css";
|
|
124
|
+
data: {
|
|
125
|
+
cssLink: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
type CustomI18nEvent = {
|
|
129
|
+
clientLifecycle: "modal-i18n";
|
|
130
|
+
data: {
|
|
131
|
+
i18n: I18nConfig;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
type RestoreBackupEvent = {
|
|
135
|
+
clientLifecycle: "restore-backup";
|
|
136
|
+
data: {
|
|
137
|
+
backup: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
type HearbeatEvent = {
|
|
141
|
+
clientLifecycle: "heartbeat";
|
|
142
|
+
data?: never;
|
|
143
|
+
};
|
|
144
|
+
type HandshakeResponse = {
|
|
145
|
+
clientLifecycle: "handshake-response";
|
|
146
|
+
data: {
|
|
147
|
+
token: string;
|
|
148
|
+
currentUrl: string;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
type SsoRedirectCompleteEvent = {
|
|
152
|
+
clientLifecycle: "sso-redirect-complete";
|
|
153
|
+
data: {
|
|
154
|
+
compressed: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/types/lifecycle/iframe.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* Event related to the iframe lifecycle
|
|
161
|
+
* @ignore
|
|
162
|
+
*/
|
|
163
|
+
type IFrameLifecycleEvent = {
|
|
164
|
+
iframeLifecycle: "connected" | "show" | "hide" | "remove-backup";
|
|
165
|
+
data?: never;
|
|
166
|
+
} | DoBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
|
|
167
|
+
type DoBackupEvent = {
|
|
168
|
+
iframeLifecycle: "do-backup";
|
|
169
|
+
data: {
|
|
170
|
+
backup?: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
type HandshakeRequestEvent = {
|
|
174
|
+
iframeLifecycle: "handshake";
|
|
175
|
+
data: {
|
|
176
|
+
token: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
type RedirectRequestEvent = {
|
|
180
|
+
iframeLifecycle: "redirect";
|
|
181
|
+
data: {
|
|
182
|
+
/**
|
|
183
|
+
* The base url to redirect to
|
|
184
|
+
* If it contain a query param `u`, the client need will suffix the current url to the base url
|
|
185
|
+
*/
|
|
186
|
+
baseRedirectUrl: string;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/constants/interactionTypes.d.ts
|
|
191
|
+
/**
|
|
192
|
+
* The final keys for each interaction types (e.g. `openArticle`) -> interaction type
|
|
193
|
+
* @inline
|
|
194
|
+
*/
|
|
195
|
+
type InteractionTypesKey = { [K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K] }[keyof typeof interactionTypes];
|
|
196
|
+
/**
|
|
197
|
+
* The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
|
|
198
|
+
* @inline
|
|
199
|
+
*/
|
|
200
|
+
type FullInteractionTypesKey = { [Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}` }[keyof typeof interactionTypes];
|
|
201
|
+
/**
|
|
202
|
+
* Each interactions types according to the product types
|
|
203
|
+
*/
|
|
204
|
+
declare const interactionTypes: {
|
|
205
|
+
readonly press: {
|
|
206
|
+
readonly openArticle: "0xc0a24ffb";
|
|
207
|
+
readonly readArticle: "0xd5bd0fbe";
|
|
208
|
+
};
|
|
209
|
+
readonly dapp: {
|
|
210
|
+
readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
|
|
211
|
+
readonly callableVerifiableStorageUpdate: "0xa07da986";
|
|
212
|
+
};
|
|
213
|
+
readonly webshop: {
|
|
214
|
+
readonly open: "0xb311798f";
|
|
215
|
+
};
|
|
216
|
+
readonly referral: {
|
|
217
|
+
readonly referred: "0x010cc3b9";
|
|
218
|
+
readonly createLink: "0xb2c0f17c";
|
|
219
|
+
};
|
|
220
|
+
readonly purchase: {
|
|
221
|
+
readonly started: "0xd87e90c3";
|
|
222
|
+
readonly completed: "0x8403aeb4";
|
|
223
|
+
readonly unsafeCompleted: "0x4d5b14e0";
|
|
224
|
+
};
|
|
225
|
+
readonly retail: {
|
|
226
|
+
readonly customerMeeting: "0x74489004";
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/types/rpc/modal/generic.d.ts
|
|
231
|
+
/**
|
|
232
|
+
* Represent a generic modal step type
|
|
233
|
+
* @ignore
|
|
234
|
+
* @inline
|
|
235
|
+
*/
|
|
236
|
+
type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
237
|
+
key: TKey;
|
|
238
|
+
params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
|
|
239
|
+
returns: TReturns;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Metadata that can be used to customize a modal step
|
|
243
|
+
* @group Modal Display
|
|
244
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
245
|
+
*/
|
|
246
|
+
type ModalStepMetadata = {
|
|
247
|
+
metadata?: {
|
|
248
|
+
/**
|
|
249
|
+
* Custom title for the step
|
|
250
|
+
* If none provided, it will use an internationalized text
|
|
251
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
252
|
+
*/
|
|
253
|
+
title?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Custom description for the step
|
|
256
|
+
* If none provided, it will use an internationalized text
|
|
257
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
258
|
+
*/
|
|
259
|
+
description?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Custom text for the primary action of the step
|
|
262
|
+
* If none provided, it will use an internationalized text
|
|
263
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
264
|
+
*/
|
|
265
|
+
primaryActionText?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Custom text for the secondary action of the step
|
|
268
|
+
* If none provided, it will use an internationalized text
|
|
269
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
270
|
+
*/
|
|
271
|
+
secondaryActionText?: string;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/types/rpc/modal/final.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* The final modal step type, could be used to display sharing options or a success reward screen.
|
|
278
|
+
*
|
|
279
|
+
* **Input**: What type final step to display?
|
|
280
|
+
* **Output**: None
|
|
281
|
+
*
|
|
282
|
+
* @group Modal Display
|
|
283
|
+
*/
|
|
284
|
+
type FinalModalStepType = GenericModalStepType<"final", {
|
|
285
|
+
dismissedMetadata?: ModalStepMetadata["metadata"];
|
|
286
|
+
action: FinalActionType;
|
|
287
|
+
autoSkip?: boolean;
|
|
288
|
+
}, object>;
|
|
289
|
+
/**
|
|
290
|
+
* The different types of final actions we can display in the final step
|
|
291
|
+
* @group Modal Display
|
|
292
|
+
*/
|
|
293
|
+
type FinalActionType = {
|
|
294
|
+
key: "sharing";
|
|
295
|
+
options?: {
|
|
296
|
+
/**
|
|
297
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
298
|
+
*/
|
|
299
|
+
popupTitle?: string;
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
302
|
+
*/
|
|
303
|
+
text?: string;
|
|
304
|
+
link?: string;
|
|
305
|
+
};
|
|
306
|
+
} | {
|
|
307
|
+
key: "reward";
|
|
308
|
+
options?: never;
|
|
309
|
+
};
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/types/rpc/sso.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* SSO Metadata
|
|
314
|
+
*/
|
|
315
|
+
type SsoMetadata = {
|
|
316
|
+
/**
|
|
317
|
+
* URL to your client, if provided will be displayed in the SSO header
|
|
318
|
+
*/
|
|
319
|
+
logoUrl?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Link to your homepage, if referenced your app name will contain a link on the sso page
|
|
322
|
+
*/
|
|
323
|
+
homepageLink?: string;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Params for preparing SSO (generating URL)
|
|
327
|
+
* Same as OpenSsoParamsType but without openInSameWindow (popup-only operation)
|
|
328
|
+
* @group RPC Schema
|
|
329
|
+
*/
|
|
330
|
+
type PrepareSsoParamsType = {
|
|
331
|
+
/**
|
|
332
|
+
* Redirect URL after the SSO (optional)
|
|
333
|
+
*/
|
|
334
|
+
redirectUrl?: string;
|
|
335
|
+
/**
|
|
336
|
+
* If the SSO should directly exit after completion
|
|
337
|
+
* @defaultValue true
|
|
338
|
+
*/
|
|
339
|
+
directExit?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Language of the SSO page (optional)
|
|
342
|
+
* It will default to the current user language (or "en" if unsupported language)
|
|
343
|
+
*/
|
|
344
|
+
lang?: "en" | "fr";
|
|
345
|
+
/**
|
|
346
|
+
* Custom SSO metadata
|
|
347
|
+
*/
|
|
348
|
+
metadata?: SsoMetadata;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Response after preparing SSO
|
|
352
|
+
* @group RPC Schema
|
|
353
|
+
*/
|
|
354
|
+
type PrepareSsoReturnType = {
|
|
355
|
+
/**
|
|
356
|
+
* The SSO URL that should be opened in a popup
|
|
357
|
+
*/
|
|
358
|
+
ssoUrl: string;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Response after an SSO has been openned
|
|
362
|
+
*/
|
|
363
|
+
type OpenSsoReturnType = {
|
|
364
|
+
/**
|
|
365
|
+
* Optional wallet address, returned when SSO completes via postMessage
|
|
366
|
+
* Note: Only present when SSO flow completes (not immediately on open)
|
|
367
|
+
*/
|
|
368
|
+
wallet?: Hex;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Params to start a SSO
|
|
372
|
+
* @group RPC Schema
|
|
373
|
+
*/
|
|
374
|
+
type OpenSsoParamsType = PrepareSsoParamsType & {
|
|
375
|
+
/**
|
|
376
|
+
* 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
|
|
377
|
+
* Note: Default true if redirectUrl is present, otherwise, false
|
|
378
|
+
*/
|
|
379
|
+
openInSameWindow?: boolean;
|
|
380
|
+
/**
|
|
381
|
+
* Custom SSO popup url if user want additionnal customisation
|
|
382
|
+
*/
|
|
383
|
+
ssoPopupUrl?: string;
|
|
384
|
+
};
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/types/rpc/modal/login.d.ts
|
|
387
|
+
/** @inline */
|
|
388
|
+
type LoginWithSso = {
|
|
389
|
+
allowSso: true;
|
|
390
|
+
ssoMetadata?: SsoMetadata;
|
|
391
|
+
};
|
|
392
|
+
/** @inline */
|
|
393
|
+
type LoginWithoutSso = {
|
|
394
|
+
allowSso?: false;
|
|
395
|
+
ssoMetadata?: never;
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* The login step for a Modal
|
|
399
|
+
*
|
|
400
|
+
* **Input**: Do we allow SSO or not? Is yes then the SSO metadata
|
|
401
|
+
* **Output**: The logged in wallet address
|
|
402
|
+
*
|
|
403
|
+
* @group Modal Display
|
|
404
|
+
*/
|
|
405
|
+
type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
406
|
+
wallet: Address;
|
|
407
|
+
}>;
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/types/rpc/modal/openSession.d.ts
|
|
410
|
+
/**
|
|
411
|
+
* Return type of the open session modal step
|
|
412
|
+
* @inline
|
|
413
|
+
* @ignore
|
|
414
|
+
*/
|
|
415
|
+
type OpenInteractionSessionReturnType = {
|
|
416
|
+
startTimestamp: number;
|
|
417
|
+
endTimestamp: number;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* The open interaction session step for a Modal
|
|
421
|
+
*
|
|
422
|
+
* **Input**: None
|
|
423
|
+
* **Output**: The interactions session period (start and end timestamp)
|
|
424
|
+
*
|
|
425
|
+
* @group Modal Display
|
|
426
|
+
*/
|
|
427
|
+
type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/types/rpc/modal/siweAuthenticate.d.ts
|
|
430
|
+
/**
|
|
431
|
+
* Parameters used send a SIWE rpc request
|
|
432
|
+
*/
|
|
433
|
+
type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
|
|
434
|
+
expirationTimeTimestamp?: number;
|
|
435
|
+
notBeforeTimestamp?: number;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* Return type of the Siwe transaction rpc request
|
|
439
|
+
* @inline
|
|
440
|
+
*/
|
|
441
|
+
type SiweAuthenticateReturnType = {
|
|
442
|
+
signature: Hex;
|
|
443
|
+
message: string;
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* The SIWE authentication step for a Modal
|
|
447
|
+
*
|
|
448
|
+
* **Input**: SIWE message parameters
|
|
449
|
+
* **Output**: SIWE result (message signed and wallet signature)
|
|
450
|
+
*
|
|
451
|
+
* @group Modal Display
|
|
452
|
+
*/
|
|
453
|
+
type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
|
|
454
|
+
siwe: SiweAuthenticationParams;
|
|
455
|
+
}, SiweAuthenticateReturnType>;
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/types/rpc/modal/transaction.d.ts
|
|
458
|
+
/**
|
|
459
|
+
* Generic format representing a tx to be sent
|
|
460
|
+
*/
|
|
461
|
+
type SendTransactionTxType = {
|
|
462
|
+
to: Address;
|
|
463
|
+
data?: Hex;
|
|
464
|
+
value?: Hex;
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* Return type of the send transaction rpc request
|
|
468
|
+
* @inline
|
|
469
|
+
*/
|
|
470
|
+
type SendTransactionReturnType = {
|
|
471
|
+
hash: Hex;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* The send transaction step for a Modal
|
|
475
|
+
*
|
|
476
|
+
* **Input**: Either a single tx or an array of tx to be sent
|
|
477
|
+
* **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)
|
|
478
|
+
*
|
|
479
|
+
* @group Modal Display
|
|
480
|
+
*/
|
|
481
|
+
type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
|
|
482
|
+
tx: SendTransactionTxType | SendTransactionTxType[];
|
|
483
|
+
}, SendTransactionReturnType>;
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/types/rpc/displayModal.d.ts
|
|
486
|
+
/**
|
|
487
|
+
* Generic type of steps we will display in the modal to the end user
|
|
488
|
+
* @group Modal Display
|
|
489
|
+
*/
|
|
490
|
+
type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
|
|
491
|
+
/**
|
|
492
|
+
* Type for the result of a modal request
|
|
493
|
+
* Just the `returns` type of each `ModalStepTypes`
|
|
494
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
495
|
+
* @group Modal Display
|
|
496
|
+
* @group RPC Schema
|
|
497
|
+
*/
|
|
498
|
+
type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = { [K in T[number]["key"]]: Extract<T[number], {
|
|
499
|
+
key: K;
|
|
500
|
+
}>["returns"] };
|
|
501
|
+
/**
|
|
502
|
+
* Type for the RPC input of a modal
|
|
503
|
+
* Just the `params` type of each `ModalStepTypes`
|
|
504
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
505
|
+
* @group Modal Display
|
|
506
|
+
* @group RPC Schema
|
|
507
|
+
*/
|
|
508
|
+
type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = { [K in T[number]["key"]]?: Extract<T[number], {
|
|
509
|
+
key: K;
|
|
510
|
+
}>["params"] };
|
|
511
|
+
/**
|
|
512
|
+
* RPC metadata for the modal, used on top level modal configuration
|
|
513
|
+
* @group Modal Display
|
|
514
|
+
* @group RPC Schema
|
|
515
|
+
*/
|
|
516
|
+
type ModalRpcMetadata = {
|
|
517
|
+
header?: {
|
|
518
|
+
title?: string;
|
|
519
|
+
icon?: string;
|
|
520
|
+
};
|
|
521
|
+
targetInteraction?: FullInteractionTypesKey;
|
|
522
|
+
/**
|
|
523
|
+
* Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
|
|
524
|
+
*/
|
|
525
|
+
i18n?: I18nConfig;
|
|
526
|
+
} & ({
|
|
527
|
+
isDismissible: true;
|
|
528
|
+
/**
|
|
529
|
+
* @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
|
|
530
|
+
*/
|
|
531
|
+
dismissActionTxt?: string;
|
|
532
|
+
} | {
|
|
533
|
+
isDismissible?: false;
|
|
534
|
+
dismissActionTxt?: never;
|
|
535
|
+
});
|
|
536
|
+
/**
|
|
537
|
+
* Params used to display a modal
|
|
538
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
539
|
+
* @group Modal Display
|
|
540
|
+
*/
|
|
541
|
+
type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
542
|
+
steps: ModalRpcStepsInput<T>;
|
|
543
|
+
metadata?: ModalRpcMetadata;
|
|
544
|
+
};
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/types/rpc/embedded/loggedIn.d.ts
|
|
547
|
+
/**
|
|
548
|
+
* The different type of action we can have on the embedded view (once the user is logged in)
|
|
549
|
+
*
|
|
550
|
+
* @group Embedded wallet
|
|
551
|
+
*/
|
|
552
|
+
type EmbeddedViewActionSharing = {
|
|
553
|
+
key: "sharing";
|
|
554
|
+
/**
|
|
555
|
+
* Some sharing options
|
|
556
|
+
*/
|
|
557
|
+
options?: {
|
|
558
|
+
/**
|
|
559
|
+
* The title that will be displayed on the system popup once the system sharing window is open
|
|
560
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
561
|
+
*/
|
|
562
|
+
popupTitle?: string;
|
|
563
|
+
/**
|
|
564
|
+
* The text that will be shared alongside the link.
|
|
565
|
+
* Can contain the variable `{LINK}` to specify where the link is placed, otherwise it will be added at the end
|
|
566
|
+
* @deprecated Use the top level `config.metadata.i18n` instead
|
|
567
|
+
*/
|
|
568
|
+
text?: string;
|
|
569
|
+
/**
|
|
570
|
+
* The link to be shared (will be suffixed with the Frak sharing context)
|
|
571
|
+
*/
|
|
572
|
+
link?: string;
|
|
573
|
+
};
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* The action to display on the logged out embedded view when the user is referred
|
|
577
|
+
*
|
|
578
|
+
* @group Embedded wallet
|
|
579
|
+
*/
|
|
580
|
+
type EmbeddedViewActionReferred = {
|
|
581
|
+
key: "referred";
|
|
582
|
+
/**
|
|
583
|
+
* No options for a referred action
|
|
584
|
+
*/
|
|
585
|
+
options?: never;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* Some configuration options for the embedded view
|
|
589
|
+
*
|
|
590
|
+
* @group Embedded wallet
|
|
591
|
+
*/
|
|
592
|
+
type LoggedInEmbeddedView = {
|
|
593
|
+
/**
|
|
594
|
+
* The main action to display on the logged in embedded view
|
|
595
|
+
*/
|
|
596
|
+
action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
|
|
597
|
+
};
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/types/rpc/embedded/loggedOut.d.ts
|
|
600
|
+
/**
|
|
601
|
+
* The view when a user is logged out
|
|
602
|
+
* @group Embedded wallet
|
|
603
|
+
*/
|
|
604
|
+
type LoggedOutEmbeddedView = {
|
|
605
|
+
/**
|
|
606
|
+
* Metadata option when displaying the embedded view
|
|
607
|
+
*/
|
|
608
|
+
metadata?: {
|
|
609
|
+
/**
|
|
610
|
+
* The main CTA for the logged out view
|
|
611
|
+
* - can include some variable, available ones are:
|
|
612
|
+
* - `{REWARD}` -> The maximum reward a user can receive when interacting on your website
|
|
613
|
+
* - can be formatted in markdown
|
|
614
|
+
*
|
|
615
|
+
* If not set, it will default to a internationalized message
|
|
616
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
617
|
+
*/
|
|
618
|
+
text?: string;
|
|
619
|
+
/**
|
|
620
|
+
* The text that will be displayed on the login button
|
|
621
|
+
*
|
|
622
|
+
* If not set, it will default to a internationalized message
|
|
623
|
+
* @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
|
|
624
|
+
*/
|
|
625
|
+
buttonText?: string;
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/types/rpc/embedded/index.d.ts
|
|
630
|
+
/**
|
|
631
|
+
* The params used to display the embedded wallet
|
|
632
|
+
*
|
|
633
|
+
* @group Embedded wallet
|
|
634
|
+
*/
|
|
635
|
+
type DisplayEmbeddedWalletParamsType = {
|
|
636
|
+
/**
|
|
637
|
+
* The embedded view to display once the user is logged in
|
|
638
|
+
*/
|
|
639
|
+
loggedIn?: LoggedInEmbeddedView;
|
|
640
|
+
/**
|
|
641
|
+
* The embedded view to display once the user is logged out
|
|
642
|
+
*/
|
|
643
|
+
loggedOut?: LoggedOutEmbeddedView;
|
|
644
|
+
/**
|
|
645
|
+
* Some metadata to customize the embedded view
|
|
646
|
+
*/
|
|
647
|
+
metadata?: {
|
|
648
|
+
/**
|
|
649
|
+
* The logo to display on the embedded wallet
|
|
650
|
+
* If undefined, will default to no logo displayed
|
|
651
|
+
*/
|
|
652
|
+
logo?: string;
|
|
653
|
+
/**
|
|
654
|
+
* Link to the homepage of the calling website
|
|
655
|
+
* If undefined, will default to the domain of the calling website
|
|
656
|
+
*/
|
|
657
|
+
homepageLink?: string;
|
|
658
|
+
/**
|
|
659
|
+
* The target interaction behind this modal
|
|
660
|
+
*/
|
|
661
|
+
targetInteraction?: FullInteractionTypesKey;
|
|
662
|
+
/**
|
|
663
|
+
* The position of the component
|
|
664
|
+
*/
|
|
665
|
+
position?: "left" | "right";
|
|
666
|
+
/**
|
|
667
|
+
* Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
|
|
668
|
+
*/
|
|
669
|
+
i18n?: I18nConfig;
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
/**
|
|
673
|
+
* The result of the display embedded wallet rpc request
|
|
674
|
+
*
|
|
675
|
+
* @group Embedded wallet
|
|
676
|
+
*/
|
|
677
|
+
type DisplayEmbeddedWalletResultType = {
|
|
678
|
+
wallet: Address;
|
|
679
|
+
};
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/constants/productTypes.d.ts
|
|
682
|
+
/**
|
|
683
|
+
* The keys for each product types
|
|
684
|
+
* @inline
|
|
685
|
+
*/
|
|
686
|
+
type ProductTypesKey = keyof typeof productTypes;
|
|
687
|
+
/**
|
|
688
|
+
* List of the product types per denominator
|
|
689
|
+
*/
|
|
690
|
+
declare const productTypes: {
|
|
691
|
+
dapp: number;
|
|
692
|
+
press: number;
|
|
693
|
+
webshop: number;
|
|
694
|
+
retail: number;
|
|
695
|
+
referral: number;
|
|
696
|
+
purchase: number;
|
|
697
|
+
};
|
|
698
|
+
/**
|
|
699
|
+
* Bitmask for each product types
|
|
700
|
+
*/
|
|
701
|
+
declare const productTypesMask: Record<ProductTypesKey, bigint>;
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/types/rpc/productInformation.d.ts
|
|
704
|
+
/**
|
|
705
|
+
* The type for the amount of tokens
|
|
706
|
+
*/
|
|
707
|
+
type TokenAmountType = {
|
|
708
|
+
amount: number;
|
|
709
|
+
eurAmount: number;
|
|
710
|
+
usdAmount: number;
|
|
711
|
+
gbpAmount: number;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* Response of the `frak_getProductInformation` RPC method
|
|
715
|
+
* @group RPC Schema
|
|
716
|
+
*/
|
|
717
|
+
type GetProductInformationReturnType = {
|
|
718
|
+
/**
|
|
719
|
+
* Current product id
|
|
720
|
+
*/
|
|
721
|
+
id: Hex;
|
|
722
|
+
/**
|
|
723
|
+
* Some metadata
|
|
724
|
+
*/
|
|
725
|
+
onChainMetadata: {
|
|
726
|
+
/**
|
|
727
|
+
* Name of the product on-chain
|
|
728
|
+
*/
|
|
729
|
+
name: string;
|
|
730
|
+
/**
|
|
731
|
+
* Domain of the product on-chain
|
|
732
|
+
*/
|
|
733
|
+
domain: string;
|
|
734
|
+
/**
|
|
735
|
+
* The supported product types
|
|
736
|
+
*/
|
|
737
|
+
productTypes: ProductTypesKey[];
|
|
738
|
+
};
|
|
739
|
+
/**
|
|
740
|
+
* The max potential reward for the referrer
|
|
741
|
+
*/
|
|
742
|
+
maxReferrer?: TokenAmountType;
|
|
743
|
+
/**
|
|
744
|
+
* The max potential reward for the referee
|
|
745
|
+
*/
|
|
746
|
+
maxReferee?: TokenAmountType;
|
|
747
|
+
/**
|
|
748
|
+
* List of all the potentials reward arround this product
|
|
749
|
+
*/
|
|
750
|
+
rewards: {
|
|
751
|
+
token: Address;
|
|
752
|
+
campaign: Address;
|
|
753
|
+
interactionTypeKey: FullInteractionTypesKey;
|
|
754
|
+
referrer: TokenAmountType;
|
|
755
|
+
referee: TokenAmountType;
|
|
756
|
+
}[];
|
|
757
|
+
};
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/types/rpc/walletStatus.d.ts
|
|
760
|
+
/**
|
|
761
|
+
* RPC Response for the method `frak_listenToWalletStatus`
|
|
762
|
+
* @group RPC Schema
|
|
763
|
+
*/
|
|
764
|
+
type WalletStatusReturnType = WalletConnected | WalletNotConnected;
|
|
765
|
+
/**
|
|
766
|
+
* @ignore
|
|
767
|
+
* @inline
|
|
768
|
+
*/
|
|
769
|
+
type WalletConnected = {
|
|
770
|
+
key: "connected";
|
|
771
|
+
wallet: Address;
|
|
772
|
+
interactionToken?: string;
|
|
773
|
+
interactionSession?: {
|
|
774
|
+
startTimestamp: number;
|
|
775
|
+
endTimestamp: number;
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* @ignore
|
|
780
|
+
* @inline
|
|
781
|
+
*/
|
|
782
|
+
type WalletNotConnected = {
|
|
783
|
+
key: "not-connected";
|
|
784
|
+
wallet?: never;
|
|
785
|
+
interactionToken?: never;
|
|
786
|
+
interactionSession?: never;
|
|
787
|
+
};
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region src/types/rpc.d.ts
|
|
790
|
+
/**
|
|
791
|
+
* RPC interface that's used for the iframe communication
|
|
792
|
+
*
|
|
793
|
+
* Define all the methods available within the iFrame RPC client with response type annotations
|
|
794
|
+
*
|
|
795
|
+
* @group RPC Schema
|
|
796
|
+
*
|
|
797
|
+
* @remarks
|
|
798
|
+
* Each method in the schema now includes a ResponseType field that indicates:
|
|
799
|
+
* - "promise": One-shot request that resolves once
|
|
800
|
+
* - "stream": Streaming request that can emit multiple values
|
|
801
|
+
*
|
|
802
|
+
* ### Methods:
|
|
803
|
+
*
|
|
804
|
+
* #### frak_listenToWalletStatus
|
|
805
|
+
* - Params: None
|
|
806
|
+
* - Returns: {@link WalletStatusReturnType}
|
|
807
|
+
* - Response Type: stream (emits updates when wallet status changes)
|
|
808
|
+
*
|
|
809
|
+
* #### frak_displayModal
|
|
810
|
+
* - Params: [requests: {@link ModalRpcStepsInput}, metadata?: {@link ModalRpcMetadata}, configMetadata: {@link FrakWalletSdkConfig}["metadata"]]
|
|
811
|
+
* - Returns: {@link ModalRpcStepsResultType}
|
|
812
|
+
* - Response Type: promise (one-shot)
|
|
813
|
+
*
|
|
814
|
+
* #### frak_sendInteraction
|
|
815
|
+
* - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
|
|
816
|
+
* - Returns: {@link SendInteractionReturnType}
|
|
817
|
+
* - Response Type: promise (one-shot)
|
|
818
|
+
*
|
|
819
|
+
* #### frak_sso
|
|
820
|
+
* - Params: [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
821
|
+
* - Returns: {@link OpenSsoReturnType}
|
|
822
|
+
* - Response Type: promise (one-shot)
|
|
823
|
+
*
|
|
824
|
+
* #### frak_getProductInformation
|
|
825
|
+
* - Params: None
|
|
826
|
+
* - Returns: {@link GetProductInformationReturnType}
|
|
827
|
+
* - Response Type: promise (one-shot)
|
|
828
|
+
*
|
|
829
|
+
* #### frak_displayEmbeddedWallet
|
|
830
|
+
* - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"]]
|
|
831
|
+
* - Returns: {@link DisplayEmbeddedWalletResultType}
|
|
832
|
+
* - Response Type: promise (one-shot)
|
|
833
|
+
*/
|
|
834
|
+
type IFrameRpcSchema = [
|
|
835
|
+
/**
|
|
836
|
+
* Method used to listen to the wallet status
|
|
837
|
+
* This is a streaming method that emits updates when wallet status changes
|
|
838
|
+
*/
|
|
839
|
+
{
|
|
840
|
+
Method: "frak_listenToWalletStatus";
|
|
841
|
+
Parameters?: undefined;
|
|
842
|
+
ReturnType: WalletStatusReturnType;
|
|
843
|
+
},
|
|
844
|
+
/**
|
|
845
|
+
* Method to display a modal with the provided steps
|
|
846
|
+
* This is a one-shot request
|
|
847
|
+
*/
|
|
848
|
+
{
|
|
849
|
+
Method: "frak_displayModal";
|
|
850
|
+
Parameters: [requests: ModalRpcStepsInput, metadata: ModalRpcMetadata | undefined, configMetadata: FrakWalletSdkConfig["metadata"]];
|
|
851
|
+
ReturnType: ModalRpcStepsResultType;
|
|
852
|
+
},
|
|
853
|
+
/**
|
|
854
|
+
* Method to transmit a user interaction
|
|
855
|
+
* This is a one-shot request
|
|
856
|
+
*/
|
|
857
|
+
{
|
|
858
|
+
Method: "frak_sendInteraction";
|
|
859
|
+
Parameters: [productId: Hex, interaction: PreparedInteraction, signature?: Hex];
|
|
860
|
+
ReturnType: SendInteractionReturnType;
|
|
861
|
+
},
|
|
862
|
+
/**
|
|
863
|
+
* Method to prepare SSO (generate URL for popup)
|
|
864
|
+
* Returns the SSO URL that should be opened in a popup
|
|
865
|
+
* Only used for popup flows (not redirect flows)
|
|
866
|
+
*/
|
|
867
|
+
{
|
|
868
|
+
Method: "frak_prepareSso";
|
|
869
|
+
Parameters: [params: PrepareSsoParamsType, name: string, customCss?: string];
|
|
870
|
+
ReturnType: PrepareSsoReturnType;
|
|
871
|
+
},
|
|
872
|
+
/**
|
|
873
|
+
* Method to open/trigger SSO
|
|
874
|
+
* Either triggers redirect (if openInSameWindow/redirectUrl)
|
|
875
|
+
* Or waits for popup completion (if popup mode)
|
|
876
|
+
* This method handles BOTH redirect and popup flows
|
|
877
|
+
*/
|
|
878
|
+
{
|
|
879
|
+
Method: "frak_openSso";
|
|
880
|
+
Parameters: [params: OpenSsoParamsType, name: string, customCss?: string];
|
|
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: [request: DisplayEmbeddedWalletParamsType, metadata: FrakWalletSdkConfig["metadata"]];
|
|
902
|
+
ReturnType: DisplayEmbeddedWalletResultType;
|
|
903
|
+
}];
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region src/types/transport.d.ts
|
|
906
|
+
/**
|
|
907
|
+
* IFrame transport interface
|
|
908
|
+
*/
|
|
909
|
+
type IFrameTransport = {
|
|
910
|
+
/**
|
|
911
|
+
* Wait for the connection to be established
|
|
912
|
+
*/
|
|
913
|
+
waitForConnection: Promise<boolean>;
|
|
914
|
+
/**
|
|
915
|
+
* Wait for the setup to be done
|
|
916
|
+
*/
|
|
917
|
+
waitForSetup: Promise<void>;
|
|
918
|
+
/**
|
|
919
|
+
* Function used to perform a single request via the iframe transport
|
|
920
|
+
*/
|
|
921
|
+
request: RpcClient<IFrameRpcSchema, LifecycleMessage>["request"];
|
|
922
|
+
/**
|
|
923
|
+
* Function used to listen to a request response via the iframe transport
|
|
924
|
+
*/
|
|
925
|
+
listenerRequest: RpcClient<IFrameRpcSchema, LifecycleMessage>["listen"];
|
|
926
|
+
/**
|
|
927
|
+
* Function used to destroy the iframe transport
|
|
928
|
+
*/
|
|
929
|
+
destroy: () => Promise<void>;
|
|
930
|
+
};
|
|
931
|
+
/**
|
|
932
|
+
* Represent an iframe event
|
|
933
|
+
*/
|
|
934
|
+
type FrakLifecycleEvent = IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
935
|
+
//#endregion
|
|
936
|
+
//#region src/types/client.d.ts
|
|
937
|
+
/**
|
|
938
|
+
* Representing a Frak client, used to interact with the Frak Wallet
|
|
939
|
+
*/
|
|
940
|
+
type FrakClient = {
|
|
941
|
+
config: FrakWalletSdkConfig;
|
|
942
|
+
debugInfo: {
|
|
943
|
+
formatDebugInfo: (error: Error | unknown | string) => string;
|
|
944
|
+
};
|
|
945
|
+
openPanel?: OpenPanel;
|
|
946
|
+
} & IFrameTransport;
|
|
947
|
+
//#endregion
|
|
948
|
+
//#region src/types/context.d.ts
|
|
949
|
+
/**
|
|
950
|
+
* The current Frak Context
|
|
951
|
+
*
|
|
952
|
+
* For now, only contain a referrer address.
|
|
953
|
+
*
|
|
954
|
+
* @ignore
|
|
955
|
+
*/
|
|
956
|
+
type FrakContext = {
|
|
957
|
+
r: Address;
|
|
958
|
+
};
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/actions/openSso.d.ts
|
|
961
|
+
declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
|
|
962
|
+
declare const ssoPopupName = "frak-sso";
|
|
963
|
+
/**
|
|
964
|
+
* Function used to open the SSO
|
|
965
|
+
* @param client - The current Frak Client
|
|
966
|
+
* @param args - The SSO parameters
|
|
967
|
+
*
|
|
968
|
+
* @description Two SSO flow modes:
|
|
969
|
+
*
|
|
970
|
+
* **Redirect Mode** (openInSameWindow: true):
|
|
971
|
+
* - Wallet generates URL and triggers redirect
|
|
972
|
+
* - Used when redirectUrl is provided
|
|
973
|
+
*
|
|
974
|
+
* **Popup Mode** (openInSameWindow: false/omitted):
|
|
975
|
+
* - SDK generates URL client-side (or uses provided ssoPopupUrl)
|
|
976
|
+
* - Opens popup synchronously (prevents popup blockers)
|
|
977
|
+
* - Waits for SSO completion via postMessage
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* First we build the sso metadata
|
|
981
|
+
* ```ts
|
|
982
|
+
* // Build the metadata
|
|
983
|
+
* const metadata: SsoMetadata = {
|
|
984
|
+
* logoUrl: "https://my-app.com/logo.png",
|
|
985
|
+
* homepageLink: "https://my-app.com",
|
|
986
|
+
* };
|
|
987
|
+
* ```
|
|
988
|
+
*
|
|
989
|
+
* Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
|
|
990
|
+
* :::code-group
|
|
991
|
+
* ```ts [Popup (default)]
|
|
992
|
+
* // Opens in popup, SDK generates URL automatically
|
|
993
|
+
* await openSso(frakConfig, {
|
|
994
|
+
* directExit: true,
|
|
995
|
+
* metadata,
|
|
996
|
+
* });
|
|
997
|
+
* ```
|
|
998
|
+
* ```ts [Redirect]
|
|
999
|
+
* // Opens in same window with redirect
|
|
1000
|
+
* await openSso(frakConfig, {
|
|
1001
|
+
* redirectUrl: "https://my-app.com/frak-sso",
|
|
1002
|
+
* metadata,
|
|
1003
|
+
* openInSameWindow: true,
|
|
1004
|
+
* });
|
|
1005
|
+
* ```
|
|
1006
|
+
* ```ts [Custom popup URL]
|
|
1007
|
+
* // Advanced: provide custom SSO URL
|
|
1008
|
+
* const { ssoUrl } = await prepareSso(frakConfig, { metadata });
|
|
1009
|
+
* await openSso(frakConfig, {
|
|
1010
|
+
* metadata,
|
|
1011
|
+
* ssoPopupUrl: `${ssoUrl}&custom=param`,
|
|
1012
|
+
* });
|
|
1013
|
+
* ```
|
|
1014
|
+
* :::
|
|
1015
|
+
*/
|
|
1016
|
+
declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1017
|
+
//#endregion
|
|
1018
|
+
export { SiweAuthenticateReturnType as A, FinalActionType as B, ModalRpcStepsInput as C, SendTransactionReturnType as D, SendTransactionModalStepType as E, OpenSsoParamsType as F, interactionTypes as G, ModalStepMetadata as H, OpenSsoReturnType as I, Currency as J, IFrameLifecycleEvent as K, PrepareSsoParamsType as L, OpenInteractionSessionModalStepType as M, OpenInteractionSessionReturnType as N, SendTransactionTxType as O, LoginModalStepType as P, LocalizedI18nConfig as Q, PrepareSsoReturnType as R, ModalRpcMetadata as S, ModalStepTypes as T, FullInteractionTypesKey as U, FinalModalStepType as V, InteractionTypesKey as W, I18nConfig as X, FrakWalletSdkConfig as Y, Language as Z, LoggedOutEmbeddedView as _, FrakClient as a, LoggedInEmbeddedView as b, IFrameRpcSchema as c, TokenAmountType as d, ProductTypesKey as f, DisplayEmbeddedWalletResultType as g, DisplayEmbeddedWalletParamsType as h, FrakContext as i, SiweAuthenticationParams as j, SiweAuthenticateModalStepType as k, WalletStatusReturnType as l, productTypesMask as m, ssoPopupFeatures as n, FrakLifecycleEvent as o, productTypes as p, ClientLifecycleEvent as q, ssoPopupName as r, IFrameTransport as s, openSso as t, GetProductInformationReturnType as u, EmbeddedViewActionReferred as v, ModalRpcStepsResultType as w, DisplayModalParamsType as x, EmbeddedViewActionSharing as y, SsoMetadata as z };
|