@yieldfabric/wallet 0.2.7 → 0.2.8
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/dist/index.cjs +15 -14
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +15 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7527,6 +7527,7 @@ var messagesService = new MessagesService();
|
|
|
7527
7527
|
// src/core/websocketChannelManager.ts
|
|
7528
7528
|
init_jwtPayload();
|
|
7529
7529
|
init_tokenStore();
|
|
7530
|
+
init_tokenRenewal();
|
|
7530
7531
|
var WebSocketChannelManager = class {
|
|
7531
7532
|
constructor(url, getAccessToken = () => exports.defaultTokenStore.getCurrentToken()) {
|
|
7532
7533
|
this.ws = null;
|
|
@@ -7535,6 +7536,9 @@ var WebSocketChannelManager = class {
|
|
|
7535
7536
|
this.reconnectAttempts = 0;
|
|
7536
7537
|
this.reconnectDelay = 1e3;
|
|
7537
7538
|
this.reconnectTimeout = null;
|
|
7539
|
+
/** The server closed us over the token (expired or missing): renew it
|
|
7540
|
+
* before reconnecting, or the next attempt is refused the same way. */
|
|
7541
|
+
this.renewBeforeReconnect = false;
|
|
7538
7542
|
// Channel management
|
|
7539
7543
|
this.channels = /* @__PURE__ */ new Map();
|
|
7540
7544
|
// entityId -> messageTypes
|
|
@@ -7599,6 +7603,12 @@ var WebSocketChannelManager = class {
|
|
|
7599
7603
|
try {
|
|
7600
7604
|
const message = JSON.parse(event.data);
|
|
7601
7605
|
console.log("\u{1F50C} WebSocket message received:", message);
|
|
7606
|
+
if (message.type === "Error") {
|
|
7607
|
+
const reason = String(message.message ?? message.error_message ?? "");
|
|
7608
|
+
console.warn("\u{1F50C} Live updates refused the connection:", reason);
|
|
7609
|
+
if (/token/i.test(reason)) this.renewBeforeReconnect = true;
|
|
7610
|
+
return;
|
|
7611
|
+
}
|
|
7602
7612
|
this.routeMessage(message);
|
|
7603
7613
|
} catch (error) {
|
|
7604
7614
|
console.error("Failed to parse WebSocket message:", error);
|
|
@@ -7769,7 +7779,11 @@ var WebSocketChannelManager = class {
|
|
|
7769
7779
|
this.reconnectAttempts++;
|
|
7770
7780
|
const delay2 = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), 3e4);
|
|
7771
7781
|
console.log(`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts})`);
|
|
7772
|
-
this.reconnectTimeout = setTimeout(() => {
|
|
7782
|
+
this.reconnectTimeout = setTimeout(async () => {
|
|
7783
|
+
if (this.renewBeforeReconnect) {
|
|
7784
|
+
this.renewBeforeReconnect = false;
|
|
7785
|
+
await tokenRenewalService.refreshToken().catch((error) => console.warn("\u{1F50C} Token renewal before reconnecting failed:", error));
|
|
7786
|
+
}
|
|
7773
7787
|
this.connect().catch((error) => {
|
|
7774
7788
|
console.error("Reconnection failed:", error);
|
|
7775
7789
|
});
|
|
@@ -9065,9 +9079,6 @@ var _GlobalNotificationService = class _GlobalNotificationService {
|
|
|
9065
9079
|
case "MessageStatusChange":
|
|
9066
9080
|
this.handleMessageStatusChange(message);
|
|
9067
9081
|
break;
|
|
9068
|
-
case "Error":
|
|
9069
|
-
this.handleError(message);
|
|
9070
|
-
break;
|
|
9071
9082
|
default:
|
|
9072
9083
|
console.log("Unhandled message type:", message.type);
|
|
9073
9084
|
}
|
|
@@ -9127,16 +9138,6 @@ var _GlobalNotificationService = class _GlobalNotificationService {
|
|
|
9127
9138
|
});
|
|
9128
9139
|
}
|
|
9129
9140
|
}
|
|
9130
|
-
handleError(message) {
|
|
9131
|
-
const notification = {
|
|
9132
|
-
id: `error-${Date.now()}`,
|
|
9133
|
-
type: "error",
|
|
9134
|
-
title: "Error",
|
|
9135
|
-
message: message.error_message || "An error occurred",
|
|
9136
|
-
duration: 6e3
|
|
9137
|
-
};
|
|
9138
|
-
this.callbacks.onNotification(notification);
|
|
9139
|
-
}
|
|
9140
9141
|
processSystemNotification(type, title, message, options) {
|
|
9141
9142
|
const notification = {
|
|
9142
9143
|
id: `system-${type}-${Date.now()}`,
|
package/dist/index.d.cts
CHANGED
|
@@ -1764,7 +1764,6 @@ declare class GlobalNotificationService {
|
|
|
1764
1764
|
private handleNewMessage;
|
|
1765
1765
|
private handleMessageUpdate;
|
|
1766
1766
|
private handleMessageStatusChange;
|
|
1767
|
-
private handleError;
|
|
1768
1767
|
processSystemNotification(type: 'info' | 'success' | 'warning' | 'error', title: string, message?: string, options?: any): void;
|
|
1769
1768
|
processApiError(error: Error, context?: string): void;
|
|
1770
1769
|
processApiSuccess(message: string, context?: string): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1764,7 +1764,6 @@ declare class GlobalNotificationService {
|
|
|
1764
1764
|
private handleNewMessage;
|
|
1765
1765
|
private handleMessageUpdate;
|
|
1766
1766
|
private handleMessageStatusChange;
|
|
1767
|
-
private handleError;
|
|
1768
1767
|
processSystemNotification(type: 'info' | 'success' | 'warning' | 'error', title: string, message?: string, options?: any): void;
|
|
1769
1768
|
processApiError(error: Error, context?: string): void;
|
|
1770
1769
|
processApiSuccess(message: string, context?: string): void;
|
package/dist/index.js
CHANGED
|
@@ -7519,6 +7519,7 @@ var messagesService = new MessagesService();
|
|
|
7519
7519
|
// src/core/websocketChannelManager.ts
|
|
7520
7520
|
init_jwtPayload();
|
|
7521
7521
|
init_tokenStore();
|
|
7522
|
+
init_tokenRenewal();
|
|
7522
7523
|
var WebSocketChannelManager = class {
|
|
7523
7524
|
constructor(url, getAccessToken = () => defaultTokenStore.getCurrentToken()) {
|
|
7524
7525
|
this.ws = null;
|
|
@@ -7527,6 +7528,9 @@ var WebSocketChannelManager = class {
|
|
|
7527
7528
|
this.reconnectAttempts = 0;
|
|
7528
7529
|
this.reconnectDelay = 1e3;
|
|
7529
7530
|
this.reconnectTimeout = null;
|
|
7531
|
+
/** The server closed us over the token (expired or missing): renew it
|
|
7532
|
+
* before reconnecting, or the next attempt is refused the same way. */
|
|
7533
|
+
this.renewBeforeReconnect = false;
|
|
7530
7534
|
// Channel management
|
|
7531
7535
|
this.channels = /* @__PURE__ */ new Map();
|
|
7532
7536
|
// entityId -> messageTypes
|
|
@@ -7591,6 +7595,12 @@ var WebSocketChannelManager = class {
|
|
|
7591
7595
|
try {
|
|
7592
7596
|
const message = JSON.parse(event.data);
|
|
7593
7597
|
console.log("\u{1F50C} WebSocket message received:", message);
|
|
7598
|
+
if (message.type === "Error") {
|
|
7599
|
+
const reason = String(message.message ?? message.error_message ?? "");
|
|
7600
|
+
console.warn("\u{1F50C} Live updates refused the connection:", reason);
|
|
7601
|
+
if (/token/i.test(reason)) this.renewBeforeReconnect = true;
|
|
7602
|
+
return;
|
|
7603
|
+
}
|
|
7594
7604
|
this.routeMessage(message);
|
|
7595
7605
|
} catch (error) {
|
|
7596
7606
|
console.error("Failed to parse WebSocket message:", error);
|
|
@@ -7761,7 +7771,11 @@ var WebSocketChannelManager = class {
|
|
|
7761
7771
|
this.reconnectAttempts++;
|
|
7762
7772
|
const delay2 = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), 3e4);
|
|
7763
7773
|
console.log(`Reconnecting in ${delay2}ms (attempt ${this.reconnectAttempts})`);
|
|
7764
|
-
this.reconnectTimeout = setTimeout(() => {
|
|
7774
|
+
this.reconnectTimeout = setTimeout(async () => {
|
|
7775
|
+
if (this.renewBeforeReconnect) {
|
|
7776
|
+
this.renewBeforeReconnect = false;
|
|
7777
|
+
await tokenRenewalService.refreshToken().catch((error) => console.warn("\u{1F50C} Token renewal before reconnecting failed:", error));
|
|
7778
|
+
}
|
|
7765
7779
|
this.connect().catch((error) => {
|
|
7766
7780
|
console.error("Reconnection failed:", error);
|
|
7767
7781
|
});
|
|
@@ -9057,9 +9071,6 @@ var _GlobalNotificationService = class _GlobalNotificationService {
|
|
|
9057
9071
|
case "MessageStatusChange":
|
|
9058
9072
|
this.handleMessageStatusChange(message);
|
|
9059
9073
|
break;
|
|
9060
|
-
case "Error":
|
|
9061
|
-
this.handleError(message);
|
|
9062
|
-
break;
|
|
9063
9074
|
default:
|
|
9064
9075
|
console.log("Unhandled message type:", message.type);
|
|
9065
9076
|
}
|
|
@@ -9119,16 +9130,6 @@ var _GlobalNotificationService = class _GlobalNotificationService {
|
|
|
9119
9130
|
});
|
|
9120
9131
|
}
|
|
9121
9132
|
}
|
|
9122
|
-
handleError(message) {
|
|
9123
|
-
const notification = {
|
|
9124
|
-
id: `error-${Date.now()}`,
|
|
9125
|
-
type: "error",
|
|
9126
|
-
title: "Error",
|
|
9127
|
-
message: message.error_message || "An error occurred",
|
|
9128
|
-
duration: 6e3
|
|
9129
|
-
};
|
|
9130
|
-
this.callbacks.onNotification(notification);
|
|
9131
|
-
}
|
|
9132
9133
|
processSystemNotification(type, title, message, options) {
|
|
9133
9134
|
const notification = {
|
|
9134
9135
|
id: `system-${type}-${Date.now()}`,
|
package/package.json
CHANGED