@frak-labs/core-sdk 0.0.7 → 0.0.8
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 +17 -31
- package/cdn/bundle.js.LICENSE.txt +10 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.cts +1285 -0
- package/dist/actions.d.ts +1285 -0
- package/dist/actions.js +1 -0
- package/dist/index.cjs +11 -487
- package/dist/index.d.cts +1152 -255
- package/dist/index.d.ts +1152 -255
- package/dist/index.js +11 -428
- package/dist/interactions.cjs +1 -0
- package/dist/{interactions/index.d.ts → interactions.d.cts} +182 -174
- package/dist/{interactions/index.d.cts → interactions.d.ts} +182 -174
- package/dist/interactions.js +1 -0
- package/package.json +14 -14
- package/dist/actions/index.cjs +0 -350
- package/dist/actions/index.d.cts +0 -501
- package/dist/actions/index.d.ts +0 -501
- package/dist/actions/index.js +0 -337
- package/dist/chunk-665P7NO4.cjs +0 -81
- package/dist/chunk-7YDJDVXY.cjs +0 -833
- package/dist/chunk-GTBCSNLF.js +0 -819
- package/dist/chunk-PHVGCFDX.cjs +0 -155
- package/dist/chunk-U2NTN5QZ.js +0 -75
- package/dist/chunk-VE6URIIJ.js +0 -149
- package/dist/context-D7aZDKLT.d.cts +0 -813
- package/dist/context-rDsQbSgB.d.ts +0 -813
- package/dist/interaction-CTQ5-kqe.d.cts +0 -43
- package/dist/interaction-CTQ5-kqe.d.ts +0 -43
- package/dist/interactions/index.cjs +0 -26
- package/dist/interactions/index.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,255 +1,1152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'viem';
|
|
5
|
-
import 'viem/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
declare class
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
private
|
|
117
|
-
private
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
* @
|
|
129
|
-
*/
|
|
130
|
-
declare
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
* @
|
|
149
|
-
*/
|
|
150
|
-
declare
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
207
|
-
* @
|
|
208
|
-
*/
|
|
209
|
-
declare
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
1
|
+
import type { Address } from 'viem';
|
|
2
|
+
import type { Hex } from 'viem';
|
|
3
|
+
import type { Prettify } from 'viem/chains';
|
|
4
|
+
import type { RpcSchema } from 'viem';
|
|
5
|
+
import type { SiweMessage } from 'viem/siwe';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base props for the iframe
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export declare const baseIframeProps: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
allow: string;
|
|
15
|
+
style: {
|
|
16
|
+
width: string;
|
|
17
|
+
height: string;
|
|
18
|
+
border: string;
|
|
19
|
+
position: string;
|
|
20
|
+
zIndex: number;
|
|
21
|
+
top: string;
|
|
22
|
+
left: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Event related to the iframe lifecycle
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
export declare type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
|
|
31
|
+
|
|
32
|
+
/** @ignore */
|
|
33
|
+
export declare class ClientNotFound extends FrakRpcError {
|
|
34
|
+
constructor();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Compress the current Frak context
|
|
39
|
+
* @param context - The context to be compressed
|
|
40
|
+
* @returns A compressed string containing the Frak context
|
|
41
|
+
*/
|
|
42
|
+
declare function compress(context?: Partial<FrakContext>): string | undefined;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The received encoded data from a client
|
|
46
|
+
* -> The encoded should contain a HashProtectedData once decoded
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
49
|
+
export declare type CompressedData = Readonly<{
|
|
50
|
+
compressed: string;
|
|
51
|
+
compressedHash: string;
|
|
52
|
+
}>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Compress json data
|
|
56
|
+
* @param data
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
export declare function compressJson(data: unknown): Promise<string>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create the Frak iframe
|
|
63
|
+
* @param args
|
|
64
|
+
* @param args.walletBaseUrl - Use `config.walletUrl` instead. Will be removed in future versions.
|
|
65
|
+
* @param args.config - The configuration object containing iframe options, including the replacement for `walletBaseUrl`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createIframe({ walletBaseUrl, config, }: {
|
|
68
|
+
walletBaseUrl?: string;
|
|
69
|
+
config?: FrakWalletSdkConfig;
|
|
70
|
+
}): Promise<HTMLIFrameElement | undefined>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create a new iframe Frak client
|
|
74
|
+
* @param args
|
|
75
|
+
* @param args.config - The configuration to use for the Frak Wallet SDK
|
|
76
|
+
* @param args.iframe - The iframe to use for the communication
|
|
77
|
+
* @returns The created Frak Client
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const frakConfig: FrakWalletSdkConfig = {
|
|
81
|
+
* metadata: {
|
|
82
|
+
* name: "My app title",
|
|
83
|
+
* },
|
|
84
|
+
* }
|
|
85
|
+
* const iframe = await createIframe({ config: frakConfig });
|
|
86
|
+
* const client = createIFrameFrakClient({ config: frakConfig, iframe });
|
|
87
|
+
*/
|
|
88
|
+
export declare function createIFrameFrakClient({ config, iframe, }: {
|
|
89
|
+
config: FrakWalletSdkConfig;
|
|
90
|
+
iframe: HTMLIFrameElement;
|
|
91
|
+
}): FrakClient;
|
|
92
|
+
|
|
93
|
+
declare type CustomCssEvent = {
|
|
94
|
+
clientLifecycle: "modal-css";
|
|
95
|
+
data: {
|
|
96
|
+
cssLink: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** @ignore */
|
|
101
|
+
export declare class DebugInfoGatherer {
|
|
102
|
+
private config?;
|
|
103
|
+
private iframe?;
|
|
104
|
+
private isSetupDone;
|
|
105
|
+
private lastResponse;
|
|
106
|
+
private lastRequest;
|
|
107
|
+
constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
|
|
108
|
+
setLastResponse(event: MessageEvent<IFrameEvent>): void;
|
|
109
|
+
setLastRequest(event: IFrameEvent, target: string): void;
|
|
110
|
+
updateSetupStatus(status: boolean): void;
|
|
111
|
+
private base64Encode;
|
|
112
|
+
/**
|
|
113
|
+
* Extract information from the iframe status
|
|
114
|
+
*/
|
|
115
|
+
private getIframeStatus;
|
|
116
|
+
private getNavigatorInfo;
|
|
117
|
+
private gatherDebugInfo;
|
|
118
|
+
static empty(): DebugInfoGatherer;
|
|
119
|
+
/**
|
|
120
|
+
* Format Frak debug information
|
|
121
|
+
*/
|
|
122
|
+
formatDebugInfo(error: Error | unknown | string): string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Decompress the given Frak context
|
|
127
|
+
* @param context - The raw context to be decompressed into a `FrakContext`
|
|
128
|
+
* @returns The decompressed Frak context, or undefined if it fails
|
|
129
|
+
*/
|
|
130
|
+
declare function decompress(context?: string): FrakContext | undefined;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Decompress the given string
|
|
134
|
+
* @param compressedData The params to encode
|
|
135
|
+
* @ignore
|
|
136
|
+
*/
|
|
137
|
+
export declare function decompressDataAndCheckHash<T>(compressedData: CompressedData): Promise<HashProtectedData<T>>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Decompress json data
|
|
141
|
+
* @param data
|
|
142
|
+
* @ignore
|
|
143
|
+
*/
|
|
144
|
+
export declare function decompressJson<T>(data: string): Promise<T | null>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Simple deferred promise wrapper
|
|
148
|
+
* @ignore
|
|
149
|
+
*/
|
|
150
|
+
export declare class Deferred<T> {
|
|
151
|
+
private readonly _promise;
|
|
152
|
+
private _resolve;
|
|
153
|
+
private _reject;
|
|
154
|
+
constructor();
|
|
155
|
+
get promise(): Promise<T>;
|
|
156
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
157
|
+
reject: (reason?: unknown) => void;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The params used to display the embeded wallet
|
|
162
|
+
*
|
|
163
|
+
* @group Embeded wallet
|
|
164
|
+
*/
|
|
165
|
+
export declare type DisplayEmbededWalletParamsType = {
|
|
166
|
+
/**
|
|
167
|
+
* The embeded view to display once the user is logged in
|
|
168
|
+
*/
|
|
169
|
+
loggedIn?: LoggedInEmbededView;
|
|
170
|
+
/**
|
|
171
|
+
* The embeded view to display once the user is logged out
|
|
172
|
+
*/
|
|
173
|
+
loggedOut?: LoggedOutEmbededView;
|
|
174
|
+
/**
|
|
175
|
+
* Some metadata to customise the embeded view
|
|
176
|
+
*/
|
|
177
|
+
metadata?: {
|
|
178
|
+
/**
|
|
179
|
+
* Language of the embeded wallet
|
|
180
|
+
* If undefined, will default to the browser language
|
|
181
|
+
*/
|
|
182
|
+
lang?: "fr" | "en";
|
|
183
|
+
/**
|
|
184
|
+
* The logo to display on the embeded wallet
|
|
185
|
+
* If undefined, will default to no logo displayed
|
|
186
|
+
*/
|
|
187
|
+
logo?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Link to the homepage of the calling website
|
|
190
|
+
* If unedfined, will default to the domain of the calling website
|
|
191
|
+
*/
|
|
192
|
+
homepageLink?: string;
|
|
193
|
+
/**
|
|
194
|
+
* The target interaction behind this modal
|
|
195
|
+
*/
|
|
196
|
+
targetInteraction?: FullInteractionTypesKey;
|
|
197
|
+
/**
|
|
198
|
+
* The position of the component
|
|
199
|
+
*/
|
|
200
|
+
position?: "left" | "right";
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Params used to display a modal
|
|
206
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
207
|
+
* @group Modal Display
|
|
208
|
+
*/
|
|
209
|
+
export declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
210
|
+
steps: ModalRpcStepsInput<T>;
|
|
211
|
+
metadata?: ModalRpcMetadata;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
declare type DoBackupEvent = {
|
|
215
|
+
iframeLifecycle: "do-backup";
|
|
216
|
+
data: {
|
|
217
|
+
backup?: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The different type of action we can have on the embeded view (once the user is logged in)
|
|
223
|
+
*
|
|
224
|
+
* @group Embeded wallet
|
|
225
|
+
*/
|
|
226
|
+
export declare type EmbededViewAction = {
|
|
227
|
+
key: "sharing";
|
|
228
|
+
/**
|
|
229
|
+
* Some sharing options
|
|
230
|
+
*/
|
|
231
|
+
options?: {
|
|
232
|
+
/**
|
|
233
|
+
* The title that will be displayed on the system popup once the system sharing window is open
|
|
234
|
+
*/
|
|
235
|
+
popupTitle?: string;
|
|
236
|
+
/**
|
|
237
|
+
* The text that will be shared alongside the link.
|
|
238
|
+
* Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
|
|
239
|
+
*/
|
|
240
|
+
text?: string;
|
|
241
|
+
/**
|
|
242
|
+
* The link to be shared (will be suffixed with the Frak sharing context)
|
|
243
|
+
*/
|
|
244
|
+
link?: string;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Type that extract the possible return type from a RPC Schema
|
|
250
|
+
* @ignore
|
|
251
|
+
*/
|
|
252
|
+
declare type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
|
|
253
|
+
Method: TMethod;
|
|
254
|
+
}>;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Type that extract the possible parameters from a RPC Schema
|
|
258
|
+
* @ignore
|
|
259
|
+
*/
|
|
260
|
+
export declare type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
|
|
261
|
+
[K in keyof TRpcSchema]: Prettify<{
|
|
262
|
+
method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
|
|
263
|
+
} & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
|
|
264
|
+
params?: never;
|
|
265
|
+
} : {
|
|
266
|
+
params: TRpcSchema[K]["Parameters"];
|
|
267
|
+
} : never)>;
|
|
268
|
+
}[number];
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Type that extract the possible return type from a RPC Schema
|
|
272
|
+
* @ignore
|
|
273
|
+
*/
|
|
274
|
+
export declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The different types of final actions we can display in the final step
|
|
278
|
+
* @group Modal Display
|
|
279
|
+
*/
|
|
280
|
+
export declare type FinalActionType = {
|
|
281
|
+
key: "sharing";
|
|
282
|
+
options?: {
|
|
283
|
+
popupTitle?: string;
|
|
284
|
+
text?: string;
|
|
285
|
+
link?: string;
|
|
286
|
+
};
|
|
287
|
+
} | {
|
|
288
|
+
key: "reward";
|
|
289
|
+
options?: never;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The final modal step type, could be used to display sharing options or a success reward screen.
|
|
294
|
+
*
|
|
295
|
+
* **Input**: What type final step to display?
|
|
296
|
+
* **Output**: None
|
|
297
|
+
*
|
|
298
|
+
* @group Modal Display
|
|
299
|
+
*/
|
|
300
|
+
export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
301
|
+
dismissedMetadata?: ModalStepMetadata["metadata"];
|
|
302
|
+
action: FinalActionType;
|
|
303
|
+
autoSkip?: boolean;
|
|
304
|
+
}, object>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Representing a Frak client, used to interact with the Frak Wallet
|
|
308
|
+
*/
|
|
309
|
+
export declare type FrakClient = {
|
|
310
|
+
config: FrakWalletSdkConfig;
|
|
311
|
+
debugInfo: {
|
|
312
|
+
formatDebugInfo: (error: Error | unknown | string) => string;
|
|
313
|
+
};
|
|
314
|
+
} & IFrameTransport;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The current Frak Context
|
|
318
|
+
*
|
|
319
|
+
* For now, only contain a referrer address.
|
|
320
|
+
*/
|
|
321
|
+
export declare type FrakContext = {
|
|
322
|
+
r: Address;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Export our frak context "class"
|
|
327
|
+
*/
|
|
328
|
+
export declare const FrakContextManager: {
|
|
329
|
+
compress: typeof compress;
|
|
330
|
+
decompress: typeof decompress;
|
|
331
|
+
parse: typeof parse;
|
|
332
|
+
update: typeof update;
|
|
333
|
+
remove: typeof remove;
|
|
334
|
+
replaceUrl: typeof replaceUrl;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Generic Frak RPC error
|
|
339
|
+
* @ignore
|
|
340
|
+
*/
|
|
341
|
+
export declare class FrakRpcError<T = undefined> extends Error {
|
|
342
|
+
code: number;
|
|
343
|
+
data?: T | undefined;
|
|
344
|
+
constructor(code: number, message: string, data?: T | undefined);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Configuration for the Nexus Wallet SDK
|
|
349
|
+
*/
|
|
350
|
+
export declare type FrakWalletSdkConfig = {
|
|
351
|
+
/**
|
|
352
|
+
* The Frak wallet url
|
|
353
|
+
* @defaultValue "https://wallet.frak.id"
|
|
354
|
+
*/
|
|
355
|
+
walletUrl?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Some metadata about your implementation of the Frak SDK
|
|
358
|
+
*/
|
|
359
|
+
metadata: {
|
|
360
|
+
/**
|
|
361
|
+
* Your application name (will be displayed in a few modals and in SSO)
|
|
362
|
+
*/
|
|
363
|
+
name: string;
|
|
364
|
+
/**
|
|
365
|
+
* Custom CSS styles to apply to the modals and components
|
|
366
|
+
*/
|
|
367
|
+
css?: string;
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* The domain name of your application
|
|
371
|
+
* @defaultValue window.location.host
|
|
372
|
+
*/
|
|
373
|
+
domain?: string;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
|
|
378
|
+
* @inline
|
|
379
|
+
*/
|
|
380
|
+
export declare type FullInteractionTypesKey = {
|
|
381
|
+
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
382
|
+
}[keyof typeof interactionTypes];
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Represent a generic modal step type
|
|
386
|
+
* @ignore
|
|
387
|
+
* @inline
|
|
388
|
+
*/
|
|
389
|
+
declare type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
390
|
+
key: TKey;
|
|
391
|
+
params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
|
|
392
|
+
returns: TReturns;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Response of the `frak_getProductInformation` RPC method
|
|
397
|
+
* @group RPC Schema
|
|
398
|
+
*/
|
|
399
|
+
export declare type GetProductInformationReturnType = {
|
|
400
|
+
/**
|
|
401
|
+
* Current product id
|
|
402
|
+
*/
|
|
403
|
+
id: Hex;
|
|
404
|
+
/**
|
|
405
|
+
* Some metadata
|
|
406
|
+
*/
|
|
407
|
+
onChainMetadata: {
|
|
408
|
+
/**
|
|
409
|
+
* Name of the product on-chain
|
|
410
|
+
*/
|
|
411
|
+
name: string;
|
|
412
|
+
/**
|
|
413
|
+
* Domain of the product on-chain
|
|
414
|
+
*/
|
|
415
|
+
domain: string;
|
|
416
|
+
/**
|
|
417
|
+
* The supported product types
|
|
418
|
+
*/
|
|
419
|
+
productTypes: ProductTypesKey[];
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* The max potential reward in EUR for the given product
|
|
423
|
+
*/
|
|
424
|
+
estimatedEurReward?: string;
|
|
425
|
+
/**
|
|
426
|
+
* List of all the potentials reward arround this product
|
|
427
|
+
*/
|
|
428
|
+
rewards: {
|
|
429
|
+
token: Address;
|
|
430
|
+
campaign: Address;
|
|
431
|
+
interactionTypeKey: FullInteractionTypesKey;
|
|
432
|
+
referrer: {
|
|
433
|
+
amount: number;
|
|
434
|
+
eurAmount: number;
|
|
435
|
+
usdAmount: number;
|
|
436
|
+
};
|
|
437
|
+
referee: {
|
|
438
|
+
amount: number;
|
|
439
|
+
eurAmount: number;
|
|
440
|
+
usdAmount: number;
|
|
441
|
+
};
|
|
442
|
+
}[];
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
declare type HandshakeRequestEvent = {
|
|
446
|
+
iframeLifecycle: "handshake";
|
|
447
|
+
data: {
|
|
448
|
+
token: string;
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
declare type HandshakeResponse = {
|
|
453
|
+
clientLifecycle: "handshake-response";
|
|
454
|
+
data: {
|
|
455
|
+
token: string;
|
|
456
|
+
currentUrl: string;
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Compress the given params, and add hash protection to (rapidly) prevent interception modification
|
|
462
|
+
* @param data The params to encode
|
|
463
|
+
* @ignore
|
|
464
|
+
*/
|
|
465
|
+
export declare function hashAndCompressData<T>(data: T): Promise<CompressedData>;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* The encoded data to send to a client / received by a client
|
|
469
|
+
* @ignore
|
|
470
|
+
*/
|
|
471
|
+
export declare type HashProtectedData<DataType> = Readonly<DataType & {
|
|
472
|
+
validationHash: string;
|
|
473
|
+
}>;
|
|
474
|
+
|
|
475
|
+
declare type HearbeatEvent = {
|
|
476
|
+
clientLifecycle: "heartbeat";
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Represent an iframe event
|
|
481
|
+
*/
|
|
482
|
+
export declare type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Event related to the iframe lifecycle
|
|
486
|
+
* @ignore
|
|
487
|
+
*/
|
|
488
|
+
export declare type IFrameLifecycleEvent = {
|
|
489
|
+
iframeLifecycle: "connected" | "show" | "hide";
|
|
490
|
+
data?: never;
|
|
491
|
+
} | DoBackupEvent | RemoveBackupEvent | HandshakeRequestEvent;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Represent an iframe rpc event
|
|
495
|
+
*/
|
|
496
|
+
export declare type IFrameRpcEvent = {
|
|
497
|
+
id: string;
|
|
498
|
+
topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
|
|
499
|
+
data: {
|
|
500
|
+
compressed: string;
|
|
501
|
+
compressedHash: string;
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* RPC interface that's used for the iframe communication
|
|
507
|
+
*
|
|
508
|
+
* Define all the methods available within the iFrame RPC client
|
|
509
|
+
*
|
|
510
|
+
* @group RPC Schema
|
|
511
|
+
*
|
|
512
|
+
* @remarks
|
|
513
|
+
* Here is the list of methods available:
|
|
514
|
+
*
|
|
515
|
+
* ### frak_listenToWalletStatus
|
|
516
|
+
* - Params: None
|
|
517
|
+
* - Returns: {@link WalletStatusReturnType}
|
|
518
|
+
*
|
|
519
|
+
* ### frak_displayModal
|
|
520
|
+
* - Params: [{@link ModalRpcStepsInput}, name: string, metadata?: {@link ModalRpcMetadata}]
|
|
521
|
+
* - Returns: {@link ModalRpcStepsResultType}
|
|
522
|
+
*
|
|
523
|
+
* ### frak_sendInteraction
|
|
524
|
+
* - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
|
|
525
|
+
* - Returns: {@link SendInteractionReturnType}
|
|
526
|
+
*
|
|
527
|
+
* ### frak_sso
|
|
528
|
+
* - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
529
|
+
* - Returns: undefined
|
|
530
|
+
*
|
|
531
|
+
* ### frak_getProductInformation
|
|
532
|
+
* - Params: None
|
|
533
|
+
* - Returns: {@link GetProductInformationReturnType}
|
|
534
|
+
*
|
|
535
|
+
* ### frak_displayEmbededWallet
|
|
536
|
+
* - Params: [{@link DisplayEmbededWalletParamsType}]
|
|
537
|
+
* - Returns: undefined
|
|
538
|
+
*/
|
|
539
|
+
export declare type IFrameRpcSchema = [
|
|
540
|
+
/**
|
|
541
|
+
* Method used to listen to the wallet status
|
|
542
|
+
*/
|
|
543
|
+
{
|
|
544
|
+
Method: "frak_listenToWalletStatus";
|
|
545
|
+
Parameters?: undefined;
|
|
546
|
+
ReturnType: WalletStatusReturnType;
|
|
547
|
+
},
|
|
548
|
+
/**
|
|
549
|
+
* Method to display a modal with the provided steps
|
|
550
|
+
*/
|
|
551
|
+
{
|
|
552
|
+
Method: "frak_displayModal";
|
|
553
|
+
Parameters: [
|
|
554
|
+
requests: ModalRpcStepsInput,
|
|
555
|
+
name: string,
|
|
556
|
+
metadata?: ModalRpcMetadata
|
|
557
|
+
];
|
|
558
|
+
ReturnType: ModalRpcStepsResultType;
|
|
559
|
+
},
|
|
560
|
+
/**
|
|
561
|
+
* Method to transmit a user interaction
|
|
562
|
+
*/
|
|
563
|
+
{
|
|
564
|
+
Method: "frak_sendInteraction";
|
|
565
|
+
Parameters: [
|
|
566
|
+
productId: Hex,
|
|
567
|
+
interaction: PreparedInteraction,
|
|
568
|
+
signature?: Hex
|
|
569
|
+
];
|
|
570
|
+
ReturnType: SendInteractionReturnType;
|
|
571
|
+
},
|
|
572
|
+
/**
|
|
573
|
+
* Method to start a SSO
|
|
574
|
+
* todo: Should also support direct tracking via a consumeKey
|
|
575
|
+
*/
|
|
576
|
+
{
|
|
577
|
+
Method: "frak_sso";
|
|
578
|
+
Parameters: [
|
|
579
|
+
params: OpenSsoParamsType,
|
|
580
|
+
name: string,
|
|
581
|
+
customCss?: string
|
|
582
|
+
];
|
|
583
|
+
ReturnType: undefined;
|
|
584
|
+
},
|
|
585
|
+
/**
|
|
586
|
+
* Method to get current product information's
|
|
587
|
+
* - Is product minted?
|
|
588
|
+
* - Does it have running campaign?
|
|
589
|
+
* - Estimated reward on actions
|
|
590
|
+
*/
|
|
591
|
+
{
|
|
592
|
+
Method: "frak_getProductInformation";
|
|
593
|
+
Parameters?: undefined;
|
|
594
|
+
ReturnType: GetProductInformationReturnType;
|
|
595
|
+
},
|
|
596
|
+
/**
|
|
597
|
+
* Method to show the embeded wallet, with potential customisation
|
|
598
|
+
*/
|
|
599
|
+
{
|
|
600
|
+
Method: "frak_displayEmbededWallet";
|
|
601
|
+
Parameters: [DisplayEmbededWalletParamsType, name: string];
|
|
602
|
+
ReturnType: undefined;
|
|
603
|
+
}
|
|
604
|
+
];
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* IFrame transport interface
|
|
608
|
+
*/
|
|
609
|
+
export declare type IFrameTransport = {
|
|
610
|
+
/**
|
|
611
|
+
* Wait for the connection to be established
|
|
612
|
+
*/
|
|
613
|
+
waitForConnection: Promise<boolean>;
|
|
614
|
+
/**
|
|
615
|
+
* Wait for the setup to be done
|
|
616
|
+
*/
|
|
617
|
+
waitForSetup: Promise<void>;
|
|
618
|
+
/**
|
|
619
|
+
* Function used to perform a single request via the iframe transport
|
|
620
|
+
*/
|
|
621
|
+
request: RequestFn<IFrameRpcSchema>;
|
|
622
|
+
/**
|
|
623
|
+
* Function used to listen to a request response via the iframe transport
|
|
624
|
+
*/
|
|
625
|
+
listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
|
|
626
|
+
/**
|
|
627
|
+
* Function used to destroy the iframe transport
|
|
628
|
+
*/
|
|
629
|
+
destroy: () => Promise<void>;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Each interactions types according to the product types
|
|
634
|
+
*/
|
|
635
|
+
export declare const interactionTypes: {
|
|
636
|
+
readonly press: {
|
|
637
|
+
readonly openArticle: "0xc0a24ffb";
|
|
638
|
+
readonly readArticle: "0xd5bd0fbe";
|
|
639
|
+
};
|
|
640
|
+
readonly dapp: {
|
|
641
|
+
readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
|
|
642
|
+
readonly callableVerifiableStorageUpdate: "0xa07da986";
|
|
643
|
+
};
|
|
644
|
+
readonly webshop: {
|
|
645
|
+
readonly open: "0xb311798f";
|
|
646
|
+
};
|
|
647
|
+
readonly referral: {
|
|
648
|
+
readonly referred: "0x010cc3b9";
|
|
649
|
+
readonly createLink: "0xb2c0f17c";
|
|
650
|
+
};
|
|
651
|
+
readonly purchase: {
|
|
652
|
+
readonly started: "0xd87e90c3";
|
|
653
|
+
readonly completed: "0x8403aeb4";
|
|
654
|
+
readonly unsafeCompleted: "0x4d5b14e0";
|
|
655
|
+
};
|
|
656
|
+
readonly retail: {
|
|
657
|
+
readonly customerMeeting: "0x74489004";
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* The final keys for each interaction types (e.g. `openArticle`) -> interaction type
|
|
663
|
+
* @inline
|
|
664
|
+
*/
|
|
665
|
+
export declare type InteractionTypesKey = {
|
|
666
|
+
[K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
|
|
667
|
+
}[keyof typeof interactionTypes];
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Represent a key provider used for the hashed and secure compression
|
|
671
|
+
* @ignore
|
|
672
|
+
*/
|
|
673
|
+
export declare type KeyProvider<DataType> = (value: DataType) => string[];
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Type used for a listening request
|
|
677
|
+
* @inline
|
|
678
|
+
*/
|
|
679
|
+
declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Some configuration options for the embeded view
|
|
683
|
+
*
|
|
684
|
+
* @group Embeded wallet
|
|
685
|
+
*/
|
|
686
|
+
export declare type LoggedInEmbededView = {
|
|
687
|
+
/**
|
|
688
|
+
* The main action to display on the logged in embeded view
|
|
689
|
+
* If none specified, the user will see his wallet with the activation button
|
|
690
|
+
*/
|
|
691
|
+
action?: EmbededViewAction;
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* The view when a user is logged out
|
|
696
|
+
* @group Embeded wallet
|
|
697
|
+
*/
|
|
698
|
+
export declare type LoggedOutEmbededView = {
|
|
699
|
+
/**
|
|
700
|
+
* Metadata option when displaying the embeded view
|
|
701
|
+
*/
|
|
702
|
+
metadata?: {
|
|
703
|
+
/**
|
|
704
|
+
* The main CTA for the logged out view
|
|
705
|
+
* - can include some variable, available ones are:
|
|
706
|
+
* - {REWARD} -> The maximum reward a user can receive when itneracting on your website
|
|
707
|
+
* - can be formatted in markdown
|
|
708
|
+
*
|
|
709
|
+
* If not sert, it will default to a internalised message
|
|
710
|
+
*/
|
|
711
|
+
text?: string;
|
|
712
|
+
/**
|
|
713
|
+
* The text that will be displayed on the login button
|
|
714
|
+
*
|
|
715
|
+
* If not set, it will default to a internalised message
|
|
716
|
+
*/
|
|
717
|
+
buttonText?: string;
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* The login step for a Modal
|
|
723
|
+
*
|
|
724
|
+
* **Input**: Do we allow SSO or not? Is yes then the SSO metadata
|
|
725
|
+
* **Output**: The logged in wallet address
|
|
726
|
+
*
|
|
727
|
+
* @group Modal Display
|
|
728
|
+
*/
|
|
729
|
+
export declare type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
730
|
+
wallet: Address;
|
|
731
|
+
}>;
|
|
732
|
+
|
|
733
|
+
/** @inline */
|
|
734
|
+
declare type LoginWithoutSso = {
|
|
735
|
+
allowSso?: false;
|
|
736
|
+
ssoMetadata?: never;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
/** @inline */
|
|
740
|
+
declare type LoginWithSso = {
|
|
741
|
+
allowSso: true;
|
|
742
|
+
ssoMetadata: SsoMetadata;
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* RPC metadata for the modal, used on top level modal configuration
|
|
747
|
+
* @group Modal Display
|
|
748
|
+
* @group RPC Schema
|
|
749
|
+
*/
|
|
750
|
+
export declare type ModalRpcMetadata = {
|
|
751
|
+
header?: {
|
|
752
|
+
title?: string;
|
|
753
|
+
icon?: string;
|
|
754
|
+
};
|
|
755
|
+
context?: string;
|
|
756
|
+
lang?: "en" | "fr";
|
|
757
|
+
targetInteraction?: FullInteractionTypesKey;
|
|
758
|
+
} & ({
|
|
759
|
+
isDismissible: true;
|
|
760
|
+
dismissActionTxt?: string;
|
|
761
|
+
} | {
|
|
762
|
+
isDismissible?: false;
|
|
763
|
+
dismissActionTxt?: never;
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Type for the RPC input of a modal
|
|
768
|
+
* Just the `params` type of each `ModalStepTypes`
|
|
769
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
770
|
+
* @group Modal Display
|
|
771
|
+
* @group RPC Schema
|
|
772
|
+
*/
|
|
773
|
+
export declare type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
774
|
+
[K in T[number]["key"]]?: Extract<T[number], {
|
|
775
|
+
key: K;
|
|
776
|
+
}>["params"];
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Type for the result of a modal request
|
|
781
|
+
* Just the `returns` type of each `ModalStepTypes`
|
|
782
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
783
|
+
* @group Modal Display
|
|
784
|
+
* @group RPC Schema
|
|
785
|
+
*/
|
|
786
|
+
export declare type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
787
|
+
[K in T[number]["key"]]: Extract<T[number], {
|
|
788
|
+
key: K;
|
|
789
|
+
}>["returns"];
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Metadata that can be used to customise a modal step
|
|
794
|
+
* @group Modal Display
|
|
795
|
+
*/
|
|
796
|
+
export declare type ModalStepMetadata = {
|
|
797
|
+
metadata?: {
|
|
798
|
+
/**
|
|
799
|
+
* Custom title for the step
|
|
800
|
+
* If none provided, it will use an internationalised text
|
|
801
|
+
*/
|
|
802
|
+
title?: string;
|
|
803
|
+
/**
|
|
804
|
+
* Custom description for the step
|
|
805
|
+
* If none provided, it will use an internationalised text
|
|
806
|
+
*/
|
|
807
|
+
description?: string;
|
|
808
|
+
/**
|
|
809
|
+
* Custom text for the primary action of the step
|
|
810
|
+
* If none provided, it will use an internationalised text
|
|
811
|
+
*/
|
|
812
|
+
primaryActionText?: string;
|
|
813
|
+
/**
|
|
814
|
+
* Custom text for the secondary action of the step
|
|
815
|
+
* If none provided, it will use an internationalised text
|
|
816
|
+
*/
|
|
817
|
+
secondaryActionText?: string;
|
|
818
|
+
};
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Generic type of steps we will display in the modal to the end user
|
|
823
|
+
* @group Modal Display
|
|
824
|
+
*/
|
|
825
|
+
export declare type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* The open interaction session step for a Modal
|
|
829
|
+
*
|
|
830
|
+
* **Input**: None
|
|
831
|
+
* **Output**: The interactions session period (start and end timestamp)
|
|
832
|
+
*
|
|
833
|
+
* @group Modal Display
|
|
834
|
+
*/
|
|
835
|
+
export declare type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Return type of the open session modal step
|
|
839
|
+
* @inline
|
|
840
|
+
* @ignore
|
|
841
|
+
*/
|
|
842
|
+
export declare type OpenInteractionSessionReturnType = {
|
|
843
|
+
startTimestamp: number;
|
|
844
|
+
endTimestamp: number;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Params to start a SSO
|
|
849
|
+
* @group RPC Schema
|
|
850
|
+
*/
|
|
851
|
+
export declare type OpenSsoParamsType = {
|
|
852
|
+
/**
|
|
853
|
+
* Redirect URL after the SSO (optional)
|
|
854
|
+
*/
|
|
855
|
+
redirectUrl?: string;
|
|
856
|
+
/**
|
|
857
|
+
* If the SSO should directly exit after completion
|
|
858
|
+
* @defaultValue true
|
|
859
|
+
*/
|
|
860
|
+
directExit?: boolean;
|
|
861
|
+
/**
|
|
862
|
+
* Language of the SSO page (optional)
|
|
863
|
+
* It will default to the current user language (or "en" if unsupported language)
|
|
864
|
+
*/
|
|
865
|
+
lang?: "en" | "fr";
|
|
866
|
+
/**
|
|
867
|
+
* Custom SSO metadata
|
|
868
|
+
*/
|
|
869
|
+
metadata: SsoMetadata;
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Parse the current URL into a Frak Context
|
|
874
|
+
* @param args
|
|
875
|
+
* @param args.url - The url to parse
|
|
876
|
+
* @returns The parsed Frak context
|
|
877
|
+
*/
|
|
878
|
+
declare function parse({ url }: {
|
|
879
|
+
url: string;
|
|
880
|
+
}): FrakContext | null | undefined;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Represent a prepared user interaction, ready to be sent on-chain via the wallet
|
|
884
|
+
*/
|
|
885
|
+
export declare type PreparedInteraction = {
|
|
886
|
+
handlerTypeDenominator: Hex;
|
|
887
|
+
interactionData: Hex;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* List of the product types per denominator
|
|
892
|
+
*/
|
|
893
|
+
export declare const productTypes: {
|
|
894
|
+
dapp: number;
|
|
895
|
+
press: number;
|
|
896
|
+
webshop: number;
|
|
897
|
+
retail: number;
|
|
898
|
+
referral: number;
|
|
899
|
+
purchase: number;
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* The keys for each product types
|
|
904
|
+
* @inline
|
|
905
|
+
*/
|
|
906
|
+
export declare type ProductTypesKey = keyof typeof productTypes;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Bitmask for each product types
|
|
910
|
+
*/
|
|
911
|
+
export declare const productTypesMask: Record<ProductTypesKey, bigint>;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Remove Frak context from current url
|
|
915
|
+
* @param url - The url to update
|
|
916
|
+
* @returns The new url without the Frak context
|
|
917
|
+
*/
|
|
918
|
+
declare function remove(url: string): string;
|
|
919
|
+
|
|
920
|
+
declare type RemoveBackupEvent = {
|
|
921
|
+
iframeLifecycle: "remove-backup";
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Replace the current url with the given Frak context
|
|
926
|
+
* @param args
|
|
927
|
+
* @param args.url - The url to update
|
|
928
|
+
* @param args.context - The context to update
|
|
929
|
+
*/
|
|
930
|
+
declare function replaceUrl({ url: baseUrl, context, }: {
|
|
931
|
+
url?: string;
|
|
932
|
+
context: Partial<FrakContext> | null;
|
|
933
|
+
}): void;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Type used for a one shot request function
|
|
937
|
+
* @inline
|
|
938
|
+
*/
|
|
939
|
+
declare type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
|
|
940
|
+
|
|
941
|
+
declare type RestoreBackupEvent = {
|
|
942
|
+
clientLifecycle: "restore-backup";
|
|
943
|
+
data: {
|
|
944
|
+
backup: string;
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* The different Frak RPC error codes
|
|
950
|
+
*/
|
|
951
|
+
export declare const RpcErrorCodes: {
|
|
952
|
+
readonly parseError: -32700;
|
|
953
|
+
readonly invalidRequest: -32600;
|
|
954
|
+
readonly methodNotFound: -32601;
|
|
955
|
+
readonly invalidParams: -32602;
|
|
956
|
+
readonly internalError: -32603;
|
|
957
|
+
readonly serverError: -32000;
|
|
958
|
+
readonly clientNotConnected: -32001;
|
|
959
|
+
readonly configError: -32002;
|
|
960
|
+
readonly corruptedResponse: -32003;
|
|
961
|
+
readonly clientAborted: -32004;
|
|
962
|
+
readonly walletNotConnected: -32005;
|
|
963
|
+
readonly serverErrorForInteractionDelegation: -32006;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Raw response that we will receive after an rpc request
|
|
968
|
+
* @ignore
|
|
969
|
+
*/
|
|
970
|
+
export declare type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
|
|
971
|
+
result: Extract<TRpcSchema[number], {
|
|
972
|
+
Method: TMethod;
|
|
973
|
+
}>["ReturnType"];
|
|
974
|
+
error?: never;
|
|
975
|
+
} | {
|
|
976
|
+
result?: never;
|
|
977
|
+
error: {
|
|
978
|
+
code: number;
|
|
979
|
+
message: string;
|
|
980
|
+
data?: unknown;
|
|
981
|
+
};
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Parameters that will be used to send an interaction to the blockchain
|
|
986
|
+
* @inline
|
|
987
|
+
*/
|
|
988
|
+
export declare type SendInteractionParamsType = {
|
|
989
|
+
/**
|
|
990
|
+
* The product id where this interaction has been made
|
|
991
|
+
* @defaultValue keccak256(toHex(window.location.host))
|
|
992
|
+
*/
|
|
993
|
+
productId?: Hex;
|
|
994
|
+
/**
|
|
995
|
+
* The prepared interaction, built from an Interaction Encoder
|
|
996
|
+
*/
|
|
997
|
+
interaction: PreparedInteraction;
|
|
998
|
+
/**
|
|
999
|
+
* A pre-computed interaction signature
|
|
1000
|
+
* If none provided, the delegated interaction validator of your product will sign it (you can manage it in the business dashboard)
|
|
1001
|
+
*
|
|
1002
|
+
* @defaultValue undefined
|
|
1003
|
+
*/
|
|
1004
|
+
validation?: Hex;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Return type of the send interaction rpc request
|
|
1009
|
+
* @group RPC Schema
|
|
1010
|
+
*/
|
|
1011
|
+
export declare type SendInteractionReturnType = {
|
|
1012
|
+
/**
|
|
1013
|
+
* The id of the interaction in the interaction pool
|
|
1014
|
+
*/
|
|
1015
|
+
delegationId: string;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* The send transaction step for a Modal
|
|
1020
|
+
*
|
|
1021
|
+
* **Input**: Either a single tx or an array of tx to be sent
|
|
1022
|
+
* **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)
|
|
1023
|
+
*
|
|
1024
|
+
* @group Modal Display
|
|
1025
|
+
*/
|
|
1026
|
+
export declare type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
|
|
1027
|
+
tx: SendTransactionTxType | SendTransactionTxType[];
|
|
1028
|
+
}, SendTransactionReturnType>;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Return type of the send transaction rpc request
|
|
1032
|
+
* @inline
|
|
1033
|
+
*/
|
|
1034
|
+
export declare type SendTransactionReturnType = {
|
|
1035
|
+
hash: Hex;
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Generic format representing a tx to be sent
|
|
1040
|
+
*/
|
|
1041
|
+
export declare type SendTransactionTxType = {
|
|
1042
|
+
to: Address;
|
|
1043
|
+
data?: Hex;
|
|
1044
|
+
value?: Hex;
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Directly setup the Frak client with an iframe
|
|
1049
|
+
* Return when the FrakClient is ready (setup and communication estbalished with the wallet)
|
|
1050
|
+
*
|
|
1051
|
+
* @param config - The configuration to use for the Frak Wallet SDK
|
|
1052
|
+
* @returns a Promise with the Frak Client
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* const frakConfig: FrakWalletSdkConfig = {
|
|
1056
|
+
* metadata: {
|
|
1057
|
+
* name: "My app title",
|
|
1058
|
+
* },
|
|
1059
|
+
* }
|
|
1060
|
+
* const client = await setupClient({ config: frakConfig });
|
|
1061
|
+
*/
|
|
1062
|
+
export declare function setupClient({ config, }: {
|
|
1063
|
+
config: FrakWalletSdkConfig;
|
|
1064
|
+
}): Promise<FrakClient | undefined>;
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* The SIWE authentication step for a Modal
|
|
1068
|
+
*
|
|
1069
|
+
* **Input**: SIWE message parameters
|
|
1070
|
+
* **Output**: SIWE result (message signed and wallet signature)
|
|
1071
|
+
*
|
|
1072
|
+
* @group Modal Display
|
|
1073
|
+
*/
|
|
1074
|
+
export declare type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
|
|
1075
|
+
siwe: SiweAuthenticationParams;
|
|
1076
|
+
}, SiweAuthenticateReturnType>;
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* Return type of the Siwe transaction rpc request
|
|
1080
|
+
* @inline
|
|
1081
|
+
*/
|
|
1082
|
+
export declare type SiweAuthenticateReturnType = {
|
|
1083
|
+
signature: Hex;
|
|
1084
|
+
message: string;
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Parameters used send a SIWE rpc request
|
|
1089
|
+
*/
|
|
1090
|
+
export declare type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
|
|
1091
|
+
expirationTimeTimestamp?: number;
|
|
1092
|
+
notBeforeTimestamp?: number;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* SSO Metadata
|
|
1097
|
+
*/
|
|
1098
|
+
export declare type SsoMetadata = {
|
|
1099
|
+
/**
|
|
1100
|
+
* URL to your client, if provided will be displayed in the SSO header
|
|
1101
|
+
*/
|
|
1102
|
+
logoUrl?: string;
|
|
1103
|
+
/**
|
|
1104
|
+
* Link to your homepage, if referenced your app name will contain a link on the sso page
|
|
1105
|
+
*/
|
|
1106
|
+
homepageLink?: string;
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Populate the current url with the given Frak context
|
|
1111
|
+
* @param args
|
|
1112
|
+
* @param args.url - The url to update
|
|
1113
|
+
* @param args.context - The context to update
|
|
1114
|
+
* @returns The new url with the Frak context
|
|
1115
|
+
*/
|
|
1116
|
+
declare function update({ url, context, }: {
|
|
1117
|
+
url?: string;
|
|
1118
|
+
context: Partial<FrakContext>;
|
|
1119
|
+
}): string | null;
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* @ignore
|
|
1123
|
+
* @inline
|
|
1124
|
+
*/
|
|
1125
|
+
declare type WalletConnected = {
|
|
1126
|
+
key: "connected";
|
|
1127
|
+
wallet: Address;
|
|
1128
|
+
interactionToken?: string;
|
|
1129
|
+
interactionSession?: {
|
|
1130
|
+
startTimestamp: number;
|
|
1131
|
+
endTimestamp: number;
|
|
1132
|
+
};
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* @ignore
|
|
1137
|
+
* @inline
|
|
1138
|
+
*/
|
|
1139
|
+
declare type WalletNotConnected = {
|
|
1140
|
+
key: "not-connected";
|
|
1141
|
+
wallet?: never;
|
|
1142
|
+
interactionToken?: never;
|
|
1143
|
+
interactionSession?: never;
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* RPC Response for the method `frak_listenToWalletStatus`
|
|
1148
|
+
* @group RPC Schema
|
|
1149
|
+
*/
|
|
1150
|
+
export declare type WalletStatusReturnType = WalletConnected | WalletNotConnected;
|
|
1151
|
+
|
|
1152
|
+
export { }
|