@tuwaio/quasar-sdk 0.1.11 → 0.2.0
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 +52 -459
- package/dist/chunk-NJH5FYLU.cjs +2 -0
- package/dist/chunk-YPUBFZPR.js +2 -0
- package/dist/cli.cjs +52 -69
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +113 -202
- package/dist/index.d.ts +113 -202
- package/dist/index.js +1 -2
- package/dist/react.cjs +1 -0
- package/dist/react.d.cts +28 -0
- package/dist/react.d.ts +28 -0
- package/dist/react.js +1 -0
- package/package.json +24 -57
package/dist/cli.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(cli_exports, {
|
|
|
34
34
|
CLI_VERSION: () => CLI_VERSION,
|
|
35
35
|
DEFAULT_API_URL: () => DEFAULT_API_URL,
|
|
36
36
|
DEFAULT_FORWARD_URL: () => DEFAULT_FORWARD_URL,
|
|
37
|
+
buildListenRequest: () => buildListenRequest,
|
|
37
38
|
handleSseMessage: () => handleSseMessage,
|
|
38
39
|
loadEnv: () => loadEnv,
|
|
39
40
|
main: () => main,
|
|
@@ -47,11 +48,11 @@ var path = __toESM(require("path"), 1);
|
|
|
47
48
|
// package.json
|
|
48
49
|
var package_default = {
|
|
49
50
|
name: "@tuwaio/quasar-sdk",
|
|
50
|
-
version: "0.
|
|
51
|
+
version: "0.2.0",
|
|
51
52
|
private: false,
|
|
52
53
|
author: "Oleksandr Tkach",
|
|
53
54
|
license: "Apache-2.0",
|
|
54
|
-
description: "Layer 5 (L5) of the TUWA Ecosystem. The Quasar Cloud
|
|
55
|
+
description: "Layer 5 (L5) of the TUWA Ecosystem. The client of the Quasar API (Quasar Cloud or a self-hosted Quasar server): transaction sync and history for Pulsar, and the quasar-sdk CLI that relays webhooks to localhost.",
|
|
55
56
|
type: "module",
|
|
56
57
|
main: "./dist/index.cjs",
|
|
57
58
|
module: "./dist/index.js",
|
|
@@ -61,6 +62,11 @@ var package_default = {
|
|
|
61
62
|
types: "./dist/index.d.ts",
|
|
62
63
|
import: "./dist/index.js",
|
|
63
64
|
require: "./dist/index.cjs"
|
|
65
|
+
},
|
|
66
|
+
"./react": {
|
|
67
|
+
types: "./dist/react.d.ts",
|
|
68
|
+
import: "./dist/react.js",
|
|
69
|
+
require: "./dist/react.cjs"
|
|
64
70
|
}
|
|
65
71
|
},
|
|
66
72
|
publishConfig: {
|
|
@@ -71,7 +77,6 @@ var package_default = {
|
|
|
71
77
|
"socket.json"
|
|
72
78
|
],
|
|
73
79
|
bin: {
|
|
74
|
-
"@tuwaio/quasar-sdk": "./dist/cli.cjs",
|
|
75
80
|
"quasar-sdk": "./dist/cli.cjs"
|
|
76
81
|
},
|
|
77
82
|
scripts: {
|
|
@@ -82,43 +87,21 @@ var package_default = {
|
|
|
82
87
|
keywords: [
|
|
83
88
|
"tuwa",
|
|
84
89
|
"web3",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"wagmi",
|
|
89
|
-
"viem",
|
|
90
|
-
"@solana/kit",
|
|
91
|
-
"wallet-standard",
|
|
92
|
-
"wallet",
|
|
93
|
-
"wallet-connect",
|
|
94
|
-
"wallets",
|
|
90
|
+
"quasar",
|
|
91
|
+
"quasar-cloud",
|
|
92
|
+
"pulsar",
|
|
95
93
|
"transaction",
|
|
96
94
|
"tracking",
|
|
97
95
|
"transaction-tracking",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"design-system",
|
|
102
|
-
"hooks",
|
|
103
|
-
"utils",
|
|
104
|
-
"components",
|
|
105
|
-
"tailwind",
|
|
106
|
-
"tailwindcss",
|
|
107
|
-
"typescript",
|
|
108
|
-
"core",
|
|
109
|
-
"headless",
|
|
110
|
-
"zustand",
|
|
111
|
-
"immer",
|
|
112
|
-
"i18n",
|
|
113
|
-
"modal",
|
|
114
|
-
"toast",
|
|
115
|
-
"quasar",
|
|
116
|
-
"cloud",
|
|
96
|
+
"transaction-history",
|
|
97
|
+
"webhooks",
|
|
98
|
+
"api-client",
|
|
117
99
|
"sdk",
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
100
|
+
"cli",
|
|
101
|
+
"typescript",
|
|
102
|
+
"evm",
|
|
103
|
+
"solana",
|
|
104
|
+
"siwx"
|
|
122
105
|
],
|
|
123
106
|
repository: {
|
|
124
107
|
type: "git",
|
|
@@ -135,38 +118,23 @@ var package_default = {
|
|
|
135
118
|
url: "https://github.com/Argeare5"
|
|
136
119
|
}
|
|
137
120
|
],
|
|
121
|
+
dependencies: {
|
|
122
|
+
ofetch: "^1.5.1"
|
|
123
|
+
},
|
|
138
124
|
peerDependencies: {
|
|
139
125
|
"@tuwaio/pulsar-core": ">=0.7",
|
|
140
|
-
|
|
141
|
-
"@tuwaio/siwx-react": ">=0.3",
|
|
142
|
-
"@tuwaio/siwx-core": ">=0.3",
|
|
143
|
-
"@tuwaio/siwx-server": ">=0.3"
|
|
126
|
+
"@tuwaio/siwx-react": ">=0.3"
|
|
144
127
|
},
|
|
145
128
|
peerDependenciesMeta: {
|
|
146
|
-
"@tuwaio/pulsar-core": {
|
|
147
|
-
optional: false
|
|
148
|
-
},
|
|
149
|
-
ofetch: {
|
|
150
|
-
optional: false
|
|
151
|
-
},
|
|
152
|
-
"@tuwaio/siwx-core": {
|
|
153
|
-
optional: true
|
|
154
|
-
},
|
|
155
|
-
"@tuwaio/siwx-server": {
|
|
156
|
-
optional: true
|
|
157
|
-
},
|
|
158
129
|
"@tuwaio/siwx-react": {
|
|
159
130
|
optional: true
|
|
160
131
|
}
|
|
161
132
|
},
|
|
162
133
|
devDependencies: {
|
|
163
|
-
"@tuwaio/pulsar-core": "^0.
|
|
164
|
-
ofetch: "^1.5.1",
|
|
134
|
+
"@tuwaio/pulsar-core": "^0.8.2",
|
|
165
135
|
tsup: "^8.5.1",
|
|
166
136
|
typescript: "6.0.3",
|
|
167
|
-
"@tuwaio/siwx-react": "^0.
|
|
168
|
-
"@tuwaio/siwx-core": "^0.3.0",
|
|
169
|
-
"@tuwaio/siwx-server": "^0.3.0"
|
|
137
|
+
"@tuwaio/siwx-react": "^0.4.0"
|
|
170
138
|
}
|
|
171
139
|
};
|
|
172
140
|
|
|
@@ -237,8 +205,8 @@ function parseArgs(args) {
|
|
|
237
205
|
function printHelp() {
|
|
238
206
|
console.log(`
|
|
239
207
|
\x1B[1m\x1B[36m\u26A1 Quasar Webhook Local Dev Relay\x1B[0m
|
|
240
|
-
|
|
241
|
-
|
|
208
|
+
Receives the deliveries of a Quasar webhook endpoint with a localhost URL
|
|
209
|
+
and posts them to your local app. No tunnel is needed.
|
|
242
210
|
|
|
243
211
|
\x1B[1mUSAGE\x1B[0m
|
|
244
212
|
$ npx @tuwaio/quasar-sdk listen [options]
|
|
@@ -263,10 +231,23 @@ Zero tunnels, zero third-party proxies, zero friction.
|
|
|
263
231
|
$ npx @tuwaio/quasar-sdk listen
|
|
264
232
|
`);
|
|
265
233
|
}
|
|
234
|
+
function buildListenRequest(params) {
|
|
235
|
+
return {
|
|
236
|
+
url: `${params.apiUrl.replace(/\/+$/, "")}/v1/engine/webhooks/listen`,
|
|
237
|
+
init: {
|
|
238
|
+
method: "GET",
|
|
239
|
+
headers: {
|
|
240
|
+
Accept: "text/event-stream",
|
|
241
|
+
"Cache-Control": "no-cache",
|
|
242
|
+
"x-webhook-secret": params.secret
|
|
243
|
+
},
|
|
244
|
+
signal: params.signal
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
266
248
|
async function runListen(options) {
|
|
267
249
|
const { secret, forwardTo, apiUrl } = options;
|
|
268
250
|
const cleanApiUrl = apiUrl.replace(/\/+$/, "");
|
|
269
|
-
const listenUrl = `${cleanApiUrl}/v1/engine/webhooks/listen?secret=${encodeURIComponent(secret)}`;
|
|
270
251
|
console.log(`
|
|
271
252
|
\x1B[36m\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\x1B[0m
|
|
272
253
|
\x1B[36m\u2502\x1B[0m \x1B[1m\x1B[36m\u26A1 Quasar Webhook Local Dev Relay\x1B[0m \x1B[36m\u2502\x1B[0m
|
|
@@ -291,14 +272,8 @@ async function runListen(options) {
|
|
|
291
272
|
try {
|
|
292
273
|
activeAbortController = new AbortController();
|
|
293
274
|
console.log(`\x1B[90mConnecting to Quasar Cloud SSE stream...\x1B[0m`);
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
headers: {
|
|
297
|
-
Accept: "text/event-stream",
|
|
298
|
-
"Cache-Control": "no-cache"
|
|
299
|
-
},
|
|
300
|
-
signal: activeAbortController.signal
|
|
301
|
-
});
|
|
275
|
+
const request = buildListenRequest({ apiUrl: cleanApiUrl, secret, signal: activeAbortController.signal });
|
|
276
|
+
const response = await fetch(request.url, request.init);
|
|
302
277
|
if (!response.ok) {
|
|
303
278
|
if (response.status === 401) {
|
|
304
279
|
console.error(
|
|
@@ -353,6 +328,13 @@ ${dataLine}` : dataLine;
|
|
|
353
328
|
}
|
|
354
329
|
}
|
|
355
330
|
}
|
|
331
|
+
if (!isShuttingDown) {
|
|
332
|
+
console.warn(
|
|
333
|
+
`\x1B[33m[warn]\x1B[0m SSE stream closed by remote server. Reconnecting in ${reconnectDelay}ms...`
|
|
334
|
+
);
|
|
335
|
+
await new Promise((resolve) => setTimeout(resolve, reconnectDelay));
|
|
336
|
+
reconnectDelay = Math.min(reconnectDelay * 2, 15e3);
|
|
337
|
+
}
|
|
356
338
|
} catch (err) {
|
|
357
339
|
if (isShuttingDown) break;
|
|
358
340
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -368,7 +350,7 @@ async function handleSseMessage(event, rawData, forwardTo) {
|
|
|
368
350
|
}
|
|
369
351
|
try {
|
|
370
352
|
const payload = JSON.parse(rawData);
|
|
371
|
-
if (event === "connected") {
|
|
353
|
+
if (event === "connected" || event === "ready") {
|
|
372
354
|
return;
|
|
373
355
|
}
|
|
374
356
|
if (event === "payload" || event === "webhook" || event === "message") {
|
|
@@ -462,6 +444,7 @@ if (!process.env.VITEST) {
|
|
|
462
444
|
CLI_VERSION,
|
|
463
445
|
DEFAULT_API_URL,
|
|
464
446
|
DEFAULT_FORWARD_URL,
|
|
447
|
+
buildListenRequest,
|
|
465
448
|
handleSseMessage,
|
|
466
449
|
loadEnv,
|
|
467
450
|
main,
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
Object.defineProperty(exports,"TransactionStatus",{enumerable:true,get:function(){return pulsarCore.TransactionStatus}});Object.defineProperty(exports,"TransactionTracker",{enumerable:true,get:function(){return pulsarCore.TransactionTracker}});exports.BASE_API_URL=o;exports.PULSAR_HISTORY_ENDPOINT=u;exports.PULSAR_SYNC_ENDPOINT=c;exports.PulsarModule=a;exports.Quasar=l;exports.QuasarSDKError=n;exports.preFlightTxCheck=A;
|
|
1
|
+
'use strict';var chunkNJH5FYLU_cjs=require('./chunk-NJH5FYLU.cjs'),ofetch=require('ofetch'),pulsarCore=require('@tuwaio/pulsar-core');var a=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 the secretKey of your Quasar app (sk_live_ or sk_test_).");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,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 a(`[Quasar SDK] Request Failed (${t}): ${p}`,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 n=class{client;pulsar;constructor(r){this.client=new o(r),this.pulsar=new s(this.client);}};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}});Object.defineProperty(exports,"TransactionStatus",{enumerable:true,get:function(){return pulsarCore.TransactionStatus}});Object.defineProperty(exports,"TransactionTracker",{enumerable:true,get:function(){return pulsarCore.TransactionTracker}});exports.PulsarModule=s;exports.Quasar=n;exports.QuasarSDKError=a;
|