@frak-labs/nexus-sdk 0.0.19 → 0.0.21

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk2SDBW6QCcjs = require('../chunk-2SDBW6QC.cjs');
3
+ var _chunkWXNW7ZMUcjs = require('../chunk-WXNW7ZMU.cjs');
4
4
 
5
5
 
6
6
 
@@ -9,14 +9,14 @@ var _chunk2SDBW6QCcjs = require('../chunk-2SDBW6QC.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkLAO7FUQ2cjs = require('../chunk-LAO7FUQ2.cjs');
12
+ var _chunkBSCR57ZIcjs = require('../chunk-BSCR57ZI.cjs');
13
13
 
14
14
 
15
15
 
16
16
 
17
17
 
18
18
 
19
- var _chunkYDZBXUC4cjs = require('../chunk-YDZBXUC4.cjs');
19
+ var _chunkE527CMMJcjs = require('../chunk-E527CMMJ.cjs');
20
20
  require('../chunk-A3XYA7S7.cjs');
21
21
  require('../chunk-UFJ7W6CQ.cjs');
22
22
 
@@ -50,8 +50,8 @@ function NexusConfigProvider(parameters) {
50
50
  function useNexusConfig() {
51
51
  const config = _react.useContext.call(void 0, NexusConfigContext);
52
52
  if (!config) {
53
- throw new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
54
- _chunkYDZBXUC4cjs.RpcErrorCodes.configError,
53
+ throw new (0, _chunkE527CMMJcjs.FrakRpcError)(
54
+ _chunkE527CMMJcjs.RpcErrorCodes.configError,
55
55
  "Nexus config not found"
56
56
  );
57
57
  }
@@ -81,12 +81,13 @@ function useWalletStatus() {
81
81
  );
82
82
  return _reactquery.useQuery.call(void 0, {
83
83
  gcTime: 0,
84
+ staleTime: 0,
84
85
  queryKey: ["nexus-sdk", "wallet-status-listener"],
85
86
  queryFn: async () => {
86
87
  if (!client) {
87
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
88
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
88
89
  }
89
- return _chunkLAO7FUQ2cjs.walletStatus.call(void 0, client, newStatusUpdated);
90
+ return _chunkBSCR57ZIcjs.walletStatus.call(void 0, client, newStatusUpdated);
90
91
  },
91
92
  enabled: !!client
92
93
  });
@@ -103,9 +104,9 @@ function useSendTransactionAction({
103
104
  mutationKey: ["nexus-sdk", "send-transaction"],
104
105
  mutationFn: async (params) => {
105
106
  if (!client) {
106
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
107
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
107
108
  }
108
- return _chunkLAO7FUQ2cjs.sendTransaction.call(void 0, client, params);
109
+ return _chunkBSCR57ZIcjs.sendTransaction.call(void 0, client, params);
109
110
  }
110
111
  });
111
112
  }
@@ -125,9 +126,9 @@ function useSiweAuthenticate({
125
126
  ],
126
127
  mutationFn: async (params) => {
127
128
  if (!client) {
128
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
129
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
129
130
  }
130
- return _chunkLAO7FUQ2cjs.siweAuthenticate.call(void 0, client, params);
131
+ return _chunkBSCR57ZIcjs.siweAuthenticate.call(void 0, client, params);
131
132
  }
132
133
  });
133
134
  }
@@ -180,12 +181,12 @@ function useFrakContext() {
180
181
  const { location } = useWindowLocation();
181
182
  const frakContext = _react.useMemo.call(void 0, () => {
182
183
  if (!_optionalChain([location, 'optionalAccess', _7 => _7.href])) return null;
183
- return _chunkYDZBXUC4cjs.FrakContextManager.parse({ url: location.href });
184
+ return _chunkE527CMMJcjs.FrakContextManager.parse({ url: location.href });
184
185
  }, [_optionalChain([location, 'optionalAccess', _8 => _8.href])]);
185
186
  const updateContext = _react.useCallback.call(void 0,
186
187
  (newContext) => {
187
188
  console.log("Updating context", { newContext });
188
- _chunkYDZBXUC4cjs.FrakContextManager.replaceUrl({
189
+ _chunkE527CMMJcjs.FrakContextManager.replaceUrl({
189
190
  url: _optionalChain([location, 'optionalAccess', _9 => _9.href]),
190
191
  context: newContext
191
192
  });
@@ -201,7 +202,8 @@ function useFrakContext() {
201
202
  // src/react/hook/helper/useReferralInteraction.ts
202
203
  function useReferralInteraction({
203
204
  productId,
204
- modalConfig
205
+ modalConfig,
206
+ options
205
207
  } = {}) {
206
208
  const client = useNexusClient();
207
209
  const { frakContext } = useFrakContext();
@@ -222,13 +224,14 @@ function useReferralInteraction({
222
224
  ],
223
225
  queryFn: () => {
224
226
  if (!client) {
225
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
227
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
226
228
  }
227
- return _chunkLAO7FUQ2cjs.processReferral.call(void 0, client, {
229
+ return _chunkBSCR57ZIcjs.processReferral.call(void 0, client, {
228
230
  walletStatus: walletStatus2,
229
231
  frakContext,
230
232
  modalConfig,
231
- productId
233
+ productId,
234
+ options
232
235
  });
233
236
  },
234
237
  enabled: !!walletStatus2
@@ -251,9 +254,9 @@ function useSendInteraction({
251
254
  mutationKey: ["nexus-sdk", "send-interaction"],
252
255
  mutationFn: async (params) => {
253
256
  if (!client) {
254
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
257
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
255
258
  }
256
- return _chunkLAO7FUQ2cjs.sendInteraction.call(void 0, client, params);
259
+ return _chunkBSCR57ZIcjs.sendInteraction.call(void 0, client, params);
257
260
  }
258
261
  });
259
262
  }
@@ -269,9 +272,9 @@ function useDisplayModal({
269
272
  mutationKey: ["nexus-sdk", "display-modal"],
270
273
  mutationFn: async (args) => {
271
274
  if (!client) {
272
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
275
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
273
276
  }
274
- return _chunkLAO7FUQ2cjs.displayModal.call(void 0, client, args);
277
+ return _chunkBSCR57ZIcjs.displayModal.call(void 0, client, args);
275
278
  }
276
279
  });
277
280
  }
@@ -285,9 +288,9 @@ function useOpenSso({ mutations } = {}) {
285
288
  mutationKey: ["nexus-sdk", "open-sso"],
286
289
  mutationFn: async (params) => {
287
290
  if (!client) {
288
- throw new (0, _chunkYDZBXUC4cjs.ClientNotFound)();
291
+ throw new (0, _chunkE527CMMJcjs.ClientNotFound)();
289
292
  }
290
- return _chunkLAO7FUQ2cjs.openSso.call(void 0, client, params);
293
+ return _chunkBSCR57ZIcjs.openSso.call(void 0, client, params);
291
294
  }
292
295
  });
293
296
  }
@@ -303,15 +306,15 @@ function NexusIFrameClientProvider({
303
306
  const config = useNexusConfig();
304
307
  const [client, setClient] = _react.useState.call(void 0, void 0);
305
308
  const iFrame = _react.createElement.call(void 0, "iframe", {
306
- ..._chunkYDZBXUC4cjs.baseIframeProps,
309
+ ..._chunkE527CMMJcjs.baseIframeProps,
307
310
  src: `${config.walletUrl}/listener`,
308
- style: _nullishCoalesce(style, () => ( _chunkYDZBXUC4cjs.baseIframeProps.style)),
311
+ style: _nullishCoalesce(style, () => ( _chunkE527CMMJcjs.baseIframeProps.style)),
309
312
  ref: (iframe) => {
310
313
  if (!iframe || client) {
311
314
  return;
312
315
  }
313
316
  setClient(
314
- _chunk2SDBW6QCcjs.createIFrameNexusClient.call(void 0, {
317
+ _chunkWXNW7ZMUcjs.createIFrameNexusClient.call(void 0, {
315
318
  iframe,
316
319
  config
317
320
  })
@@ -1,12 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
3
- import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, k as SendTransactionReturnType, h as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-DaEox5q4.cjs';
3
+ import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, k as SendTransactionReturnType, h as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../FrakContext-BsezWx2F.cjs';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import { UseMutationOptions } from '@tanstack/react-query';
6
6
  import * as viem from 'viem';
7
7
  import { Hex } from 'viem';
8
8
  import { F as FrakRpcError } from '../error-Dflr3G5x.cjs';
9
- import { S as SendTransactionParams, a as SiweAuthenticateModalParams } from '../sendTransaction-MhdJPTWd.cjs';
9
+ import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-YbCg90hu.cjs';
10
10
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.cjs';
11
11
  import 'viem/chains';
12
12
  import 'viem/siwe';
@@ -117,10 +117,12 @@ declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams)
117
117
  * -> And automatically set the referral context in the url
118
118
  * @param productId
119
119
  * @param modalConfig
120
+ * @param options
120
121
  */
121
- declare function useReferralInteraction({ productId, modalConfig, }?: {
122
+ declare function useReferralInteraction({ productId, modalConfig, options, }?: {
122
123
  productId?: Hex;
123
124
  modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
125
+ options?: ProcessReferralOptions;
124
126
  }): Error | ("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral");
125
127
 
126
128
  type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
@@ -1,12 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
3
- import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, k as SendTransactionReturnType, h as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-ALy_TEwJ.js';
3
+ import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, k as SendTransactionReturnType, h as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../FrakContext-p0Jtv9gl.js';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import { UseMutationOptions } from '@tanstack/react-query';
6
6
  import * as viem from 'viem';
7
7
  import { Hex } from 'viem';
8
8
  import { F as FrakRpcError } from '../error-Dflr3G5x.js';
9
- import { S as SendTransactionParams, a as SiweAuthenticateModalParams } from '../sendTransaction-BOd-pvXr.js';
9
+ import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-t3gUNwJu.js';
10
10
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.js';
11
11
  import 'viem/chains';
12
12
  import 'viem/siwe';
@@ -117,10 +117,12 @@ declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams)
117
117
  * -> And automatically set the referral context in the url
118
118
  * @param productId
119
119
  * @param modalConfig
120
+ * @param options
120
121
  */
121
- declare function useReferralInteraction({ productId, modalConfig, }?: {
122
+ declare function useReferralInteraction({ productId, modalConfig, options, }?: {
122
123
  productId?: Hex;
123
124
  modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
125
+ options?: ProcessReferralOptions;
124
126
  }): Error | ("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral");
125
127
 
126
128
  type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createIFrameNexusClient
3
- } from "../chunk-54MUKMZK.js";
3
+ } from "../chunk-ZZ7LUFNV.js";
4
4
  import {
5
5
  displayModal,
6
6
  openSso,
@@ -9,14 +9,14 @@ import {
9
9
  sendTransaction,
10
10
  siweAuthenticate,
11
11
  walletStatus
12
- } from "../chunk-ACCWBBZ7.js";
12
+ } from "../chunk-MDGMJ6EQ.js";
13
13
  import {
14
14
  ClientNotFound,
15
15
  FrakContextManager,
16
16
  FrakRpcError,
17
17
  RpcErrorCodes,
18
18
  baseIframeProps
19
- } from "../chunk-7K4L7VQC.js";
19
+ } from "../chunk-ZRPCX25Q.js";
20
20
  import "../chunk-TIKEZMSD.js";
21
21
  import "../chunk-HY6YATLS.js";
22
22
 
@@ -81,6 +81,7 @@ function useWalletStatus() {
81
81
  );
82
82
  return useQuery({
83
83
  gcTime: 0,
84
+ staleTime: 0,
84
85
  queryKey: ["nexus-sdk", "wallet-status-listener"],
85
86
  queryFn: async () => {
86
87
  if (!client) {
@@ -201,7 +202,8 @@ function useFrakContext() {
201
202
  // src/react/hook/helper/useReferralInteraction.ts
202
203
  function useReferralInteraction({
203
204
  productId,
204
- modalConfig
205
+ modalConfig,
206
+ options
205
207
  } = {}) {
206
208
  const client = useNexusClient();
207
209
  const { frakContext } = useFrakContext();
@@ -228,7 +230,8 @@ function useReferralInteraction({
228
230
  walletStatus: walletStatus2,
229
231
  frakContext,
230
232
  modalConfig,
231
- productId
233
+ productId,
234
+ options
232
235
  });
233
236
  },
234
237
  enabled: !!walletStatus2
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.19",
14
+ "version": "0.0.21",
15
15
  "description": "Frak 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": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -1,10 +0,0 @@
1
- import { Address } from 'viem';
2
-
3
- /**
4
- * The type of the nexus context
5
- */
6
- type FrakContext = Readonly<{
7
- r: Address;
8
- }>;
9
-
10
- export type { FrakContext as F };
@@ -1,10 +0,0 @@
1
- import { Address } from 'viem';
2
-
3
- /**
4
- * The type of the nexus context
5
- */
6
- type FrakContext = Readonly<{
7
- r: Address;
8
- }>;
9
-
10
- export type { FrakContext as F };
@@ -1,30 +0,0 @@
1
- import { g as SiweAuthenticationParams, b as ModalRpcMetadata, a as NexusClient, h as SiweAuthenticateReturnType, j as SendTransactionModalStepType, k as SendTransactionReturnType } from './client-ALy_TEwJ.js';
2
-
3
- /**
4
- * Partial SIWE params, since we can rebuild them from the SDK if they are empty
5
- */
6
- type SiweAuthenticateModalParams = {
7
- siwe?: Partial<SiweAuthenticationParams>;
8
- metadata?: ModalRpcMetadata;
9
- };
10
- /**
11
- * Function used to launch a siwe authentication
12
- * @param client
13
- * @param siwe
14
- * @param context
15
- */
16
- declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
17
-
18
- type SendTransactionParams = {
19
- tx: SendTransactionModalStepType["params"]["tx"];
20
- metadata?: ModalRpcMetadata;
21
- };
22
- /**
23
- * Function used to send a user transaction
24
- * @param client
25
- * @param tx
26
- * @param context
27
- */
28
- declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
29
-
30
- export { type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, siweAuthenticate as s };
@@ -1,30 +0,0 @@
1
- import { g as SiweAuthenticationParams, b as ModalRpcMetadata, a as NexusClient, h as SiweAuthenticateReturnType, j as SendTransactionModalStepType, k as SendTransactionReturnType } from './client-DaEox5q4.cjs';
2
-
3
- /**
4
- * Partial SIWE params, since we can rebuild them from the SDK if they are empty
5
- */
6
- type SiweAuthenticateModalParams = {
7
- siwe?: Partial<SiweAuthenticationParams>;
8
- metadata?: ModalRpcMetadata;
9
- };
10
- /**
11
- * Function used to launch a siwe authentication
12
- * @param client
13
- * @param siwe
14
- * @param context
15
- */
16
- declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
17
-
18
- type SendTransactionParams = {
19
- tx: SendTransactionModalStepType["params"]["tx"];
20
- metadata?: ModalRpcMetadata;
21
- };
22
- /**
23
- * Function used to send a user transaction
24
- * @param client
25
- * @param tx
26
- * @param context
27
- */
28
- declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
29
-
30
- export { type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, siweAuthenticate as s };