een-api-toolkit 0.3.15 → 0.3.20
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/CHANGELOG.md +45 -6
- package/README.md +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +585 -0
- package/dist/index.js +485 -261
- package/dist/index.js.map +1 -1
- package/docs/AI-CONTEXT.md +144 -1
- package/examples/vue-alerts-metrics/e2e/auth.spec.ts +8 -1
- package/examples/vue-alerts-metrics/package-lock.json +8 -1
- package/examples/vue-alerts-metrics/package.json +4 -3
- package/examples/vue-alerts-metrics/src/components/AlertsList.vue +567 -16
- package/examples/vue-alerts-metrics/src/components/CameraSelector.vue +16 -6
- package/examples/vue-alerts-metrics/src/components/MetricsChart.vue +23 -9
- package/examples/vue-alerts-metrics/src/components/NotificationsList.vue +579 -17
- package/examples/vue-alerts-metrics/src/components/TimeRangeSelector.vue +197 -12
- package/examples/vue-alerts-metrics/src/composables/useHlsPlayer.ts +285 -0
- package/examples/vue-alerts-metrics/src/views/Dashboard.vue +31 -9
- package/examples/vue-alerts-metrics/src/views/Home.vue +56 -7
- package/examples/vue-event-subscriptions/.env.example +15 -0
- package/examples/vue-event-subscriptions/README.md +103 -0
- package/examples/vue-event-subscriptions/e2e/app.spec.ts +71 -0
- package/examples/vue-event-subscriptions/e2e/auth.spec.ts +290 -0
- package/examples/vue-event-subscriptions/index.html +13 -0
- package/examples/vue-event-subscriptions/package-lock.json +1719 -0
- package/examples/vue-event-subscriptions/package.json +28 -0
- package/examples/vue-event-subscriptions/playwright.config.ts +47 -0
- package/examples/vue-event-subscriptions/src/App.vue +233 -0
- package/examples/vue-event-subscriptions/src/main.ts +25 -0
- package/examples/vue-event-subscriptions/src/router/index.ts +68 -0
- package/examples/vue-event-subscriptions/src/views/Callback.vue +76 -0
- package/examples/vue-event-subscriptions/src/views/Home.vue +192 -0
- package/examples/vue-event-subscriptions/src/views/LiveEvents.vue +640 -0
- package/examples/vue-event-subscriptions/src/views/Login.vue +33 -0
- package/examples/vue-event-subscriptions/src/views/Logout.vue +59 -0
- package/examples/vue-event-subscriptions/src/views/Subscriptions.vue +402 -0
- package/examples/vue-event-subscriptions/src/vite-env.d.ts +12 -0
- package/examples/vue-event-subscriptions/tsconfig.json +21 -0
- package/examples/vue-event-subscriptions/tsconfig.node.json +10 -0
- package/examples/vue-event-subscriptions/vite.config.ts +12 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineStore as
|
|
2
|
-
import { ref as
|
|
3
|
-
const
|
|
1
|
+
import { defineStore as le } from "pinia";
|
|
2
|
+
import { ref as E, computed as N } from "vue";
|
|
3
|
+
const fe = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, _e = () => {
|
|
4
4
|
try {
|
|
5
|
-
return
|
|
5
|
+
return fe?.VITE_DEBUG === "true";
|
|
6
6
|
} catch {
|
|
7
7
|
return !1;
|
|
8
8
|
}
|
|
@@ -10,12 +10,12 @@ const le = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, _e
|
|
|
10
10
|
function c(...e) {
|
|
11
11
|
_e() && console.log("[een-api-toolkit]", ...e);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const we = {
|
|
14
14
|
localStorage: "persists across sessions",
|
|
15
15
|
sessionStorage: "per-tab, cleared on tab close",
|
|
16
16
|
memory: "tokens lost on page refresh"
|
|
17
17
|
};
|
|
18
|
-
class
|
|
18
|
+
class ge {
|
|
19
19
|
store = /* @__PURE__ */ new Map();
|
|
20
20
|
getItem(n) {
|
|
21
21
|
return this.store.get(n) ?? null;
|
|
@@ -27,7 +27,7 @@ class fe {
|
|
|
27
27
|
this.store.delete(n);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
class
|
|
30
|
+
class J {
|
|
31
31
|
constructor(n) {
|
|
32
32
|
this.storage = n;
|
|
33
33
|
}
|
|
@@ -41,49 +41,49 @@ class Q {
|
|
|
41
41
|
this.storage.removeItem(n);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
let
|
|
45
|
-
function
|
|
46
|
-
return
|
|
44
|
+
let C = "localStorage", H = null;
|
|
45
|
+
function x() {
|
|
46
|
+
return H || (H = new ge()), H;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
48
|
+
function he(e) {
|
|
49
|
+
C = e;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function be() {
|
|
52
|
+
return C;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
switch (
|
|
54
|
+
function z() {
|
|
55
|
+
switch (C) {
|
|
56
56
|
case "memory":
|
|
57
|
-
return
|
|
57
|
+
return x();
|
|
58
58
|
case "sessionStorage":
|
|
59
|
-
return typeof sessionStorage < "u" ? new
|
|
59
|
+
return typeof sessionStorage < "u" ? new J(sessionStorage) : (c("sessionStorage unavailable, falling back to memory storage"), x());
|
|
60
60
|
default:
|
|
61
|
-
return typeof localStorage < "u" ? new
|
|
61
|
+
return typeof localStorage < "u" ? new J(localStorage) : (c("localStorage unavailable, falling back to memory storage"), x());
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
let
|
|
64
|
+
const v = {};
|
|
65
|
+
let D = {};
|
|
66
66
|
function Ne(e = {}) {
|
|
67
67
|
const n = e.storageStrategy ?? "localStorage";
|
|
68
|
-
|
|
69
|
-
proxyUrl: e.proxyUrl ??
|
|
70
|
-
clientId: e.clientId ??
|
|
71
|
-
redirectUri: e.redirectUri ??
|
|
68
|
+
he(n), D = {
|
|
69
|
+
proxyUrl: e.proxyUrl ?? v?.VITE_PROXY_URL,
|
|
70
|
+
clientId: e.clientId ?? v?.VITE_EEN_CLIENT_ID,
|
|
71
|
+
redirectUri: e.redirectUri ?? v?.VITE_REDIRECT_URI,
|
|
72
72
|
storageStrategy: n,
|
|
73
|
-
debug: e.debug ??
|
|
73
|
+
debug: e.debug ?? v?.VITE_DEBUG === "true"
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
76
|
+
function Le() {
|
|
77
|
+
return D;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function V() {
|
|
80
|
+
return D.proxyUrl ?? v?.VITE_PROXY_URL;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return
|
|
82
|
+
function Re() {
|
|
83
|
+
return D.clientId ?? v?.VITE_EEN_CLIENT_ID;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
return
|
|
85
|
+
function X() {
|
|
86
|
+
return D.redirectUri ?? v?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
|
|
87
87
|
}
|
|
88
88
|
function l(e) {
|
|
89
89
|
return { data: e, error: null };
|
|
@@ -91,92 +91,95 @@ function l(e) {
|
|
|
91
91
|
function r(e, n, t, i) {
|
|
92
92
|
return { data: null, error: { code: e, message: n, status: t, details: i } };
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return F || (F = Promise.resolve().then(() => ye).then((e) => e.refreshToken)), F;
|
|
94
|
+
function A(e) {
|
|
95
|
+
return e.endsWith("+00:00") ? e : e.endsWith("Z") ? e.replace("Z", "+00:00") : e;
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
let Q = null;
|
|
98
|
+
function pe() {
|
|
99
|
+
return Q || (Q = Promise.resolve().then(() => ye).then((e) => e.refreshToken)), Q;
|
|
100
|
+
}
|
|
101
|
+
const f = le("een-auth", () => {
|
|
102
|
+
const e = E(null), n = E(null), t = E(null), i = E(null), a = E(null), o = E(443), s = E(null), d = E(null), h = E(!1);
|
|
103
|
+
let I = null;
|
|
104
|
+
const p = E(!1), _ = E(null), S = N(() => !!e.value), y = N(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), R = N(() => n.value ? Date.now() >= n.value : !0), q = N(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
|
|
105
|
+
function B(u, g) {
|
|
106
|
+
e.value = u, n.value = Date.now() + g * 1e3, k(), P(), c("Token set, expires in", g, "seconds");
|
|
104
107
|
}
|
|
105
|
-
function
|
|
106
|
-
t.value = u,
|
|
108
|
+
function w(u) {
|
|
109
|
+
t.value = u, k();
|
|
107
110
|
}
|
|
108
|
-
function
|
|
109
|
-
i.value = u,
|
|
111
|
+
function U(u) {
|
|
112
|
+
i.value = u, k();
|
|
110
113
|
}
|
|
111
|
-
function
|
|
114
|
+
function $(u) {
|
|
112
115
|
if (typeof u == "string")
|
|
113
116
|
try {
|
|
114
|
-
const
|
|
115
|
-
a.value =
|
|
116
|
-
} catch (
|
|
117
|
-
c("Failed to parse URL, using as hostname:",
|
|
117
|
+
const g = new URL(u.startsWith("http") ? u : `https://${u}`);
|
|
118
|
+
a.value = g.hostname, o.value = g.port ? parseInt(g.port, 10) : 443;
|
|
119
|
+
} catch (g) {
|
|
120
|
+
c("Failed to parse URL, using as hostname:", g instanceof Error ? g.message : String(g)), a.value = u, o.value = 443;
|
|
118
121
|
}
|
|
119
122
|
else
|
|
120
123
|
a.value = u.hostname, o.value = u.port ?? 443;
|
|
121
|
-
|
|
124
|
+
k(), c("Base URL set:", y.value);
|
|
122
125
|
}
|
|
123
|
-
function
|
|
124
|
-
s.value = u,
|
|
126
|
+
function T(u) {
|
|
127
|
+
s.value = u, k();
|
|
125
128
|
}
|
|
126
|
-
function
|
|
129
|
+
function P() {
|
|
127
130
|
if (d.value && (clearTimeout(d.value), d.value = null), !n.value || !e.value)
|
|
128
131
|
return;
|
|
129
|
-
const u = Date.now(),
|
|
130
|
-
c("Auto-refresh scheduled in", Math.round(
|
|
131
|
-
await
|
|
132
|
-
},
|
|
132
|
+
const u = Date.now(), O = n.value - u, b = 300 * 1e3, ce = O / 2, ue = Math.min(b, ce), de = Math.max(O - ue, 60 * 1e3), G = Math.max(de, 5e3);
|
|
133
|
+
c("Auto-refresh scheduled in", Math.round(G / 1e3), "seconds"), d.value = setTimeout(async () => {
|
|
134
|
+
await re();
|
|
135
|
+
}, G);
|
|
133
136
|
}
|
|
134
|
-
async function
|
|
135
|
-
return
|
|
137
|
+
async function re() {
|
|
138
|
+
return I ? (c("Refresh already in progress, waiting for existing refresh"), I) : (h.value = !0, c("Performing auto-refresh"), I = (async () => {
|
|
136
139
|
try {
|
|
137
|
-
const
|
|
138
|
-
|
|
140
|
+
const g = await (await pe())();
|
|
141
|
+
g.error ? (p.value = !0, _.value = g.error.message, c("Auto-refresh failed:", g.error.message)) : (p.value = !1, _.value = null, c("Auto-refresh successful"));
|
|
139
142
|
} catch (u) {
|
|
140
|
-
|
|
143
|
+
p.value = !0, _.value = u instanceof Error ? u.message : String(u), c("Auto-refresh error:", u);
|
|
141
144
|
} finally {
|
|
142
|
-
|
|
145
|
+
h.value = !1, I = null;
|
|
143
146
|
}
|
|
144
|
-
})(),
|
|
147
|
+
})(), I);
|
|
145
148
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
149
|
+
function ie() {
|
|
150
|
+
p.value = !1, _.value = null;
|
|
148
151
|
}
|
|
149
|
-
function
|
|
150
|
-
d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, i.value = null, a.value = null, o.value = 443, s.value = null,
|
|
152
|
+
function K() {
|
|
153
|
+
d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, i.value = null, a.value = null, o.value = 443, s.value = null, p.value = !1, _.value = null, se(), c("Logged out");
|
|
151
154
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
155
|
+
function oe() {
|
|
156
|
+
ae(), e.value && !R.value ? (P(), c("Initialized from storage")) : e.value && R.value && (c("Stored token expired, clearing"), K());
|
|
154
157
|
}
|
|
155
|
-
function
|
|
158
|
+
function k() {
|
|
156
159
|
try {
|
|
157
|
-
const u =
|
|
160
|
+
const u = z();
|
|
158
161
|
e.value && u.setItem("een_token", e.value), n.value && u.setItem("een_tokenExpiration", String(n.value)), t.value && u.setItem("een_refreshTokenMarker", t.value), i.value && u.setItem("een_sessionId", i.value), a.value && u.setItem("een_hostname", a.value), o.value !== 443 && u.setItem("een_port", String(o.value)), s.value && u.setItem("een_userProfile", JSON.stringify(s.value));
|
|
159
162
|
} catch (u) {
|
|
160
163
|
c("Failed to save to storage:", u instanceof Error ? u.message : String(u));
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
|
-
function
|
|
166
|
+
function ae() {
|
|
164
167
|
try {
|
|
165
|
-
const u =
|
|
168
|
+
const u = z();
|
|
166
169
|
e.value = u.getItem("een_token");
|
|
167
|
-
const
|
|
168
|
-
n.value =
|
|
169
|
-
const
|
|
170
|
-
o.value =
|
|
171
|
-
const
|
|
172
|
-
s.value =
|
|
170
|
+
const g = u.getItem("een_tokenExpiration");
|
|
171
|
+
n.value = g ? parseInt(g, 10) : null, t.value = u.getItem("een_refreshTokenMarker"), i.value = u.getItem("een_sessionId"), a.value = u.getItem("een_hostname");
|
|
172
|
+
const O = u.getItem("een_port");
|
|
173
|
+
o.value = O ? parseInt(O, 10) : 443;
|
|
174
|
+
const b = u.getItem("een_userProfile");
|
|
175
|
+
s.value = b ? JSON.parse(b) : null;
|
|
173
176
|
} catch (u) {
|
|
174
177
|
c("Failed to load from storage:", u instanceof Error ? u.message : String(u));
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
|
-
function
|
|
180
|
+
function se() {
|
|
178
181
|
try {
|
|
179
|
-
const u =
|
|
182
|
+
const u = z();
|
|
180
183
|
u.removeItem("een_token"), u.removeItem("een_tokenExpiration"), u.removeItem("een_refreshTokenMarker"), u.removeItem("een_sessionId"), u.removeItem("een_hostname"), u.removeItem("een_port"), u.removeItem("een_userProfile");
|
|
181
184
|
} catch (u) {
|
|
182
185
|
c("Failed to clear storage:", u instanceof Error ? u.message : String(u));
|
|
@@ -191,28 +194,28 @@ const _ = de("een-auth", () => {
|
|
|
191
194
|
hostname: a,
|
|
192
195
|
port: o,
|
|
193
196
|
userProfile: s,
|
|
194
|
-
isRefreshing:
|
|
195
|
-
refreshFailed:
|
|
196
|
-
refreshFailedMessage:
|
|
197
|
+
isRefreshing: h,
|
|
198
|
+
refreshFailed: p,
|
|
199
|
+
refreshFailedMessage: _,
|
|
197
200
|
// Computed
|
|
198
|
-
isAuthenticated:
|
|
199
|
-
baseUrl:
|
|
200
|
-
isTokenExpired:
|
|
201
|
-
tokenExpiresIn:
|
|
201
|
+
isAuthenticated: S,
|
|
202
|
+
baseUrl: y,
|
|
203
|
+
isTokenExpired: R,
|
|
204
|
+
tokenExpiresIn: q,
|
|
202
205
|
// Actions
|
|
203
|
-
setToken:
|
|
204
|
-
setRefreshTokenMarker:
|
|
205
|
-
setSessionId:
|
|
206
|
-
setBaseUrl:
|
|
207
|
-
setUserProfile:
|
|
208
|
-
setupAutoRefresh:
|
|
209
|
-
clearRefreshFailed:
|
|
210
|
-
logout:
|
|
211
|
-
initialize:
|
|
206
|
+
setToken: B,
|
|
207
|
+
setRefreshTokenMarker: w,
|
|
208
|
+
setSessionId: U,
|
|
209
|
+
setBaseUrl: $,
|
|
210
|
+
setUserProfile: T,
|
|
211
|
+
setupAutoRefresh: P,
|
|
212
|
+
clearRefreshFailed: ie,
|
|
213
|
+
logout: K,
|
|
214
|
+
initialize: oe
|
|
212
215
|
};
|
|
213
|
-
}),
|
|
214
|
-
function
|
|
215
|
-
const e =
|
|
216
|
+
}), Ee = "https://auth.eagleeyenetworks.com/oauth2/authorize";
|
|
217
|
+
function Ie() {
|
|
218
|
+
const e = Re();
|
|
216
219
|
if (!e)
|
|
217
220
|
throw new Error("Client ID not configured. Call initEenToolkit() or set VITE_EEN_CLIENT_ID");
|
|
218
221
|
const n = crypto.randomUUID();
|
|
@@ -224,18 +227,18 @@ function Ee() {
|
|
|
224
227
|
client_id: e,
|
|
225
228
|
response_type: "code",
|
|
226
229
|
scope: "vms.all",
|
|
227
|
-
redirect_uri:
|
|
230
|
+
redirect_uri: X(),
|
|
228
231
|
state: n
|
|
229
232
|
});
|
|
230
|
-
return c("Generated auth URL with state:", n), `${
|
|
233
|
+
return c("Generated auth URL with state:", n), `${Ee}?${t.toString()}`;
|
|
231
234
|
}
|
|
232
|
-
async function
|
|
233
|
-
const n =
|
|
235
|
+
async function Y(e) {
|
|
236
|
+
const n = V();
|
|
234
237
|
if (!n)
|
|
235
238
|
return r("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
|
|
236
239
|
const t = new URLSearchParams({
|
|
237
240
|
code: e,
|
|
238
|
-
redirect_uri:
|
|
241
|
+
redirect_uri: X()
|
|
239
242
|
});
|
|
240
243
|
try {
|
|
241
244
|
const i = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
|
|
@@ -255,11 +258,11 @@ async function M(e) {
|
|
|
255
258
|
return r("NETWORK_ERROR", `Failed to exchange code: ${String(i)}`);
|
|
256
259
|
}
|
|
257
260
|
}
|
|
258
|
-
async function
|
|
259
|
-
const e =
|
|
261
|
+
async function Te() {
|
|
262
|
+
const e = V();
|
|
260
263
|
if (!e)
|
|
261
264
|
return r("AUTH_FAILED", "Proxy URL not configured");
|
|
262
|
-
const n =
|
|
265
|
+
const n = f();
|
|
263
266
|
try {
|
|
264
267
|
const t = {
|
|
265
268
|
Accept: "application/json"
|
|
@@ -280,11 +283,11 @@ async function Ie() {
|
|
|
280
283
|
return r("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
|
-
async function
|
|
284
|
-
const e =
|
|
286
|
+
async function Ae() {
|
|
287
|
+
const e = V();
|
|
285
288
|
if (!e)
|
|
286
289
|
return r("AUTH_FAILED", "Proxy URL not configured");
|
|
287
|
-
const n =
|
|
290
|
+
const n = f();
|
|
288
291
|
try {
|
|
289
292
|
const t = {
|
|
290
293
|
Accept: "application/json"
|
|
@@ -304,7 +307,7 @@ async function Te() {
|
|
|
304
307
|
return n.logout(), r("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
|
|
305
308
|
}
|
|
306
309
|
}
|
|
307
|
-
async function
|
|
310
|
+
async function Ue(e, n) {
|
|
308
311
|
let t = null;
|
|
309
312
|
try {
|
|
310
313
|
t = sessionStorage.getItem("een_oauth_state"), sessionStorage.removeItem("een_oauth_state");
|
|
@@ -312,16 +315,16 @@ async function Ae(e, n) {
|
|
|
312
315
|
}
|
|
313
316
|
if (!t)
|
|
314
317
|
return r("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
|
|
315
|
-
if (!
|
|
318
|
+
if (!Se(n, t))
|
|
316
319
|
return r("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
|
|
317
320
|
c("State validated, exchanging code for token");
|
|
318
|
-
const i = await
|
|
321
|
+
const i = await Y(e);
|
|
319
322
|
if (i.error)
|
|
320
323
|
return i;
|
|
321
|
-
const a =
|
|
324
|
+
const a = f(), o = i.data;
|
|
322
325
|
return a.setToken(o.accessToken, o.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(o.sessionId), a.setBaseUrl(o.httpsBaseUrl), c("Auth callback complete, user:", o.userEmail), l(o);
|
|
323
326
|
}
|
|
324
|
-
function
|
|
327
|
+
function Se(e, n) {
|
|
325
328
|
if (e.length !== n.length)
|
|
326
329
|
return !1;
|
|
327
330
|
let t = 0;
|
|
@@ -331,14 +334,14 @@ function Ue(e, n) {
|
|
|
331
334
|
}
|
|
332
335
|
const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
333
336
|
__proto__: null,
|
|
334
|
-
getAccessToken:
|
|
335
|
-
getAuthUrl:
|
|
336
|
-
handleAuthCallback:
|
|
337
|
-
refreshToken:
|
|
338
|
-
revokeToken:
|
|
337
|
+
getAccessToken: Y,
|
|
338
|
+
getAuthUrl: Ie,
|
|
339
|
+
handleAuthCallback: Ue,
|
|
340
|
+
refreshToken: Te,
|
|
341
|
+
revokeToken: Ae
|
|
339
342
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
340
343
|
async function je() {
|
|
341
|
-
const e =
|
|
344
|
+
const e = f();
|
|
342
345
|
if (!e.isAuthenticated)
|
|
343
346
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
344
347
|
if (!e.baseUrl)
|
|
@@ -354,15 +357,15 @@ async function je() {
|
|
|
354
357
|
}
|
|
355
358
|
});
|
|
356
359
|
if (!t.ok)
|
|
357
|
-
return
|
|
360
|
+
return M(t);
|
|
358
361
|
const i = await t.json();
|
|
359
362
|
return c("Current user fetched:", i.email), e.setUserProfile(i), l(i);
|
|
360
363
|
} catch (t) {
|
|
361
364
|
return r("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
|
-
async function
|
|
365
|
-
const n =
|
|
367
|
+
async function Fe(e) {
|
|
368
|
+
const n = f();
|
|
366
369
|
if (!n.isAuthenticated)
|
|
367
370
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
368
371
|
if (!n.baseUrl)
|
|
@@ -380,15 +383,15 @@ async function Le(e) {
|
|
|
380
383
|
}
|
|
381
384
|
});
|
|
382
385
|
if (!o.ok)
|
|
383
|
-
return
|
|
386
|
+
return M(o);
|
|
384
387
|
const s = await o.json();
|
|
385
388
|
return c("Users fetched:", s.results?.length ?? 0, "users"), l(s);
|
|
386
389
|
} catch (o) {
|
|
387
390
|
return r("NETWORK_ERROR", `Failed to fetch users: ${String(o)}`);
|
|
388
391
|
}
|
|
389
392
|
}
|
|
390
|
-
async function
|
|
391
|
-
const t =
|
|
393
|
+
async function qe(e, n) {
|
|
394
|
+
const t = f();
|
|
392
395
|
if (!t.isAuthenticated)
|
|
393
396
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
394
397
|
if (!t.baseUrl)
|
|
@@ -408,14 +411,14 @@ async function Fe(e, n) {
|
|
|
408
411
|
}
|
|
409
412
|
});
|
|
410
413
|
if (!s.ok)
|
|
411
|
-
return
|
|
414
|
+
return M(s);
|
|
412
415
|
const d = await s.json();
|
|
413
416
|
return c("User fetched:", d.email), l(d);
|
|
414
417
|
} catch (s) {
|
|
415
418
|
return r("NETWORK_ERROR", `Failed to fetch user: ${String(s)}`);
|
|
416
419
|
}
|
|
417
420
|
}
|
|
418
|
-
async function
|
|
421
|
+
async function M(e) {
|
|
419
422
|
const n = e.status;
|
|
420
423
|
let t;
|
|
421
424
|
try {
|
|
@@ -437,8 +440,8 @@ async function B(e) {
|
|
|
437
440
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
438
441
|
}
|
|
439
442
|
}
|
|
440
|
-
async function
|
|
441
|
-
const n =
|
|
443
|
+
async function Be(e) {
|
|
444
|
+
const n = f();
|
|
442
445
|
if (!n.isAuthenticated)
|
|
443
446
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
444
447
|
if (!n.baseUrl)
|
|
@@ -456,7 +459,7 @@ async function qe(e) {
|
|
|
456
459
|
}
|
|
457
460
|
});
|
|
458
461
|
if (!o.ok)
|
|
459
|
-
return
|
|
462
|
+
return Z(o);
|
|
460
463
|
const s = await o.json();
|
|
461
464
|
return c("Cameras fetched:", s.results?.length ?? 0, "cameras"), l(s);
|
|
462
465
|
} catch (o) {
|
|
@@ -464,7 +467,7 @@ async function qe(e) {
|
|
|
464
467
|
}
|
|
465
468
|
}
|
|
466
469
|
async function Pe(e, n) {
|
|
467
|
-
const t =
|
|
470
|
+
const t = f();
|
|
468
471
|
if (!t.isAuthenticated)
|
|
469
472
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
470
473
|
if (!t.baseUrl)
|
|
@@ -484,14 +487,14 @@ async function Pe(e, n) {
|
|
|
484
487
|
}
|
|
485
488
|
});
|
|
486
489
|
if (!s.ok)
|
|
487
|
-
return
|
|
490
|
+
return Z(s);
|
|
488
491
|
const d = await s.json();
|
|
489
492
|
return c("Camera fetched:", d.name), l(d);
|
|
490
493
|
} catch (s) {
|
|
491
494
|
return r("NETWORK_ERROR", `Failed to fetch camera: ${String(s)}`);
|
|
492
495
|
}
|
|
493
496
|
}
|
|
494
|
-
async function
|
|
497
|
+
async function Z(e) {
|
|
495
498
|
const n = e.status;
|
|
496
499
|
let t;
|
|
497
500
|
try {
|
|
@@ -513,8 +516,8 @@ async function V(e) {
|
|
|
513
516
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
|
-
async function
|
|
517
|
-
const n =
|
|
519
|
+
async function He(e) {
|
|
520
|
+
const n = f();
|
|
518
521
|
if (!n.isAuthenticated)
|
|
519
522
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
520
523
|
if (!n.baseUrl)
|
|
@@ -532,15 +535,15 @@ async function Be(e) {
|
|
|
532
535
|
}
|
|
533
536
|
});
|
|
534
537
|
if (!o.ok)
|
|
535
|
-
return
|
|
538
|
+
return ee(o);
|
|
536
539
|
const s = await o.json();
|
|
537
540
|
return c("Bridges fetched:", s.results?.length ?? 0, "bridges"), l(s);
|
|
538
541
|
} catch (o) {
|
|
539
542
|
return r("NETWORK_ERROR", `Failed to fetch bridges: ${String(o)}`);
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
|
-
async function
|
|
543
|
-
const t =
|
|
545
|
+
async function xe(e, n) {
|
|
546
|
+
const t = f();
|
|
544
547
|
if (!t.isAuthenticated)
|
|
545
548
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
546
549
|
if (!t.baseUrl)
|
|
@@ -560,14 +563,14 @@ async function He(e, n) {
|
|
|
560
563
|
}
|
|
561
564
|
});
|
|
562
565
|
if (!s.ok)
|
|
563
|
-
return
|
|
566
|
+
return ee(s);
|
|
564
567
|
const d = await s.json();
|
|
565
568
|
return c("Bridge fetched:", d.name), l(d);
|
|
566
569
|
} catch (s) {
|
|
567
570
|
return r("NETWORK_ERROR", `Failed to fetch bridge: ${String(s)}`);
|
|
568
571
|
}
|
|
569
572
|
}
|
|
570
|
-
async function
|
|
573
|
+
async function ee(e) {
|
|
571
574
|
const n = e.status;
|
|
572
575
|
let t;
|
|
573
576
|
try {
|
|
@@ -589,25 +592,25 @@ async function W(e) {
|
|
|
589
592
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
590
593
|
}
|
|
591
594
|
}
|
|
592
|
-
const
|
|
593
|
-
function
|
|
595
|
+
const ve = 3e4;
|
|
596
|
+
function m(e = ve) {
|
|
594
597
|
const n = new AbortController(), t = setTimeout(() => n.abort(), e);
|
|
595
598
|
return { controller: n, timeoutId: t };
|
|
596
599
|
}
|
|
597
|
-
function
|
|
600
|
+
function te(e) {
|
|
598
601
|
const n = new Uint8Array(e), t = 8192, i = [];
|
|
599
602
|
for (let o = 0; o < n.byteLength; o += t) {
|
|
600
603
|
const s = n.subarray(o, Math.min(o + t, n.byteLength));
|
|
601
604
|
let d = "";
|
|
602
|
-
for (let
|
|
603
|
-
d += String.fromCharCode(s[
|
|
605
|
+
for (let h = 0; h < s.length; h++)
|
|
606
|
+
d += String.fromCharCode(s[h]);
|
|
604
607
|
i.push(d);
|
|
605
608
|
}
|
|
606
609
|
const a = i.join("");
|
|
607
610
|
return typeof btoa == "function" ? btoa(a) : Buffer.from(a, "binary").toString("base64");
|
|
608
611
|
}
|
|
609
|
-
async function
|
|
610
|
-
const n =
|
|
612
|
+
async function ze(e) {
|
|
613
|
+
const n = f();
|
|
611
614
|
if (!n.isAuthenticated)
|
|
612
615
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
613
616
|
if (!n.baseUrl)
|
|
@@ -624,7 +627,7 @@ async function xe(e) {
|
|
|
624
627
|
t.append("deviceId", e.deviceId), t.append("type", e.type), t.append("mediaType", e.mediaType), t.append("startTimestamp__gte", e.startTimestamp), e.endTimestamp && t.append("endTimestamp__lte", e.endTimestamp), typeof e.coalesce == "boolean" && t.append("coalesce", String(e.coalesce)), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), e.pageToken && t.append("pageToken", e.pageToken), typeof e.pageSize == "number" && t.append("pageSize", String(e.pageSize));
|
|
625
628
|
const i = `${n.baseUrl}/api/v3.0/media?${t.toString()}`;
|
|
626
629
|
c("Fetching media intervals:", i);
|
|
627
|
-
const { controller: a, timeoutId: o } =
|
|
630
|
+
const { controller: a, timeoutId: o } = m();
|
|
628
631
|
try {
|
|
629
632
|
const s = await fetch(i, {
|
|
630
633
|
method: "GET",
|
|
@@ -635,7 +638,7 @@ async function xe(e) {
|
|
|
635
638
|
signal: a.signal
|
|
636
639
|
});
|
|
637
640
|
if (!s.ok)
|
|
638
|
-
return
|
|
641
|
+
return L(s);
|
|
639
642
|
const d = await s.json();
|
|
640
643
|
return c("Media intervals fetched:", d.results?.length ?? 0, "intervals"), l(d);
|
|
641
644
|
} catch (s) {
|
|
@@ -644,8 +647,8 @@ async function xe(e) {
|
|
|
644
647
|
clearTimeout(o);
|
|
645
648
|
}
|
|
646
649
|
}
|
|
647
|
-
async function
|
|
648
|
-
const n =
|
|
650
|
+
async function Qe(e) {
|
|
651
|
+
const n = f();
|
|
649
652
|
if (!n.isAuthenticated)
|
|
650
653
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
651
654
|
if (!n.baseUrl)
|
|
@@ -656,7 +659,7 @@ async function ze(e) {
|
|
|
656
659
|
i.append("deviceId", e.deviceId), i.append("type", t);
|
|
657
660
|
const a = `${n.baseUrl}/api/v3.0/media/liveImage.jpeg?${i.toString()}`;
|
|
658
661
|
c("Fetching live image:", a);
|
|
659
|
-
const { controller: o, timeoutId: s } =
|
|
662
|
+
const { controller: o, timeoutId: s } = m();
|
|
660
663
|
try {
|
|
661
664
|
const d = await fetch(a, {
|
|
662
665
|
method: "GET",
|
|
@@ -665,14 +668,14 @@ async function ze(e) {
|
|
|
665
668
|
Authorization: `Bearer ${n.token}`
|
|
666
669
|
},
|
|
667
670
|
signal: o.signal
|
|
668
|
-
}),
|
|
671
|
+
}), h = d.headers.get("X-Een-Timestamp"), I = d.headers.get("X-Een-PrevToken");
|
|
669
672
|
if (!d.ok)
|
|
670
|
-
return
|
|
671
|
-
const
|
|
672
|
-
return c("Live image fetched, timestamp:",
|
|
673
|
-
imageData:
|
|
674
|
-
timestamp:
|
|
675
|
-
prevToken:
|
|
673
|
+
return L(d);
|
|
674
|
+
const p = await d.arrayBuffer(), S = `data:image/jpeg;base64,${te(p)}`;
|
|
675
|
+
return c("Live image fetched, timestamp:", h), l({
|
|
676
|
+
imageData: S,
|
|
677
|
+
timestamp: h,
|
|
678
|
+
prevToken: I
|
|
676
679
|
});
|
|
677
680
|
} catch (d) {
|
|
678
681
|
return d instanceof Error && d.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch live image: ${String(d)}`);
|
|
@@ -680,8 +683,8 @@ async function ze(e) {
|
|
|
680
683
|
clearTimeout(s);
|
|
681
684
|
}
|
|
682
685
|
}
|
|
683
|
-
async function
|
|
684
|
-
const n =
|
|
686
|
+
async function Ce(e) {
|
|
687
|
+
const n = f();
|
|
685
688
|
if (!n.isAuthenticated)
|
|
686
689
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
687
690
|
if (!n.baseUrl)
|
|
@@ -696,7 +699,7 @@ async function Qe(e) {
|
|
|
696
699
|
e.deviceId && t.append("deviceId", e.deviceId), e.pageToken && t.append("pageToken", e.pageToken), e.type && t.append("type", e.type), e.timestamp__lt && t.append("timestamp__lt", e.timestamp__lt), e.timestamp__lte && t.append("timestamp__lte", e.timestamp__lte), e.timestamp && t.append("timestamp", e.timestamp), e.timestamp__gte && t.append("timestamp__gte", e.timestamp__gte), e.timestamp__gt && t.append("timestamp__gt", e.timestamp__gt), e.overlayId__in && e.overlayId__in.length > 0 && t.append("overlayId__in", e.overlayId__in.join(",")), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), typeof e.targetWidth == "number" && t.append("targetWidth", String(e.targetWidth)), typeof e.targetHeight == "number" && t.append("targetHeight", String(e.targetHeight));
|
|
697
700
|
const i = `${n.baseUrl}/api/v3.0/media/recordedImage.jpeg?${t.toString()}`;
|
|
698
701
|
c("Fetching recorded image:", i);
|
|
699
|
-
const { controller: a, timeoutId: o } =
|
|
702
|
+
const { controller: a, timeoutId: o } = m();
|
|
700
703
|
try {
|
|
701
704
|
const s = await fetch(i, {
|
|
702
705
|
method: "GET",
|
|
@@ -705,16 +708,16 @@ async function Qe(e) {
|
|
|
705
708
|
Authorization: `Bearer ${n.token}`
|
|
706
709
|
},
|
|
707
710
|
signal: a.signal
|
|
708
|
-
}), d = s.headers.get("X-Een-Timestamp"),
|
|
711
|
+
}), d = s.headers.get("X-Een-Timestamp"), h = s.headers.get("X-Een-NextToken"), I = s.headers.get("X-Een-PrevToken"), p = s.headers.get("X-Een-OverlaySvg");
|
|
709
712
|
if (!s.ok)
|
|
710
|
-
return
|
|
711
|
-
const
|
|
713
|
+
return L(s);
|
|
714
|
+
const _ = await s.arrayBuffer(), y = `data:image/jpeg;base64,${te(_)}`;
|
|
712
715
|
return c("Recorded image fetched, timestamp:", d), l({
|
|
713
|
-
imageData:
|
|
716
|
+
imageData: y,
|
|
714
717
|
timestamp: d,
|
|
715
|
-
nextToken:
|
|
716
|
-
prevToken:
|
|
717
|
-
overlaySvg:
|
|
718
|
+
nextToken: h,
|
|
719
|
+
prevToken: I,
|
|
720
|
+
overlaySvg: p
|
|
718
721
|
});
|
|
719
722
|
} catch (s) {
|
|
720
723
|
return s instanceof Error && s.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch recorded image: ${String(s)}`);
|
|
@@ -722,7 +725,7 @@ async function Qe(e) {
|
|
|
722
725
|
clearTimeout(o);
|
|
723
726
|
}
|
|
724
727
|
}
|
|
725
|
-
async function
|
|
728
|
+
async function L(e) {
|
|
726
729
|
const n = e.status;
|
|
727
730
|
let t;
|
|
728
731
|
try {
|
|
@@ -746,15 +749,15 @@ async function D(e) {
|
|
|
746
749
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
747
750
|
}
|
|
748
751
|
}
|
|
749
|
-
async function
|
|
750
|
-
const e =
|
|
752
|
+
async function $e() {
|
|
753
|
+
const e = f();
|
|
751
754
|
if (!e.isAuthenticated)
|
|
752
755
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
753
756
|
if (!e.baseUrl)
|
|
754
757
|
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
755
758
|
const n = `${e.baseUrl}/api/v3.0/media/session`;
|
|
756
759
|
c("Fetching media session:", n);
|
|
757
|
-
const { controller: t, timeoutId: i } =
|
|
760
|
+
const { controller: t, timeoutId: i } = m();
|
|
758
761
|
try {
|
|
759
762
|
const a = await fetch(n, {
|
|
760
763
|
method: "GET",
|
|
@@ -765,7 +768,7 @@ async function ve() {
|
|
|
765
768
|
signal: t.signal
|
|
766
769
|
});
|
|
767
770
|
if (!a.ok)
|
|
768
|
-
return
|
|
771
|
+
return L(a);
|
|
769
772
|
const o = await a.json();
|
|
770
773
|
return c("Media session URL received:", o.url), l(o);
|
|
771
774
|
} catch (a) {
|
|
@@ -774,11 +777,11 @@ async function ve() {
|
|
|
774
777
|
clearTimeout(i);
|
|
775
778
|
}
|
|
776
779
|
}
|
|
777
|
-
async function
|
|
778
|
-
const e =
|
|
780
|
+
async function Ve() {
|
|
781
|
+
const e = f();
|
|
779
782
|
if (!e.isAuthenticated)
|
|
780
783
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
781
|
-
const n = await
|
|
784
|
+
const n = await $e();
|
|
782
785
|
if (n.error)
|
|
783
786
|
return r(
|
|
784
787
|
n.error.code,
|
|
@@ -789,7 +792,7 @@ async function Ce() {
|
|
|
789
792
|
return r("API_ERROR", "No session URL returned from media session endpoint");
|
|
790
793
|
const t = n.data.url;
|
|
791
794
|
c("Calling session URL to set cookie:", t);
|
|
792
|
-
const { controller: i, timeoutId: a } =
|
|
795
|
+
const { controller: i, timeoutId: a } = m();
|
|
793
796
|
try {
|
|
794
797
|
const o = await fetch(t, {
|
|
795
798
|
method: "GET",
|
|
@@ -805,8 +808,8 @@ async function Ce() {
|
|
|
805
808
|
const s = o.status;
|
|
806
809
|
let d;
|
|
807
810
|
try {
|
|
808
|
-
const
|
|
809
|
-
d =
|
|
811
|
+
const h = await o.json();
|
|
812
|
+
d = h.message ?? h.error ?? o.statusText;
|
|
810
813
|
} catch {
|
|
811
814
|
d = o.statusText || "Unknown error";
|
|
812
815
|
}
|
|
@@ -823,7 +826,7 @@ async function Ce() {
|
|
|
823
826
|
}
|
|
824
827
|
}
|
|
825
828
|
async function Me(e) {
|
|
826
|
-
const n =
|
|
829
|
+
const n = f();
|
|
827
830
|
if (!n.isAuthenticated)
|
|
828
831
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
829
832
|
if (!n.baseUrl)
|
|
@@ -873,11 +876,8 @@ async function ke(e) {
|
|
|
873
876
|
return r("API_ERROR", t || e.statusText || "API error", n);
|
|
874
877
|
}
|
|
875
878
|
}
|
|
876
|
-
function
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
async function Ve(e) {
|
|
880
|
-
const n = _();
|
|
879
|
+
async function We(e) {
|
|
880
|
+
const n = f();
|
|
881
881
|
if (!n.isAuthenticated)
|
|
882
882
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
883
883
|
if (!n.baseUrl)
|
|
@@ -889,7 +889,7 @@ async function Ve(e) {
|
|
|
889
889
|
if (!e.startTimestamp__gte)
|
|
890
890
|
return r("VALIDATION_ERROR", "startTimestamp__gte parameter is required");
|
|
891
891
|
const t = new URLSearchParams();
|
|
892
|
-
t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte",
|
|
892
|
+
t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte", A(e.startTimestamp__gte)), e.pageSize && t.append("pageSize", String(e.pageSize)), e.pageToken && t.append("pageToken", e.pageToken), e.startTimestamp__lte && t.append("startTimestamp__lte", A(e.startTimestamp__lte)), e.endTimestamp__gte && t.append("endTimestamp__gte", A(e.endTimestamp__gte)), e.endTimestamp__lte && t.append("endTimestamp__lte", A(e.endTimestamp__lte)), e.sort && t.append("sort", e.sort), e.include && e.include.length > 0 && t.append("include", e.include.join(","));
|
|
893
893
|
const i = t.toString(), a = `${n.baseUrl}/api/v3.0/events${i ? `?${i}` : ""}`;
|
|
894
894
|
c("Fetching events:", a);
|
|
895
895
|
try {
|
|
@@ -901,15 +901,15 @@ async function Ve(e) {
|
|
|
901
901
|
}
|
|
902
902
|
});
|
|
903
903
|
if (!o.ok)
|
|
904
|
-
return
|
|
904
|
+
return j(o);
|
|
905
905
|
const s = await o.json();
|
|
906
906
|
return c("Events fetched:", s.results?.length ?? 0, "events"), l(s);
|
|
907
907
|
} catch (o) {
|
|
908
908
|
return r("NETWORK_ERROR", `Failed to fetch events: ${String(o)}`);
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
|
-
async function
|
|
912
|
-
const t =
|
|
911
|
+
async function Ke(e, n) {
|
|
912
|
+
const t = f();
|
|
913
913
|
if (!t.isAuthenticated)
|
|
914
914
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
915
915
|
if (!t.baseUrl)
|
|
@@ -929,15 +929,15 @@ async function We(e, n) {
|
|
|
929
929
|
}
|
|
930
930
|
});
|
|
931
931
|
if (!s.ok)
|
|
932
|
-
return
|
|
932
|
+
return j(s);
|
|
933
933
|
const d = await s.json();
|
|
934
934
|
return c("Event fetched:", d.id), l(d);
|
|
935
935
|
} catch (s) {
|
|
936
936
|
return r("NETWORK_ERROR", `Failed to fetch event: ${String(s)}`);
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
|
-
async function
|
|
940
|
-
const n =
|
|
939
|
+
async function Ge(e) {
|
|
940
|
+
const n = f();
|
|
941
941
|
if (!n.isAuthenticated)
|
|
942
942
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
943
943
|
if (!n.baseUrl)
|
|
@@ -955,15 +955,15 @@ async function Ke(e) {
|
|
|
955
955
|
}
|
|
956
956
|
});
|
|
957
957
|
if (!o.ok)
|
|
958
|
-
return
|
|
958
|
+
return j(o);
|
|
959
959
|
const s = await o.json();
|
|
960
960
|
return c("Event types fetched:", s.results?.length ?? 0, "types"), l(s);
|
|
961
961
|
} catch (o) {
|
|
962
962
|
return r("NETWORK_ERROR", `Failed to fetch event types: ${String(o)}`);
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
async function
|
|
966
|
-
const n =
|
|
965
|
+
async function Je(e) {
|
|
966
|
+
const n = f();
|
|
967
967
|
if (!n.isAuthenticated)
|
|
968
968
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
969
969
|
if (!n.baseUrl)
|
|
@@ -983,14 +983,14 @@ async function Ge(e) {
|
|
|
983
983
|
}
|
|
984
984
|
});
|
|
985
985
|
if (!o.ok)
|
|
986
|
-
return
|
|
986
|
+
return j(o);
|
|
987
987
|
const s = await o.json();
|
|
988
988
|
return c("Event field values fetched:", s.type?.length ?? 0, "types"), l(s);
|
|
989
989
|
} catch (o) {
|
|
990
990
|
return r("NETWORK_ERROR", `Failed to fetch event field values: ${String(o)}`);
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
|
-
async function
|
|
993
|
+
async function j(e) {
|
|
994
994
|
const n = e.status;
|
|
995
995
|
let t;
|
|
996
996
|
try {
|
|
@@ -1012,8 +1012,8 @@ async function m(e) {
|
|
|
1012
1012
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
|
-
async function
|
|
1016
|
-
const n =
|
|
1015
|
+
async function Xe(e) {
|
|
1016
|
+
const n = f();
|
|
1017
1017
|
if (!n.isAuthenticated)
|
|
1018
1018
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1019
1019
|
if (!n.baseUrl)
|
|
@@ -1023,7 +1023,7 @@ async function Je(e) {
|
|
|
1023
1023
|
if (!e.eventType)
|
|
1024
1024
|
return r("VALIDATION_ERROR", "eventType parameter is required");
|
|
1025
1025
|
const t = new URLSearchParams();
|
|
1026
|
-
t.append("actor", e.actor), t.append("eventType", e.eventType), e.timestamp__gte && t.append("timestamp__gte",
|
|
1026
|
+
t.append("actor", e.actor), t.append("eventType", e.eventType), e.timestamp__gte && t.append("timestamp__gte", A(e.timestamp__gte)), e.timestamp__lte && t.append("timestamp__lte", A(e.timestamp__lte)), e.aggregateByMinutes !== void 0 && t.append("aggregateByMinutes", String(e.aggregateByMinutes));
|
|
1027
1027
|
const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventMetrics${i ? `?${i}` : ""}`;
|
|
1028
1028
|
c("Fetching event metrics:", a);
|
|
1029
1029
|
try {
|
|
@@ -1035,14 +1035,14 @@ async function Je(e) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
});
|
|
1037
1037
|
if (!o.ok)
|
|
1038
|
-
return
|
|
1038
|
+
return Oe(o);
|
|
1039
1039
|
const s = await o.json();
|
|
1040
1040
|
return c("Event metrics fetched:", s.length, "metrics"), l(s);
|
|
1041
1041
|
} catch (o) {
|
|
1042
1042
|
return r("NETWORK_ERROR", `Failed to fetch event metrics: ${String(o)}`);
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
|
-
async function
|
|
1045
|
+
async function Oe(e) {
|
|
1046
1046
|
const n = e.status;
|
|
1047
1047
|
let t;
|
|
1048
1048
|
try {
|
|
@@ -1064,14 +1064,14 @@ async function $e(e) {
|
|
|
1064
1064
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
async function
|
|
1068
|
-
const n =
|
|
1067
|
+
async function Ye(e) {
|
|
1068
|
+
const n = f();
|
|
1069
1069
|
if (!n.isAuthenticated)
|
|
1070
1070
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1071
1071
|
if (!n.baseUrl)
|
|
1072
1072
|
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1073
1073
|
const t = new URLSearchParams();
|
|
1074
|
-
e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte",
|
|
1074
|
+
e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", A(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", A(e.timestamp__gte)), e?.creatorId && t.append("creatorId", e.creatorId), e?.alertType__in && e.alertType__in.length > 0 && t.append("alertType__in", e.alertType__in.join(",")), e?.actorId__in && e.actorId__in.length > 0 && t.append("actorId__in", e.actorId__in.join(",")), e?.actorType__in && e.actorType__in.length > 0 && t.append("actorType__in", e.actorType__in.join(",")), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.ruleId && t.append("ruleId", e.ruleId), e?.ruleId__in && e.ruleId__in.length > 0 && t.append("ruleId__in", e.ruleId__in.join(",")), e?.eventId && t.append("eventId", e.eventId), e?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.priority__gte !== void 0 && t.append("priority__gte", String(e.priority__gte)), e?.priority__lte !== void 0 && t.append("priority__lte", String(e.priority__lte)), e?.showInvalidAlerts !== void 0 && t.append("showInvalidAlerts", String(e.showInvalidAlerts)), e?.alertActionId__in && e.alertActionId__in.length > 0 && t.append("alertActionId__in", e.alertActionId__in.join(",")), e?.alertActionStatus__in && e.alertActionStatus__in.length > 0 && t.append("alertActionStatus__in", e.alertActionStatus__in.join(",")), e?.include && e.include.length > 0 && t.append("include", e.include.join(",")), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
|
|
1075
1075
|
const i = t.toString(), a = `${n.baseUrl}/api/v3.0/alerts${i ? `?${i}` : ""}`;
|
|
1076
1076
|
c("Fetching alerts:", a);
|
|
1077
1077
|
try {
|
|
@@ -1083,15 +1083,15 @@ async function Xe(e) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
});
|
|
1085
1085
|
if (!o.ok)
|
|
1086
|
-
return
|
|
1086
|
+
return W(o);
|
|
1087
1087
|
const s = await o.json();
|
|
1088
1088
|
return c("Alerts fetched:", s.results?.length ?? 0, "alerts"), l(s);
|
|
1089
1089
|
} catch (o) {
|
|
1090
1090
|
return r("NETWORK_ERROR", `Failed to fetch alerts: ${String(o)}`);
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
|
-
async function
|
|
1094
|
-
const t =
|
|
1093
|
+
async function Ze(e, n) {
|
|
1094
|
+
const t = f();
|
|
1095
1095
|
if (!t.isAuthenticated)
|
|
1096
1096
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1097
1097
|
if (!t.baseUrl)
|
|
@@ -1111,15 +1111,15 @@ async function Ye(e, n) {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
});
|
|
1113
1113
|
if (!s.ok)
|
|
1114
|
-
return
|
|
1114
|
+
return W(s);
|
|
1115
1115
|
const d = await s.json();
|
|
1116
1116
|
return c("Alert fetched:", d.id), l(d);
|
|
1117
1117
|
} catch (s) {
|
|
1118
1118
|
return r("NETWORK_ERROR", `Failed to fetch alert: ${String(s)}`);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
|
-
async function
|
|
1122
|
-
const n =
|
|
1121
|
+
async function et(e) {
|
|
1122
|
+
const n = f();
|
|
1123
1123
|
if (!n.isAuthenticated)
|
|
1124
1124
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1125
1125
|
if (!n.baseUrl)
|
|
@@ -1137,14 +1137,14 @@ async function Ze(e) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
});
|
|
1139
1139
|
if (!o.ok)
|
|
1140
|
-
return
|
|
1140
|
+
return W(o);
|
|
1141
1141
|
const s = await o.json();
|
|
1142
1142
|
return c("Alert types fetched:", s.results?.length ?? 0, "types"), l(s);
|
|
1143
1143
|
} catch (o) {
|
|
1144
1144
|
return r("NETWORK_ERROR", `Failed to fetch alert types: ${String(o)}`);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
async function
|
|
1147
|
+
async function W(e) {
|
|
1148
1148
|
const n = e.status;
|
|
1149
1149
|
let t;
|
|
1150
1150
|
try {
|
|
@@ -1166,14 +1166,14 @@ async function H(e) {
|
|
|
1166
1166
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
1167
1167
|
}
|
|
1168
1168
|
}
|
|
1169
|
-
async function
|
|
1170
|
-
const n =
|
|
1169
|
+
async function tt(e) {
|
|
1170
|
+
const n = f();
|
|
1171
1171
|
if (!n.isAuthenticated)
|
|
1172
1172
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1173
1173
|
if (!n.baseUrl)
|
|
1174
1174
|
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1175
1175
|
const t = new URLSearchParams();
|
|
1176
|
-
e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte",
|
|
1176
|
+
e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", A(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", A(e.timestamp__gte)), e?.alertId && t.append("alertId", e.alertId), e?.alertType && t.append("alertType", e.alertType), e?.actorId && t.append("actorId", e.actorId), e?.actorType && t.append("actorType", e.actorType), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.category && t.append("category", e.category), e?.userId && t.append("userId", e.userId), e?.read !== void 0 && t.append("read", String(e.read)), e?.status && t.append("status", e.status), e?.includeV1Notifications !== void 0 && t.append("includeV1Notifications", String(e.includeV1Notifications)), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
|
|
1177
1177
|
const i = t.toString(), a = `${n.baseUrl}/api/v3.0/notifications${i ? `?${i}` : ""}`;
|
|
1178
1178
|
c("Fetching notifications:", a);
|
|
1179
1179
|
try {
|
|
@@ -1185,15 +1185,15 @@ async function et(e) {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
});
|
|
1187
1187
|
if (!o.ok)
|
|
1188
|
-
return
|
|
1188
|
+
return ne(o);
|
|
1189
1189
|
const s = await o.json();
|
|
1190
1190
|
return c("Notifications fetched:", s.results?.length ?? 0, "notifications"), l(s);
|
|
1191
1191
|
} catch (o) {
|
|
1192
1192
|
return r("NETWORK_ERROR", `Failed to fetch notifications: ${String(o)}`);
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
|
-
async function
|
|
1196
|
-
const n =
|
|
1195
|
+
async function nt(e) {
|
|
1196
|
+
const n = f();
|
|
1197
1197
|
if (!n.isAuthenticated)
|
|
1198
1198
|
return r("AUTH_REQUIRED", "Authentication required");
|
|
1199
1199
|
if (!n.baseUrl)
|
|
@@ -1211,14 +1211,14 @@ async function tt(e) {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
});
|
|
1213
1213
|
if (!i.ok)
|
|
1214
|
-
return
|
|
1214
|
+
return ne(i);
|
|
1215
1215
|
const a = await i.json();
|
|
1216
1216
|
return c("Notification fetched:", a.id), l(a);
|
|
1217
1217
|
} catch (i) {
|
|
1218
1218
|
return r("NETWORK_ERROR", `Failed to fetch notification: ${String(i)}`);
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
1221
|
-
async function
|
|
1221
|
+
async function ne(e) {
|
|
1222
1222
|
const n = e.status;
|
|
1223
1223
|
let t;
|
|
1224
1224
|
try {
|
|
@@ -1240,44 +1240,268 @@ async function G(e) {
|
|
|
1240
1240
|
return r("API_ERROR", `API error: ${t}`, n);
|
|
1241
1241
|
}
|
|
1242
1242
|
}
|
|
1243
|
+
async function rt(e) {
|
|
1244
|
+
const n = f();
|
|
1245
|
+
if (!n.isAuthenticated)
|
|
1246
|
+
return r("AUTH_REQUIRED", "Authentication required");
|
|
1247
|
+
if (!n.baseUrl)
|
|
1248
|
+
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1249
|
+
const t = new URLSearchParams();
|
|
1250
|
+
e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken);
|
|
1251
|
+
const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventSubscriptions${i ? `?${i}` : ""}`;
|
|
1252
|
+
c("Fetching event subscriptions:", a);
|
|
1253
|
+
try {
|
|
1254
|
+
const o = await fetch(a, {
|
|
1255
|
+
method: "GET",
|
|
1256
|
+
headers: {
|
|
1257
|
+
Accept: "application/json",
|
|
1258
|
+
Authorization: `Bearer ${n.token}`
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
if (!o.ok)
|
|
1262
|
+
return F(o);
|
|
1263
|
+
const s = await o.json();
|
|
1264
|
+
return c("Event subscriptions fetched:", s.results?.length ?? 0, "subscriptions"), l(s);
|
|
1265
|
+
} catch (o) {
|
|
1266
|
+
return r("NETWORK_ERROR", `Failed to fetch event subscriptions: ${String(o)}`);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
async function it(e) {
|
|
1270
|
+
const n = f();
|
|
1271
|
+
if (!n.isAuthenticated)
|
|
1272
|
+
return r("AUTH_REQUIRED", "Authentication required");
|
|
1273
|
+
if (!n.baseUrl)
|
|
1274
|
+
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1275
|
+
if (!e)
|
|
1276
|
+
return r("VALIDATION_ERROR", "Subscription ID is required");
|
|
1277
|
+
const t = `${n.baseUrl}/api/v3.0/eventSubscriptions/${encodeURIComponent(e)}`;
|
|
1278
|
+
c("Fetching event subscription:", t);
|
|
1279
|
+
try {
|
|
1280
|
+
const i = await fetch(t, {
|
|
1281
|
+
method: "GET",
|
|
1282
|
+
headers: {
|
|
1283
|
+
Accept: "application/json",
|
|
1284
|
+
Authorization: `Bearer ${n.token}`
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
if (!i.ok)
|
|
1288
|
+
return F(i);
|
|
1289
|
+
const a = await i.json();
|
|
1290
|
+
return c("Event subscription fetched:", a.id), l(a);
|
|
1291
|
+
} catch (i) {
|
|
1292
|
+
return r("NETWORK_ERROR", `Failed to fetch event subscription: ${String(i)}`);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
async function ot(e) {
|
|
1296
|
+
const n = f();
|
|
1297
|
+
if (!n.isAuthenticated)
|
|
1298
|
+
return r("AUTH_REQUIRED", "Authentication required");
|
|
1299
|
+
if (!n.baseUrl)
|
|
1300
|
+
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1301
|
+
if (!e.deliveryConfig)
|
|
1302
|
+
return r("VALIDATION_ERROR", "deliveryConfig is required");
|
|
1303
|
+
if (!e.filters || e.filters.length === 0)
|
|
1304
|
+
return r("VALIDATION_ERROR", "At least one filter is required");
|
|
1305
|
+
for (const i of e.filters) {
|
|
1306
|
+
if (!i.actors || i.actors.length === 0)
|
|
1307
|
+
return r("VALIDATION_ERROR", "Each filter must have at least one actor");
|
|
1308
|
+
if (!i.types || i.types.length === 0)
|
|
1309
|
+
return r("VALIDATION_ERROR", "Each filter must have at least one event type");
|
|
1310
|
+
}
|
|
1311
|
+
const t = `${n.baseUrl}/api/v3.0/eventSubscriptions`;
|
|
1312
|
+
c("Creating event subscription:", t);
|
|
1313
|
+
try {
|
|
1314
|
+
const i = await fetch(t, {
|
|
1315
|
+
method: "POST",
|
|
1316
|
+
headers: {
|
|
1317
|
+
Accept: "application/json",
|
|
1318
|
+
"Content-Type": "application/json",
|
|
1319
|
+
Authorization: `Bearer ${n.token}`
|
|
1320
|
+
},
|
|
1321
|
+
body: JSON.stringify(e)
|
|
1322
|
+
});
|
|
1323
|
+
if (!i.ok)
|
|
1324
|
+
return F(i);
|
|
1325
|
+
const a = await i.json();
|
|
1326
|
+
return c("Event subscription created:", a.id), l(a);
|
|
1327
|
+
} catch (i) {
|
|
1328
|
+
return r("NETWORK_ERROR", `Failed to create event subscription: ${String(i)}`);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
async function at(e) {
|
|
1332
|
+
const n = f();
|
|
1333
|
+
if (!n.isAuthenticated)
|
|
1334
|
+
return r("AUTH_REQUIRED", "Authentication required");
|
|
1335
|
+
if (!n.baseUrl)
|
|
1336
|
+
return r("AUTH_REQUIRED", "Base URL not configured");
|
|
1337
|
+
if (!e)
|
|
1338
|
+
return r("VALIDATION_ERROR", "Subscription ID is required");
|
|
1339
|
+
const t = `${n.baseUrl}/api/v3.0/eventSubscriptions/${encodeURIComponent(e)}`;
|
|
1340
|
+
c("Deleting event subscription:", t);
|
|
1341
|
+
try {
|
|
1342
|
+
const i = await fetch(t, {
|
|
1343
|
+
method: "DELETE",
|
|
1344
|
+
headers: {
|
|
1345
|
+
Accept: "application/json",
|
|
1346
|
+
Authorization: `Bearer ${n.token}`
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1349
|
+
return i.ok ? (c("Event subscription deleted:", e), l(void 0)) : F(i);
|
|
1350
|
+
} catch (i) {
|
|
1351
|
+
return r("NETWORK_ERROR", `Failed to delete event subscription: ${String(i)}`);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
function st(e, n) {
|
|
1355
|
+
const t = f();
|
|
1356
|
+
if (!t.isAuthenticated)
|
|
1357
|
+
return r("AUTH_REQUIRED", "Authentication required");
|
|
1358
|
+
if (!t.token)
|
|
1359
|
+
return r("AUTH_REQUIRED", "Access token not available");
|
|
1360
|
+
if (!e)
|
|
1361
|
+
return r("VALIDATION_ERROR", "SSE URL is required");
|
|
1362
|
+
try {
|
|
1363
|
+
const _ = new URL(e);
|
|
1364
|
+
if (![".eagleeyenetworks.com", ".een.cloud"].some(
|
|
1365
|
+
(R) => _.hostname === R.substring(1) || _.hostname.endsWith(R)
|
|
1366
|
+
))
|
|
1367
|
+
return r("VALIDATION_ERROR", `SSE URL domain not allowed: ${_.hostname}`);
|
|
1368
|
+
} catch {
|
|
1369
|
+
return r("VALIDATION_ERROR", "Invalid SSE URL format");
|
|
1370
|
+
}
|
|
1371
|
+
const i = 1024 * 1024;
|
|
1372
|
+
let a = "connecting", o = new AbortController(), s = !1;
|
|
1373
|
+
const d = (_) => {
|
|
1374
|
+
a = _, n.onStatusChange?.(a);
|
|
1375
|
+
}, h = () => {
|
|
1376
|
+
s || (s = !0, c("Closing SSE connection"), o?.abort(), o = null, d("disconnected"));
|
|
1377
|
+
};
|
|
1378
|
+
return (async () => {
|
|
1379
|
+
if (!(s || !o)) {
|
|
1380
|
+
d("connecting"), c("Connecting to SSE:", e);
|
|
1381
|
+
try {
|
|
1382
|
+
const _ = await fetch(e, {
|
|
1383
|
+
method: "GET",
|
|
1384
|
+
headers: {
|
|
1385
|
+
Accept: "text/event-stream",
|
|
1386
|
+
Authorization: `Bearer ${t.token}`
|
|
1387
|
+
},
|
|
1388
|
+
signal: o.signal
|
|
1389
|
+
});
|
|
1390
|
+
if (!_.ok)
|
|
1391
|
+
throw new Error(`HTTP ${_.status}: ${_.statusText}`);
|
|
1392
|
+
if (!_.body)
|
|
1393
|
+
throw new Error("Response body is not available");
|
|
1394
|
+
d("connected"), c("SSE connected");
|
|
1395
|
+
const S = _.body.getReader(), y = new TextDecoder();
|
|
1396
|
+
let R = "";
|
|
1397
|
+
for (; !s; ) {
|
|
1398
|
+
const { done: q, value: B } = await S.read();
|
|
1399
|
+
if (q) {
|
|
1400
|
+
c("SSE stream ended");
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
if (R += y.decode(B, { stream: !0 }), R.length > i) {
|
|
1404
|
+
c("SSE buffer exceeded maximum size, resetting"), R = "";
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
const w = R.split(`
|
|
1408
|
+
`);
|
|
1409
|
+
R = w.pop() || "";
|
|
1410
|
+
let U = "";
|
|
1411
|
+
for (const $ of w)
|
|
1412
|
+
if ($.startsWith("data:")) {
|
|
1413
|
+
const T = $.substring(5).trimStart();
|
|
1414
|
+
U = U ? `${U}
|
|
1415
|
+
${T}` : T;
|
|
1416
|
+
} else if ($ === "" && U) {
|
|
1417
|
+
try {
|
|
1418
|
+
const T = JSON.parse(U);
|
|
1419
|
+
c("SSE event received:", T.type, T.actorId), n.onEvent(T);
|
|
1420
|
+
} catch (T) {
|
|
1421
|
+
c("Failed to parse SSE event:", T);
|
|
1422
|
+
}
|
|
1423
|
+
U = "";
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
} catch (_) {
|
|
1427
|
+
if (s || _ instanceof Error && _.name === "AbortError")
|
|
1428
|
+
return;
|
|
1429
|
+
c("SSE error:", _), d("error"), n.onError?.(_ instanceof Error ? _ : new Error(String(_)));
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
})(), l({
|
|
1433
|
+
close: h,
|
|
1434
|
+
get status() {
|
|
1435
|
+
return a;
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
async function F(e) {
|
|
1440
|
+
const n = e.status;
|
|
1441
|
+
let t;
|
|
1442
|
+
try {
|
|
1443
|
+
const i = await e.json();
|
|
1444
|
+
t = i.message ?? i.error ?? e.statusText;
|
|
1445
|
+
} catch (i) {
|
|
1446
|
+
c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
|
|
1447
|
+
}
|
|
1448
|
+
switch (n) {
|
|
1449
|
+
case 401:
|
|
1450
|
+
return r("AUTH_REQUIRED", t, n);
|
|
1451
|
+
case 403:
|
|
1452
|
+
return r("FORBIDDEN", t, n);
|
|
1453
|
+
case 404:
|
|
1454
|
+
return r("NOT_FOUND", t, n);
|
|
1455
|
+
case 429:
|
|
1456
|
+
return r("RATE_LIMITED", t, n);
|
|
1457
|
+
default:
|
|
1458
|
+
return r("API_ERROR", t, n);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1243
1461
|
export {
|
|
1244
|
-
|
|
1462
|
+
we as STORAGE_STRATEGY_DESCRIPTIONS,
|
|
1463
|
+
st as connectToEventSubscription,
|
|
1464
|
+
ot as createEventSubscription,
|
|
1465
|
+
at as deleteEventSubscription,
|
|
1245
1466
|
r as failure,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1467
|
+
A as formatTimestamp,
|
|
1468
|
+
Y as getAccessToken,
|
|
1469
|
+
Ze as getAlert,
|
|
1470
|
+
Ie as getAuthUrl,
|
|
1471
|
+
xe as getBridge,
|
|
1472
|
+
He as getBridges,
|
|
1251
1473
|
Pe as getCamera,
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1474
|
+
Be as getCameras,
|
|
1475
|
+
Re as getClientId,
|
|
1476
|
+
Le as getConfig,
|
|
1255
1477
|
je as getCurrentUser,
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1478
|
+
Ke as getEvent,
|
|
1479
|
+
Xe as getEventMetrics,
|
|
1480
|
+
it as getEventSubscription,
|
|
1481
|
+
Qe as getLiveImage,
|
|
1482
|
+
$e as getMediaSession,
|
|
1483
|
+
nt as getNotification,
|
|
1484
|
+
V as getProxyUrl,
|
|
1485
|
+
Ce as getRecordedImage,
|
|
1486
|
+
X as getRedirectUri,
|
|
1487
|
+
be as getStorageStrategy,
|
|
1488
|
+
qe as getUser,
|
|
1489
|
+
Fe as getUsers,
|
|
1490
|
+
Ue as handleAuthCallback,
|
|
1268
1491
|
Ne as initEenToolkit,
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1492
|
+
Ve as initMediaSession,
|
|
1493
|
+
et as listAlertTypes,
|
|
1494
|
+
Ye as listAlerts,
|
|
1495
|
+
Je as listEventFieldValues,
|
|
1496
|
+
rt as listEventSubscriptions,
|
|
1497
|
+
Ge as listEventTypes,
|
|
1498
|
+
We as listEvents,
|
|
1275
1499
|
Me as listFeeds,
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1500
|
+
ze as listMedia,
|
|
1501
|
+
tt as listNotifications,
|
|
1502
|
+
Te as refreshToken,
|
|
1503
|
+
Ae as revokeToken,
|
|
1280
1504
|
l as success,
|
|
1281
|
-
|
|
1505
|
+
f as useAuthStore
|
|
1282
1506
|
};
|
|
1283
1507
|
//# sourceMappingURL=index.js.map
|