@frak-labs/nexus-sdk 0.0.9 → 0.0.11

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 (43) hide show
  1. package/dist/chunk-5CFD5FM2.js +86 -0
  2. package/dist/chunk-7MVQQ2X6.js +381 -0
  3. package/dist/chunk-ETV4XYOV.cjs +7 -0
  4. package/dist/chunk-GUDT2W6I.js +70 -0
  5. package/dist/chunk-IQQTTKJL.cjs +70 -0
  6. package/dist/chunk-PKBMQBKP.js +7 -0
  7. package/dist/chunk-S5FVCA2E.cjs +86 -0
  8. package/dist/chunk-V3S6RBRJ.cjs +381 -0
  9. package/dist/client-C7u9zGwC.d.cts +332 -0
  10. package/dist/client-gE3fYzkD.d.ts +332 -0
  11. package/dist/core/actions/index.cjs +3 -3
  12. package/dist/core/actions/index.d.cts +21 -28
  13. package/dist/core/actions/index.d.ts +21 -28
  14. package/dist/core/actions/index.js +12 -12
  15. package/dist/core/index.cjs +3 -8
  16. package/dist/core/index.d.cts +8 -35
  17. package/dist/core/index.d.ts +8 -35
  18. package/dist/core/index.js +9 -14
  19. package/dist/core/interactions/index.cjs +13 -0
  20. package/dist/core/interactions/index.d.cts +53 -0
  21. package/dist/core/interactions/index.d.ts +53 -0
  22. package/dist/core/interactions/index.js +13 -0
  23. package/dist/error-C4Zm5nQe.d.cts +27 -0
  24. package/dist/error-C4Zm5nQe.d.ts +27 -0
  25. package/dist/interaction-D3-M3nBh.d.cts +22 -0
  26. package/dist/interaction-D3-M3nBh.d.ts +22 -0
  27. package/dist/react/index.cjs +279 -166
  28. package/dist/react/index.d.cts +80 -37
  29. package/dist/react/index.d.ts +80 -37
  30. package/dist/react/index.js +291 -178
  31. package/dist/sendTransaction-BZW627cT.d.cts +30 -0
  32. package/dist/sendTransaction-DpJTfGJc.d.ts +30 -0
  33. package/package.json +16 -7
  34. package/dist/chunk-AYZHGMEV.cjs +0 -171
  35. package/dist/chunk-PDR3CF3P.js +0 -86
  36. package/dist/chunk-SZUN32YC.js +0 -171
  37. package/dist/chunk-VK7GPKK4.js +0 -169
  38. package/dist/chunk-X4JNNWJ4.cjs +0 -86
  39. package/dist/chunk-ZOLP2FJZ.cjs +0 -169
  40. package/dist/client-BwzXSgqQ.d.cts +0 -278
  41. package/dist/client-BwzXSgqQ.d.ts +0 -278
  42. package/dist/watchUnlockStatus-DXClCYH9.d.cts +0 -43
  43. package/dist/watchUnlockStatus-WJxoDliF.d.ts +0 -43
@@ -1,278 +0,0 @@
1
- import { Hex, Address, RpcSchema } from 'viem';
2
- import { Prettify } from 'viem/chains';
3
-
4
- /**
5
- * Configuration for the Nexus Wallet SDK
6
- */
7
- type NexusWalletSdkConfig = Readonly<{
8
- walletUrl: string;
9
- metadata: {
10
- name: string;
11
- };
12
- }>;
13
-
14
- /**
15
- * Parameters of the referred request
16
- */
17
- type SetUserReferredParams = Readonly<{
18
- contentId: Hex;
19
- }>;
20
- /**
21
- * Return type of the referred request
22
- */
23
- type SetUserReferredReturnType = UserIsSameWallet | UserReferredSuccessful | UserReferredHistory;
24
- type UserIsSameWallet = {
25
- key: "same-wallet";
26
- };
27
- type UserReferredSuccessful = {
28
- key: "referred-successful";
29
- };
30
- type UserReferredHistory = {
31
- key: "referred-history";
32
- };
33
-
34
- type PaidArticleUnlockPrice = Readonly<{
35
- index: number;
36
- unlockDurationInSec: number;
37
- frkAmount: Hex;
38
- }>;
39
-
40
- /**
41
- * Request to unlock a paid article
42
- */
43
- type StartArticleUnlockParams = Readonly<{
44
- articleId: Hex;
45
- contentId: Hex;
46
- imageUrl: string;
47
- articleTitle: string;
48
- contentTitle: string;
49
- price: PaidArticleUnlockPrice;
50
- articleUrl: string;
51
- redirectUrl: string;
52
- previewUrl?: string;
53
- provider: "le-monde" | "wired" | "l-equipe";
54
- }>;
55
- /**
56
- * Return type of the unlock request
57
- */
58
- type StartArticleUnlockReturnType = UnlockSuccess | AlreadyUnlocked | UnlockError;
59
- type UnlockSuccess = {
60
- key: "success";
61
- status: "in-progress";
62
- user: Address;
63
- userOpHash: Hex;
64
- };
65
- type AlreadyUnlocked = {
66
- key: "already-unlocked";
67
- status: "unlocked";
68
- user: Address;
69
- };
70
- type UnlockError = {
71
- key: "error" | "cancelled";
72
- status: "locked";
73
- user?: Address;
74
- reason?: string;
75
- };
76
-
77
- /**
78
- * The response to the get unlock options response
79
- */
80
- type UnlockOptionsReturnType = Readonly<{
81
- frkBalanceAsHex?: Hex;
82
- prices: {
83
- index: number;
84
- unlockDurationInSec: number;
85
- frkAmount: Hex;
86
- isUserAccessible: boolean | null;
87
- }[];
88
- }>;
89
-
90
- /**
91
- * The different types of response for the current unlock status
92
- */
93
- type ArticleUnlockStatusReturnType = Readonly<UnlockStatusLocked | UnlockStatusProcessing | UnlockStatusValid | UnlockStatusError>;
94
- /**
95
- * When the content unlocked was expired or not unlocked
96
- */
97
- type UnlockStatusLocked = {
98
- key: "expired";
99
- status: "locked";
100
- expiredAt: number;
101
- } | {
102
- key: "not-unlocked";
103
- status: "locked";
104
- };
105
- /**
106
- * When the content unlock is in progress
107
- */
108
- type UnlockStatusProcessing = {
109
- status: "in-progress";
110
- } & ({
111
- key: "preparing" | "waiting-user-validation";
112
- } | {
113
- key: "waiting-transaction-bundling";
114
- userOpHash: Hex;
115
- } | {
116
- key: "waiting-transaction-confirmation";
117
- userOpHash: Hex;
118
- txHash: Hex;
119
- });
120
- /**
121
- * When the content is unlocked
122
- */
123
- type UnlockStatusValid = {
124
- key: "valid";
125
- status: "unlocked";
126
- allowedUntil: number;
127
- };
128
- /**
129
- * When the unlock content is in error
130
- */
131
- type UnlockStatusError = {
132
- key: "error";
133
- status: "locked";
134
- reason: string;
135
- };
136
-
137
- type WalletStatusReturnType = Readonly<WalletConnected | WalletNotConnected>;
138
- type WalletConnected = {
139
- key: "connected";
140
- wallet: Address;
141
- };
142
- type WalletNotConnected = {
143
- key: "not-connected";
144
- };
145
-
146
- /**
147
- * RPC interface that's used for the iframe communication
148
- */
149
- type IFrameRpcSchema = [
150
- /**
151
- * Method used to fetch an article unlock options
152
- */
153
- {
154
- Method: "frak_getArticleUnlockOptions";
155
- Parameters: [contentId: Hex, articleId: Hex];
156
- ReturnType: UnlockOptionsReturnType;
157
- },
158
- /**
159
- * Method used to listen to the wallet status
160
- */
161
- {
162
- Method: "frak_listenToWalletStatus";
163
- Parameters?: undefined;
164
- ReturnType: WalletStatusReturnType;
165
- },
166
- /**
167
- * Method used to listen to an article unlock status
168
- */
169
- {
170
- Method: "frak_listenToArticleUnlockStatus";
171
- Parameters: [contentId: Hex, articleId: Hex];
172
- ReturnType: ArticleUnlockStatusReturnType;
173
- },
174
- /**
175
- * Method used to set the referred user
176
- */
177
- {
178
- Method: "frak_listenToSetUserReferred";
179
- Parameters: [contentId: Hex, walletAddress: Address];
180
- ReturnType: SetUserReferredReturnType;
181
- }
182
- ];
183
- /**
184
- * RPC interface that's used for the redirection communication
185
- */
186
- type RedirectRpcSchema = [
187
- /**
188
- * Method used to start the unlock of an article
189
- */
190
- {
191
- Method: "frak_startArticleUnlock";
192
- Path: "/paywall";
193
- Parameters: StartArticleUnlockParams;
194
- ReturnType: StartArticleUnlockReturnType;
195
- }
196
- ];
197
-
198
- /**
199
- * Type that extract the possible parameters from a RPC Schema
200
- */
201
- type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema | undefined = undefined> = TRpcSchema extends RpcSchema ? {
202
- [K in keyof TRpcSchema]: Prettify<{
203
- method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
204
- } & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
205
- params?: never;
206
- } : {
207
- params: TRpcSchema[K]["Parameters"];
208
- } : never)>;
209
- }[number] : {
210
- method: string;
211
- params?: unknown;
212
- };
213
- /**
214
- * Type that extract the possible return type from a RPC Schema
215
- */
216
- type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema | undefined = undefined, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = TRpcSchema extends RpcSchema ? ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"] : unknown;
217
- /**
218
- * Type that extract the possible return type from a RPC Schema
219
- */
220
- type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema | undefined = undefined, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = TRpcSchema extends RpcSchema ? Extract<TRpcSchema[number], {
221
- Method: TMethod;
222
- }> : unknown;
223
- /**
224
- * Type used for a one shot request function
225
- */
226
- type RequestFn<TRpcSchema extends RpcSchema | undefined = undefined> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
227
- /**
228
- * Type used for a one shot request function
229
- */
230
- type ListenerRequestFn<TRpcSchema extends RpcSchema | undefined = undefined> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>>(args: TParameters, callback: (result: ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>) => void) => Promise<void>;
231
- /**
232
- * IFrame transport interface
233
- */
234
- type IFrameTransport = {
235
- /**
236
- * Wait for the connection to be established
237
- */
238
- waitForConnection: Promise<boolean>;
239
- /**
240
- * Function used to perform a single request via the iframe transport
241
- */
242
- request: RequestFn<IFrameRpcSchema>;
243
- /**
244
- * Function used to listen to a request response via the iframe transport
245
- */
246
- listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
247
- /**
248
- * Function used to destroy the iframe transport
249
- */
250
- destroy: () => Promise<void>;
251
- };
252
- /**
253
- * Represent an iframe event
254
- */
255
- type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent;
256
- /**
257
- * Represent an iframe rpc event
258
- */
259
- type IFrameRpcEvent = {
260
- id: string;
261
- topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
262
- data: {
263
- compressed: string;
264
- compressedHash: string;
265
- };
266
- };
267
- type IFrameLifecycleEvent = {
268
- lifecycle: "connected";
269
- };
270
-
271
- /**
272
- * Representing a Nexus client
273
- */
274
- type NexusClient = {
275
- config: NexusWalletSdkConfig;
276
- } & IFrameTransport;
277
-
278
- export type { ArticleUnlockStatusReturnType as A, ExtractedParametersFromRpc as E, IFrameRpcSchema as I, NexusClient as N, PaidArticleUnlockPrice as P, RedirectRpcSchema as R, StartArticleUnlockReturnType as S, UnlockOptionsReturnType as U, WalletStatusReturnType as W, NexusWalletSdkConfig as a, StartArticleUnlockParams as b, SetUserReferredReturnType as c, ExtractedReturnTypeFromRpc as d, SetUserReferredParams as e, IFrameTransport as f, IFrameRpcEvent as g, IFrameEvent as h };
@@ -1,43 +0,0 @@
1
- import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-BwzXSgqQ.cjs';
3
-
4
- /**
5
- * Type used to get the unlock options
6
- */
7
- type GetUnlockOptionsParams = {
8
- articleId: Hex;
9
- contentId: Hex;
10
- };
11
- /**
12
- * Function used to fetch the unlock option for the given client
13
- * @param client
14
- * @param articleId
15
- * @param contentId
16
- */
17
- declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
18
- frkBalanceAsHex?: `0x${string}` | undefined;
19
- prices: {
20
- index: number;
21
- unlockDurationInSec: number;
22
- frkAmount: `0x${string}`;
23
- isUserAccessible: boolean | null;
24
- }[];
25
- }>>;
26
-
27
- /**
28
- * Type used to get the unlock options
29
- */
30
- type WatchUnlockStatusParams = {
31
- articleId: Hex;
32
- contentId: Hex;
33
- };
34
- /**
35
- * Function used to watch a current article unlock status
36
- * @param client
37
- * @param articleId
38
- * @param contentId
39
- * @param callback
40
- */
41
- declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
42
-
43
- export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };
@@ -1,43 +0,0 @@
1
- import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-BwzXSgqQ.js';
3
-
4
- /**
5
- * Type used to get the unlock options
6
- */
7
- type GetUnlockOptionsParams = {
8
- articleId: Hex;
9
- contentId: Hex;
10
- };
11
- /**
12
- * Function used to fetch the unlock option for the given client
13
- * @param client
14
- * @param articleId
15
- * @param contentId
16
- */
17
- declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
18
- frkBalanceAsHex?: `0x${string}` | undefined;
19
- prices: {
20
- index: number;
21
- unlockDurationInSec: number;
22
- frkAmount: `0x${string}`;
23
- isUserAccessible: boolean | null;
24
- }[];
25
- }>>;
26
-
27
- /**
28
- * Type used to get the unlock options
29
- */
30
- type WatchUnlockStatusParams = {
31
- articleId: Hex;
32
- contentId: Hex;
33
- };
34
- /**
35
- * Function used to watch a current article unlock status
36
- * @param client
37
- * @param articleId
38
- * @param contentId
39
- * @param callback
40
- */
41
- declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
42
-
43
- export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };