@tuwaio/quasar-sdk 0.0.18 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,25 +7,24 @@
7
7
  <img src="https://cdn.jsdelivr.net/gh/TuwaIO/workflows@main/preview/repos/quasar_sdk.png" alt="Quasar SDK Architecture" width="100%" />
8
8
  </p>
9
9
 
10
- > The official **Layer 5 (L5)** server-side Node.js & Edge SDK for the **TUWA Quasar Cloud**, featuring built-in React authentication bridges.
10
+ > The official **Layer 5 (L5)** server-side Node.js & Edge SDK for the **TUWA Quasar Cloud**.
11
11
 
12
12
  ---
13
13
 
14
14
  ## 🏛️ What is `@tuwaio/quasar-sdk`?
15
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.
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 sync infrastructure states.
17
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.
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.
19
19
 
20
20
  ---
21
21
 
22
22
  ## ✨ Key Features
23
23
 
24
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.
25
+ - **🔐 Headless SIWX (CAIP-122) Auth Ready**: Seamlessly pairs with `@tuwaio/sdk/siwx/server` for strict cryptographic verification of user sessions before allowing database writes.
26
26
  - **⚡ Edge Ready**: Uses `ofetch` and lightweight cryptography to run seamlessly in Cloudflare Workers and Vercel Edge.
27
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
28
 
30
29
  ---
31
30
 
@@ -44,7 +43,8 @@ _Note: `ofetch` and `@tuwaio/pulsar-core` are required as peer dependencies to e
44
43
  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).
45
44
 
46
45
  ```typescript
47
- import { Quasar, MiniSessionAuth, utils } from '@tuwaio/quasar-sdk';
46
+ import { Quasar } from '@tuwaio/quasar-sdk';
47
+ import { verifySiwxPayload, type SiwxSession } from '@tuwaio/sdk/siwx/server';
48
48
  import type { Transaction } from '@tuwaio/sdk/pulsar';
49
49
 
50
50
  // Initialize Quasar with your Secret Key from the Dashboard
@@ -53,9 +53,9 @@ const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
53
53
  /**
54
54
  * Example Next.js Server Action to Sync a Transaction
55
55
  */
56
- export async function syncTransaction(tx: Transaction, authData: MiniSessionAuth) {
56
+ export async function syncTransaction(tx: Transaction, sessionData: SiwxSession) {
57
57
  // 1. Verify the client's signature (prevent unauthorized spoofing)
58
- const isValid = await utils.verifyMiniSession(authData);
58
+ const isValid = await verifySiwxPayload(sessionData);
59
59
  if (!isValid) throw new Error('Invalid signature.');
60
60
 
61
61
  // 2. Sync the transaction securely to the Quasar Cloud
@@ -68,9 +68,9 @@ export async function syncTransaction(tx: Transaction, authData: MiniSessionAuth
68
68
  */
69
69
  export async function getHistory(
70
70
  params: { walletAddress: string; page: number; limit: number; appName: string },
71
- authData: MiniSessionAuth,
71
+ sessionData: SiwxSession,
72
72
  ) {
73
- const isValid = await utils.verifyMiniSession(authData);
73
+ const isValid = await verifySiwxPayload(sessionData);
74
74
  if (!isValid) throw new Error('Invalid signature.');
75
75
 
76
76
  // Return the paginated transaction history
@@ -80,83 +80,19 @@ export async function getHistory(
80
80
 
81
81
  ---
82
82
 
83
- ## 🔐 React Authentication Bridge
83
+ ## 🔐 Frontend Authentication (SIWX)
84
84
 
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).
85
+ The Quasar SDK relies on the standard **SIWX (CAIP-122)** protocol for authenticating requests.
86
86
 
87
- ### 1. Create the Auth Store
87
+ You should use the headless `useSatelliteSiwxAutoAuth` hook provided by `@tuwaio/sdk/siwx` on your frontend. This hook automatically prompts users to sign a CAIP-122 message when they connect their wallet, and establishes a secure session with your backend.
88
88
 
89
- Before using the bridge, create a persistent Zustand store using the provided utility to manage the signature lifecycle.
90
-
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.
103
-
104
- ```tsx
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);
111
-
112
- return (
113
- <QuasarEvmAuthBridge
114
- activeConnection={activeConnection} // Structural interface for wallet state
115
- store={store} // Zustand store API
116
- wagmiConfig={wagmiConfig} // Wagmi config
117
- session={session} // Current session state
118
- setSession={setSession} // Session setter
119
- />
120
- );
121
- }
122
- ```
123
-
124
- ### Solana-Only Bridge (No EVM dependencies required)
125
-
126
- If your project only supports Solana, import from the `/react/solana` subpath.
127
-
128
- ```tsx
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);
135
-
136
- return (
137
- <QuasarSolanaAuthBridge
138
- activeConnection={activeConnection}
139
- store={store}
140
- session={session}
141
- setSession={setSession}
142
- />
143
- );
144
- }
145
- ```
146
-
147
- ### Unified Cross-Chain Bridge
148
-
149
- If your project supports both ecosystems and has all peer dependencies installed (`@wagmi/core`, `@solana/react`, etc.), you can use the unified bridge:
150
-
151
- ```tsx
152
- import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
153
- ```
89
+ For detailed frontend integration, see the [SIWX Documentation](https://sdk.docs.tuwa.io/quasar-cloud/react-bridges).
154
90
 
155
91
  ---
156
92
 
157
93
  ## 🌍 The Full Flow (Production Architecture)
158
94
 
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:
95
+ 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 **Pulsar Store** and **Headless SIWX** dance together effortlessly:
160
96
 
161
97
  ### 1. Define Your Transaction Types (`types.ts`)
162
98
 
@@ -186,39 +122,28 @@ Proxy calls to Quasar Cloud using your backend to protect secret keys.
186
122
  // src/app/actions.ts
187
123
  'use server';
188
124
 
189
- import { Quasar, MiniSessionAuth, utils } from '@tuwaio/quasar-sdk';
125
+ import { Quasar } from '@tuwaio/quasar-sdk';
126
+ import { verifySiwxPayload, type SiwxSession } from '@tuwaio/sdk/siwx/server';
190
127
  import { TransactionUnion } from '@/types';
191
128
 
192
129
  const quasar = new Quasar({ secretKey: process.env.QUASAR_SDK_SK ?? '' });
193
130
 
194
- export async function syncTransaction(tx: TransactionUnion, authData: MiniSessionAuth) {
195
- const isValid = await utils.verifyMiniSession(authData);
131
+ export async function syncTransaction(tx: TransactionUnion, sessionData: SiwxSession) {
132
+ const isValid = await verifySiwxPayload(sessionData);
196
133
  if (!isValid) throw new Error('Invalid signature.');
197
134
 
198
135
  await quasar.pulsar.syncCreate(tx, 'My App');
199
136
  return { success: true };
200
137
  }
201
138
 
202
- export async function getHistory(params: any, authData: MiniSessionAuth) {
203
- const isValid = await utils.verifyMiniSession(authData);
139
+ export async function getHistory(params: any, sessionData: SiwxSession) {
140
+ const isValid = await verifySiwxPayload(sessionData);
204
141
  if (!isValid) throw new Error('Invalid signature.');
205
142
 
206
143
  return quasar.pulsar.getHistory(params);
207
144
  }
208
145
  ```
209
146
 
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
147
  ```ts
223
148
  // src/hooks/usePulsarStore.ts
224
149
  'use client';
@@ -226,7 +151,8 @@ export const useAuthStore = utils.createMiniSessionStore('quasar-mini-session-st
226
151
  import { createPulsarStore, createTxInMemoryStore, createBoundedUseStore } from '@tuwaio/sdk/pulsar';
227
152
  import { pulsarEvmAdapter } from '@tuwaio/evm-sdk/pulsar';
228
153
  import { pulsarSolanaAdapter } from '@tuwaio/solana-sdk/pulsar';
229
- import { getMiniSessionAuth } from '@tuwaio/quasar-sdk/react';
154
+ import { useSiwxSessionStore } from '@tuwaio/sdk/siwx';
155
+ import { preFlightTxCheck } from '@tuwaio/quasar-sdk';
230
156
 
231
157
  import { getHistory, syncTransaction } from '@/app/actions';
232
158
  import { wagmiConfig, appEVMChains, solanaRPCUrls } from '@/configs/appConfig';
@@ -238,14 +164,16 @@ const initialStore = createPulsarStore<TransactionUnion>({
238
164
  name: storageName,
239
165
  adapter: [pulsarEvmAdapter(wagmiConfig, appEVMChains), pulsarSolanaAdapter({ rpcUrls: solanaRPCUrls })],
240
166
  beforeTxProcess: async () => {
241
- // Ensures we have a valid signature before executing any blockchain logic
242
- await getMiniSessionAuth();
167
+ // Ensures we have a valid SIWX session and Quasar Cloud is reachable before executing blockchain logic
168
+ await preFlightTxCheck();
243
169
  },
244
170
  onRemoteCreate: async (tx) => {
245
171
  try {
246
172
  // Syncs the new transaction to Quasar via Next.js Server Actions
247
- const auth = await getMiniSessionAuth();
248
- await syncTransaction(tx as TransactionUnion, auth);
173
+ const session = useSiwxSessionStore.getState().session;
174
+ if (session) {
175
+ await syncTransaction(tx as TransactionUnion, session);
176
+ }
249
177
  } catch (err) {
250
178
  console.error('[PulsarHook] Remote sync failed:', err);
251
179
  }
@@ -259,8 +187,10 @@ const pulsarInMemoryStore = createTxInMemoryStore<TransactionUnion>({
259
187
  localTransactionsPool: initialStore.getState().transactionsPool,
260
188
  getHistory: async ({ page, walletAddress }) => {
261
189
  try {
262
- const auth = await getMiniSessionAuth();
263
- const history = await getHistory({ walletAddress, page, limit: 10, appName: 'My App' }, auth);
190
+ const session = useSiwxSessionStore.getState().session;
191
+ if (!session) return null;
192
+
193
+ const history = await getHistory({ walletAddress, page, limit: 10, appName: 'My App' }, session);
264
194
 
265
195
  if (!history) return null;
266
196
 
@@ -280,49 +210,7 @@ initialStore.subscribe((state) => pulsarInMemoryStore.getState().syncWithLocalPo
280
210
  export const usePulsarInMemoryStore = createBoundedUseStore(pulsarInMemoryStore);
281
211
  ```
282
212
 
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;
312
-
313
- return (
314
- <QuasarSDKAuthBridge
315
- activeConnection={activeConnection as QuasarActiveConnection}
316
- store={store as any}
317
- wagmiConfig={wagmiConfig}
318
- session={session}
319
- setSession={setSession}
320
- />
321
- );
322
- }
323
- ```
324
-
325
- ### 6. Nova Transactions Provider (`NovaTransactionsProvider.tsx`)
213
+ ### 4. Nova Transactions Provider (`NovaTransactionsProvider.tsx`)
326
214
 
327
215
  ```tsx
328
216
  // src/providers/NovaTransactionsProvider.tsx
@@ -361,24 +249,24 @@ export function NovaTransactionsProvider({ pagination }: { pagination: TxInMemor
361
249
  }
362
250
  ```
363
251
 
364
- ### 7. The Seamless UI Integration (`AppProviders.tsx`)
252
+ ### 5. The Seamless UI Integration (`AppProviders.tsx`)
365
253
 
366
254
  ```tsx
367
255
  // src/providers/AppProviders.tsx
368
256
  'use client';
369
257
 
370
- import { SatelliteConnectProvider } from '@tuwaio/sdk/satellite';
258
+ import { SatelliteConnectProvider, useSatelliteConnection } from '@tuwaio/sdk/satellite';
371
259
  import { NovaConnectProvider } from '@tuwaio/sdk/nova-connect';
372
260
  import { satelliteEVMAdapter } from '@tuwaio/evm-sdk/satellite';
373
261
  import { EVMConnectorsWatcher } from '@tuwaio/evm-sdk/nova-connect';
374
262
  import { satelliteSolanaAdapter } from '@tuwaio/solana-sdk/satellite';
375
263
  import { SolanaConnectorsWatcher } from '@tuwaio/solana-sdk/nova-connect';
376
- import { getMiniSessionAuth } from '@tuwaio/quasar-sdk/react';
264
+ import { useSiwx, useSiwxSession } from '@tuwaio/sdk/siwx';
265
+ import { isSafeApp, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/sdk/orbit';
377
266
 
378
267
  import { appEVMChains, solanaRPCUrls, wagmiConfig } from '@/configs/appConfig';
379
268
  import { usePulsarInMemoryStore, usePulsarStore } from '@/hooks/usePulsarStore';
380
269
  import { NovaTransactionsProvider } from '@/providers/NovaTransactionsProvider';
381
- import { QuasarAuthBridge } from '@/providers/QuasarSDKAuthProvider';
382
270
 
383
271
  export function AppProviders({ children }: { children: React.ReactNode }) {
384
272
  const getAdapter = usePulsarStore((state) => state.getAdapter);
@@ -393,31 +281,35 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
393
281
 
394
282
  const pagination = { isLoading, isError, currentPage, hasMore, fetchNextPage };
395
283
 
284
+ // Watch SIWX session to keep connection state aligned
285
+ const siwxSession = useSiwxSession();
286
+ const { signIn } = useSiwx();
287
+
396
288
  return (
397
289
  <SatelliteConnectProvider
398
290
  adapter={[satelliteEVMAdapter(wagmiConfig, appEVMChains), satelliteSolanaAdapter({ rpcUrls: solanaRPCUrls })]}
399
291
  autoConnect={true}
400
292
  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
- }
293
+ const isEVM = getAdapterFromConnectorType(connection.connectorType) === OrbitAdapter.EVM;
294
+ if (isEVM && isSafeApp) return;
295
+
296
+ // Trigger SIWX flow
297
+ await signIn();
298
+
299
+ // Fetch history slightly after connection and sign-in
300
+ setTimeout(() => fetchInitial(connection.address), 2000);
408
301
  }}
409
302
  >
410
- <EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
411
- <SolanaConnectorsWatcher />
303
+ <EVMConnectorsWatcher wagmiConfig={wagmiConfig} siwx={siwxSession} />
304
+ <SolanaConnectorsWatcher siwx={siwxSession} />
412
305
 
413
- <QuasarAuthBridge />
414
306
  <NovaTransactionsProvider pagination={pagination} />
415
307
 
416
308
  <NovaConnectProvider
417
309
  appChains={appEVMChains}
418
310
  solanaRPCUrls={solanaRPCUrls}
419
311
  transactionPool={transactionsPool}
420
- pulsarAdapter={getAdapter() as any}
312
+ pulsarAdapter={getAdapter()}
421
313
  withImpersonated
422
314
  withBalance
423
315
  withChain
@@ -430,7 +322,7 @@ export function AppProviders({ children }: { children: React.ReactNode }) {
430
322
  }
431
323
  ```
432
324
 
433
- ### 8. Creating a Transaction (Usage)
325
+ ### 6. Creating a Transaction (Usage)
434
326
 
435
327
  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
328
 
@@ -485,12 +377,10 @@ export function SwapButton() {
485
377
 
486
378
  ## 📦 Available Namespaces
487
379
 
488
- This package provides the following server-side utilities and React bridges:
380
+ This package provides the following server-side utilities and React helpers:
489
381
 
490
382
  - `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.
383
+ - `preFlightTxCheck` — A client-side helper to ensure the user has a valid SIWX session and Quasar Cloud is reachable before prompting wallet signatures.
494
384
 
495
385
  ---
496
386
 
package/dist/index.cjs CHANGED
@@ -1 +1,2 @@
1
- 'use strict';var chunkUIDJZGQ7_cjs=require('./chunk-UIDJZGQ7.cjs'),chunkNJH5FYLU_cjs=require('./chunk-NJH5FYLU.cjs'),ofetch=require('ofetch');var i=class extends Error{status;originalError;constructor(r,e,t){super(r),this.name="QuasarSDKError",this.status=e,this.originalError=t;}},o=class{secretKey;internalSecret;baseUrl;timeout;constructor(r){if(!r.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=r.secretKey,this.internalSecret=r.internalSecret,this.baseUrl=r.baseUrl||chunkNJH5FYLU_cjs.a,this.timeout=r.timeout||1e4;}async request(r,e={}){try{return await ofetch.ofetch(r,{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(t){throw this.buildError(t)}}buildError(r){let e=r,t=e.statusCode??e.response?.status,S=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (t===401||t===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${t}): ${S}`,t,e)}};var s=class{constructor(r){this.client=r;}async syncCreate(r,e){return this.client.request(chunkNJH5FYLU_cjs.b,{method:"POST",body:{...r,appName:e}})}async getHistory(r={}){return this.client.request(chunkNJH5FYLU_cjs.c,{method:"GET",query:{page:r.page??1,limit:r.limit??10,chainId:r.chainId,status:r.status,txKey:r.txKey,appName:r.appName,walletAddress:r.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(r){this.client=new o(r),this.pulsar=new s(this.client);}};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}});Object.defineProperty(exports,"BASE_API_URL",{enumerable:true,get:function(){return chunkNJH5FYLU_cjs.a}});Object.defineProperty(exports,"PULSAR_HISTORY_ENDPOINT",{enumerable:true,get:function(){return chunkNJH5FYLU_cjs.c}});Object.defineProperty(exports,"PULSAR_SYNC_ENDPOINT",{enumerable:true,get:function(){return chunkNJH5FYLU_cjs.b}});exports.PulsarModule=s;exports.Quasar=y;exports.QuasarSDKError=i;exports.utils=E;
1
+ 'use strict';var siwxReact=require('@tuwaio/siwx-react'),ofetch=require('ofetch');var a="https://api.tuwa.io",c="/v1/engine/pulsar/sync",u="/v1/engine/pulsar/history";var i=class extends Error{status;originalError;constructor(r,e,t){super(r),this.name="QuasarSDKError",this.status=e,this.originalError=t;}},n=class{secretKey;internalSecret;baseUrl;timeout;constructor(r){if(!r.secretKey)throw new Error("[Quasar SDK] Missing API Key. Provide a secretKey starting with sk_live_.");this.secretKey=r.secretKey,this.internalSecret=r.internalSecret,this.baseUrl=r.baseUrl||a,this.timeout=r.timeout||1e4;}async request(r,e={}){try{return await ofetch.ofetch(r,{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(t){throw this.buildError(t)}}buildError(r){let e=r,t=e.statusCode??e.response?.status,p=(e.data??e.response?._data)?.error??e.message??"Unknown Error";return (t===401||t===403)&&console.error("\u{1F6A8} [Quasar SDK] Auth Error. Check your Secret Key and scopes."),new i(`[Quasar SDK] Request Failed (${t}): ${p}`,t,e)}};var o=class{constructor(r){this.client=r;}async syncCreate(r,e){return this.client.request(c,{method:"POST",body:{...r,appName:e}})}async getHistory(r={}){return this.client.request(u,{method:"GET",query:{page:r.page??1,limit:r.limit??10,chainId:r.chainId,status:r.status,txKey:r.txKey,appName:r.appName,walletAddress:r.walletAddress}})}};async function Q(s){if(!siwxReact.useSiwxSessionStore.getState().session)throw new Error("[QuasarSDK] No SIWX Session found. User must be signed in.");let e=s||a;try{let t=await fetch(`${e}/v1/engine/monitoring/health`,{method:"GET",cache:"no-store"});if(!t.ok)throw new Error(`[QuasarSDK] API Health check failed with status: ${t.status}`)}catch(t){throw new Error("[QuasarSDK] Quasar Cloud Engine is currently unreachable.",{cause:t})}}var l=class{client;pulsar;constructor(r){this.client=new n(r),this.pulsar=new o(this.client);}};
2
+ exports.BASE_API_URL=a;exports.PULSAR_HISTORY_ENDPOINT=u;exports.PULSAR_SYNC_ENDPOINT=c;exports.PulsarModule=o;exports.Quasar=l;exports.QuasarSDKError=i;exports.preFlightTxCheck=Q;