@vitia.ai/secure-api-client-vue 0.1.1 → 0.1.3
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 +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +22 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -2742,22 +2742,22 @@ class Ms {
|
|
|
2742
2742
|
if (!(this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING))) {
|
|
2743
2743
|
if (this._connectPromise) return this._connectPromise;
|
|
2744
2744
|
this._connectPromise = (async () => {
|
|
2745
|
-
const {
|
|
2746
|
-
this.ws = new WebSocket(
|
|
2745
|
+
const { ans: t } = await this.client.get("/url/notifications"), { url: r } = t.data[0];
|
|
2746
|
+
this.ws = new WebSocket(r), this.ws.onopen = () => {
|
|
2747
2747
|
this._reconnectAttempt = 0, console.log("Notifications connected");
|
|
2748
|
-
}, this.ws.onmessage = async (
|
|
2748
|
+
}, this.ws.onmessage = async (s) => {
|
|
2749
2749
|
try {
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
const
|
|
2753
|
-
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
} catch (
|
|
2757
|
-
console.warn("Failed to process notification:",
|
|
2750
|
+
const i = JSON.parse(s.data), o = await this.client.decryptAndVerify(i), c = this.subscriptions.request[o == null ? void 0 : o.correlation_id];
|
|
2751
|
+
c && Object.values(c).length > 0 && Object.values(c).forEach((f) => f(o));
|
|
2752
|
+
const a = this.subscriptions.status[o == null ? void 0 : o.status];
|
|
2753
|
+
a && Object.values(a).length > 0 && Object.values(a).forEach((f) => f(o));
|
|
2754
|
+
const u = this.subscriptions.topic[o == null ? void 0 : o.topic];
|
|
2755
|
+
u && Object.values(u).length > 0 && Object.values(u).forEach((f) => f(o)), Object.values(this.listeners).forEach((f) => f(o));
|
|
2756
|
+
} catch (i) {
|
|
2757
|
+
console.warn("Failed to process notification:", i);
|
|
2758
2758
|
}
|
|
2759
|
-
}, this.ws.onerror = (
|
|
2760
|
-
console.error("Notifications error",
|
|
2759
|
+
}, this.ws.onerror = (s) => {
|
|
2760
|
+
console.error("Notifications error", s);
|
|
2761
2761
|
}, this.ws.onclose = () => {
|
|
2762
2762
|
this.scheduleReconnect(), console.log("Notifications closed");
|
|
2763
2763
|
};
|
|
@@ -2962,7 +2962,7 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
2962
2962
|
var t, r, s;
|
|
2963
2963
|
(!this.session || !this.session.sessionId || !this.session.sessionExpiresAt || !this.session.encKey || !this.session.macKey) && await this.handshake();
|
|
2964
2964
|
const e = new Date(Date.now() + 5 * 60 * 1e3);
|
|
2965
|
-
(t = this.session) != null && t.sessionExpiresAt && new Date((r = this.session) == null ? void 0 : r.sessionExpiresAt) < e && await this.extendHandshake(), (s = this.session) != null && s.
|
|
2965
|
+
(t = this.session) != null && t.sessionExpiresAt && new Date((r = this.session) == null ? void 0 : r.sessionExpiresAt) < e && await this.extendHandshake(), (s = this.session) != null && s.accessToken && this.isTokenExpired() && await this.refresh();
|
|
2966
2966
|
}
|
|
2967
2967
|
async extendHandshake() {
|
|
2968
2968
|
await this.post("/handshake/extend", {}).then(async (e) => {
|
|
@@ -2999,9 +2999,14 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
2999
2999
|
return r === 0;
|
|
3000
3000
|
}
|
|
3001
3001
|
async login(e) {
|
|
3002
|
-
await this.
|
|
3002
|
+
(!this.session || !this.session.sessionId || !this.session.sessionExpiresAt || !this.session.encKey || !this.session.macKey) && await this.handshake(), this.updateSession({
|
|
3003
|
+
accessToken: void 0,
|
|
3004
|
+
tokenType: void 0,
|
|
3005
|
+
expiresAt: void 0,
|
|
3006
|
+
refreshToken: void 0
|
|
3007
|
+
});
|
|
3003
3008
|
const t = {};
|
|
3004
|
-
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope), "email" in e && "socialLoginId" in e && (t.email = e.email, t.social_login_id = e.socialLoginId, t.scope = e.scope), "jwt" in e && this.updateSession({
|
|
3009
|
+
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope, t.oauth_session = e.oauthSession), "email" in e && "socialLoginId" in e && (t.email = e.email, t.social_login_id = e.socialLoginId, t.scope = e.scope, t.oauth_session = e.oauthSession), "jwt" in e && this.updateSession({
|
|
3005
3010
|
accessToken: e.jwt,
|
|
3006
3011
|
tokenType: "Bearer"
|
|
3007
3012
|
}), "refreshToken" in e && (t.refresh_token = e.refreshToken);
|
|
@@ -3010,7 +3015,7 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
3010
3015
|
token_type: i,
|
|
3011
3016
|
expires_at: o,
|
|
3012
3017
|
refresh_token: c
|
|
3013
|
-
} = r;
|
|
3018
|
+
} = r.data[0];
|
|
3014
3019
|
return s && this.updateSession({ accessToken: s }), i && this.updateSession({ tokenType: i }), o && this.updateSession({ expiresAt: o }), c && this.updateSession({ refreshToken: c }), {
|
|
3015
3020
|
accessToken: s,
|
|
3016
3021
|
tokenType: i,
|