@frak-labs/nexus-sdk 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +2 -72
  2. package/dist/bundle/bundle.js +6 -6
  3. package/package.json +11 -64
  4. package/dist/FrakContext-DKSVaeVb.d.cts +0 -450
  5. package/dist/FrakContext-DjeuWC2U.d.ts +0 -450
  6. package/dist/chunk-2VNIEGOJ.js +0 -864
  7. package/dist/chunk-4MMSQL44.js +0 -351
  8. package/dist/chunk-4PVF24BB.cjs +0 -114
  9. package/dist/chunk-BOGCLEPR.js +0 -80
  10. package/dist/chunk-DE2KWQVP.cjs +0 -351
  11. package/dist/chunk-FETGS7X7.js +0 -114
  12. package/dist/chunk-H4BK3CNV.cjs +0 -864
  13. package/dist/chunk-P3J2BIUT.cjs +0 -80
  14. package/dist/chunk-QLM5NFMZ.cjs +0 -245
  15. package/dist/chunk-YPQA63LW.js +0 -245
  16. package/dist/core/actions/index.cjs +0 -29
  17. package/dist/core/actions/index.d.cts +0 -92
  18. package/dist/core/actions/index.d.ts +0 -92
  19. package/dist/core/actions/index.js +0 -29
  20. package/dist/core/index.cjs +0 -34
  21. package/dist/core/index.d.cts +0 -167
  22. package/dist/core/index.d.ts +0 -167
  23. package/dist/core/index.js +0 -34
  24. package/dist/core/interactions/index.cjs +0 -13
  25. package/dist/core/interactions/index.d.cts +0 -65
  26. package/dist/core/interactions/index.d.ts +0 -65
  27. package/dist/core/interactions/index.js +0 -13
  28. package/dist/error-Dflr3G5x.d.cts +0 -27
  29. package/dist/error-Dflr3G5x.d.ts +0 -27
  30. package/dist/interaction-BngPoHA0.d.cts +0 -22
  31. package/dist/interaction-BngPoHA0.d.ts +0 -22
  32. package/dist/processReferral-CJI_Rc4K.d.ts +0 -53
  33. package/dist/processReferral-DUP8imQV.d.cts +0 -53
  34. package/dist/react/index.cjs +0 -366
  35. package/dist/react/index.d.cts +0 -167
  36. package/dist/react/index.d.ts +0 -167
  37. package/dist/react/index.js +0 -366
@@ -1,450 +0,0 @@
1
- import { Address, Hex, RpcSchema } from 'viem';
2
- import { Prettify } from 'viem/chains';
3
- import { SiweMessage } from 'viem/siwe';
4
- import { P as PreparedInteraction, a as SendInteractionReturnType } from './interaction-BngPoHA0.js';
5
-
6
- /**
7
- * Configuration for the Nexus Wallet SDK
8
- */
9
- type NexusWalletSdkConfig = Readonly<{
10
- walletUrl?: string;
11
- metadata: {
12
- name: string;
13
- css?: string;
14
- buttonShare?: string;
15
- };
16
- domain?: string;
17
- }>;
18
-
19
- /**
20
- * Event related to the iframe lifecycle
21
- */
22
- type IFrameLifecycleEvent = {
23
- iframeLifecycle: "connected" | "show" | "hide";
24
- data?: never;
25
- } | DoBackupEvent | RemoveBackupEvent;
26
- type DoBackupEvent = {
27
- iframeLifecycle: "do-backup";
28
- data: {
29
- backup?: string;
30
- };
31
- };
32
- type RemoveBackupEvent = {
33
- iframeLifecycle: "remove-backup";
34
- };
35
-
36
- /**
37
- * Event related to the iframe lifecycle
38
- */
39
- type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent;
40
- type CustomCssEvent = {
41
- clientLifecycle: "modal-css";
42
- data: {
43
- cssLink: string;
44
- };
45
- };
46
- type RestoreBackupEvent = {
47
- clientLifecycle: "restore-backup";
48
- data: {
49
- backup: string;
50
- };
51
- };
52
-
53
- /**
54
- * SSO Metadata
55
- */
56
- type SsoMetadata = {
57
- logoUrl?: string;
58
- homepageLink?: string;
59
- links?: {
60
- confidentialityLink?: string;
61
- helpLink?: string;
62
- cguLink?: string;
63
- };
64
- };
65
- /**
66
- * Params to start a SSO
67
- */
68
- type OpenSsoParamsType = {
69
- redirectUrl?: string;
70
- directExit?: boolean;
71
- lang?: "en" | "fr";
72
- metadata: SsoMetadata;
73
- };
74
-
75
- /**
76
- * Represent a generic modal step type
77
- */
78
- type GenericModalStepType<TKey, TParams, TReturns> = {
79
- key: TKey;
80
- params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
81
- returns: TReturns;
82
- };
83
- type ModalStepMetadata = {
84
- metadata?: {
85
- title?: string;
86
- description?: string;
87
- primaryActionText?: string;
88
- secondaryActionText?: string;
89
- };
90
- };
91
-
92
- type LoginWithSso = {
93
- allowSso: true;
94
- ssoMetadata: SsoMetadata;
95
- };
96
- type LoginWithoutSso = {
97
- allowSso?: false;
98
- ssoMetadata?: never;
99
- };
100
- /**
101
- * Generic type of modal we will display to the end user
102
- */
103
- type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
104
- wallet: Address;
105
- }>;
106
-
107
- /**
108
- * Parameters of the send transaction rpc request
109
- */
110
- type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
111
- expirationTimeTimestamp?: number;
112
- notBeforeTimestamp?: number;
113
- };
114
- /**
115
- * Return type of the send transaction rpc request
116
- */
117
- type SiweAuthenticateReturnType = Readonly<{
118
- signature: Hex;
119
- message: string;
120
- }>;
121
- /**
122
- * Generic type of modal we will display to the end user
123
- */
124
- type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
125
- siwe: SiweAuthenticationParams;
126
- }, SiweAuthenticateReturnType>;
127
-
128
- /**
129
- * Generic format representing a tx to be sent
130
- */
131
- type SendTransactionTxType = Readonly<{
132
- to: Address;
133
- data?: Hex;
134
- value?: Hex;
135
- }>;
136
- /**
137
- * Return type of the send transaction rpc request
138
- */
139
- type SendTransactionReturnType = Readonly<{
140
- hash: Hex;
141
- }>;
142
- type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
143
- tx: SendTransactionTxType | SendTransactionTxType[];
144
- }, SendTransactionReturnType>;
145
-
146
- /**
147
- * Return type of the send transaction rpc request
148
- */
149
- type OpenInteractionSessionReturnType = Readonly<{
150
- startTimestamp: number;
151
- endTimestamp: number;
152
- }>;
153
- /**
154
- * Generic type of modal we will display to the end user
155
- */
156
- type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
157
-
158
- /**
159
- * The final modal step type (displayed on success or dimissed)
160
- */
161
- type FinalModalStepType = GenericModalStepType<"final", {
162
- dismissedMetadata?: ModalStepMetadata["metadata"];
163
- action: FinalActionType;
164
- autoSkip?: boolean;
165
- }, object>;
166
- type FinalActionType = {
167
- key: "sharing";
168
- options?: {
169
- popupTitle?: string;
170
- text?: string;
171
- link?: string;
172
- };
173
- } | {
174
- key: "reward";
175
- options?: never;
176
- };
177
-
178
- /**
179
- * Generic type of steps we will display in the modal to the end user
180
- */
181
- type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
182
- /**
183
- * Type for the result of a modal request
184
- */
185
- type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
186
- [K in T[number]["key"]]: Extract<T[number], {
187
- key: K;
188
- }>["returns"];
189
- };
190
- /**
191
- * Type for the RPC input of a modal
192
- */
193
- type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
194
- [K in T[number]["key"]]?: Extract<T[number], {
195
- key: K;
196
- }>["params"];
197
- };
198
- /**
199
- * RPC metadata for the modal
200
- */
201
- type ModalRpcMetadata = Readonly<{
202
- header?: {
203
- title?: string;
204
- icon?: string;
205
- };
206
- context?: string;
207
- lang?: "en" | "fr";
208
- } & ({
209
- isDismissible: true;
210
- dismissActionTxt?: string;
211
- } | {
212
- isDismissible?: false;
213
- dismissActionTxt?: never;
214
- })>;
215
- /**
216
- * Generic params used to display modals
217
- */
218
- type DisplayModalParamsType<T extends ModalStepTypes[]> = {
219
- steps: ModalRpcStepsInput<T>;
220
- metadata?: ModalRpcMetadata;
221
- };
222
-
223
- /**
224
- * The keys for each product types
225
- */
226
- type ProductTypesKey = keyof typeof productTypes;
227
- /**
228
- * List of the product types per denominator
229
- */
230
- declare const productTypes: {
231
- dapp: number;
232
- press: number;
233
- webshop: number;
234
- referral: number;
235
- purchase: number;
236
- };
237
- /**
238
- * Bitmask for each product types
239
- */
240
- declare const productTypesMask: Record<ProductTypesKey, bigint>;
241
-
242
- type GetProductInformationReturnType = Readonly<{
243
- /**
244
- * Current product id
245
- */
246
- id: Hex;
247
- /**
248
- * Some metadata
249
- */
250
- onChainMetadata: {
251
- /**
252
- * Name of the product on-chain
253
- */
254
- name: string;
255
- /**
256
- * Domain of the product on-chain
257
- */
258
- domain: string;
259
- /**
260
- * The supported product types
261
- */
262
- productTypes: ProductTypesKey[];
263
- };
264
- /**
265
- * Current the current estimated product reward
266
- */
267
- estimatedEurReward?: string;
268
- }>;
269
-
270
- type WalletStatusReturnType = Readonly<WalletConnected | WalletNotConnected>;
271
- type WalletConnected = {
272
- key: "connected";
273
- wallet: Address;
274
- interactionToken?: string;
275
- interactionSession?: {
276
- startTimestamp: number;
277
- endTimestamp: number;
278
- };
279
- };
280
- type WalletNotConnected = {
281
- key: "not-connected";
282
- wallet?: never;
283
- interactionToken?: never;
284
- interactionSession?: never;
285
- };
286
-
287
- /**
288
- * RPC interface that's used for the iframe communication
289
- */
290
- type IFrameRpcSchema = [
291
- /**
292
- * Method used to listen to the wallet status
293
- */
294
- {
295
- Method: "frak_listenToWalletStatus";
296
- Parameters?: undefined;
297
- ReturnType: WalletStatusReturnType;
298
- },
299
- /**
300
- * Method to transmit a user interaction
301
- */
302
- {
303
- Method: "frak_displayModal";
304
- Parameters: [
305
- requests: ModalRpcStepsInput,
306
- name: string,
307
- metadata?: ModalRpcMetadata
308
- ];
309
- ReturnType: ModalRpcStepsResultType;
310
- },
311
- /**
312
- * Method to transmit a user interaction
313
- */
314
- {
315
- Method: "frak_sendInteraction";
316
- Parameters: [
317
- productId: Hex,
318
- interaction: PreparedInteraction,
319
- signature?: Hex
320
- ];
321
- ReturnType: SendInteractionReturnType;
322
- },
323
- /**
324
- * Method to start a SSO
325
- * todo: Should also support direct tracking via a consumeKey
326
- */
327
- {
328
- Method: "frak_sso";
329
- Parameters: [
330
- params: OpenSsoParamsType,
331
- name: string,
332
- customCss?: string
333
- ];
334
- ReturnType: undefined;
335
- },
336
- /**
337
- * Method to get current product information's
338
- * - Is product minted?
339
- * - Does it have running campaign?
340
- * - Estimated reward on actions
341
- */
342
- {
343
- Method: "frak_getProductInformation";
344
- Parameters?: undefined;
345
- ReturnType: GetProductInformationReturnType;
346
- }
347
- ];
348
-
349
- /**
350
- * Type that extract the possible parameters from a RPC Schema
351
- */
352
- type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
353
- [K in keyof TRpcSchema]: Prettify<{
354
- method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
355
- } & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
356
- params?: never;
357
- } : {
358
- params: TRpcSchema[K]["Parameters"];
359
- } : never)>;
360
- }[number];
361
- /**
362
- * Type that extract the possible return type from a RPC Schema
363
- */
364
- type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
365
- /**
366
- * Type that extract the possible return type from a RPC Schema
367
- */
368
- type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
369
- Method: TMethod;
370
- }>;
371
- /**
372
- * Raw response that we will receive after an rpc request
373
- */
374
- type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
375
- result: Extract<TRpcSchema[number], {
376
- Method: TMethod;
377
- }>["ReturnType"];
378
- error?: never;
379
- } | {
380
- result?: never;
381
- error: {
382
- code: number;
383
- message: string;
384
- data?: unknown;
385
- };
386
- };
387
- /**
388
- * Type used for a one shot request function
389
- */
390
- type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
391
- /**
392
- * Type used for a one shot request function
393
- */
394
- type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
395
- /**
396
- * IFrame transport interface
397
- */
398
- type IFrameTransport = {
399
- /**
400
- * Wait for the connection to be established
401
- */
402
- waitForConnection: Promise<boolean>;
403
- /**
404
- * Wait for the setup to be done
405
- */
406
- waitForSetup: Promise<void>;
407
- /**
408
- * Function used to perform a single request via the iframe transport
409
- */
410
- request: RequestFn<IFrameRpcSchema>;
411
- /**
412
- * Function used to listen to a request response via the iframe transport
413
- */
414
- listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
415
- /**
416
- * Function used to destroy the iframe transport
417
- */
418
- destroy: () => Promise<void>;
419
- };
420
- /**
421
- * Represent an iframe event
422
- */
423
- type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
424
- /**
425
- * Represent an iframe rpc event
426
- */
427
- type IFrameRpcEvent = {
428
- id: string;
429
- topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
430
- data: {
431
- compressed: string;
432
- compressedHash: string;
433
- };
434
- };
435
-
436
- /**
437
- * Representing a Nexus client
438
- */
439
- type NexusClient = {
440
- config: NexusWalletSdkConfig;
441
- } & IFrameTransport;
442
-
443
- /**
444
- * The type of the nexus context
445
- */
446
- type FrakContext = Readonly<{
447
- r: Address;
448
- }>;
449
-
450
- export { type ClientLifecycleEvent as C, type DisplayModalParamsType as D, type ExtractedParametersFromRpc as E, type FrakContext as F, type GetProductInformationReturnType as G, type IFrameRpcSchema as I, type LoginModalStepType as L, type ModalStepTypes as M, type NexusWalletSdkConfig as N, type OpenSsoParamsType as O, type ProductTypesKey as P, type RpcResponse as R, type SsoMetadata as S, type WalletStatusReturnType as W, type NexusClient as a, productTypesMask as b, type ModalRpcMetadata as c, type ModalRpcStepsInput as d, type ModalRpcStepsResultType as e, type ModalStepMetadata as f, type SiweAuthenticateModalStepType as g, type SiweAuthenticationParams as h, type SiweAuthenticateReturnType as i, type SendTransactionTxType as j, type SendTransactionModalStepType as k, type SendTransactionReturnType as l, type OpenInteractionSessionReturnType as m, type OpenInteractionSessionModalStepType as n, type FinalModalStepType as o, productTypes as p, type FinalActionType as q, type IFrameTransport as r, type IFrameRpcEvent as s, type IFrameEvent as t, type IFrameLifecycleEvent as u, type ExtractedReturnTypeFromRpc as v };