@tuwaio/quasar-sdk 0.0.7 → 0.0.9
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 +46 -3
- package/dist/chunk-7F6I4FHE.js +1 -0
- package/dist/chunk-EDXCZKX7.mjs +1 -0
- package/dist/chunk-ERWWKRPN.mjs +1 -0
- package/dist/chunk-HVUZ52OX.js +1 -0
- package/dist/chunk-OJCR5A56.js +1 -0
- package/dist/chunk-RZ4TLBSP.js +1 -0
- package/dist/chunk-SF2BM2YA.mjs +1 -0
- package/dist/chunk-UW6TWEYM.mjs +1 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/react/evm.d.mts +56 -0
- package/dist/react/evm.d.ts +56 -0
- package/dist/react/evm.js +1 -0
- package/dist/react/evm.mjs +1 -0
- package/dist/react/solana.d.mts +52 -0
- package/dist/react/solana.d.ts +52 -0
- package/dist/react/solana.js +1 -0
- package/dist/react/solana.mjs +1 -0
- package/dist/react.d.mts +19 -37
- package/dist/react.d.ts +19 -37
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/shared-BeprN_w-.d.ts +35 -0
- package/dist/shared-CFhEPXTt.d.mts +35 -0
- package/package.json +11 -1
- package/dist/chunk-HJ3SAN77.mjs +0 -1
- package/dist/chunk-M56HRFZC.js +0 -1
package/README.md
CHANGED
|
@@ -43,14 +43,18 @@ const history = await quasar.pulsar.getHistory({ chainId: 1 });
|
|
|
43
43
|
|
|
44
44
|
## React Authentication Bridge
|
|
45
45
|
|
|
46
|
-
The SDK provides
|
|
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:
|
|
47
|
+
|
|
48
|
+
### 1. EVM-Only Bridge (No Solana dependencies required)
|
|
49
|
+
|
|
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.
|
|
47
51
|
|
|
48
52
|
```tsx
|
|
49
|
-
import {
|
|
53
|
+
import { QuasarEvmAuthBridge } from '@tuwaio/quasar-sdk/react/evm';
|
|
50
54
|
|
|
51
55
|
function MyApp() {
|
|
52
56
|
return (
|
|
53
|
-
<
|
|
57
|
+
<QuasarEvmAuthBridge
|
|
54
58
|
activeConnection={activeConnection} // Structural interface for wallet state
|
|
55
59
|
store={store} // Zustand store API
|
|
56
60
|
wagmiConfig={config} // Wagmi config
|
|
@@ -61,6 +65,45 @@ function MyApp() {
|
|
|
61
65
|
}
|
|
62
66
|
```
|
|
63
67
|
|
|
68
|
+
### 2. Solana-Only Bridge (No EVM dependencies required)
|
|
69
|
+
|
|
70
|
+
If your project only supports Solana, import from the `/react/solana` subpath. This avoids compile-time errors if `@wagmi/core` is not installed.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { QuasarSolanaAuthBridge } from '@tuwaio/quasar-sdk/react/solana';
|
|
74
|
+
|
|
75
|
+
function MyApp() {
|
|
76
|
+
return (
|
|
77
|
+
<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
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Unified Cross-Chain Bridge
|
|
88
|
+
|
|
89
|
+
If your project supports both ecosystems and has all peer dependencies installed, you can use the unified bridge:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
|
|
93
|
+
|
|
94
|
+
function MyApp() {
|
|
95
|
+
return (
|
|
96
|
+
<QuasarAuthBridge
|
|
97
|
+
activeConnection={activeConnection}
|
|
98
|
+
store={store}
|
|
99
|
+
wagmiConfig={config}
|
|
100
|
+
session={miniSession}
|
|
101
|
+
setSession={setMiniSession}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
64
107
|
## Modules
|
|
65
108
|
|
|
66
109
|
### Pulsar — `quasar.pulsar`
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -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 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;
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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.d.mts
CHANGED
|
@@ -287,6 +287,9 @@ declare function createMiniSessionStore(storageName?: string): zustand.UseBoundS
|
|
|
287
287
|
*
|
|
288
288
|
* @param connection - The current active wallet connection data (address, signer, etc).
|
|
289
289
|
* @param store - A store implementation (Zustand or compatible) for session persistence.
|
|
290
|
+
* @param maxAge - Maximum allowed session age in milliseconds. Must match the value
|
|
291
|
+
* passed to `verifyMiniSession` to keep cache and verification in sync.
|
|
292
|
+
* Defaults to `DEFAULT_MAX_AGE` (5 minutes).
|
|
290
293
|
* @returns A promise resolving to a valid MiniSessionAuth object.
|
|
291
294
|
* @throws {Error} If the wallet is disconnected or signing fails.
|
|
292
295
|
*
|
|
@@ -295,7 +298,7 @@ declare function createMiniSessionStore(storageName?: string): zustand.UseBoundS
|
|
|
295
298
|
declare function getMiniSessionAuth(connection: ConnectionData, store: {
|
|
296
299
|
miniSession: MiniSessionAuth | null;
|
|
297
300
|
setMiniSession: (session: MiniSessionAuth | null) => void;
|
|
298
|
-
}): Promise<MiniSessionAuth>;
|
|
301
|
+
}, maxAge?: number): Promise<MiniSessionAuth>;
|
|
299
302
|
|
|
300
303
|
declare const BASE_API_URL = "https://api.tuwa.io";
|
|
301
304
|
declare const PULSAR_SYNC_ENDPOINT = "/v1/engine/pulsar/sync";
|
package/dist/index.d.ts
CHANGED
|
@@ -287,6 +287,9 @@ declare function createMiniSessionStore(storageName?: string): zustand.UseBoundS
|
|
|
287
287
|
*
|
|
288
288
|
* @param connection - The current active wallet connection data (address, signer, etc).
|
|
289
289
|
* @param store - A store implementation (Zustand or compatible) for session persistence.
|
|
290
|
+
* @param maxAge - Maximum allowed session age in milliseconds. Must match the value
|
|
291
|
+
* passed to `verifyMiniSession` to keep cache and verification in sync.
|
|
292
|
+
* Defaults to `DEFAULT_MAX_AGE` (5 minutes).
|
|
290
293
|
* @returns A promise resolving to a valid MiniSessionAuth object.
|
|
291
294
|
* @throws {Error} If the wallet is disconnected or signing fails.
|
|
292
295
|
*
|
|
@@ -295,7 +298,7 @@ declare function createMiniSessionStore(storageName?: string): zustand.UseBoundS
|
|
|
295
298
|
declare function getMiniSessionAuth(connection: ConnectionData, store: {
|
|
296
299
|
miniSession: MiniSessionAuth | null;
|
|
297
300
|
setMiniSession: (session: MiniSessionAuth | null) => void;
|
|
298
|
-
}): Promise<MiniSessionAuth>;
|
|
301
|
+
}, maxAge?: number): Promise<MiniSessionAuth>;
|
|
299
302
|
|
|
300
303
|
declare const BASE_API_URL = "https://api.tuwa.io";
|
|
301
304
|
declare const PULSAR_SYNC_ENDPOINT = "/v1/engine/pulsar/sync";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
Object.defineProperty(exports,"ChainType",{enumerable:true,get:function(){return
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {h as h$1,g,e,f,d as d$1}from'./chunk-
|
|
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
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,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Config } from '@wagmi/core';
|
|
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';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the QuasarEvmAuthBridge component.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
interface QuasarEvmAuthBridgeProps {
|
|
14
|
+
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
15
|
+
activeConnection: QuasarActiveConnection | null | undefined;
|
|
16
|
+
/** The state store API (usually from SatelliteStoreContext). */
|
|
17
|
+
store: StoreApi<unknown>;
|
|
18
|
+
/** The Wagmi configuration instance for EVM signing. */
|
|
19
|
+
wagmiConfig: Config;
|
|
20
|
+
/** The current Mini-Session authentication data from your state store. */
|
|
21
|
+
session: MiniSessionAuth | null;
|
|
22
|
+
/** Callback to update the session in your state store. */
|
|
23
|
+
setSession: (session: MiniSessionAuth | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
26
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
27
|
+
* Defaults to 5 minutes.
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
30
|
+
/** Optional callback triggered when an address mismatch is detected. */
|
|
31
|
+
onAddressMismatch?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The Quasar EVM Authentication Bridge.
|
|
35
|
+
*
|
|
36
|
+
* This component orchestrates signature requests specifically for EVM wallets,
|
|
37
|
+
* avoiding any Solana library dependencies.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { QuasarEvmAuthBridge } from '@tuwaio/quasar-sdk/react/evm';
|
|
42
|
+
*
|
|
43
|
+
* <QuasarEvmAuthBridge
|
|
44
|
+
* activeConnection={activeConnection}
|
|
45
|
+
* store={store}
|
|
46
|
+
* wagmiConfig={config}
|
|
47
|
+
* session={auth.miniSession}
|
|
48
|
+
* setSession={auth.setMiniSession}
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
55
|
+
|
|
56
|
+
export { QuasarActiveConnection, QuasarEvmAuthBridge, type QuasarEvmAuthBridgeProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Config } from '@wagmi/core';
|
|
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';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the QuasarEvmAuthBridge component.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
interface QuasarEvmAuthBridgeProps {
|
|
14
|
+
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
15
|
+
activeConnection: QuasarActiveConnection | null | undefined;
|
|
16
|
+
/** The state store API (usually from SatelliteStoreContext). */
|
|
17
|
+
store: StoreApi<unknown>;
|
|
18
|
+
/** The Wagmi configuration instance for EVM signing. */
|
|
19
|
+
wagmiConfig: Config;
|
|
20
|
+
/** The current Mini-Session authentication data from your state store. */
|
|
21
|
+
session: MiniSessionAuth | null;
|
|
22
|
+
/** Callback to update the session in your state store. */
|
|
23
|
+
setSession: (session: MiniSessionAuth | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
26
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
27
|
+
* Defaults to 5 minutes.
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
30
|
+
/** Optional callback triggered when an address mismatch is detected. */
|
|
31
|
+
onAddressMismatch?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The Quasar EVM Authentication Bridge.
|
|
35
|
+
*
|
|
36
|
+
* This component orchestrates signature requests specifically for EVM wallets,
|
|
37
|
+
* avoiding any Solana library dependencies.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { QuasarEvmAuthBridge } from '@tuwaio/quasar-sdk/react/evm';
|
|
42
|
+
*
|
|
43
|
+
* <QuasarEvmAuthBridge
|
|
44
|
+
* activeConnection={activeConnection}
|
|
45
|
+
* store={store}
|
|
46
|
+
* wagmiConfig={config}
|
|
47
|
+
* session={auth.miniSession}
|
|
48
|
+
* setSession={auth.setMiniSession}
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
declare function QuasarEvmAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarEvmAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
55
|
+
|
|
56
|
+
export { QuasarActiveConnection, QuasarEvmAuthBridge, type QuasarEvmAuthBridgeProps };
|
|
@@ -0,0 +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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as QuasarEvmAuthBridge}from'../chunk-EDXCZKX7.mjs';export{b as getMiniSessionAuth}from'../chunk-UW6TWEYM.mjs';import'../chunk-SF2BM2YA.mjs';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
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';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Props for the QuasarSolanaAuthBridge component.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface QuasarSolanaAuthBridgeProps {
|
|
13
|
+
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
14
|
+
activeConnection: QuasarActiveConnection | null | undefined;
|
|
15
|
+
/** The state store API (usually from SatelliteStoreContext). */
|
|
16
|
+
store: StoreApi<unknown>;
|
|
17
|
+
/** The current Mini-Session authentication data from your state store. */
|
|
18
|
+
session: MiniSessionAuth | null;
|
|
19
|
+
/** Callback to update the session in your state store. */
|
|
20
|
+
setSession: (session: MiniSessionAuth | null) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
23
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
24
|
+
* Defaults to 5 minutes.
|
|
25
|
+
*/
|
|
26
|
+
maxAge?: number;
|
|
27
|
+
/** Optional callback triggered when an address mismatch is detected. */
|
|
28
|
+
onAddressMismatch?: () => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The Quasar Solana Authentication Bridge.
|
|
32
|
+
*
|
|
33
|
+
* This component orchestrates signature requests specifically for Solana wallets,
|
|
34
|
+
* avoiding any EVM / Wagmi library dependencies.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { QuasarSolanaAuthBridge } from '@tuwaio/quasar-sdk/react/solana';
|
|
39
|
+
*
|
|
40
|
+
* <QuasarSolanaAuthBridge
|
|
41
|
+
* activeConnection={activeConnection}
|
|
42
|
+
* store={store}
|
|
43
|
+
* session={auth.miniSession}
|
|
44
|
+
* setSession={auth.setMiniSession}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
51
|
+
|
|
52
|
+
export { QuasarActiveConnection, QuasarSolanaAuthBridge, type QuasarSolanaAuthBridgeProps };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
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';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Props for the QuasarSolanaAuthBridge component.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface QuasarSolanaAuthBridgeProps {
|
|
13
|
+
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
14
|
+
activeConnection: QuasarActiveConnection | null | undefined;
|
|
15
|
+
/** The state store API (usually from SatelliteStoreContext). */
|
|
16
|
+
store: StoreApi<unknown>;
|
|
17
|
+
/** The current Mini-Session authentication data from your state store. */
|
|
18
|
+
session: MiniSessionAuth | null;
|
|
19
|
+
/** Callback to update the session in your state store. */
|
|
20
|
+
setSession: (session: MiniSessionAuth | null) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
23
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
24
|
+
* Defaults to 5 minutes.
|
|
25
|
+
*/
|
|
26
|
+
maxAge?: number;
|
|
27
|
+
/** Optional callback triggered when an address mismatch is detected. */
|
|
28
|
+
onAddressMismatch?: () => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The Quasar Solana Authentication Bridge.
|
|
32
|
+
*
|
|
33
|
+
* This component orchestrates signature requests specifically for Solana wallets,
|
|
34
|
+
* avoiding any EVM / Wagmi library dependencies.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { QuasarSolanaAuthBridge } from '@tuwaio/quasar-sdk/react/solana';
|
|
39
|
+
*
|
|
40
|
+
* <QuasarSolanaAuthBridge
|
|
41
|
+
* activeConnection={activeConnection}
|
|
42
|
+
* store={store}
|
|
43
|
+
* session={auth.miniSession}
|
|
44
|
+
* setSession={auth.setMiniSession}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare function QuasarSolanaAuthBridge({ activeConnection, store, session, setSession, maxAge, onAddressMismatch, }: QuasarSolanaAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
51
|
+
|
|
52
|
+
export { QuasarActiveConnection, QuasarSolanaAuthBridge, type QuasarSolanaAuthBridgeProps };
|
|
@@ -0,0 +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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as QuasarSolanaAuthBridge}from'../chunk-ERWWKRPN.mjs';export{b as getMiniSessionAuth}from'../chunk-UW6TWEYM.mjs';import'../chunk-SF2BM2YA.mjs';
|
package/dist/react.d.mts
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Config } from '@wagmi/core';
|
|
3
|
-
import { UiWalletAccount } from '@wallet-standard/react';
|
|
4
3
|
import { StoreApi } from 'zustand';
|
|
5
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';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
interface QuasarActiveConnection {
|
|
12
|
-
/** Whether the wallet is currently connected. */
|
|
13
|
-
isConnected: boolean;
|
|
14
|
-
/** The active wallet address. */
|
|
15
|
-
address: string;
|
|
16
|
-
/** The chain ID (number for EVM, string for Solana). */
|
|
17
|
-
chainId: string | number;
|
|
18
|
-
/** The UiWalletAccount object (required for Solana signing). */
|
|
19
|
-
connectedAccount?: UiWalletAccount;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Static utility to retrieve or trigger a Mini-Session authentication.
|
|
23
|
-
* This is the primary way for services outside the React tree to get an auth token.
|
|
24
|
-
*
|
|
25
|
-
* @returns A promise resolving to the valid Mini-Session Auth.
|
|
26
|
-
* @throws {Error} If the bridge is not mounted or the wallet is disconnected.
|
|
9
|
+
* Props for the unified QuasarAuthBridge component.
|
|
27
10
|
*
|
|
28
11
|
* @public
|
|
29
12
|
*/
|
|
30
|
-
declare function getMiniSessionAuth(): Promise<MiniSessionAuth>;
|
|
31
|
-
/**
|
|
32
|
-
* Props for the QuasarAuthBridge component.
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
13
|
interface QuasarAuthBridgeProps {
|
|
36
14
|
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
37
15
|
activeConnection: QuasarActiveConnection | null | undefined;
|
|
@@ -43,24 +21,28 @@ interface QuasarAuthBridgeProps {
|
|
|
43
21
|
session: MiniSessionAuth | null;
|
|
44
22
|
/** Callback to update the session in your state store. */
|
|
45
23
|
setSession: (session: MiniSessionAuth | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
26
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
27
|
+
* Defaults to 5 minutes.
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
46
30
|
/** Optional callback triggered when an address mismatch is detected. */
|
|
47
31
|
onAddressMismatch?: () => void;
|
|
48
32
|
}
|
|
49
33
|
/**
|
|
50
|
-
* The Quasar Authentication Bridge.
|
|
51
|
-
*
|
|
52
|
-
* This component orchestrates signature requests across Solana and EVM ecosystems.
|
|
53
|
-
* It decouples the SDK from specific library hooks by accepting connection data as props.
|
|
34
|
+
* The Unified Quasar Authentication Bridge.
|
|
54
35
|
*
|
|
55
|
-
* It
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
36
|
+
* This component acts as a unified cross-chain coordinator. It dynamically
|
|
37
|
+
* renders either the EVM or Solana specific bridges based on the connection type.
|
|
38
|
+
* Note: importing this component requires having both `@wagmi/core` and `@solana/react` installed.
|
|
39
|
+
* If you only need EVM or Solana bindings, import directly from the corresponding subpath:
|
|
40
|
+
* - `@tuwaio/quasar-sdk/react/evm`
|
|
41
|
+
* - `@tuwaio/quasar-sdk/react/solana`
|
|
59
42
|
*
|
|
60
43
|
* @example
|
|
61
44
|
* ```tsx
|
|
62
|
-
*
|
|
63
|
-
* const store = useContext(SatelliteStoreContext);
|
|
45
|
+
* import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
|
|
64
46
|
*
|
|
65
47
|
* <QuasarAuthBridge
|
|
66
48
|
* activeConnection={activeConnection}
|
|
@@ -73,6 +55,6 @@ interface QuasarAuthBridgeProps {
|
|
|
73
55
|
*
|
|
74
56
|
* @public
|
|
75
57
|
*/
|
|
76
|
-
declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
77
59
|
|
|
78
|
-
export {
|
|
60
|
+
export { QuasarActiveConnection, QuasarAuthBridge, type QuasarAuthBridgeProps };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Config } from '@wagmi/core';
|
|
3
|
-
import { UiWalletAccount } from '@wallet-standard/react';
|
|
4
3
|
import { StoreApi } from 'zustand';
|
|
5
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';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
interface QuasarActiveConnection {
|
|
12
|
-
/** Whether the wallet is currently connected. */
|
|
13
|
-
isConnected: boolean;
|
|
14
|
-
/** The active wallet address. */
|
|
15
|
-
address: string;
|
|
16
|
-
/** The chain ID (number for EVM, string for Solana). */
|
|
17
|
-
chainId: string | number;
|
|
18
|
-
/** The UiWalletAccount object (required for Solana signing). */
|
|
19
|
-
connectedAccount?: UiWalletAccount;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Static utility to retrieve or trigger a Mini-Session authentication.
|
|
23
|
-
* This is the primary way for services outside the React tree to get an auth token.
|
|
24
|
-
*
|
|
25
|
-
* @returns A promise resolving to the valid Mini-Session Auth.
|
|
26
|
-
* @throws {Error} If the bridge is not mounted or the wallet is disconnected.
|
|
9
|
+
* Props for the unified QuasarAuthBridge component.
|
|
27
10
|
*
|
|
28
11
|
* @public
|
|
29
12
|
*/
|
|
30
|
-
declare function getMiniSessionAuth(): Promise<MiniSessionAuth>;
|
|
31
|
-
/**
|
|
32
|
-
* Props for the QuasarAuthBridge component.
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
13
|
interface QuasarAuthBridgeProps {
|
|
36
14
|
/** The active connection object (usually from useSatelliteConnectStore). */
|
|
37
15
|
activeConnection: QuasarActiveConnection | null | undefined;
|
|
@@ -43,24 +21,28 @@ interface QuasarAuthBridgeProps {
|
|
|
43
21
|
session: MiniSessionAuth | null;
|
|
44
22
|
/** Callback to update the session in your state store. */
|
|
45
23
|
setSession: (session: MiniSessionAuth | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum session age in milliseconds. Must be the same value passed to
|
|
26
|
+
* `verifyMiniSession` — this is the single source of truth for session lifetime.
|
|
27
|
+
* Defaults to 5 minutes.
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
46
30
|
/** Optional callback triggered when an address mismatch is detected. */
|
|
47
31
|
onAddressMismatch?: () => void;
|
|
48
32
|
}
|
|
49
33
|
/**
|
|
50
|
-
* The Quasar Authentication Bridge.
|
|
51
|
-
*
|
|
52
|
-
* This component orchestrates signature requests across Solana and EVM ecosystems.
|
|
53
|
-
* It decouples the SDK from specific library hooks by accepting connection data as props.
|
|
34
|
+
* The Unified Quasar Authentication Bridge.
|
|
54
35
|
*
|
|
55
|
-
* It
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
36
|
+
* This component acts as a unified cross-chain coordinator. It dynamically
|
|
37
|
+
* renders either the EVM or Solana specific bridges based on the connection type.
|
|
38
|
+
* Note: importing this component requires having both `@wagmi/core` and `@solana/react` installed.
|
|
39
|
+
* If you only need EVM or Solana bindings, import directly from the corresponding subpath:
|
|
40
|
+
* - `@tuwaio/quasar-sdk/react/evm`
|
|
41
|
+
* - `@tuwaio/quasar-sdk/react/solana`
|
|
59
42
|
*
|
|
60
43
|
* @example
|
|
61
44
|
* ```tsx
|
|
62
|
-
*
|
|
63
|
-
* const store = useContext(SatelliteStoreContext);
|
|
45
|
+
* import { QuasarAuthBridge } from '@tuwaio/quasar-sdk/react';
|
|
64
46
|
*
|
|
65
47
|
* <QuasarAuthBridge
|
|
66
48
|
* activeConnection={activeConnection}
|
|
@@ -73,6 +55,6 @@ interface QuasarAuthBridgeProps {
|
|
|
73
55
|
*
|
|
74
56
|
* @public
|
|
75
57
|
*/
|
|
76
|
-
declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
declare function QuasarAuthBridge({ activeConnection, store, wagmiConfig, session, setSession, maxAge, onAddressMismatch, }: QuasarAuthBridgeProps): react_jsx_runtime.JSX.Element | null;
|
|
77
59
|
|
|
78
|
-
export {
|
|
60
|
+
export { QuasarActiveConnection, QuasarAuthBridge, type QuasarAuthBridgeProps };
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
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;
|
package/dist/react.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
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};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { b as MiniSessionAuth } from './types-Ctaain6g.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module react/shared
|
|
5
|
+
* @description Shared React-agnostic state and type definitions for Quasar React Bridges.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Structural interface for the active wallet connection state.
|
|
10
|
+
* Used to decoupling the SDK from specific library hooks.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
interface QuasarActiveConnection {
|
|
15
|
+
/** Whether the wallet is currently connected. */
|
|
16
|
+
isConnected: boolean;
|
|
17
|
+
/** The active wallet address. */
|
|
18
|
+
address: string;
|
|
19
|
+
/** The chain ID (number for EVM, string for Solana). */
|
|
20
|
+
chainId: string | number;
|
|
21
|
+
/** The UiWalletAccount object (required for Solana signing). */
|
|
22
|
+
connectedAccount?: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Static utility to retrieve or trigger a Mini-Session authentication.
|
|
26
|
+
* This is the primary way for services outside the React tree to get an auth token.
|
|
27
|
+
*
|
|
28
|
+
* @returns A promise resolving to the valid Mini-Session Auth.
|
|
29
|
+
* @throws {Error} If the bridge is not mounted or the wallet is disconnected.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
declare function getMiniSessionAuth(): Promise<MiniSessionAuth>;
|
|
34
|
+
|
|
35
|
+
export { type QuasarActiveConnection as Q, getMiniSessionAuth as g };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { b as MiniSessionAuth } from './types-Ctaain6g.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module react/shared
|
|
5
|
+
* @description Shared React-agnostic state and type definitions for Quasar React Bridges.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Structural interface for the active wallet connection state.
|
|
10
|
+
* Used to decoupling the SDK from specific library hooks.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
interface QuasarActiveConnection {
|
|
15
|
+
/** Whether the wallet is currently connected. */
|
|
16
|
+
isConnected: boolean;
|
|
17
|
+
/** The active wallet address. */
|
|
18
|
+
address: string;
|
|
19
|
+
/** The chain ID (number for EVM, string for Solana). */
|
|
20
|
+
chainId: string | number;
|
|
21
|
+
/** The UiWalletAccount object (required for Solana signing). */
|
|
22
|
+
connectedAccount?: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Static utility to retrieve or trigger a Mini-Session authentication.
|
|
26
|
+
* This is the primary way for services outside the React tree to get an auth token.
|
|
27
|
+
*
|
|
28
|
+
* @returns A promise resolving to the valid Mini-Session Auth.
|
|
29
|
+
* @throws {Error} If the bridge is not mounted or the wallet is disconnected.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
declare function getMiniSessionAuth(): Promise<MiniSessionAuth>;
|
|
34
|
+
|
|
35
|
+
export { type QuasarActiveConnection as Q, getMiniSessionAuth as g };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/quasar-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
"types": "./dist/react.d.ts",
|
|
19
19
|
"import": "./dist/react.mjs",
|
|
20
20
|
"require": "./dist/react.js"
|
|
21
|
+
},
|
|
22
|
+
"./react/evm": {
|
|
23
|
+
"types": "./dist/react/evm.d.ts",
|
|
24
|
+
"import": "./dist/react/evm.mjs",
|
|
25
|
+
"require": "./dist/react/evm.js"
|
|
26
|
+
},
|
|
27
|
+
"./react/solana": {
|
|
28
|
+
"types": "./dist/react/solana.d.ts",
|
|
29
|
+
"import": "./dist/react/solana.mjs",
|
|
30
|
+
"require": "./dist/react/solana.js"
|
|
21
31
|
}
|
|
22
32
|
},
|
|
23
33
|
"publishConfig": {
|
package/dist/chunk-HJ3SAN77.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {create}from'zustand';import {persist}from'zustand/middleware';var d=(a=>(a.EVM="EVM",a.SOLANA="SOLANA",a))(d||{});var S=300*1e3,w=60*1e3,m=30*1e3;function y(e){return `Mini-Session Login: ${e}`}async function f(e){let t=new Date().toISOString(),a=y(t);if(e.chainType==="EVM"){let n=e.signer;try{return {signature:await n.signMessage({account:e.walletAddress,message:a}),timestamp:t}}catch(s){throw new Error(`[SDK] EVM signing failed: ${s.message}`,{cause:s})}}if(e.chainType==="SOLANA"){let n=e.signer,s;try{s=await import('gill');}catch(r){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:r})}try{let i=s.getUtf8Encoder().encode(a),o;if(n.modifyAndSignMessages){let l=s.createSignableMessage(i),[p]=await n.modifyAndSignMessages([l]),u=p.signatures[n.address];if(!u)throw new Error(`[SDK] Signature missing for address: ${n.address}`);o=u;}else if(n.signMessages){let[l]=await n.signMessages([i]);if(!l?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=l.signature;}else if(n.signMessage)o=await n.signMessage(i);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:s.getSignatureFromBytes(o),timestamp:t}}catch(r){throw new Error(`[SDK] Solana signing failed: ${r.message}`,{cause:r})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function v(e){let t=new Date(e.timestamp).getTime(),a=Date.now();if(isNaN(t))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let n=e.maxAge??S;if(a-t>n)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(t>a+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let s=y(e.timestamp);if(e.chainType==="EVM"){let r;try{r=await import('viem');}catch(i){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:i})}return await r.verifyMessage({address:e.walletAddress,message:s,signature:e.signature})}if(e.chainType==="SOLANA"){let r;try{r=await import('gill');}catch(i){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:i})}try{let i=r.address(e.walletAddress);return await r.verifySignatureForAddress(i,e.signature,s)}catch{return false}}return false}var c=null;function R(e="mini-session-storage"){return create()(persist(t=>({miniSession:null,setMiniSession:a=>t({miniSession:a}),clearSession:()=>t({miniSession:null})}),{name:e}))}async function C(e,t){let{isConnected:a,address:n,chainType:s,signer:r}=e;if(!a||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let i=t.miniSession;if(i&&i.walletAddress===n&&i.chainType===s){let o=Date.now(),g=new Date(i.timestamp).getTime();if(o-g<S-m)return i}return c||(c=f({signer:r,walletAddress:n,chainType:s}).then(o=>{let g={...o,chainType:s,walletAddress:n};return t.setMiniSession(g),g}).finally(()=>{c=null;})),c}export{d as a,S as b,m as c,y as d,f as e,v as f,R as g,C as h};
|
package/dist/chunk-M56HRFZC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var zustand=require('zustand'),middleware=require('zustand/middleware');var d=(a=>(a.EVM="EVM",a.SOLANA="SOLANA",a))(d||{});var S=300*1e3,w=60*1e3,m=30*1e3;function y(e){return `Mini-Session Login: ${e}`}async function f(e){let t=new Date().toISOString(),a=y(t);if(e.chainType==="EVM"){let n=e.signer;try{return {signature:await n.signMessage({account:e.walletAddress,message:a}),timestamp:t}}catch(s){throw new Error(`[SDK] EVM signing failed: ${s.message}`,{cause:s})}}if(e.chainType==="SOLANA"){let n=e.signer,s;try{s=await import('gill');}catch(r){throw new Error('[SDK] Peer dependency "gill" is required for Solana signing.',{cause:r})}try{let i=s.getUtf8Encoder().encode(a),o;if(n.modifyAndSignMessages){let l=s.createSignableMessage(i),[p]=await n.modifyAndSignMessages([l]),u=p.signatures[n.address];if(!u)throw new Error(`[SDK] Signature missing for address: ${n.address}`);o=u;}else if(n.signMessages){let[l]=await n.signMessages([i]);if(!l?.signature)throw new Error("[SDK] Wallet returned invalid signMessages output.");o=l.signature;}else if(n.signMessage)o=await n.signMessage(i);else throw new Error("[SDK] Signer lacks message signing capabilities.");return {signature:s.getSignatureFromBytes(o),timestamp:t}}catch(r){throw new Error(`[SDK] Solana signing failed: ${r.message}`,{cause:r})}}throw new Error(`[SDK] Unsupported chain type: ${e.chainType}`)}async function v(e){let t=new Date(e.timestamp).getTime(),a=Date.now();if(isNaN(t))throw new Error("[SDK] Invalid timestamp format. Use ISO string.");let n=e.maxAge??S;if(a-t>n)throw new Error("[SDK] Signature expired. Please sign a fresh message.");if(t>a+w)throw new Error("[SDK] Timestamp is in the future. Check your system clock.");let s=y(e.timestamp);if(e.chainType==="EVM"){let r;try{r=await import('viem');}catch(i){throw new Error('[SDK] Peer dependency "viem" is required for EVM verification.',{cause:i})}return await r.verifyMessage({address:e.walletAddress,message:s,signature:e.signature})}if(e.chainType==="SOLANA"){let r;try{r=await import('gill');}catch(i){throw new Error('[SDK] Peer dependency "gill" is required for Solana verification.',{cause:i})}try{let i=r.address(e.walletAddress);return await r.verifySignatureForAddress(i,e.signature,s)}catch{return false}}return false}var c=null;function R(e="mini-session-storage"){return zustand.create()(middleware.persist(t=>({miniSession:null,setMiniSession:a=>t({miniSession:a}),clearSession:()=>t({miniSession:null})}),{name:e}))}async function C(e,t){let{isConnected:a,address:n,chainType:s,signer:r}=e;if(!a||!n)throw new Error("[SDK] Wallet not connected. Please connect your wallet first.");let i=t.miniSession;if(i&&i.walletAddress===n&&i.chainType===s){let o=Date.now(),g=new Date(i.timestamp).getTime();if(o-g<S-m)return i}return c||(c=f({signer:r,walletAddress:n,chainType:s}).then(o=>{let g={...o,chainType:s,walletAddress:n};return t.setMiniSession(g),g}).finally(()=>{c=null;})),c}exports.a=d;exports.b=S;exports.c=m;exports.d=y;exports.e=f;exports.f=v;exports.g=R;exports.h=C;
|