@fivenorth/loop-sdk 0.7.4 → 0.7.6
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.js +19 -11
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2694,7 +2694,7 @@ class LoopWallet {
|
|
|
2694
2694
|
|
|
2695
2695
|
// src/index.ts
|
|
2696
2696
|
class LoopSDK {
|
|
2697
|
-
version = "0.7.
|
|
2697
|
+
version = "0.7.6";
|
|
2698
2698
|
appName = "Unknown";
|
|
2699
2699
|
connection = null;
|
|
2700
2700
|
session = null;
|
|
@@ -2789,22 +2789,24 @@ class LoopSDK {
|
|
|
2789
2789
|
throw new Error("SDK not initialized. Call init() first.");
|
|
2790
2790
|
}
|
|
2791
2791
|
await this.autoConnect();
|
|
2792
|
-
if (this.session
|
|
2793
|
-
|
|
2794
|
-
return;
|
|
2792
|
+
if (!this.session) {
|
|
2793
|
+
throw new Error("No valid session found. The network connection maynot available or the backend is not reachable.");
|
|
2795
2794
|
}
|
|
2796
|
-
if (this.session
|
|
2795
|
+
if (this.session.isAuthorized()) {
|
|
2797
2796
|
return;
|
|
2798
2797
|
}
|
|
2799
2798
|
try {
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
this.connection.
|
|
2799
|
+
if (!this.session.ticketId) {
|
|
2800
|
+
const { ticket_id: ticketId } = await this.connection.getTicket(this.appName, this.session.sessionId, this.version);
|
|
2801
|
+
this.session.setTicketId(ticketId);
|
|
2802
|
+
}
|
|
2803
|
+
if (!this.connection.connectInProgress()) {
|
|
2804
|
+
this.connection.connectWebSocket(this.session.ticketId, this.handleWebSocketMessage.bind(this));
|
|
2805
|
+
}
|
|
2806
|
+
this.showQrCode(this.buildConnectUrl(this.session.ticketId));
|
|
2805
2807
|
} catch (error) {
|
|
2806
2808
|
console.error(error);
|
|
2807
|
-
|
|
2809
|
+
throw error;
|
|
2808
2810
|
}
|
|
2809
2811
|
}
|
|
2810
2812
|
handleWebSocketMessage(event) {
|
|
@@ -2857,6 +2859,12 @@ class LoopSDK {
|
|
|
2857
2859
|
this.provider.handleResponse(message);
|
|
2858
2860
|
}
|
|
2859
2861
|
}
|
|
2862
|
+
getConnectUrl() {
|
|
2863
|
+
if (!this.session?.ticketId) {
|
|
2864
|
+
throw new Error("No ticket ID found. Please call connect() first.");
|
|
2865
|
+
}
|
|
2866
|
+
return this.buildConnectUrl(this.session.ticketId);
|
|
2867
|
+
}
|
|
2860
2868
|
buildConnectUrl(ticketId) {
|
|
2861
2869
|
const url = new URL("/.connect/", this.connection.walletUrl);
|
|
2862
2870
|
url.searchParams.set("ticketId", ticketId);
|