@frak-labs/nexus-sdk 0.0.4 → 0.0.7

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/README.md CHANGED
@@ -8,7 +8,7 @@ Checkout our documentation for more informations about the usage:
8
8
 
9
9
  To have more info about how does it works under the hood, you can check [this](https://docs.frak.id/wallet-sdk/under-the-hood)
10
10
 
11
- > :warning: **This is in active development**: Only supporting polygon Mumbai at the moment, **DO NOT USE IN PROD**
11
+ > :warning: **This is in active development**: Only supporting testnets at the moment, **DO NOT USE IN PROD**
12
12
 
13
13
 
14
14
  ## Installation
@@ -29,6 +29,7 @@ type StartArticleUnlockParams = Readonly<{
29
29
  articleUrl: string;
30
30
  redirectUrl: string;
31
31
  previewUrl?: string;
32
+ provider: "le-monde" | "wired" | "l-equipe";
32
33
  }>;
33
34
  /**
34
35
  * Return type of the unlock request
@@ -69,7 +70,7 @@ type UnlockOptionsReturnType = Readonly<{
69
70
  */
70
71
  type ArticleUnlockStatusReturnType = Readonly<UnlockStatusLocked | UnlockStatusProcessing | UnlockStatusValid | UnlockStatusError>;
71
72
  /**
72
- * When the content unlocked was expired a few time ago
73
+ * When the content unlocked was expired or not unlocked
73
74
  */
74
75
  type UnlockStatusLocked = {
75
76
  key: "expired";
@@ -80,7 +81,7 @@ type UnlockStatusLocked = {
80
81
  status: "locked";
81
82
  };
82
83
  /**
83
- * When the content unlocked was expired a few time ago
84
+ * When the content unlock is in progress
84
85
  */
85
86
  type UnlockStatusProcessing = {
86
87
  status: "in-progress";
@@ -95,7 +96,7 @@ type UnlockStatusProcessing = {
95
96
  txHash: Hex;
96
97
  });
97
98
  /**
98
- * When the content unlocked was expired a few time ago
99
+ * When the content is unlocked
99
100
  */
100
101
  type UnlockStatusValid = {
101
102
  key: "valid";
@@ -103,7 +104,7 @@ type UnlockStatusValid = {
103
104
  allowedUntil: number;
104
105
  };
105
106
  /**
106
- * When the content unlocked was expired a few time ago
107
+ * When the unlock content is in error
107
108
  */
108
109
  type UnlockStatusError = {
109
110
  key: "error";
@@ -29,6 +29,7 @@ type StartArticleUnlockParams = Readonly<{
29
29
  articleUrl: string;
30
30
  redirectUrl: string;
31
31
  previewUrl?: string;
32
+ provider: "le-monde" | "wired" | "l-equipe";
32
33
  }>;
33
34
  /**
34
35
  * Return type of the unlock request
@@ -69,7 +70,7 @@ type UnlockOptionsReturnType = Readonly<{
69
70
  */
70
71
  type ArticleUnlockStatusReturnType = Readonly<UnlockStatusLocked | UnlockStatusProcessing | UnlockStatusValid | UnlockStatusError>;
71
72
  /**
72
- * When the content unlocked was expired a few time ago
73
+ * When the content unlocked was expired or not unlocked
73
74
  */
74
75
  type UnlockStatusLocked = {
75
76
  key: "expired";
@@ -80,7 +81,7 @@ type UnlockStatusLocked = {
80
81
  status: "locked";
81
82
  };
82
83
  /**
83
- * When the content unlocked was expired a few time ago
84
+ * When the content unlock is in progress
84
85
  */
85
86
  type UnlockStatusProcessing = {
86
87
  status: "in-progress";
@@ -95,7 +96,7 @@ type UnlockStatusProcessing = {
95
96
  txHash: Hex;
96
97
  });
97
98
  /**
98
- * When the content unlocked was expired a few time ago
99
+ * When the content is unlocked
99
100
  */
100
101
  type UnlockStatusValid = {
101
102
  key: "valid";
@@ -103,7 +104,7 @@ type UnlockStatusValid = {
103
104
  allowedUntil: number;
104
105
  };
105
106
  /**
106
- * When the content unlocked was expired a few time ago
107
+ * When the unlock content is in error
107
108
  */
108
109
  type UnlockStatusError = {
109
110
  key: "error";
@@ -1,5 +1,5 @@
1
- export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-DvDS55TN.cjs';
2
- import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-gnNyzrko.cjs';
1
+ export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-B4kRztOM.cjs';
2
+ import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-DWLJ8zR-.cjs';
3
3
  import 'viem';
4
4
  import 'viem/chains';
5
5
 
@@ -1,5 +1,5 @@
1
- export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-Btjg-WTs.js';
2
- import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-gnNyzrko.js';
1
+ export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus--7dFtOJr.js';
2
+ import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-DWLJ8zR-.js';
3
3
  import 'viem';
4
4
  import 'viem/chains';
5
5
 
@@ -1,5 +1,5 @@
1
- import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-gnNyzrko.cjs';
2
- export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-gnNyzrko.cjs';
1
+ import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-DWLJ8zR-.cjs';
2
+ export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-DWLJ8zR-.cjs';
3
3
  import 'viem';
4
4
  import 'viem/chains';
5
5
 
@@ -1,5 +1,5 @@
1
- import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-gnNyzrko.js';
2
- export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-gnNyzrko.js';
1
+ import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-DWLJ8zR-.js';
2
+ export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-DWLJ8zR-.js';
3
3
  import 'viem';
4
4
  import 'viem/chains';
5
5
 
@@ -61,7 +61,8 @@ function useArticleUnlockOptions({ articleId }) {
61
61
  }
62
62
  return await _chunk3LF3FGI6cjs.getArticleUnlockOptions.call(void 0, client, { articleId });
63
63
  },
64
- enabled: !!articleId
64
+ enabled: !!articleId,
65
+ gcTime: 0
65
66
  });
66
67
  }
67
68
 
@@ -78,6 +79,7 @@ function useWalletStatus() {
78
79
  [queryClient]
79
80
  );
80
81
  return _reactquery.useQuery.call(void 0, {
82
+ gcTime: 0,
81
83
  queryKey: ["walletStatusListener"],
82
84
  queryFn: async () => {
83
85
  await _chunk3LF3FGI6cjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
@@ -103,7 +105,11 @@ function useArticleUnlockStatus({ articleId }) {
103
105
  );
104
106
  return _reactquery.useQuery.call(void 0, {
105
107
  queryKey: ["articleUnlockStatusListener", _nullishCoalesce(articleId, () => ( "no-article-id"))],
108
+ gcTime: 0,
106
109
  queryFn: async () => {
110
+ if (!articleId) {
111
+ return null;
112
+ }
107
113
  await _chunk3LF3FGI6cjs.watchUnlockStatus.call(void 0, client, { articleId }, newStatusUpdated);
108
114
  return {
109
115
  status: "waiting-response",
@@ -122,7 +128,7 @@ function NexusIFrameClientProvider({
122
128
  children
123
129
  }) {
124
130
  const config = useNexusConfig();
125
- const [iframeElem, setIframElem] = _react.useState.call(void 0,
131
+ const [iframeElem, setIframeElem] = _react.useState.call(void 0,
126
132
  void 0
127
133
  );
128
134
  const client = _react.useMemo.call(void 0,
@@ -143,10 +149,10 @@ function NexusIFrameClientProvider({
143
149
  },
144
150
  ref: (iframe) => {
145
151
  if (!iframe) {
146
- setIframElem(void 0);
152
+ setIframeElem(void 0);
147
153
  return;
148
154
  }
149
- setIframElem(iframe);
155
+ setIframeElem(iframe);
150
156
  }
151
157
  });
152
158
  const providerComponent = _react.createElement.call(void 0,
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { PropsWithChildren, ReactNode } from 'react';
3
- import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-gnNyzrko.cjs';
4
- import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
5
- import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DvDS55TN.cjs';
3
+ import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-DWLJ8zR-.cjs';
4
+ import * as _tanstack_react_query from '@tanstack/react-query';
5
+ import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-B4kRztOM.cjs';
6
6
  import 'viem';
7
7
  import 'viem/chains';
8
8
 
@@ -70,7 +70,7 @@ declare function useNexusClient(): NexusClient;
70
70
  /**
71
71
  * Hook used to get the unlock options for an article
72
72
  */
73
- declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query_build_legacy_types.UseQueryResult<Readonly<{
73
+ declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
74
74
  prices: {
75
75
  index: number;
76
76
  unlockDurationInSec: number;
@@ -85,15 +85,15 @@ type WalletStatusQueryReturnType = WalletStatusReturnType | {
85
85
  /**
86
86
  * Hooks used to listen to the current wallet status
87
87
  */
88
- declare function useWalletStatus(): _tanstack_react_query_build_legacy_types.UseQueryResult<WalletStatusQueryReturnType, Error>;
88
+ declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusQueryReturnType, Error>;
89
89
 
90
90
  type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
91
91
  status: "waiting-response";
92
92
  key: "waiting-response";
93
93
  };
94
94
  /**
95
- * Hooks used to listen to the current wallet status
95
+ * Hooks used to listen to the current article unlock status
96
96
  */
97
- declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query_build_legacy_types.UseQueryResult<ArticleUnlockStatusQueryReturnType, Error>;
97
+ declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
98
98
 
99
99
  export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { PropsWithChildren, ReactNode } from 'react';
3
- import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-gnNyzrko.js';
4
- import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
5
- import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-Btjg-WTs.js';
3
+ import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-DWLJ8zR-.js';
4
+ import * as _tanstack_react_query from '@tanstack/react-query';
5
+ import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus--7dFtOJr.js';
6
6
  import 'viem';
7
7
  import 'viem/chains';
8
8
 
@@ -70,7 +70,7 @@ declare function useNexusClient(): NexusClient;
70
70
  /**
71
71
  * Hook used to get the unlock options for an article
72
72
  */
73
- declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query_build_legacy_types.UseQueryResult<Readonly<{
73
+ declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
74
74
  prices: {
75
75
  index: number;
76
76
  unlockDurationInSec: number;
@@ -85,15 +85,15 @@ type WalletStatusQueryReturnType = WalletStatusReturnType | {
85
85
  /**
86
86
  * Hooks used to listen to the current wallet status
87
87
  */
88
- declare function useWalletStatus(): _tanstack_react_query_build_legacy_types.UseQueryResult<WalletStatusQueryReturnType, Error>;
88
+ declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusQueryReturnType, Error>;
89
89
 
90
90
  type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
91
91
  status: "waiting-response";
92
92
  key: "waiting-response";
93
93
  };
94
94
  /**
95
- * Hooks used to listen to the current wallet status
95
+ * Hooks used to listen to the current article unlock status
96
96
  */
97
- declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query_build_legacy_types.UseQueryResult<ArticleUnlockStatusQueryReturnType, Error>;
97
+ declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
98
98
 
99
99
  export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
@@ -61,7 +61,8 @@ function useArticleUnlockOptions({ articleId }) {
61
61
  }
62
62
  return await getArticleUnlockOptions(client, { articleId });
63
63
  },
64
- enabled: !!articleId
64
+ enabled: !!articleId,
65
+ gcTime: 0
65
66
  });
66
67
  }
67
68
 
@@ -78,6 +79,7 @@ function useWalletStatus() {
78
79
  [queryClient]
79
80
  );
80
81
  return useQuery2({
82
+ gcTime: 0,
81
83
  queryKey: ["walletStatusListener"],
82
84
  queryFn: async () => {
83
85
  await watchWalletStatus(client, newStatusUpdated);
@@ -103,7 +105,11 @@ function useArticleUnlockStatus({ articleId }) {
103
105
  );
104
106
  return useQuery3({
105
107
  queryKey: ["articleUnlockStatusListener", articleId ?? "no-article-id"],
108
+ gcTime: 0,
106
109
  queryFn: async () => {
110
+ if (!articleId) {
111
+ return null;
112
+ }
107
113
  await watchUnlockStatus(client, { articleId }, newStatusUpdated);
108
114
  return {
109
115
  status: "waiting-response",
@@ -122,7 +128,7 @@ function NexusIFrameClientProvider({
122
128
  children
123
129
  }) {
124
130
  const config = useNexusConfig();
125
- const [iframeElem, setIframElem] = useState(
131
+ const [iframeElem, setIframeElem] = useState(
126
132
  void 0
127
133
  );
128
134
  const client = useMemo(
@@ -143,10 +149,10 @@ function NexusIFrameClientProvider({
143
149
  },
144
150
  ref: (iframe) => {
145
151
  if (!iframe) {
146
- setIframElem(void 0);
152
+ setIframeElem(void 0);
147
153
  return;
148
154
  }
149
- setIframElem(iframe);
155
+ setIframeElem(iframe);
150
156
  }
151
157
  });
152
158
  const providerComponent = createElement2(
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-gnNyzrko.js';
2
+ import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-DWLJ8zR-.js';
3
3
 
4
4
  /**
5
5
  * Type used to get the unlock options
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-gnNyzrko.cjs';
2
+ import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-DWLJ8zR-.cjs';
3
3
 
4
4
  /**
5
5
  * Type used to get the unlock options
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.4",
14
+ "version": "0.0.7",
15
15
  "description": "Nexus Wallet client SDK, helping any person to interact with the Frak wallet, and require the unlock of a premium article within the Frak ecosystem.",
16
16
  "repository": "https://github.com/frak-id/wallet",
17
17
  "homepage": "https://docs.frak.id/wallet-sdk",
@@ -72,7 +72,7 @@
72
72
  "js-sha256": "^0.11.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@tanstack/react-query": ">=5.0.0",
75
+ "@tanstack/react-query": ">=5.29.2",
76
76
  "@types/node": "^20",
77
77
  "tsup": "^8.0.2",
78
78
  "typescript": "^5"