@tuwaio/quasar-sdk 0.0.10 → 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 (41) hide show
  1. package/README.md +423 -95
  2. package/dist/chunk-2MHRTJOV.js +1 -0
  3. package/dist/chunk-2VPVIX5M.js +1 -0
  4. package/dist/chunk-AQEHRYJP.cjs +1 -0
  5. package/dist/chunk-C6JAMIC3.js +1 -0
  6. package/dist/chunk-HVUZ52OX.js +1 -1
  7. package/dist/chunk-NIIKETIK.cjs +1 -0
  8. package/dist/chunk-UIDJZGQ7.cjs +1 -0
  9. package/dist/chunk-ZVKFOJG3.cjs +1 -0
  10. package/dist/index.cjs +2 -0
  11. package/dist/{index.d.mts → index.d.cts} +2 -2
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +2 -2
  14. package/dist/react/evm.cjs +1 -0
  15. package/dist/react/{evm.d.mts → evm.d.cts} +5 -5
  16. package/dist/react/evm.d.ts +5 -5
  17. package/dist/react/evm.js +1 -1
  18. package/dist/react/solana.cjs +1 -0
  19. package/dist/react/{solana.d.mts → solana.d.cts} +5 -5
  20. package/dist/react/solana.d.ts +5 -5
  21. package/dist/react/solana.js +1 -1
  22. package/dist/react.cjs +1 -0
  23. package/dist/{react.d.mts → react.d.cts} +5 -5
  24. package/dist/react.d.ts +5 -5
  25. package/dist/react.js +1 -1
  26. package/dist/{shared-BeprN_w-.d.ts → shared-BDH89Mck.d.ts} +1 -1
  27. package/dist/{shared-CFhEPXTt.d.mts → shared-D2uX4Ua8.d.cts} +1 -1
  28. package/dist/{types-Ctaain6g.d.mts → types-C4cwIvHT.d.cts} +5 -3
  29. package/dist/{types-Ctaain6g.d.ts → types-C4cwIvHT.d.ts} +5 -3
  30. package/package.json +65 -22
  31. package/dist/chunk-7F6I4FHE.js +0 -1
  32. package/dist/chunk-EDXCZKX7.mjs +0 -1
  33. package/dist/chunk-ERWWKRPN.mjs +0 -1
  34. package/dist/chunk-OJCR5A56.js +0 -1
  35. package/dist/chunk-RZ4TLBSP.js +0 -1
  36. package/dist/chunk-SF2BM2YA.mjs +0 -1
  37. package/dist/chunk-UW6TWEYM.mjs +0 -1
  38. package/dist/index.mjs +0 -2
  39. package/dist/react/evm.mjs +0 -1
  40. package/dist/react/solana.mjs +0 -1
  41. package/dist/react.mjs +0 -1
package/README.md CHANGED
@@ -1,168 +1,496 @@
1
- # Quasar SDK
1
+ # @tuwaio/quasar-sdk
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/@tuwaio/quasar-sdk.svg)](https://www.npmjs.com/package/@tuwaio/quasar-sdk)
4
4
  [![License](https://img.shields.io/npm/l/@tuwaio/quasar-sdk.svg)](./LICENSE)
5
- [![Build Status](https://img.shields.io/github/actions/workflow/status/TuwaIO/sdk/release.yml?branch=main)](https://github.com/TuwaIO/sdk/actions)
6
5
 
7
- > The official server-side Node.js & Edge SDK for the **TUWA Quasar Cloud**, featuring built-in React authentication bridges.
6
+ <p align="center">
7
+ <img src="https://cdn.jsdelivr.net/gh/TuwaIO/workflows@main/preview/repos/quasar_sdk.png" alt="Quasar SDK Architecture" width="100%" />
8
+ </p>
8
9
 
9
- ## Installation
10
+ > The official **Layer 5 (L5)** server-side Node.js & Edge SDK for the **TUWA Quasar Cloud**, featuring built-in React authentication bridges.
11
+
12
+ ---
13
+
14
+ ## 🏛️ What is `@tuwaio/quasar-sdk`?
15
+
16
+ `@tuwaio/quasar-sdk` is **Layer 5 (L5)** of the TUWA ecosystem architecture — the official backend companion to the TUWA client libraries. It serves as the gateway to the **Quasar Cloud Engine**, allowing your server to securely push transaction logs, query paginated transaction histories, and cryptographically verify client signatures.
17
+
18
+ It operates strictly on the server (Node.js, Next.js Server Actions, or Edge functions) and uses Secret Keys to communicate with Quasar's iron-dome guarded endpoints. It also includes React Bridges for establishing secure "Mini-Session" authentication on the client side.
19
+
20
+ ---
21
+
22
+ ## ✨ Key Features
23
+
24
+ - **☁️ Cloud Sync**: Automatically persist pending and terminal transaction states to the Quasar Database for cross-device history.
25
+ - **🔐 Mini-Session Auth**: Built-in cryptographic verification and React bridges (`QuasarAuthBridge`) to handle mini-session authentication across EVM and Solana with zero boilerplate.
26
+ - **⚡ Edge Ready**: Uses `ofetch` and lightweight cryptography to run seamlessly in Cloudflare Workers and Vercel Edge.
27
+ - **📦 InMemory Sync**: Perfectly pairs with `@tuwaio/sdk/pulsar` (`createTxInMemoryStore`) to fetch history and hydrate local React states.
28
+ - **⛓️ Multi-Chain Support**: Provides separate lightweight bridges for EVM (`react/evm`) and Solana (`react/solana`), ensuring minimal bundle sizes.
29
+
30
+ ---
31
+
32
+ ## 💾 Installation
10
33
 
11
34
  ```bash
12
- # Using pnpm (recommended)
13
- pnpm add @tuwaio/quasar-sdk ofetch
35
+ pnpm add @tuwaio/quasar-sdk ofetch @tuwaio/pulsar-core
14
36
  ```
15
37
 
16
- ### Peer Dependencies
38
+ _Note: `ofetch` and `@tuwaio/pulsar-core` are required as peer dependencies to ensure ultra-fast HTTP requests and strict TypeScript compatibility._
17
39
 
18
- | Package | Version | Requirement |
19
- | -------------------------- | ---------- | ------------------------------------------ |
20
- | `@tuwaio/pulsar-core` | `>=0.6.0` | **Required** (Core types) |
21
- | `ofetch` | `>=1.5.1` | **Required** (Transport) |
22
- | `react` | `>=18.0.0` | Optional (React Bridge support) |
23
- | `@solana/react` | `>=6.9.0` | Optional (Solana signing) |
24
- | `@wallet-standard/react` | `>=1.0.2` | Optional (Wallet Standard) |
25
- | `@wagmi/core` | `>=3.0.0` | Optional (EVM signing) |
26
- | `viem` | `^2.0.0` | Optional (EVM Auth primitives) |
27
- | `gill` | `^0.14.0` | Optional (Solana Auth primitives) |
28
- | `zustand` | `^5.0.0` | Optional (Session state management) |
40
+ ---
29
41
 
30
- ## Quick Start
42
+ ## 🚀 Quick Start (Node.js / Edge)
43
+
44
+ This is a basic example of how to interact with the Quasar Cloud directly from your secure backend environments (like Next.js API Routes, Server Actions, or NestJS).
31
45
 
32
46
  ```typescript
33
- import { Quasar } from '@tuwaio/quasar-sdk';
47
+ import { Quasar, MiniSessionAuth, utils } from '@tuwaio/quasar-sdk';
48
+ import type { Transaction } from '@tuwaio/sdk/pulsar';
49
+
50
+ // Initialize Quasar with your Secret Key from the Dashboard
51
+ const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
52
+
53
+ /**
54
+ * Example Next.js Server Action to Sync a Transaction
55
+ */
56
+ export async function syncTransaction(tx: Transaction, authData: MiniSessionAuth) {
57
+ // 1. Verify the client's signature (prevent unauthorized spoofing)
58
+ const isValid = await utils.verifyMiniSession(authData);
59
+ if (!isValid) throw new Error('Invalid signature.');
60
+
61
+ // 2. Sync the transaction securely to the Quasar Cloud
62
+ await quasar.pulsar.syncCreate(tx, 'My Application');
63
+ return { success: true };
64
+ }
34
65
 
35
- const quasar = new Quasar({ secretKey: 'sk_live_your_secret_key' });
66
+ /**
67
+ * Example Next.js Server Action to Fetch History
68
+ */
69
+ export async function getHistory(
70
+ params: { walletAddress: string; page: number; limit: number; appName: string },
71
+ authData: MiniSessionAuth,
72
+ ) {
73
+ const isValid = await utils.verifyMiniSession(authData);
74
+ if (!isValid) throw new Error('Invalid signature.');
75
+
76
+ // Return the paginated transaction history
77
+ return quasar.pulsar.getHistory(params);
78
+ }
79
+ ```
36
80
 
37
- // Sync a pending transaction to the cloud
38
- const { txKey } = await quasar.pulsar.syncCreate(transaction, 'My Application');
81
+ ---
39
82
 
40
- // Query transaction history
41
- const history = await quasar.pulsar.getHistory({ chainId: 1 });
42
- ```
83
+ ## 🔐 React Authentication Bridge
43
84
 
44
- ## React Authentication Bridge
85
+ The SDK provides React components to handle mini-session authentication with zero boilerplate. This bridges the gap between your frontend (where the wallet is) and your backend (where the Quasar Secret Key lives).
45
86
 
46
- The SDK provides React components to handle authentication with zero boilerplate. To prevent issues with missing optional peer dependencies at build time, the SDK exposes separate ecosystem entry points:
87
+ ### 1. Create the Auth Store
47
88
 
48
- ### 1. EVM-Only Bridge (No Solana dependencies required)
89
+ Before using the bridge, create a persistent Zustand store using the provided utility to manage the signature lifecycle.
49
90
 
50
- If your project only supports EVM chains, import from the `/react/evm` subpath. This avoids compile-time errors if `@solana/react` is not installed.
91
+ ```ts
92
+ // src/hooks/useAuthStore.ts
93
+ import { utils } from '@tuwaio/quasar-sdk';
94
+
95
+ export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-storage');
96
+ ```
97
+
98
+ To prevent issues with missing optional peer dependencies at build time, the SDK exposes separate ecosystem entry points for the Bridge:
99
+
100
+ ### EVM-Only Bridge (No Solana dependencies required)
101
+
102
+ If your project only supports EVM chains, import from the `/react/evm` subpath.
51
103
 
52
104
  ```tsx
53
105
  import { QuasarEvmAuthBridge } from '@tuwaio/quasar-sdk/react/evm';
106
+ import { useAuthStore } from '@/hooks/useAuthStore';
107
+
108
+ export function MyApp({ activeConnection, store, wagmiConfig }) {
109
+ const session = useAuthStore((s) => s.miniSession);
110
+ const setSession = useAuthStore((s) => s.setMiniSession);
54
111
 
55
- function MyApp() {
56
112
  return (
57
113
  <QuasarEvmAuthBridge
58
114
  activeConnection={activeConnection} // Structural interface for wallet state
59
- store={store} // Zustand store API
60
- wagmiConfig={config} // Wagmi config
61
- session={miniSession} // Current session state
62
- setSession={setMiniSession} // Session setter
115
+ store={store} // Zustand store API
116
+ wagmiConfig={wagmiConfig} // Wagmi config
117
+ session={session} // Current session state
118
+ setSession={setSession} // Session setter
63
119
  />
64
120
  );
65
121
  }
66
122
  ```
67
123
 
68
- ### 2. Solana-Only Bridge (No EVM dependencies required)
124
+ ### Solana-Only Bridge (No EVM dependencies required)
69
125
 
70
- If your project only supports Solana, import from the `/react/solana` subpath. This avoids compile-time errors if `@wagmi/core` is not installed.
126
+ If your project only supports Solana, import from the `/react/solana` subpath.
71
127
 
72
128
  ```tsx
73
129
  import { QuasarSolanaAuthBridge } from '@tuwaio/quasar-sdk/react/solana';
130
+ import { useAuthStore } from '@/hooks/useAuthStore';
131
+
132
+ export function MyApp({ activeConnection, store }) {
133
+ const session = useAuthStore((s) => s.miniSession);
134
+ const setSession = useAuthStore((s) => s.setMiniSession);
74
135
 
75
- function MyApp() {
76
136
  return (
77
137
  <QuasarSolanaAuthBridge
78
- activeConnection={activeConnection} // Structural interface for wallet state
79
- store={store} // Zustand store API
80
- session={miniSession} // Current session state
81
- setSession={setMiniSession} // Session setter
138
+ activeConnection={activeConnection}
139
+ store={store}
140
+ session={session}
141
+ setSession={setSession}
82
142
  />
83
143
  );
84
144
  }
85
145
  ```
86
146
 
87
- ### 3. Unified Cross-Chain Bridge
147
+ ### Unified Cross-Chain Bridge
88
148
 
89
- If your project supports both ecosystems and has all peer dependencies installed, you can use the unified bridge:
149
+ If your project supports both ecosystems and has all peer dependencies installed (`@wagmi/core`, `@solana/react`, etc.), you can use the unified bridge:
90
150
 
91
151
  ```tsx
92
152
  import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 🌍 The Full Flow (Production Architecture)
158
+
159
+ To see how incredibly powerful `@tuwaio/quasar-sdk` is when combined with `@tuwaio/sdk`, here is a complete architectural overview without any skipped steps. Notice how the **Auth Store**, **Pulsar Store**, and **QuasarAuthBridge** dance together effortlessly:
160
+
161
+ ### 1. Define Your Transaction Types (`types.ts`)
162
+
163
+ First, define the strict union of all possible transactions your app supports.
164
+
165
+ ```ts
166
+ // src/types.ts
167
+ import type { Transaction } from '@tuwaio/sdk/pulsar';
168
+
169
+ export enum AppTxType {
170
+ SWAP = 'SWAP',
171
+ }
172
+
173
+ export type SwapTx = Transaction & {
174
+ type: AppTxType.SWAP;
175
+ payload: { tokenIn: string; tokenOut: string; amount: number };
176
+ };
177
+
178
+ export type TransactionUnion = SwapTx;
179
+ ```
180
+
181
+ ### 2. Secure Server Proxy (`actions.ts`)
182
+
183
+ Proxy calls to Quasar Cloud using your backend to protect secret keys.
184
+
185
+ ```ts
186
+ // src/app/actions.ts
187
+ 'use server';
188
+
189
+ import { Quasar, MiniSessionAuth, utils } from '@tuwaio/quasar-sdk';
190
+ import { TransactionUnion } from '@/types';
191
+
192
+ const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
193
+
194
+ export async function syncTransaction(tx: TransactionUnion, authData: MiniSessionAuth) {
195
+ const isValid = await utils.verifyMiniSession(authData);
196
+ if (!isValid) throw new Error('Invalid signature.');
197
+
198
+ await quasar.pulsar.syncCreate(tx, 'My App');
199
+ return { success: true };
200
+ }
201
+
202
+ export async function getHistory(params: any, authData: MiniSessionAuth) {
203
+ const isValid = await utils.verifyMiniSession(authData);
204
+ if (!isValid) throw new Error('Invalid signature.');
205
+
206
+ return quasar.pulsar.getHistory(params);
207
+ }
208
+ ```
209
+
210
+ ### 3. The Client Auth Store (`useAuthStore.ts`)
211
+
212
+ ```tsx
213
+ // src/hooks/useAuthStore.ts
214
+ import { utils } from '@tuwaio/quasar-sdk';
215
+
216
+ // Automatically persists the verified signature in localStorage
217
+ export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-storage');
218
+ ```
219
+
220
+ ### 4. The Headless Tracking Store (`usePulsarStore.ts`)
221
+
222
+ ```ts
223
+ // src/hooks/usePulsarStore.ts
224
+ 'use client';
225
+
226
+ import { createPulsarStore, createTxInMemoryStore, createBoundedUseStore } from '@tuwaio/sdk/pulsar';
227
+ import { pulsarEvmAdapter } from '@tuwaio/evm-sdk/pulsar';
228
+ import { pulsarSolanaAdapter } from '@tuwaio/solana-sdk/pulsar';
229
+ import { getMiniSessionAuth } from '@tuwaio/quasar-sdk/react';
230
+
231
+ import { getHistory, syncTransaction } from '@/app/actions';
232
+ import { wagmiConfig, appEVMChains, solanaRPCUrls } from '@/configs/appConfig';
233
+ import { TransactionUnion } from '@/types';
234
+
235
+ const storageName = 'transactions-tracking-storage';
236
+
237
+ const initialStore = createPulsarStore<TransactionUnion>({
238
+ name: storageName,
239
+ adapter: [pulsarEvmAdapter(wagmiConfig, appEVMChains), pulsarSolanaAdapter({ rpcUrls: solanaRPCUrls })],
240
+ beforeTxProcess: async () => {
241
+ // Ensures we have a valid signature before executing any blockchain logic
242
+ await getMiniSessionAuth();
243
+ },
244
+ onRemoteCreate: async (tx) => {
245
+ try {
246
+ // Syncs the new transaction to Quasar via Next.js Server Actions
247
+ const auth = await getMiniSessionAuth();
248
+ await syncTransaction(tx as TransactionUnion, auth);
249
+ } catch (err) {
250
+ console.error('[PulsarHook] Remote sync failed:', err);
251
+ }
252
+ },
253
+ });
254
+
255
+ export const usePulsarStore = createBoundedUseStore(initialStore);
256
+
257
+ // Wrap with inMemoryStore to enable remote history fetching & pagination
258
+ const pulsarInMemoryStore = createTxInMemoryStore<TransactionUnion>({
259
+ localTransactionsPool: initialStore.getState().transactionsPool,
260
+ getHistory: async ({ page, walletAddress }) => {
261
+ try {
262
+ const auth = await getMiniSessionAuth();
263
+ const history = await getHistory({ walletAddress, page, limit: 10, appName: 'My App' }, auth);
264
+
265
+ if (!history) return null;
266
+
267
+ return { ...history, docs: history.docs as TransactionUnion[] };
268
+ } catch (error) {
269
+ console.error('[PulsarHook] Failed to fetch history:', error);
270
+ throw error;
271
+ }
272
+ },
273
+ onHistoryFetched: async (remoteTxs) => {
274
+ await initialStore.getState().injectExternalPendingTxs(remoteTxs);
275
+ },
276
+ });
277
+
278
+ initialStore.subscribe((state) => pulsarInMemoryStore.getState().syncWithLocalPool(state.transactionsPool));
279
+
280
+ export const usePulsarInMemoryStore = createBoundedUseStore(pulsarInMemoryStore);
281
+ ```
282
+
283
+ ### 5. The Quasar Auth Bridge (`QuasarSDKAuthProvider.tsx`)
284
+
285
+ ```tsx
286
+ // src/providers/QuasarSDKAuthProvider.tsx
287
+ 'use client';
288
+
289
+ import { useContext, useEffect } from 'react';
290
+ import { useSatelliteConnectStore, SatelliteStoreContext } from '@tuwaio/sdk/satellite';
291
+ import { QuasarActiveConnection, QuasarAuthBridge as QuasarSDKAuthBridge } from '@tuwaio/quasar-sdk/react';
292
+
293
+ import { wagmiConfig } from '@/configs/appConfig';
294
+ import { useAuthStore } from '@/hooks/useAuthStore';
295
+
296
+ export function QuasarAuthBridge() {
297
+ const activeConnection = useSatelliteConnectStore((s) => s.activeConnection);
298
+ const store = useContext(SatelliteStoreContext);
299
+
300
+ const session = useAuthStore((s) => s.miniSession);
301
+ const setSession = useAuthStore((s) => s.setMiniSession);
302
+ const clearSession = useAuthStore((s) => s.clearSession);
303
+
304
+ // Clear Quasar Mini-Session when wallet disconnects
305
+ useEffect(() => {
306
+ if (!activeConnection?.isConnected) {
307
+ clearSession();
308
+ }
309
+ }, [activeConnection?.isConnected, clearSession]);
310
+
311
+ if (!activeConnection || !store) return null;
93
312
 
94
- function MyApp() {
95
313
  return (
96
- <QuasarAuthBridge
97
- activeConnection={activeConnection}
98
- store={store}
99
- wagmiConfig={config}
100
- session={miniSession}
101
- setSession={setMiniSession}
314
+ <QuasarSDKAuthBridge
315
+ activeConnection={activeConnection as QuasarActiveConnection}
316
+ store={store as any}
317
+ wagmiConfig={wagmiConfig}
318
+ session={session}
319
+ setSession={setSession}
102
320
  />
103
321
  );
104
322
  }
105
323
  ```
106
324
 
107
- ## Modules
325
+ ### 6. Nova Transactions Provider (`NovaTransactionsProvider.tsx`)
326
+
327
+ ```tsx
328
+ // src/providers/NovaTransactionsProvider.tsx
329
+ 'use client';
108
330
 
109
- ### Pulsar — `quasar.pulsar`
331
+ import { useSatelliteConnectStore } from '@tuwaio/sdk/satellite';
332
+ import { useInitializeTransactionsPool, type TxInMemoryPagination } from '@tuwaio/sdk/pulsar';
333
+ import { getAdapterFromConnectorType } from '@tuwaio/sdk/orbit';
334
+ import { NovaTransactionsProvider as NTP } from '@tuwaio/sdk/nova-transactions/providers';
335
+ import { usePulsarInMemoryStore, usePulsarStore } from '@/hooks/usePulsarStore';
110
336
 
111
- | Method | Description |
112
- | -------------------------- | --------------------------------------------------- |
113
- | `syncCreate(tx, appName?)` | Sync a new pending transaction to the cloud |
114
- | `getHistory(query?)` | Retrieve paginated transaction history with filters |
337
+ export function NovaTransactionsProvider({ pagination }: { pagination: TxInMemoryPagination }) {
338
+ const initialTx = usePulsarStore((state) => state.initialTx);
339
+ const closeTxTrackedModal = usePulsarStore((state) => state.closeTxTrackedModal);
340
+ const executeTxAction = usePulsarStore((state) => state.executeTxAction);
341
+ const initializeTransactionsPool = usePulsarStore((state) => state.initializeTransactionsPool);
115
342
 
116
- ### Utils — `utils`
343
+ const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
344
+ const getAdapter = usePulsarStore((state) => state.getAdapter);
345
+ const transactionsPool = usePulsarInMemoryStore((state) => state.transactionsPool);
117
346
 
118
- Security and authentication utilities for signature verification and session management.
347
+ useInitializeTransactionsPool({ initializeTransactionsPool });
119
348
 
120
- ```typescript
121
- import { utils, ChainType } from '@tuwaio/quasar-sdk';
122
-
123
- // Verify a Mini-Session signature on the server
124
- const isValid = await utils.verifyMiniSession({
125
- walletAddress: '0x...',
126
- signature,
127
- timestamp,
128
- chainType: ChainType.EVM
129
- });
349
+ return (
350
+ <NTP
351
+ transactionsPool={transactionsPool}
352
+ initialTx={initialTx}
353
+ closeTxTrackedModal={closeTxTrackedModal}
354
+ executeTxAction={executeTxAction}
355
+ connectedWalletAddress={activeConnection?.isConnected ? activeConnection.address : undefined}
356
+ connectedAdapterType={getAdapterFromConnectorType(activeConnection?.connectorType ?? 'evm:')}
357
+ adapter={getAdapter()}
358
+ pagination={pagination}
359
+ />
360
+ );
361
+ }
130
362
  ```
131
363
 
132
- | Method | Description |
133
- | ------------------------------ | ------------------------------------------------------ |
134
- | `createMiniSessionMessage(ts)` | Format a standard login message for signing |
135
- | `signMiniSession(params)` | Trigger signature request in the connected wallet |
136
- | `verifyMiniSession(params)` | Verify an EVM or Solana signature with expiration check |
137
- | `createMiniSessionStore(name)` | Create a persistent Zustand store for session caching |
138
- | `getMiniSessionAuth(conn, st)` | Core logic for signing and caching a mini-session |
364
+ ### 7. The Seamless UI Integration (`AppProviders.tsx`)
139
365
 
140
- ## Error Handling
366
+ ```tsx
367
+ // src/providers/AppProviders.tsx
368
+ 'use client';
369
+
370
+ import { SatelliteConnectProvider } from '@tuwaio/sdk/satellite';
371
+ import { NovaConnectProvider } from '@tuwaio/sdk/nova-connect';
372
+ import { satelliteEVMAdapter } from '@tuwaio/evm-sdk/satellite';
373
+ import { EVMConnectorsWatcher } from '@tuwaio/evm-sdk/nova-connect';
374
+ import { satelliteSolanaAdapter } from '@tuwaio/solana-sdk/satellite';
375
+ import { SolanaConnectorsWatcher } from '@tuwaio/solana-sdk/nova-connect';
376
+ import { getMiniSessionAuth } from '@tuwaio/quasar-sdk/react';
377
+
378
+ import { appEVMChains, solanaRPCUrls, wagmiConfig } from '@/configs/appConfig';
379
+ import { usePulsarInMemoryStore, usePulsarStore } from '@/hooks/usePulsarStore';
380
+ import { NovaTransactionsProvider } from '@/providers/NovaTransactionsProvider';
381
+ import { QuasarAuthBridge } from '@/providers/QuasarSDKAuthProvider';
382
+
383
+ export function AppProviders({ children }: { children: React.ReactNode }) {
384
+ const getAdapter = usePulsarStore((state) => state.getAdapter);
385
+ const transactionsPool = usePulsarInMemoryStore((state) => state.transactionsPool);
386
+
387
+ const isLoading = usePulsarInMemoryStore((state) => state.isLoading);
388
+ const isError = usePulsarInMemoryStore((state) => state.isError);
389
+ const currentPage = usePulsarInMemoryStore((state) => state.currentPage);
390
+ const hasMore = usePulsarInMemoryStore((state) => state.hasMore);
391
+ const fetchNextPage = usePulsarInMemoryStore((state) => state.fetchNextPage);
392
+ const fetchInitial = usePulsarInMemoryStore((state) => state.fetchInitial);
393
+
394
+ const pagination = { isLoading, isError, currentPage, hasMore, fetchNextPage };
141
395
 
142
- ```typescript
143
- import { QuasarSDKError } from '@tuwaio/quasar-sdk';
144
-
145
- try {
146
- await quasar.pulsar.getHistory();
147
- } catch (err) {
148
- if (err instanceof QuasarSDKError) {
149
- console.error(err.status); // HTTP status code
150
- console.error(err.message); // Formatted error message
151
- }
396
+ return (
397
+ <SatelliteConnectProvider
398
+ adapter={[satelliteEVMAdapter(wagmiConfig, appEVMChains), satelliteSolanaAdapter({ rpcUrls: solanaRPCUrls })]}
399
+ autoConnect={true}
400
+ callbackAfterConnected={async (connection) => {
401
+ try {
402
+ await getMiniSessionAuth();
403
+ setTimeout(() => fetchInitial(connection.address), 2000);
404
+ } catch (err) {
405
+ console.error('[QuasarAuth] Auto-authentication failed:', err);
406
+ setTimeout(() => fetchInitial(connection.address), 2000);
407
+ }
408
+ }}
409
+ >
410
+ <EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
411
+ <SolanaConnectorsWatcher />
412
+
413
+ <QuasarAuthBridge />
414
+ <NovaTransactionsProvider pagination={pagination} />
415
+
416
+ <NovaConnectProvider
417
+ appChains={appEVMChains}
418
+ solanaRPCUrls={solanaRPCUrls}
419
+ transactionPool={transactionsPool}
420
+ pulsarAdapter={getAdapter() as any}
421
+ withImpersonated
422
+ withBalance
423
+ withChain
424
+ pagination={pagination}
425
+ >
426
+ {children}
427
+ </NovaConnectProvider>
428
+ </SatelliteConnectProvider>
429
+ );
430
+ }
431
+ ```
432
+
433
+ ### 8. Creating a Transaction (Usage)
434
+
435
+ Now you can safely execute strictly-typed, cross-chain transactions anywhere in your app. The store automatically routes the transaction to the correct adapter, and Quasar syncs it to the cloud.
436
+
437
+ ```tsx
438
+ // src/components/SwapButton.tsx
439
+ 'use client';
440
+
441
+ import { getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/sdk/orbit';
442
+ import { useSatelliteConnectStore } from '@tuwaio/sdk/satellite';
443
+ import { TxActionButton } from '@tuwaio/sdk/nova-transactions';
444
+ import { usePulsarStore, usePulsarInMemoryStore } from '@/hooks/usePulsarStore';
445
+ import { AppTxType } from '@/types';
446
+
447
+ export function SwapButton() {
448
+ const executeTxAction = usePulsarStore((s) => s.executeTxAction);
449
+ const getLastTxKey = usePulsarStore((s) => s.getLastTxKey);
450
+ const transactionsPool = usePulsarInMemoryStore((s) => s.transactionsPool);
451
+ const activeConnection = useSatelliteConnectStore((s) => s.activeConnection);
452
+
453
+ const handleSwapAction = async () => {
454
+ // Dynamically determine the adapter based on the currently connected wallet
455
+ const adapterType = getAdapterFromConnectorType(activeConnection?.connectorType ?? 'evm:');
456
+
457
+ await executeTxAction({
458
+ actionFunction: async () => {
459
+ /* your wagmi/solana contract call */
460
+ },
461
+ params: {
462
+ adapter: adapterType,
463
+ type: AppTxType.SWAP,
464
+ title: 'Token Swap',
465
+ desiredChainID: adapterType === OrbitAdapter.EVM ? 1 : undefined,
466
+ payload: { tokenIn: 'USDC', tokenOut: adapterType === OrbitAdapter.EVM ? 'ETH' : 'SOL', amount: 100 },
467
+ },
468
+ });
469
+ };
470
+
471
+ return (
472
+ <TxActionButton
473
+ action={handleSwapAction}
474
+ getLastTxKey={getLastTxKey}
475
+ transactionsPool={transactionsPool}
476
+ walletAddress={activeConnection?.address}
477
+ >
478
+ Cross-Chain Swap
479
+ </TxActionButton>
480
+ );
152
481
  }
153
482
  ```
154
483
 
155
- ## Configuration
484
+ ---
156
485
 
157
- | Property | Type | Required | Default | Description |
158
- | ----------- | -------- | -------- | --------------------- | --------------------------------- |
159
- | `secretKey` | `string` | ✅ | — | Server-side API key (`sk_live_*`) |
160
- | `baseUrl` | `string` | ❌ | `https://api.tuwa.io` | API base URL |
161
- | `timeout` | `number` | ❌ | `10000` | Request timeout (ms) |
486
+ ## 📦 Available Namespaces
162
487
 
163
- ## Documentation
488
+ This package provides the following server-side utilities and React bridges:
164
489
 
165
- Full API reference: [sdk.docs.tuwa.io](https://sdk.docs.tuwa.io/)
490
+ - `Quasar` — The main server-side client class instance used to access `quasar.pulsar.*` methods.
491
+ - `utils` — Security and authentication utilities for signature verification (`verifyMiniSession`, `signMiniSession`, `createMiniSessionStore`).
492
+ - `QuasarAuthBridge` (exported via subpaths) — The client-side React component for triggering and managing the signature flow automatically when the wallet connects.
493
+ - `MiniSessionAuth` — The strict type definition mapping the structure of the authentication payload.
166
494
 
167
495
  ---
168
496
 
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-HVUZ52OX.js';import {h}from'./chunk-C6JAMIC3.js';import {useWalletAccountMessageSigner}from'@solana/react';import {useEffect,useRef,useCallback}from'react';import {jsx}from'react/jsx-runtime';function K({activeConnection:n,store:i,session:e,setSession:t,maxAge:s,onAddressMismatch:r}){return useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),r?.());},[n?.address,e,t,r]),!n?.isConnected||!i?null:jsx(p,{connectedAccount:n.connectedAccount,store:i,session:e,setSession:t,maxAge:s})}function p({connectedAccount:n,store:i,session:e,setSession:t,maxAge:s}){let r=useWalletAccountMessageSigner(n),c=useRef(r),d=useRef(e),A=useRef(t);useEffect(()=>{c.current=r;},[r]),useEffect(()=>{d.current=e;},[e]),useEffect(()=>{A.current=t;},[t]);let S=useCallback(async()=>{let a=i.getState().activeConnection;if(!a?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let g=c.current;if(!g)throw new Error("[QuasarSDK] Solana Message Signer not initialized.");return h({isConnected:a.isConnected,address:a.address,chainType:"SOLANA",signer:g},{miniSession:d.current,setMiniSession:A.current},s)},[i,s]);return useEffect(()=>(a(S),()=>{a(null);}),[S]),null}export{K as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-HVUZ52OX.js';import {h}from'./chunk-C6JAMIC3.js';import {getWalletClient}from'@wagmi/core';import {useEffect,useRef,useCallback}from'react';import {jsx}from'react/jsx-runtime';function R({activeConnection:n,store:i,wagmiConfig:r,session:e,setSession:t,maxAge:s,onAddressMismatch:o}){return useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!i?null:jsx(S,{wagmiConfig:r,store:i,session:e,setSession:t,maxAge:s})}function S({wagmiConfig:n,store:i,session:r,setSession:e,maxAge:t}){let s=useRef(r),o=useRef(e);useEffect(()=>{s.current=r;},[r]),useEffect(()=>{o.current=e;},[e]);let l=useCallback(async()=>{let u=i.getState().activeConnection;if(!u?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let d=await getWalletClient(n);if(!d)throw new Error("[QuasarSDK] EVM Signer not found");return h({isConnected:u.isConnected,address:u.address,chainType:"EVM",signer:d},{miniSession:s.current,setMiniSession:o.current},t)},[i,n,t]);return useEffect(()=>(a(l),()=>{a(null);}),[l]),null}export{R as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkNIIKETIK_cjs=require('./chunk-NIIKETIK.cjs'),chunkUIDJZGQ7_cjs=require('./chunk-UIDJZGQ7.cjs'),react$1=require('@solana/react'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function K({activeConnection:n,store:i,session:e,setSession:t,maxAge:s,onAddressMismatch:r}){return react.useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),r?.());},[n?.address,e,t,r]),!n?.isConnected||!i?null:jsxRuntime.jsx(p,{connectedAccount:n.connectedAccount,store:i,session:e,setSession:t,maxAge:s})}function p({connectedAccount:n,store:i,session:e,setSession:t,maxAge:s}){let r=react$1.useWalletAccountMessageSigner(n),c=react.useRef(r),d=react.useRef(e),A=react.useRef(t);react.useEffect(()=>{c.current=r;},[r]),react.useEffect(()=>{d.current=e;},[e]),react.useEffect(()=>{A.current=t;},[t]);let S=react.useCallback(async()=>{let a=i.getState().activeConnection;if(!a?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let g=c.current;if(!g)throw new Error("[QuasarSDK] Solana Message Signer not initialized.");return chunkUIDJZGQ7_cjs.h({isConnected:a.isConnected,address:a.address,chainType:"SOLANA",signer:g},{miniSession:d.current,setMiniSession:A.current},s)},[i,s]);return react.useEffect(()=>(chunkNIIKETIK_cjs.a(S),()=>{chunkNIIKETIK_cjs.a(null);}),[S]),null}exports.a=K;
@@ -0,0 +1 @@
1
+ import {create}from'zustand';import {persist}from'zustand/middleware';var m=(t=>(t.EVM="EVM",t.SOLANA="SOLANA",t))(m||{});var u=300*1e3,w=60*1e3,y=30*1e3;function f(e){return `Mini-Session Login: ${e}`}async function p(e){let r=new Date().toISOString(),t=f(r);if(e.chainType==="EVM"){let i=e.signer;try{return {signature:await i.signMessage({account:e.walletAddress,message:t}),timestamp:r}}catch(n){throw new Error(`[SDK] EVM signing failed: ${n.message}`,{cause:n})}}if(e.chainType==="SOLANA"){let i=e.signer,n;try{n=await import('gill');}catch(s){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:s})}try{let a=n.getUtf8Encoder().encode(t),o;if(i.modifyAndSignMessages){let g=n.createSignableMessage(a),d=(await i.modifyAndSignMessages([g]))[0].signatures[i.address];if(!d)throw new Error(`[SDK] Signature missing for address: ${i.address}`);o=d;}else if(i.signMessages){let S=(await i.signMessages([a]))[0];if(!S?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=S.signature;}else if(i.signMessage)o=await i.signMessage(a);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:n.getSignatureFromBytes(o),timestamp:r}}catch(s){throw new Error(`[SDK] Solana signing failed: ${s.message}`,{cause:s})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function v(e){let r=new Date(e.timestamp).getTime(),t=Date.now();if(isNaN(r))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let i=e.maxAge??u;if(t-r>i)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(r>t+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let n=f(e.timestamp);if(e.chainType==="EVM"){let s;try{s=await import('viem');}catch(a){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:a})}return await s.verifyMessage({address:e.walletAddress,message:n,signature:e.signature})}if(e.chainType==="SOLANA"){let s;try{s=await import('gill');}catch(a){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:a})}try{let a=s.address(e.walletAddress);return await s.verifySignatureForAddress(a,e.signature,n)}catch{return false}}return false}var c=null;function C(e="mini-session-storage"){return create()(persist(r=>({miniSession:null,setMiniSession:t=>r({miniSession:t}),clearSession:()=>r({miniSession:null})}),{name:e}))}async function N(e,r,t=u){let{isConnected:i,address:n,chainType:s,signer:a}=e;if(!i||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let o=r.miniSession;if(o&&o.walletAddress===n&&o.chainType===s){let l=Date.now(),g=new Date(o.timestamp).getTime();if(l-g<t-y)return o}return c||(c=p({signer:a,walletAddress:n,chainType:s}).then(l=>{let g={...l,chainType:s,walletAddress:n};return r.setMiniSession(g),g}).finally(()=>{c=null;})),c}export{m as a,u as b,y as c,f as d,p as e,v as f,C as g,N as h};
@@ -1 +1 @@
1
- 'use strict';var n=null;function t(e){n=e;}async function r(){for(let e=0;e<15;e++){if(n)return n();await new Promise(i=>setTimeout(i,200));}throw new Error("[QuasarSDK] Auth helper not initialized. Ensure QuasarAuthBridge is mounted and wallet is connected.")}exports.a=t;exports.b=r;
1
+ var n=null;function t(e){n=e;}async function r(){for(let e=0;e<15;e++){if(n)return n();await new Promise(i=>setTimeout(i,200));}throw new Error("[QuasarSDK] Auth helper not initialized. Ensure QuasarAuthBridge is mounted and wallet is connected.")}export{t as a,r as b};
@@ -0,0 +1 @@
1
+ 'use strict';var n=null;function t(e){n=e;}async function r(){for(let e=0;e<15;e++){if(n)return n();await new Promise(i=>setTimeout(i,200));}throw new Error("[QuasarSDK] Auth helper not initialized. Ensure QuasarAuthBridge is mounted and wallet is connected.")}exports.a=t;exports.b=r;
@@ -0,0 +1 @@
1
+ 'use strict';var zustand=require('zustand'),middleware=require('zustand/middleware');var m=(t=>(t.EVM="EVM",t.SOLANA="SOLANA",t))(m||{});var u=300*1e3,w=60*1e3,y=30*1e3;function f(e){return `Mini-Session Login: ${e}`}async function p(e){let r=new Date().toISOString(),t=f(r);if(e.chainType==="EVM"){let i=e.signer;try{return {signature:await i.signMessage({account:e.walletAddress,message:t}),timestamp:r}}catch(n){throw new Error(`[SDK] EVM signing failed: ${n.message}`,{cause:n})}}if(e.chainType==="SOLANA"){let i=e.signer,n;try{n=await import('gill');}catch(s){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:s})}try{let a=n.getUtf8Encoder().encode(t),o;if(i.modifyAndSignMessages){let g=n.createSignableMessage(a),d=(await i.modifyAndSignMessages([g]))[0].signatures[i.address];if(!d)throw new Error(`[SDK] Signature missing for address: ${i.address}`);o=d;}else if(i.signMessages){let S=(await i.signMessages([a]))[0];if(!S?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=S.signature;}else if(i.signMessage)o=await i.signMessage(a);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:n.getSignatureFromBytes(o),timestamp:r}}catch(s){throw new Error(`[SDK] Solana signing failed: ${s.message}`,{cause:s})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function v(e){let r=new Date(e.timestamp).getTime(),t=Date.now();if(isNaN(r))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let i=e.maxAge??u;if(t-r>i)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(r>t+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let n=f(e.timestamp);if(e.chainType==="EVM"){let s;try{s=await import('viem');}catch(a){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:a})}return await s.verifyMessage({address:e.walletAddress,message:n,signature:e.signature})}if(e.chainType==="SOLANA"){let s;try{s=await import('gill');}catch(a){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:a})}try{let a=s.address(e.walletAddress);return await s.verifySignatureForAddress(a,e.signature,n)}catch{return false}}return false}var c=null;function C(e="mini-session-storage"){return zustand.create()(middleware.persist(r=>({miniSession:null,setMiniSession:t=>r({miniSession:t}),clearSession:()=>r({miniSession:null})}),{name:e}))}async function N(e,r,t=u){let{isConnected:i,address:n,chainType:s,signer:a}=e;if(!i||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let o=r.miniSession;if(o&&o.walletAddress===n&&o.chainType===s){let l=Date.now(),g=new Date(o.timestamp).getTime();if(l-g<t-y)return o}return c||(c=p({signer:a,walletAddress:n,chainType:s}).then(l=>{let g={...l,chainType:s,walletAddress:n};return r.setMiniSession(g),g}).finally(()=>{c=null;})),c}exports.a=m;exports.b=u;exports.c=y;exports.d=f;exports.e=p;exports.f=v;exports.g=C;exports.h=N;
@@ -0,0 +1 @@
1
+ 'use strict';var chunkNIIKETIK_cjs=require('./chunk-NIIKETIK.cjs'),chunkUIDJZGQ7_cjs=require('./chunk-UIDJZGQ7.cjs'),core=require('@wagmi/core'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function R({activeConnection:n,store:i,wagmiConfig:r,session:e,setSession:t,maxAge:s,onAddressMismatch:o}){return react.useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!i?null:jsxRuntime.jsx(S,{wagmiConfig:r,store:i,session:e,setSession:t,maxAge:s})}function S({wagmiConfig:n,store:i,session:r,setSession:e,maxAge:t}){let s=react.useRef(r),o=react.useRef(e);react.useEffect(()=>{s.current=r;},[r]),react.useEffect(()=>{o.current=e;},[e]);let l=react.useCallback(async()=>{let u=i.getState().activeConnection;if(!u?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let d=await core.getWalletClient(n);if(!d)throw new Error("[QuasarSDK] EVM Signer not found");return chunkUIDJZGQ7_cjs.h({isConnected:u.isConnected,address:u.address,chainType:"EVM",signer:d},{miniSession:s.current,setMiniSession:o.current},t)},[i,n,t]);return react.useEffect(()=>(chunkNIIKETIK_cjs.a(l),()=>{chunkNIIKETIK_cjs.a(null);}),[l]),null}exports.a=R;
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkUIDJZGQ7_cjs=require('./chunk-UIDJZGQ7.cjs'),ofetch=require('ofetch');var m="https://api.tuwa.io",h="/v1/engine/pulsar/sync",d="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(t,e,r){super(t),this.name="QuasarSDKError",this.status=e,this.originalError=r;}},o=class{secretKey;internalSecret;baseUrl;timeout;constructor(t){if(!t.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=t.secretKey,this.internalSecret=t.internalSecret,this.baseUrl=t.baseUrl||m,this.timeout=t.timeout||1e4;}async request(t,e={}){try{return await ofetch.ofetch(t,{baseURL:this.baseUrl,timeout:this.timeout,...e,headers:{"Content-Type":"application/json","x-tuwa-secret-key":this.secretKey,...this.internalSecret?{"x-internal-secret":this.internalSecret}:{},...e.headers}})}catch(r){throw this.buildError(r)}}buildError(t){let e=t,r=e.statusCode??e.response?.status,S=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (r===401||r===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${r}): ${S}`,r,e)}};var s=class{constructor(t){this.client=t;}async syncCreate(t,e){return this.client.request(h,{method:"POST",body:{...t,appName:e}})}async getHistory(t={}){return this.client.request(d,{method:"GET",query:{page:t.page??1,limit:t.limit??10,chainId:t.chainId,status:t.status,txKey:t.txKey,appName:t.appName,walletAddress:t.walletAddress}})}};var E={createMiniSessionMessage:chunkUIDJZGQ7_cjs.d,verifyMiniSession:chunkUIDJZGQ7_cjs.f,signMiniSession:chunkUIDJZGQ7_cjs.e,createMiniSessionStore:chunkUIDJZGQ7_cjs.g,getMiniSessionAuth:chunkUIDJZGQ7_cjs.h},y=class{static utils=E;client;pulsar;constructor(t){this.client=new o(t),this.pulsar=new s(this.client);}};
2
+ Object.defineProperty(exports,"ChainType",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.a}});Object.defineProperty(exports,"DEFAULT_MAX_AGE",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.b}});Object.defineProperty(exports,"NETWORK_SAFETY_BUFFER",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.c}});Object.defineProperty(exports,"createMiniSessionMessage",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.d}});Object.defineProperty(exports,"createMiniSessionStore",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.g}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.h}});Object.defineProperty(exports,"signMiniSession",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.e}});Object.defineProperty(exports,"verifyMiniSession",{enumerable:true,get:function(){return chunkUIDJZGQ7_cjs.f}});exports.BASE_API_URL=m;exports.PULSAR_HISTORY_ENDPOINT=d;exports.PULSAR_SYNC_ENDPOINT=h;exports.PulsarModule=s;exports.Quasar=y;exports.QuasarSDKError=i;exports.utils=E;
@@ -1,6 +1,6 @@
1
1
  import { FetchOptions } from 'ofetch';
2
- import { Q as QuasarConfig, H as HistoryQuery, P as PaginatedResult, V as VerifySessionParams, S as SignSessionParams, a as SignSessionResult, M as MiniSessionStore, C as ConnectionData, b as MiniSessionAuth } from './types-Ctaain6g.mjs';
3
- export { c as ChainType, E as EvmSigner, d as SolanaSignedMessage, e as SolanaSigner } from './types-Ctaain6g.mjs';
2
+ import { Q as QuasarConfig, H as HistoryQuery, P as PaginatedResult, V as VerifySessionParams, S as SignSessionParams, a as SignSessionResult, M as MiniSessionStore, C as ConnectionData, b as MiniSessionAuth } from './types-C4cwIvHT.cjs';
3
+ export { c as ChainType, E as EvmSigner, d as SolanaSignableMessage, e as SolanaSigner } from './types-C4cwIvHT.cjs';
4
4
  import { Transaction } from '@tuwaio/pulsar-core';
5
5
  export { Transaction, UpdatableTransactionFields } from '@tuwaio/pulsar-core';
6
6
  import * as zustand_middleware from 'zustand/middleware';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FetchOptions } from 'ofetch';
2
- import { Q as QuasarConfig, H as HistoryQuery, P as PaginatedResult, V as VerifySessionParams, S as SignSessionParams, a as SignSessionResult, M as MiniSessionStore, C as ConnectionData, b as MiniSessionAuth } from './types-Ctaain6g.js';
3
- export { c as ChainType, E as EvmSigner, d as SolanaSignedMessage, e as SolanaSigner } from './types-Ctaain6g.js';
2
+ import { Q as QuasarConfig, H as HistoryQuery, P as PaginatedResult, V as VerifySessionParams, S as SignSessionParams, a as SignSessionResult, M as MiniSessionStore, C as ConnectionData, b as MiniSessionAuth } from './types-C4cwIvHT.js';
3
+ export { c as ChainType, E as EvmSigner, d as SolanaSignableMessage, e as SolanaSigner } from './types-C4cwIvHT.js';
4
4
  import { Transaction } from '@tuwaio/pulsar-core';
5
5
  export { Transaction, UpdatableTransactionFields } from '@tuwaio/pulsar-core';
6
6
  import * as zustand_middleware from 'zustand/middleware';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkOJCR5A56_js=require('./chunk-OJCR5A56.js'),ofetch=require('ofetch');var m="https://api.tuwa.io",h="/v1/engine/pulsar/sync",d="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(t,e,r){super(t),this.name="QuasarSDKError",this.status=e,this.originalError=r;}},o=class{secretKey;internalSecret;baseUrl;timeout;constructor(t){if(!t.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=t.secretKey,this.internalSecret=t.internalSecret,this.baseUrl=t.baseUrl||m,this.timeout=t.timeout||1e4;}async request(t,e={}){try{return await ofetch.ofetch(t,{baseURL:this.baseUrl,timeout:this.timeout,...e,headers:{"Content-Type":"application/json","x-tuwa-secret-key":this.secretKey,...this.internalSecret?{"x-internal-secret":this.internalSecret}:{},...e.headers}})}catch(r){throw this.buildError(r)}}buildError(t){let e=t,r=e.statusCode??e.response?.status,S=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (r===401||r===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${r}): ${S}`,r,e)}};var s=class{constructor(t){this.client=t;}async syncCreate(t,e){return this.client.request(h,{method:"POST",body:{...t,appName:e}})}async getHistory(t={}){return this.client.request(d,{method:"GET",query:{page:t.page??1,limit:t.limit??10,chainId:t.chainId,status:t.status,txKey:t.txKey,appName:t.appName,walletAddress:t.walletAddress}})}};var E={createMiniSessionMessage:chunkOJCR5A56_js.d,verifyMiniSession:chunkOJCR5A56_js.f,signMiniSession:chunkOJCR5A56_js.e,createMiniSessionStore:chunkOJCR5A56_js.g,getMiniSessionAuth:chunkOJCR5A56_js.h},y=class{static utils=E;client;pulsar;constructor(t){this.client=new o(t),this.pulsar=new s(this.client);}};
2
- Object.defineProperty(exports,"ChainType",{enumerable:true,get:function(){return chunkOJCR5A56_js.a}});Object.defineProperty(exports,"DEFAULT_MAX_AGE",{enumerable:true,get:function(){return chunkOJCR5A56_js.b}});Object.defineProperty(exports,"NETWORK_SAFETY_BUFFER",{enumerable:true,get:function(){return chunkOJCR5A56_js.c}});Object.defineProperty(exports,"createMiniSessionMessage",{enumerable:true,get:function(){return chunkOJCR5A56_js.d}});Object.defineProperty(exports,"createMiniSessionStore",{enumerable:true,get:function(){return chunkOJCR5A56_js.g}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkOJCR5A56_js.h}});Object.defineProperty(exports,"signMiniSession",{enumerable:true,get:function(){return chunkOJCR5A56_js.e}});Object.defineProperty(exports,"verifyMiniSession",{enumerable:true,get:function(){return chunkOJCR5A56_js.f}});exports.BASE_API_URL=m;exports.PULSAR_HISTORY_ENDPOINT=d;exports.PULSAR_SYNC_ENDPOINT=h;exports.PulsarModule=s;exports.Quasar=y;exports.QuasarSDKError=i;exports.utils=E;
1
+ import {h as h$1,g,e,f,d as d$1}from'./chunk-C6JAMIC3.js';export{a as ChainType,b as DEFAULT_MAX_AGE,c as NETWORK_SAFETY_BUFFER,d as createMiniSessionMessage,g as createMiniSessionStore,h as getMiniSessionAuth,e as signMiniSession,f as verifyMiniSession}from'./chunk-C6JAMIC3.js';import {ofetch}from'ofetch';var m="https://api.tuwa.io",h="/v1/engine/pulsar/sync",d="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(t,e,r){super(t),this.name="QuasarSDKError",this.status=e,this.originalError=r;}},o=class{secretKey;internalSecret;baseUrl;timeout;constructor(t){if(!t.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=t.secretKey,this.internalSecret=t.internalSecret,this.baseUrl=t.baseUrl||m,this.timeout=t.timeout||1e4;}async request(t,e={}){try{return await ofetch(t,{baseURL:this.baseUrl,timeout:this.timeout,...e,headers:{"Content-Type":"application/json","x-tuwa-secret-key":this.secretKey,...this.internalSecret?{"x-internal-secret":this.internalSecret}:{},...e.headers}})}catch(r){throw this.buildError(r)}}buildError(t){let e=t,r=e.statusCode??e.response?.status,S=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (r===401||r===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${r}): ${S}`,r,e)}};var s=class{constructor(t){this.client=t;}async syncCreate(t,e){return this.client.request(h,{method:"POST",body:{...t,appName:e}})}async getHistory(t={}){return this.client.request(d,{method:"GET",query:{page:t.page??1,limit:t.limit??10,chainId:t.chainId,status:t.status,txKey:t.txKey,appName:t.appName,walletAddress:t.walletAddress}})}};var E={createMiniSessionMessage:d$1,verifyMiniSession:f,signMiniSession:e,createMiniSessionStore:g,getMiniSessionAuth:h$1},y=class{static utils=E;client;pulsar;constructor(t){this.client=new o(t),this.pulsar=new s(this.client);}};
2
+ export{m as BASE_API_URL,d as PULSAR_HISTORY_ENDPOINT,h as PULSAR_SYNC_ENDPOINT,s as PulsarModule,y as Quasar,i as QuasarSDKError,E as utils};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkZVKFOJG3_cjs=require('../chunk-ZVKFOJG3.cjs'),chunkNIIKETIK_cjs=require('../chunk-NIIKETIK.cjs');require('../chunk-UIDJZGQ7.cjs');Object.defineProperty(exports,"QuasarEvmAuthBridge",{enumerable:true,get:function(){return chunkZVKFOJG3_cjs.a}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkNIIKETIK_cjs.b}});
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { Config } from '@wagmi/core';
3
3
  import { StoreApi } from 'zustand';
4
- import { b as MiniSessionAuth } from '../types-Ctaain6g.mjs';
5
- import { Q as QuasarActiveConnection } from '../shared-CFhEPXTt.mjs';
6
- export { g as getMiniSessionAuth } from '../shared-CFhEPXTt.mjs';
4
+ import { b as MiniSessionAuth } from '../types-C4cwIvHT.cjs';
5
+ import { Q as QuasarActiveConnection } from '../shared-D2uX4Ua8.cjs';
6
+ export { g as getMiniSessionAuth } from '../shared-D2uX4Ua8.cjs';
7
7
 
8
8
  /**
9
9
  * Props for the QuasarEvmAuthBridge component.
@@ -51,6 +51,6 @@ interface QuasarEvmAuthBridgeProps {
51
51
  *
52
52
  * @public
53
53
  */
54
- declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
54
+ declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react.JSX.Element | null;
55
55
 
56
56
  export { QuasarActiveConnection, QuasarEvmAuthBridge, type QuasarEvmAuthBridgeProps };
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { Config } from '@wagmi/core';
3
3
  import { StoreApi } from 'zustand';
4
- import { b as MiniSessionAuth } from '../types-Ctaain6g.js';
5
- import { Q as QuasarActiveConnection } from '../shared-BeprN_w-.js';
6
- export { g as getMiniSessionAuth } from '../shared-BeprN_w-.js';
4
+ import { b as MiniSessionAuth } from '../types-C4cwIvHT.js';
5
+ import { Q as QuasarActiveConnection } from '../shared-BDH89Mck.js';
6
+ export { g as getMiniSessionAuth } from '../shared-BDH89Mck.js';
7
7
 
8
8
  /**
9
9
  * Props for the QuasarEvmAuthBridge component.
@@ -51,6 +51,6 @@ interface QuasarEvmAuthBridgeProps {
51
51
  *
52
52
  * @public
53
53
  */
54
- declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
54
+ declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react.JSX.Element | null;
55
55
 
56
56
  export { QuasarActiveConnection, QuasarEvmAuthBridge, type QuasarEvmAuthBridgeProps };
package/dist/react/evm.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunk7F6I4FHE_js=require('../chunk-7F6I4FHE.js'),chunkHVUZ52OX_js=require('../chunk-HVUZ52OX.js');require('../chunk-OJCR5A56.js');Object.defineProperty(exports,"QuasarEvmAuthBridge",{enumerable:true,get:function(){return chunk7F6I4FHE_js.a}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkHVUZ52OX_js.b}});
1
+ export{a as QuasarEvmAuthBridge}from'../chunk-2VPVIX5M.js';export{b as getMiniSessionAuth}from'../chunk-HVUZ52OX.js';import'../chunk-C6JAMIC3.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkAQEHRYJP_cjs=require('../chunk-AQEHRYJP.cjs'),chunkNIIKETIK_cjs=require('../chunk-NIIKETIK.cjs');require('../chunk-UIDJZGQ7.cjs');Object.defineProperty(exports,"QuasarSolanaAuthBridge",{enumerable:true,get:function(){return chunkAQEHRYJP_cjs.a}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkNIIKETIK_cjs.b}});
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { StoreApi } from 'zustand';
3
- import { b as MiniSessionAuth } from '../types-Ctaain6g.mjs';
4
- import { Q as QuasarActiveConnection } from '../shared-CFhEPXTt.mjs';
5
- export { g as getMiniSessionAuth } from '../shared-CFhEPXTt.mjs';
3
+ import { b as MiniSessionAuth } from '../types-C4cwIvHT.cjs';
4
+ import { Q as QuasarActiveConnection } from '../shared-D2uX4Ua8.cjs';
5
+ export { g as getMiniSessionAuth } from '../shared-D2uX4Ua8.cjs';
6
6
 
7
7
  /**
8
8
  * Props for the QuasarSolanaAuthBridge component.
@@ -47,6 +47,6 @@ interface QuasarSolanaAuthBridgeProps {
47
47
  *
48
48
  * @public
49
49
  */
50
- declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
50
+ declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react.JSX.Element | null;
51
51
 
52
52
  export { QuasarActiveConnection, QuasarSolanaAuthBridge, type QuasarSolanaAuthBridgeProps };
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { StoreApi } from 'zustand';
3
- import { b as MiniSessionAuth } from '../types-Ctaain6g.js';
4
- import { Q as QuasarActiveConnection } from '../shared-BeprN_w-.js';
5
- export { g as getMiniSessionAuth } from '../shared-BeprN_w-.js';
3
+ import { b as MiniSessionAuth } from '../types-C4cwIvHT.js';
4
+ import { Q as QuasarActiveConnection } from '../shared-BDH89Mck.js';
5
+ export { g as getMiniSessionAuth } from '../shared-BDH89Mck.js';
6
6
 
7
7
  /**
8
8
  * Props for the QuasarSolanaAuthBridge component.
@@ -47,6 +47,6 @@ interface QuasarSolanaAuthBridgeProps {
47
47
  *
48
48
  * @public
49
49
  */
50
- declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
50
+ declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react.JSX.Element | null;
51
51
 
52
52
  export { QuasarActiveConnection, QuasarSolanaAuthBridge, type QuasarSolanaAuthBridgeProps };
@@ -1 +1 @@
1
- 'use strict';var chunkRZ4TLBSP_js=require('../chunk-RZ4TLBSP.js'),chunkHVUZ52OX_js=require('../chunk-HVUZ52OX.js');require('../chunk-OJCR5A56.js');Object.defineProperty(exports,"QuasarSolanaAuthBridge",{enumerable:true,get:function(){return chunkRZ4TLBSP_js.a}});Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkHVUZ52OX_js.b}});
1
+ export{a as QuasarSolanaAuthBridge}from'../chunk-2MHRTJOV.js';export{b as getMiniSessionAuth}from'../chunk-HVUZ52OX.js';import'../chunk-C6JAMIC3.js';
package/dist/react.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var chunkZVKFOJG3_cjs=require('./chunk-ZVKFOJG3.cjs'),chunkAQEHRYJP_cjs=require('./chunk-AQEHRYJP.cjs'),chunkNIIKETIK_cjs=require('./chunk-NIIKETIK.cjs');require('./chunk-UIDJZGQ7.cjs');var react=require('react'),jsxRuntime=require('react/jsx-runtime');function C({activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n,onAddressMismatch:s}){let m=typeof r?.chainId=="string"?"SOLANA":"EVM";return react.useEffect(()=>{i&&r?.address&&i.walletAddress!==r.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),o(null),s?.());},[r?.address,i,o,s]),!r?.isConnected||!e?null:m==="SOLANA"?jsxRuntime.jsx(chunkAQEHRYJP_cjs.a,{activeConnection:r,store:e,session:i,setSession:o,maxAge:n}):jsxRuntime.jsx(chunkZVKFOJG3_cjs.a,{activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n})}Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkNIIKETIK_cjs.b}});exports.QuasarAuthBridge=C;
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { Config } from '@wagmi/core';
3
3
  import { StoreApi } from 'zustand';
4
- import { b as MiniSessionAuth } from './types-Ctaain6g.mjs';
5
- import { Q as QuasarActiveConnection } from './shared-CFhEPXTt.mjs';
6
- export { g as getMiniSessionAuth } from './shared-CFhEPXTt.mjs';
4
+ import { b as MiniSessionAuth } from './types-C4cwIvHT.cjs';
5
+ import { Q as QuasarActiveConnection } from './shared-D2uX4Ua8.cjs';
6
+ export { g as getMiniSessionAuth } from './shared-D2uX4Ua8.cjs';
7
7
 
8
8
  /**
9
9
  * Props for the unified QuasarAuthBridge component.
@@ -55,6 +55,6 @@ interface QuasarAuthBridgeProps {
55
55
  *
56
56
  * @public
57
57
  */
58
- declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
58
+ declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react.JSX.Element | null;
59
59
 
60
60
  export { QuasarActiveConnection, QuasarAuthBridge, type QuasarAuthBridgeProps };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { Config } from '@wagmi/core';
3
3
  import { StoreApi } from 'zustand';
4
- import { b as MiniSessionAuth } from './types-Ctaain6g.js';
5
- import { Q as QuasarActiveConnection } from './shared-BeprN_w-.js';
6
- export { g as getMiniSessionAuth } from './shared-BeprN_w-.js';
4
+ import { b as MiniSessionAuth } from './types-C4cwIvHT.js';
5
+ import { Q as QuasarActiveConnection } from './shared-BDH89Mck.js';
6
+ export { g as getMiniSessionAuth } from './shared-BDH89Mck.js';
7
7
 
8
8
  /**
9
9
  * Props for the unified QuasarAuthBridge component.
@@ -55,6 +55,6 @@ interface QuasarAuthBridgeProps {
55
55
  *
56
56
  * @public
57
57
  */
58
- declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
58
+ declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react.JSX.Element | null;
59
59
 
60
60
  export { QuasarActiveConnection, QuasarAuthBridge, type QuasarAuthBridgeProps };
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunk7F6I4FHE_js=require('./chunk-7F6I4FHE.js'),chunkRZ4TLBSP_js=require('./chunk-RZ4TLBSP.js'),chunkHVUZ52OX_js=require('./chunk-HVUZ52OX.js');require('./chunk-OJCR5A56.js');var react=require('react'),jsxRuntime=require('react/jsx-runtime');function C({activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n,onAddressMismatch:s}){let m=typeof r?.chainId=="string"?"SOLANA":"EVM";return react.useEffect(()=>{i&&r?.address&&i.walletAddress!==r.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),o(null),s?.());},[r?.address,i,o,s]),!r?.isConnected||!e?null:m==="SOLANA"?jsxRuntime.jsx(chunkRZ4TLBSP_js.a,{activeConnection:r,store:e,session:i,setSession:o,maxAge:n}):jsxRuntime.jsx(chunk7F6I4FHE_js.a,{activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n})}Object.defineProperty(exports,"getMiniSessionAuth",{enumerable:true,get:function(){return chunkHVUZ52OX_js.b}});exports.QuasarAuthBridge=C;
1
+ import {a as a$1}from'./chunk-2VPVIX5M.js';import {a}from'./chunk-2MHRTJOV.js';export{b as getMiniSessionAuth}from'./chunk-HVUZ52OX.js';import'./chunk-C6JAMIC3.js';import {useEffect}from'react';import {jsx}from'react/jsx-runtime';function C({activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n,onAddressMismatch:s}){let m=typeof r?.chainId=="string"?"SOLANA":"EVM";return useEffect(()=>{i&&r?.address&&i.walletAddress!==r.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),o(null),s?.());},[r?.address,i,o,s]),!r?.isConnected||!e?null:m==="SOLANA"?jsx(a,{activeConnection:r,store:e,session:i,setSession:o,maxAge:n}):jsx(a$1,{activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n})}export{C as QuasarAuthBridge};
@@ -1,4 +1,4 @@
1
- import { b as MiniSessionAuth } from './types-Ctaain6g.js';
1
+ import { b as MiniSessionAuth } from './types-C4cwIvHT.js';
2
2
 
3
3
  /**
4
4
  * @module react/shared
@@ -1,4 +1,4 @@
1
- import { b as MiniSessionAuth } from './types-Ctaain6g.mjs';
1
+ import { b as MiniSessionAuth } from './types-C4cwIvHT.cjs';
2
2
 
3
3
  /**
4
4
  * @module react/shared
@@ -117,7 +117,9 @@ interface EvmSigner {
117
117
  * Result structure for a signed Solana message in Web3 v2.
118
118
  * @public
119
119
  */
120
- interface SolanaSignedMessage {
120
+ interface SolanaSignableMessage {
121
+ /** The content of the message as bytes. */
122
+ readonly content: Uint8Array;
121
123
  /** A map of public addresses to their corresponding signature bytes. */
122
124
  readonly signatures: Readonly<Record<string, Uint8Array>>;
123
125
  }
@@ -133,7 +135,7 @@ interface SolanaSigner {
133
135
  * Modern Web3 v2 method to modify and sign messages.
134
136
  * Used by latest @solana/react hooks.
135
137
  */
136
- modifyAndSignMessages?: (messages: readonly unknown[]) => Promise<readonly SolanaSignedMessage[]>;
138
+ modifyAndSignMessages?: (messages: readonly SolanaSignableMessage[]) => Promise<readonly SolanaSignableMessage[]>;
137
139
  /**
138
140
  * Plural signing method (Wallet Standard).
139
141
  */
@@ -185,4 +187,4 @@ interface ConnectionData {
185
187
  signer: EvmSigner | SolanaSigner;
186
188
  }
187
189
 
188
- export { type ConnectionData as C, type EvmSigner as E, type HistoryQuery as H, type MiniSessionStore as M, type PaginatedResult as P, type QuasarConfig as Q, type SignSessionParams as S, type VerifySessionParams as V, type SignSessionResult as a, type MiniSessionAuth as b, ChainType as c, type SolanaSignedMessage as d, type SolanaSigner as e };
190
+ export { type ConnectionData as C, type EvmSigner as E, type HistoryQuery as H, type MiniSessionStore as M, type PaginatedResult as P, type QuasarConfig as Q, type SignSessionParams as S, type VerifySessionParams as V, type SignSessionResult as a, type MiniSessionAuth as b, ChainType as c, type SolanaSignableMessage as d, type SolanaSigner as e };
@@ -117,7 +117,9 @@ interface EvmSigner {
117
117
  * Result structure for a signed Solana message in Web3 v2.
118
118
  * @public
119
119
  */
120
- interface SolanaSignedMessage {
120
+ interface SolanaSignableMessage {
121
+ /** The content of the message as bytes. */
122
+ readonly content: Uint8Array;
121
123
  /** A map of public addresses to their corresponding signature bytes. */
122
124
  readonly signatures: Readonly<Record<string, Uint8Array>>;
123
125
  }
@@ -133,7 +135,7 @@ interface SolanaSigner {
133
135
  * Modern Web3 v2 method to modify and sign messages.
134
136
  * Used by latest @solana/react hooks.
135
137
  */
136
- modifyAndSignMessages?: (messages: readonly unknown[]) => Promise<readonly SolanaSignedMessage[]>;
138
+ modifyAndSignMessages?: (messages: readonly SolanaSignableMessage[]) => Promise<readonly SolanaSignableMessage[]>;
137
139
  /**
138
140
  * Plural signing method (Wallet Standard).
139
141
  */
@@ -185,4 +187,4 @@ interface ConnectionData {
185
187
  signer: EvmSigner | SolanaSigner;
186
188
  }
187
189
 
188
- export { type ConnectionData as C, type EvmSigner as E, type HistoryQuery as H, type MiniSessionStore as M, type PaginatedResult as P, type QuasarConfig as Q, type SignSessionParams as S, type VerifySessionParams as V, type SignSessionResult as a, type MiniSessionAuth as b, ChainType as c, type SolanaSignedMessage as d, type SolanaSigner as e };
190
+ export { type ConnectionData as C, type EvmSigner as E, type HistoryQuery as H, type MiniSessionStore as M, type PaginatedResult as P, type QuasarConfig as Q, type SignSessionParams as S, type VerifySessionParams as V, type SignSessionResult as a, type MiniSessionAuth as b, ChainType as c, type SolanaSignableMessage as d, type SolanaSigner as e };
package/package.json CHANGED
@@ -1,33 +1,34 @@
1
1
  {
2
2
  "name": "@tuwaio/quasar-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
7
- "description": "The official server-side Node.js & Edge SDK for the TUWA Quasar Cloud.",
8
- "main": "./dist/index.js",
9
- "module": "./dist/index.mjs",
7
+ "description": "Layer 5 (L5) of the TUWA Ecosystem. The Quasar Cloud SDK providing server-side Node.js & Edge utilities for transaction indexing, billing, and backend API integration.",
8
+ "type": "module",
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
10
11
  "types": "./dist/index.d.ts",
11
12
  "exports": {
12
13
  ".": {
13
14
  "types": "./dist/index.d.ts",
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.js"
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
16
17
  },
17
18
  "./react": {
18
19
  "types": "./dist/react.d.ts",
19
- "import": "./dist/react.mjs",
20
- "require": "./dist/react.js"
20
+ "import": "./dist/react.js",
21
+ "require": "./dist/react.cjs"
21
22
  },
22
23
  "./react/evm": {
23
24
  "types": "./dist/react/evm.d.ts",
24
- "import": "./dist/react/evm.mjs",
25
- "require": "./dist/react/evm.js"
25
+ "import": "./dist/react/evm.js",
26
+ "require": "./dist/react/evm.cjs"
26
27
  },
27
28
  "./react/solana": {
28
29
  "types": "./dist/react/solana.d.ts",
29
- "import": "./dist/react/solana.mjs",
30
- "require": "./dist/react/solana.js"
30
+ "import": "./dist/react/solana.js",
31
+ "require": "./dist/react/solana.cjs"
31
32
  }
32
33
  },
33
34
  "publishConfig": {
@@ -37,10 +38,46 @@
37
38
  "dist"
38
39
  ],
39
40
  "keywords": [
41
+ "tuwa",
40
42
  "web3",
43
+ "evm",
44
+ "ethereum",
45
+ "solana",
46
+ "wagmi",
47
+ "viem",
48
+ "gill",
49
+ "wallet-standard",
50
+ "wallet",
51
+ "wallet-connect",
52
+ "wallets",
41
53
  "transaction",
42
54
  "tracking",
43
- "sdk"
55
+ "transaction-tracking",
56
+ "react",
57
+ "ui",
58
+ "ui-kit",
59
+ "design-system",
60
+ "hooks",
61
+ "utils",
62
+ "components",
63
+ "tailwind",
64
+ "tailwindcss",
65
+ "typescript",
66
+ "core",
67
+ "headless",
68
+ "zustand",
69
+ "immer",
70
+ "i18n",
71
+ "modal",
72
+ "toast",
73
+ "quasar",
74
+ "cloud",
75
+ "sdk",
76
+ "siwe",
77
+ "next-auth",
78
+ "cosmos",
79
+ "playground",
80
+ "cli"
44
81
  ],
45
82
  "repository": {
46
83
  "type": "git",
@@ -58,17 +95,23 @@
58
95
  }
59
96
  ],
60
97
  "peerDependencies": {
61
- "@solana/react": ">=6.9.0",
98
+ "@solana/react": "6.x.x",
62
99
  "@tuwaio/pulsar-core": ">=0.6.0",
63
100
  "@wagmi/core": "3.x.x",
64
101
  "@wallet-standard/react": "1.x.x",
102
+ "gill": ">=0.14.0",
65
103
  "ofetch": ">=1.5.1",
66
104
  "react": ">=19.2.0",
67
- "gill": ">=0.14",
68
105
  "viem": "2.x.x",
69
106
  "zustand": "5.x.x"
70
107
  },
71
108
  "peerDependenciesMeta": {
109
+ "@tuwaio/pulsar-core": {
110
+ "optional": false
111
+ },
112
+ "ofetch": {
113
+ "optional": false
114
+ },
72
115
  "viem": {
73
116
  "optional": true
74
117
  },
@@ -93,18 +136,18 @@
93
136
  },
94
137
  "devDependencies": {
95
138
  "@solana/react": "^6.9.0",
96
- "@tuwaio/pulsar-core": "^0.6.4",
97
- "@types/react": "^19.2.15",
98
- "@wagmi/core": "^3.5.0",
99
- "@wallet-standard/react": "^1.0.2",
139
+ "@tuwaio/pulsar-core": "^0.6.7",
140
+ "@types/react": "^19.2.17",
141
+ "@wagmi/core": "^3.6.3",
142
+ "@wallet-standard/react": "^1.0.3",
100
143
  "ofetch": "^1.5.1",
101
- "react": "^19.2.6",
144
+ "react": "^19.2.7",
102
145
  "tsup": "^8.5.1",
103
146
  "typescript": "^6.0.3",
104
- "zustand": "^5.0.13"
147
+ "zustand": "^5.0.14"
105
148
  },
106
149
  "scripts": {
107
- "start": "tsup --watch",
150
+ "start": "tsup src/index.ts --watch",
108
151
  "build": "tsup"
109
152
  }
110
153
  }
@@ -1 +0,0 @@
1
- 'use strict';var chunkHVUZ52OX_js=require('./chunk-HVUZ52OX.js'),chunkOJCR5A56_js=require('./chunk-OJCR5A56.js'),core=require('@wagmi/core'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function R({activeConnection:n,store:i,wagmiConfig:r,session:e,setSession:t,maxAge:s,onAddressMismatch:o}){return react.useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!i?null:jsxRuntime.jsx(S,{wagmiConfig:r,store:i,session:e,setSession:t,maxAge:s})}function S({wagmiConfig:n,store:i,session:r,setSession:e,maxAge:t}){let s=react.useRef(r),o=react.useRef(e);react.useEffect(()=>{s.current=r;},[r]),react.useEffect(()=>{o.current=e;},[e]);let l=react.useCallback(async()=>{let u=i.getState().activeConnection;if(!u?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let d=await core.getWalletClient(n);if(!d)throw new Error("[QuasarSDK] EVM Signer not found");return chunkOJCR5A56_js.h({isConnected:u.isConnected,address:u.address,chainType:"EVM",signer:d},{miniSession:s.current,setMiniSession:o.current},t)},[i,n,t]);return react.useEffect(()=>(chunkHVUZ52OX_js.a(l),()=>{chunkHVUZ52OX_js.a(null);}),[l]),null}exports.a=R;
@@ -1 +0,0 @@
1
- import {a}from'./chunk-UW6TWEYM.mjs';import {h}from'./chunk-SF2BM2YA.mjs';import {getWalletClient}from'@wagmi/core';import {useEffect,useRef,useCallback}from'react';import {jsx}from'react/jsx-runtime';function R({activeConnection:n,store:i,wagmiConfig:r,session:e,setSession:t,maxAge:s,onAddressMismatch:o}){return useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!i?null:jsx(S,{wagmiConfig:r,store:i,session:e,setSession:t,maxAge:s})}function S({wagmiConfig:n,store:i,session:r,setSession:e,maxAge:t}){let s=useRef(r),o=useRef(e);useEffect(()=>{s.current=r;},[r]),useEffect(()=>{o.current=e;},[e]);let l=useCallback(async()=>{let u=i.getState().activeConnection;if(!u?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let d=await getWalletClient(n);if(!d)throw new Error("[QuasarSDK] EVM Signer not found");return h({isConnected:u.isConnected,address:u.address,chainType:"EVM",signer:d},{miniSession:s.current,setMiniSession:o.current},t)},[i,n,t]);return useEffect(()=>(a(l),()=>{a(null);}),[l]),null}export{R as a};
@@ -1 +0,0 @@
1
- import {a}from'./chunk-UW6TWEYM.mjs';import {h}from'./chunk-SF2BM2YA.mjs';import {useWalletAccountMessageSigner}from'@solana/react';import {useEffect,useRef,useCallback}from'react';import {jsx}from'react/jsx-runtime';function D({activeConnection:n,store:r,session:e,setSession:t,maxAge:i,onAddressMismatch:o}){return useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!r?null:jsx(p,{connectedAccount:n.connectedAccount,store:r,session:e,setSession:t,maxAge:i})}function p({connectedAccount:n,store:r,session:e,setSession:t,maxAge:i}){let o=useWalletAccountMessageSigner(n),l=useRef(o),d=useRef(e),A=useRef(t);useEffect(()=>{l.current=o;},[o]),useEffect(()=>{d.current=e;},[e]),useEffect(()=>{A.current=t;},[t]);let S=useCallback(async()=>{let a=r.getState().activeConnection;if(!a?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let f=l.current;if(!f)throw new Error("[QuasarSDK] Solana Message Signer not initialized.");return h({isConnected:a.isConnected,address:a.address,chainType:"SOLANA",signer:f},{miniSession:d.current,setMiniSession:A.current},i)},[r,i]);return useEffect(()=>(a(S),()=>{a(null);}),[S]),null}export{D as a};
@@ -1 +0,0 @@
1
- 'use strict';var zustand=require('zustand'),middleware=require('zustand/middleware');var d=(t=>(t.EVM="EVM",t.SOLANA="SOLANA",t))(d||{});var S=300*1e3,w=60*1e3,m=30*1e3;function y(e){return `Mini-Session Login: ${e}`}async function f(e){let r=new Date().toISOString(),t=y(r);if(e.chainType==="EVM"){let i=e.signer;try{return {signature:await i.signMessage({account:e.walletAddress,message:t}),timestamp:r}}catch(n){throw new Error(`[SDK] EVM signing failed: ${n.message}`,{cause:n})}}if(e.chainType==="SOLANA"){let i=e.signer,n;try{n=await import('gill');}catch(s){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:s})}try{let a=n.getUtf8Encoder().encode(t),o;if(i.modifyAndSignMessages){let g=n.createSignableMessage(a),[p]=await i.modifyAndSignMessages([g]),u=p.signatures[i.address];if(!u)throw new Error(`[SDK] Signature missing for address: ${i.address}`);o=u;}else if(i.signMessages){let[g]=await i.signMessages([a]);if(!g?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=g.signature;}else if(i.signMessage)o=await i.signMessage(a);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:n.getSignatureFromBytes(o),timestamp:r}}catch(s){throw new Error(`[SDK] Solana signing failed: ${s.message}`,{cause:s})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function b(e){let r=new Date(e.timestamp).getTime(),t=Date.now();if(isNaN(r))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let i=e.maxAge??S;if(t-r>i)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(r>t+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let n=y(e.timestamp);if(e.chainType==="EVM"){let s;try{s=await import('viem');}catch(a){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:a})}return await s.verifyMessage({address:e.walletAddress,message:n,signature:e.signature})}if(e.chainType==="SOLANA"){let s;try{s=await import('gill');}catch(a){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:a})}try{let a=s.address(e.walletAddress);return await s.verifySignatureForAddress(a,e.signature,n)}catch{return false}}return false}var c=null;function R(e="mini-session-storage"){return zustand.create()(middleware.persist(r=>({miniSession:null,setMiniSession:t=>r({miniSession:t}),clearSession:()=>r({miniSession:null})}),{name:e}))}async function C(e,r,t=S){let{isConnected:i,address:n,chainType:s,signer:a}=e;if(!i||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let o=r.miniSession;if(o&&o.walletAddress===n&&o.chainType===s){let l=Date.now(),g=new Date(o.timestamp).getTime();if(l-g<t-m)return o}return c||(c=f({signer:a,walletAddress:n,chainType:s}).then(l=>{let g={...l,chainType:s,walletAddress:n};return r.setMiniSession(g),g}).finally(()=>{c=null;})),c}exports.a=d;exports.b=S;exports.c=m;exports.d=y;exports.e=f;exports.f=b;exports.g=R;exports.h=C;
@@ -1 +0,0 @@
1
- 'use strict';var chunkHVUZ52OX_js=require('./chunk-HVUZ52OX.js'),chunkOJCR5A56_js=require('./chunk-OJCR5A56.js'),react$1=require('@solana/react'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function D({activeConnection:n,store:r,session:e,setSession:t,maxAge:i,onAddressMismatch:o}){return react.useEffect(()=>{e&&n?.address&&e.walletAddress!==n.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),t(null),o?.());},[n?.address,e,t,o]),!n?.isConnected||!r?null:jsxRuntime.jsx(p,{connectedAccount:n.connectedAccount,store:r,session:e,setSession:t,maxAge:i})}function p({connectedAccount:n,store:r,session:e,setSession:t,maxAge:i}){let o=react$1.useWalletAccountMessageSigner(n),l=react.useRef(o),d=react.useRef(e),A=react.useRef(t);react.useEffect(()=>{l.current=o;},[o]),react.useEffect(()=>{d.current=e;},[e]),react.useEffect(()=>{A.current=t;},[t]);let S=react.useCallback(async()=>{let a=r.getState().activeConnection;if(!a?.isConnected)throw new Error("[QuasarSDK] Wallet disconnected");let f=l.current;if(!f)throw new Error("[QuasarSDK] Solana Message Signer not initialized.");return chunkOJCR5A56_js.h({isConnected:a.isConnected,address:a.address,chainType:"SOLANA",signer:f},{miniSession:d.current,setMiniSession:A.current},i)},[r,i]);return react.useEffect(()=>(chunkHVUZ52OX_js.a(S),()=>{chunkHVUZ52OX_js.a(null);}),[S]),null}exports.a=D;
@@ -1 +0,0 @@
1
- import {create}from'zustand';import {persist}from'zustand/middleware';var d=(t=>(t.EVM="EVM",t.SOLANA="SOLANA",t))(d||{});var S=300*1e3,w=60*1e3,m=30*1e3;function y(e){return `Mini-Session Login: ${e}`}async function f(e){let r=new Date().toISOString(),t=y(r);if(e.chainType==="EVM"){let i=e.signer;try{return {signature:await i.signMessage({account:e.walletAddress,message:t}),timestamp:r}}catch(n){throw new Error(`[SDK] EVM signing failed: ${n.message}`,{cause:n})}}if(e.chainType==="SOLANA"){let i=e.signer,n;try{n=await import('gill');}catch(s){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:s})}try{let a=n.getUtf8Encoder().encode(t),o;if(i.modifyAndSignMessages){let g=n.createSignableMessage(a),[p]=await i.modifyAndSignMessages([g]),u=p.signatures[i.address];if(!u)throw new Error(`[SDK] Signature missing for address: ${i.address}`);o=u;}else if(i.signMessages){let[g]=await i.signMessages([a]);if(!g?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=g.signature;}else if(i.signMessage)o=await i.signMessage(a);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:n.getSignatureFromBytes(o),timestamp:r}}catch(s){throw new Error(`[SDK] Solana signing failed: ${s.message}`,{cause:s})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function b(e){let r=new Date(e.timestamp).getTime(),t=Date.now();if(isNaN(r))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let i=e.maxAge??S;if(t-r>i)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(r>t+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let n=y(e.timestamp);if(e.chainType==="EVM"){let s;try{s=await import('viem');}catch(a){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:a})}return await s.verifyMessage({address:e.walletAddress,message:n,signature:e.signature})}if(e.chainType==="SOLANA"){let s;try{s=await import('gill');}catch(a){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:a})}try{let a=s.address(e.walletAddress);return await s.verifySignatureForAddress(a,e.signature,n)}catch{return false}}return false}var c=null;function R(e="mini-session-storage"){return create()(persist(r=>({miniSession:null,setMiniSession:t=>r({miniSession:t}),clearSession:()=>r({miniSession:null})}),{name:e}))}async function C(e,r,t=S){let{isConnected:i,address:n,chainType:s,signer:a}=e;if(!i||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let o=r.miniSession;if(o&&o.walletAddress===n&&o.chainType===s){let l=Date.now(),g=new Date(o.timestamp).getTime();if(l-g<t-m)return o}return c||(c=f({signer:a,walletAddress:n,chainType:s}).then(l=>{let g={...l,chainType:s,walletAddress:n};return r.setMiniSession(g),g}).finally(()=>{c=null;})),c}export{d as a,S as b,m as c,y as d,f as e,b as f,R as g,C as h};
@@ -1 +0,0 @@
1
- var n=null;function t(e){n=e;}async function r(){for(let e=0;e<15;e++){if(n)return n();await new Promise(i=>setTimeout(i,200));}throw new Error("[QuasarSDK] Auth helper not initialized. Ensure QuasarAuthBridge is mounted and wallet is connected.")}export{t as a,r as b};
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- import {h as h$1,g,e,f,d as d$1}from'./chunk-SF2BM2YA.mjs';export{a as ChainType,b as DEFAULT_MAX_AGE,c as NETWORK_SAFETY_BUFFER,d as createMiniSessionMessage,g as createMiniSessionStore,h as getMiniSessionAuth,e as signMiniSession,f as verifyMiniSession}from'./chunk-SF2BM2YA.mjs';import {ofetch}from'ofetch';var m="https://api.tuwa.io",h="/v1/engine/pulsar/sync",d="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(t,e,r){super(t),this.name="QuasarSDKError",this.status=e,this.originalError=r;}},o=class{secretKey;internalSecret;baseUrl;timeout;constructor(t){if(!t.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=t.secretKey,this.internalSecret=t.internalSecret,this.baseUrl=t.baseUrl||m,this.timeout=t.timeout||1e4;}async request(t,e={}){try{return await ofetch(t,{baseURL:this.baseUrl,timeout:this.timeout,...e,headers:{"Content-Type":"application/json","x-tuwa-secret-key":this.secretKey,...this.internalSecret?{"x-internal-secret":this.internalSecret}:{},...e.headers}})}catch(r){throw this.buildError(r)}}buildError(t){let e=t,r=e.statusCode??e.response?.status,S=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (r===401||r===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${r}): ${S}`,r,e)}};var s=class{constructor(t){this.client=t;}async syncCreate(t,e){return this.client.request(h,{method:"POST",body:{...t,appName:e}})}async getHistory(t={}){return this.client.request(d,{method:"GET",query:{page:t.page??1,limit:t.limit??10,chainId:t.chainId,status:t.status,txKey:t.txKey,appName:t.appName,walletAddress:t.walletAddress}})}};var E={createMiniSessionMessage:d$1,verifyMiniSession:f,signMiniSession:e,createMiniSessionStore:g,getMiniSessionAuth:h$1},y=class{static utils=E;client;pulsar;constructor(t){this.client=new o(t),this.pulsar=new s(this.client);}};
2
- export{m as BASE_API_URL,d as PULSAR_HISTORY_ENDPOINT,h as PULSAR_SYNC_ENDPOINT,s as PulsarModule,y as Quasar,i as QuasarSDKError,E as utils};
@@ -1 +0,0 @@
1
- export{a as QuasarEvmAuthBridge}from'../chunk-EDXCZKX7.mjs';export{b as getMiniSessionAuth}from'../chunk-UW6TWEYM.mjs';import'../chunk-SF2BM2YA.mjs';
@@ -1 +0,0 @@
1
- export{a as QuasarSolanaAuthBridge}from'../chunk-ERWWKRPN.mjs';export{b as getMiniSessionAuth}from'../chunk-UW6TWEYM.mjs';import'../chunk-SF2BM2YA.mjs';
package/dist/react.mjs DELETED
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-EDXCZKX7.mjs';import {a}from'./chunk-ERWWKRPN.mjs';export{b as getMiniSessionAuth}from'./chunk-UW6TWEYM.mjs';import'./chunk-SF2BM2YA.mjs';import {useEffect}from'react';import {jsx}from'react/jsx-runtime';function C({activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n,onAddressMismatch:s}){let m=typeof r?.chainId=="string"?"SOLANA":"EVM";return useEffect(()=>{i&&r?.address&&i.walletAddress!==r.address&&(console.log("[QuasarSDK] Address mismatch detected, clearing session..."),o(null),s?.());},[r?.address,i,o,s]),!r?.isConnected||!e?null:m==="SOLANA"?jsx(a,{activeConnection:r,store:e,session:i,setSession:o,maxAge:n}):jsx(a$1,{activeConnection:r,store:e,wagmiConfig:d,session:i,setSession:o,maxAge:n})}export{C as QuasarAuthBridge};