ault-sdk-ts 0.0.2-alpha.6 → 0.0.2-alpha.7
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 +6 -15
- package/dist/index.cjs +4 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -41
- package/dist/index.js.map +1 -1
- package/dist/ws/client.d.ts +0 -3
- package/dist/ws/types.d.ts +1 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5009,16 +5009,13 @@ var DexWsClient = class {
|
|
|
5009
5009
|
this.pendingCommands = /* @__PURE__ */ new Map();
|
|
5010
5010
|
this.reconnectAttempt = 0;
|
|
5011
5011
|
this.reconnectTimer = null;
|
|
5012
|
-
this.authenticated = false;
|
|
5013
5012
|
this.connectResolvers = [];
|
|
5014
5013
|
this.url = url;
|
|
5015
5014
|
this.options = {
|
|
5016
5015
|
reconnect: opts?.reconnect ?? true,
|
|
5017
5016
|
maxReconnectAttempts: opts?.maxReconnectAttempts ?? Infinity,
|
|
5018
5017
|
reconnectDelay: opts?.reconnectDelay ?? 1e3,
|
|
5019
|
-
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5020
|
-
signMessage: opts?.signMessage,
|
|
5021
|
-
address: opts?.address
|
|
5018
|
+
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5022
5019
|
};
|
|
5023
5020
|
}
|
|
5024
5021
|
// -----------------------------------------------------------------------
|
|
@@ -5027,9 +5024,6 @@ var DexWsClient = class {
|
|
|
5027
5024
|
get state() {
|
|
5028
5025
|
return this.connectionState;
|
|
5029
5026
|
}
|
|
5030
|
-
get isAuthenticated() {
|
|
5031
|
-
return this.authenticated;
|
|
5032
|
-
}
|
|
5033
5027
|
connect() {
|
|
5034
5028
|
if (this.connectionState === "connected") return Promise.resolve();
|
|
5035
5029
|
if (this.connectionState === "connecting") {
|
|
@@ -5046,7 +5040,6 @@ var DexWsClient = class {
|
|
|
5046
5040
|
disconnect() {
|
|
5047
5041
|
this.clearReconnectTimer();
|
|
5048
5042
|
this.connectionState = "disconnected";
|
|
5049
|
-
this.authenticated = false;
|
|
5050
5043
|
if (this.ws) {
|
|
5051
5044
|
this.ws.close(NORMAL_CLOSURE);
|
|
5052
5045
|
this.ws = null;
|
|
@@ -5081,26 +5074,6 @@ var DexWsClient = class {
|
|
|
5081
5074
|
this.send({ action: "unsubscribe", topic });
|
|
5082
5075
|
}
|
|
5083
5076
|
}
|
|
5084
|
-
async authenticate(address, signMessage) {
|
|
5085
|
-
const addr = address ?? this.options.address;
|
|
5086
|
-
const signer = signMessage ?? this.options.signMessage;
|
|
5087
|
-
if (!addr || !signer) {
|
|
5088
|
-
throw new WebSocketError("address and signMessage are required for authentication");
|
|
5089
|
-
}
|
|
5090
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5091
|
-
const message = `ault-dex-auth:${timestamp}`;
|
|
5092
|
-
const signature = await signer(message);
|
|
5093
|
-
const resp = await this.sendCommand({
|
|
5094
|
-
action: "authenticate",
|
|
5095
|
-
address: addr,
|
|
5096
|
-
signature,
|
|
5097
|
-
message
|
|
5098
|
-
});
|
|
5099
|
-
if (!resp.success) {
|
|
5100
|
-
throw new WebSocketError(resp.error ?? "Authentication failed");
|
|
5101
|
-
}
|
|
5102
|
-
this.authenticated = true;
|
|
5103
|
-
}
|
|
5104
5077
|
on(event, handler) {
|
|
5105
5078
|
let set = this.listeners.get(event);
|
|
5106
5079
|
if (!set) {
|
|
@@ -5233,15 +5206,8 @@ var DexWsClient = class {
|
|
|
5233
5206
|
this.createSocket();
|
|
5234
5207
|
}, jitteredDelay);
|
|
5235
5208
|
}
|
|
5236
|
-
|
|
5209
|
+
resubscribeAll() {
|
|
5237
5210
|
this.emit("reconnected");
|
|
5238
|
-
if (this.authenticated) {
|
|
5239
|
-
this.authenticated = false;
|
|
5240
|
-
try {
|
|
5241
|
-
await this.authenticate();
|
|
5242
|
-
} catch {
|
|
5243
|
-
}
|
|
5244
|
-
}
|
|
5245
5211
|
for (const [topic, sub] of this.subscriptions) {
|
|
5246
5212
|
this.send({ action: "subscribe", topic, ttl: sub.ttl });
|
|
5247
5213
|
}
|
|
@@ -15854,10 +15820,7 @@ function createAultClient(options) {
|
|
|
15854
15820
|
"WebSocket URL not configured. Set dexWsUrl or dexApiUrl in your network config."
|
|
15855
15821
|
);
|
|
15856
15822
|
}
|
|
15857
|
-
wsClient = new DexWsClient(wsUrl,
|
|
15858
|
-
address: options.signerAddress,
|
|
15859
|
-
...options.wsOptions
|
|
15860
|
-
});
|
|
15823
|
+
wsClient = new DexWsClient(wsUrl, options.wsOptions);
|
|
15861
15824
|
}
|
|
15862
15825
|
return wsClient;
|
|
15863
15826
|
},
|
|
@@ -17925,7 +17888,7 @@ function createDexWs(url, options) {
|
|
|
17925
17888
|
}
|
|
17926
17889
|
|
|
17927
17890
|
// src/index.ts
|
|
17928
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
17891
|
+
var SDK_VERSION = "0.0.2-alpha.7";
|
|
17929
17892
|
export {
|
|
17930
17893
|
AGENT_DEFAULTS,
|
|
17931
17894
|
AULT_SIGNER_MARKER,
|