een-api-toolkit 0.0.18 → 0.1.4

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -5
  2. package/README.md +29 -41
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +339 -821
  6. package/dist/index.js +295 -340
  7. package/dist/index.js.map +1 -1
  8. package/docs/AI-CONTEXT.md +151 -237
  9. package/examples/vue-bridges/.env.example +13 -0
  10. package/examples/vue-bridges/e2e/app.spec.ts +73 -0
  11. package/examples/vue-bridges/e2e/auth.spec.ts +206 -0
  12. package/examples/{vue-basic → vue-bridges}/index.html +1 -1
  13. package/examples/vue-bridges/package-lock.json +1583 -0
  14. package/examples/vue-bridges/package.json +28 -0
  15. package/examples/vue-bridges/playwright.config.ts +46 -0
  16. package/examples/vue-bridges/src/App.vue +108 -0
  17. package/examples/vue-bridges/src/router/index.ts +68 -0
  18. package/examples/vue-bridges/src/views/BridgeDetail.vue +279 -0
  19. package/examples/vue-bridges/src/views/Bridges.vue +297 -0
  20. package/examples/vue-bridges/src/views/Callback.vue +76 -0
  21. package/examples/vue-bridges/src/views/Home.vue +150 -0
  22. package/examples/vue-bridges/src/views/Login.vue +33 -0
  23. package/examples/vue-bridges/src/views/Logout.vue +66 -0
  24. package/examples/vue-bridges/src/vite-env.d.ts +12 -0
  25. package/examples/vue-cameras/e2e/app.spec.ts +2 -2
  26. package/examples/vue-cameras/e2e/auth.spec.ts +206 -0
  27. package/examples/vue-cameras/src/App.vue +4 -4
  28. package/examples/vue-cameras/src/views/CameraDetail.vue +57 -9
  29. package/examples/vue-cameras/src/views/Cameras.vue +69 -18
  30. package/examples/vue-cameras/src/views/Home.vue +36 -11
  31. package/examples/{vue-basic → vue-users}/README.md +4 -4
  32. package/examples/{vue-basic → vue-users}/e2e/app.spec.ts +3 -3
  33. package/examples/{vue-basic → vue-users}/e2e/auth.spec.ts +2 -2
  34. package/examples/vue-users/index.html +13 -0
  35. package/examples/{vue-basic → vue-users}/package-lock.json +3 -3
  36. package/examples/{vue-basic → vue-users}/package.json +1 -1
  37. package/examples/{vue-basic → vue-users}/src/App.vue +1 -1
  38. package/examples/vue-users/src/main.ts +23 -0
  39. package/examples/{vue-basic → vue-users}/src/views/Home.vue +27 -12
  40. package/examples/{vue-basic → vue-users}/src/views/Users.vue +51 -10
  41. package/examples/vue-users/tsconfig.json +21 -0
  42. package/examples/vue-users/tsconfig.node.json +10 -0
  43. package/examples/vue-users/vite.config.ts +12 -0
  44. package/package.json +1 -1
  45. /package/examples/{vue-basic → vue-bridges}/src/main.ts +0 -0
  46. /package/examples/{vue-basic → vue-bridges}/tsconfig.json +0 -0
  47. /package/examples/{vue-basic → vue-bridges}/tsconfig.node.json +0 -0
  48. /package/examples/{vue-basic → vue-bridges}/vite.config.ts +0 -0
  49. /package/examples/{vue-basic → vue-users}/.env.example +0 -0
  50. /package/examples/{vue-basic → vue-users}/playwright.config.ts +0 -0
  51. /package/examples/{vue-basic → vue-users}/src/router/index.ts +0 -0
  52. /package/examples/{vue-basic → vue-users}/src/views/Callback.vue +0 -0
  53. /package/examples/{vue-basic → vue-users}/src/views/Login.vue +0 -0
  54. /package/examples/{vue-basic → vue-users}/src/views/Logout.vue +0 -0
  55. /package/examples/{vue-basic → vue-users}/src/vite-env.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,120 +1,120 @@
1
1
  import { defineStore as Y } from "pinia";
2
- import { ref as u, computed as p, onMounted as x, watch as Z } from "vue";
3
- const S = {};
4
- let $ = {};
5
- function Re(e = {}) {
6
- $ = {
7
- proxyUrl: e.proxyUrl ?? S?.VITE_PROXY_URL,
8
- clientId: e.clientId ?? S?.VITE_EEN_CLIENT_ID,
9
- redirectUri: e.redirectUri ?? S?.VITE_REDIRECT_URI,
10
- debug: e.debug ?? S?.VITE_DEBUG === "true"
2
+ import { ref as _, computed as S } from "vue";
3
+ const g = {};
4
+ let U = {};
5
+ function _e(e = {}) {
6
+ U = {
7
+ proxyUrl: e.proxyUrl ?? g?.VITE_PROXY_URL,
8
+ clientId: e.clientId ?? g?.VITE_EEN_CLIENT_ID,
9
+ redirectUri: e.redirectUri ?? g?.VITE_REDIRECT_URI,
10
+ debug: e.debug ?? g?.VITE_DEBUG === "true"
11
11
  };
12
12
  }
13
- function Te() {
14
- return $;
13
+ function fe() {
14
+ return U;
15
15
  }
16
- function C() {
17
- return $.proxyUrl ?? S?.VITE_PROXY_URL;
16
+ function $() {
17
+ return U.proxyUrl ?? g?.VITE_PROXY_URL;
18
18
  }
19
- function ee() {
20
- return $.clientId ?? S?.VITE_EEN_CLIENT_ID;
19
+ function Z() {
20
+ return U.clientId ?? g?.VITE_EEN_CLIENT_ID;
21
21
  }
22
- function N() {
23
- return $.redirectUri ?? S?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
22
+ function j() {
23
+ return U.redirectUri ?? g?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
24
24
  }
25
- function T(e) {
25
+ function f(e) {
26
26
  return { data: e, error: null };
27
27
  }
28
- function l(e, n, t, r) {
28
+ function o(e, n, t, r) {
29
29
  return { data: null, error: { code: e, message: n, status: t, details: r } };
30
30
  }
31
- const te = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, ne = () => {
31
+ const ee = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, te = () => {
32
32
  try {
33
- return te?.VITE_DEBUG === "true";
33
+ return ee?.VITE_DEBUG === "true";
34
34
  } catch {
35
35
  return !1;
36
36
  }
37
37
  };
38
38
  function c(...e) {
39
- ne() && console.log("[een-api-toolkit]", ...e);
39
+ te() && console.log("[een-api-toolkit]", ...e);
40
40
  }
41
- let O = null;
42
- function re() {
43
- return O || (O = Promise.resolve().then(() => ce).then((e) => e.refreshToken)), O;
41
+ let y = null;
42
+ function ne() {
43
+ return y || (y = Promise.resolve().then(() => ue).then((e) => e.refreshToken)), y;
44
44
  }
45
- const E = Y("een-auth", () => {
46
- const e = u(null), n = u(null), t = u(null), r = u(null), o = u(null), a = u(443), i = u(null), f = u(null), I = u(!1);
47
- let g = null;
48
- const _ = u(!1), d = u(null), m = p(() => !!e.value), k = p(() => o.value ? a.value === 443 ? `https://${o.value}` : `https://${o.value}:${a.value}` : null), U = p(() => n.value ? Date.now() >= n.value : !0), A = p(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
49
- function R(s, h) {
50
- e.value = s, n.value = Date.now() + h * 1e3, P(), w(), c("Token set, expires in", h, "seconds");
45
+ const h = Y("een-auth", () => {
46
+ const e = _(null), n = _(null), t = _(null), r = _(null), a = _(null), i = _(443), u = _(null), d = _(null), v = _(!1);
47
+ let E = null;
48
+ const R = _(!1), I = _(null), F = S(() => !!e.value), w = S(() => a.value ? i.value === 443 ? `https://${a.value}` : `https://${a.value}:${i.value}` : null), A = S(() => n.value ? Date.now() >= n.value : !0), P = S(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
49
+ function C(s, l) {
50
+ e.value = s, n.value = Date.now() + l * 1e3, T(), k(), c("Token set, expires in", l, "seconds");
51
51
  }
52
- function y(s) {
53
- t.value = s, P();
52
+ function N(s) {
53
+ t.value = s, T();
54
54
  }
55
- function v(s) {
56
- r.value = s, P();
55
+ function q(s) {
56
+ r.value = s, T();
57
57
  }
58
58
  function B(s) {
59
59
  if (typeof s == "string")
60
60
  try {
61
- const h = new URL(s.startsWith("http") ? s : `https://${s}`);
62
- o.value = h.hostname, a.value = h.port ? parseInt(h.port, 10) : 443;
63
- } catch (h) {
64
- c("Failed to parse URL, using as hostname:", h instanceof Error ? h.message : String(h)), o.value = s, a.value = 443;
61
+ const l = new URL(s.startsWith("http") ? s : `https://${s}`);
62
+ a.value = l.hostname, i.value = l.port ? parseInt(l.port, 10) : 443;
63
+ } catch (l) {
64
+ c("Failed to parse URL, using as hostname:", l instanceof Error ? l.message : String(l)), a.value = s, i.value = 443;
65
65
  }
66
66
  else
67
- o.value = s.hostname, a.value = s.port ?? 443;
68
- P(), c("Base URL set:", k.value);
67
+ a.value = s.hostname, i.value = s.port ?? 443;
68
+ T(), c("Base URL set:", w.value);
69
69
  }
70
- function z(s) {
71
- i.value = s, P();
70
+ function H(s) {
71
+ u.value = s, T();
72
72
  }
73
- function w() {
74
- if (f.value && (clearTimeout(f.value), f.value = null), !n.value || !e.value)
73
+ function k() {
74
+ if (d.value && (clearTimeout(d.value), d.value = null), !n.value || !e.value)
75
75
  return;
76
- const s = Date.now(), D = n.value - s, G = 300 * 1e3, K = D / 2, J = Math.min(G, K), X = Math.max(D - J, 60 * 1e3), j = Math.max(X, 5e3);
77
- c("Auto-refresh scheduled in", Math.round(j / 1e3), "seconds"), f.value = setTimeout(async () => {
78
- await H();
79
- }, j);
76
+ const s = Date.now(), p = n.value - s, G = 300 * 1e3, K = p / 2, J = Math.min(G, K), X = Math.max(p - J, 60 * 1e3), O = Math.max(X, 5e3);
77
+ c("Auto-refresh scheduled in", Math.round(O / 1e3), "seconds"), d.value = setTimeout(async () => {
78
+ await z();
79
+ }, O);
80
80
  }
81
- async function H() {
82
- return g ? (c("Refresh already in progress, waiting for existing refresh"), g) : (I.value = !0, c("Performing auto-refresh"), g = (async () => {
81
+ async function z() {
82
+ return E ? (c("Refresh already in progress, waiting for existing refresh"), E) : (v.value = !0, c("Performing auto-refresh"), E = (async () => {
83
83
  try {
84
- const h = await (await re())();
85
- h.error ? (_.value = !0, d.value = h.error.message, c("Auto-refresh failed:", h.error.message)) : (_.value = !1, d.value = null, c("Auto-refresh successful"));
84
+ const l = await (await ne())();
85
+ l.error ? (R.value = !0, I.value = l.error.message, c("Auto-refresh failed:", l.error.message)) : (R.value = !1, I.value = null, c("Auto-refresh successful"));
86
86
  } catch (s) {
87
- _.value = !0, d.value = s instanceof Error ? s.message : String(s), c("Auto-refresh error:", s);
87
+ R.value = !0, I.value = s instanceof Error ? s.message : String(s), c("Auto-refresh error:", s);
88
88
  } finally {
89
- I.value = !1, g = null;
89
+ v.value = !1, E = null;
90
90
  }
91
- })(), g);
91
+ })(), E);
92
92
  }
93
93
  function M() {
94
- _.value = !1, d.value = null;
94
+ R.value = !1, I.value = null;
95
95
  }
96
- function F() {
97
- f.value && (clearTimeout(f.value), f.value = null), e.value = null, n.value = null, t.value = null, r.value = null, o.value = null, a.value = 443, i.value = null, _.value = !1, d.value = null, W(), c("Logged out");
96
+ function m() {
97
+ d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, r.value = null, a.value = null, i.value = 443, u.value = null, R.value = !1, I.value = null, W(), c("Logged out");
98
98
  }
99
- function V() {
100
- Q(), e.value && !U.value ? (w(), c("Initialized from storage")) : e.value && U.value && (c("Stored token expired, clearing"), F());
99
+ function Q() {
100
+ V(), e.value && !A.value ? (k(), c("Initialized from storage")) : e.value && A.value && (c("Stored token expired, clearing"), m());
101
101
  }
102
- function P() {
102
+ function T() {
103
103
  try {
104
- e.value && localStorage.setItem("een_token", e.value), n.value && localStorage.setItem("een_tokenExpiration", String(n.value)), t.value && localStorage.setItem("een_refreshTokenMarker", t.value), r.value && localStorage.setItem("een_sessionId", r.value), o.value && localStorage.setItem("een_hostname", o.value), a.value !== 443 && localStorage.setItem("een_port", String(a.value)), i.value && localStorage.setItem("een_userProfile", JSON.stringify(i.value));
104
+ e.value && localStorage.setItem("een_token", e.value), n.value && localStorage.setItem("een_tokenExpiration", String(n.value)), t.value && localStorage.setItem("een_refreshTokenMarker", t.value), r.value && localStorage.setItem("een_sessionId", r.value), a.value && localStorage.setItem("een_hostname", a.value), i.value !== 443 && localStorage.setItem("een_port", String(i.value)), u.value && localStorage.setItem("een_userProfile", JSON.stringify(u.value));
105
105
  } catch (s) {
106
106
  c("Failed to save to localStorage:", s instanceof Error ? s.message : String(s));
107
107
  }
108
108
  }
109
- function Q() {
109
+ function V() {
110
110
  try {
111
111
  e.value = localStorage.getItem("een_token");
112
112
  const s = localStorage.getItem("een_tokenExpiration");
113
- n.value = s ? parseInt(s, 10) : null, t.value = localStorage.getItem("een_refreshTokenMarker"), r.value = localStorage.getItem("een_sessionId"), o.value = localStorage.getItem("een_hostname");
114
- const h = localStorage.getItem("een_port");
115
- a.value = h ? parseInt(h, 10) : 443;
116
- const D = localStorage.getItem("een_userProfile");
117
- i.value = D ? JSON.parse(D) : null;
113
+ n.value = s ? parseInt(s, 10) : null, t.value = localStorage.getItem("een_refreshTokenMarker"), r.value = localStorage.getItem("een_sessionId"), a.value = localStorage.getItem("een_hostname");
114
+ const l = localStorage.getItem("een_port");
115
+ i.value = l ? parseInt(l, 10) : 443;
116
+ const p = localStorage.getItem("een_userProfile");
117
+ u.value = p ? JSON.parse(p) : null;
118
118
  } catch (s) {
119
119
  c("Failed to load from localStorage:", s instanceof Error ? s.message : String(s));
120
120
  }
@@ -132,31 +132,31 @@ const E = Y("een-auth", () => {
132
132
  tokenExpiration: n,
133
133
  refreshTokenMarker: t,
134
134
  sessionId: r,
135
- hostname: o,
136
- port: a,
137
- userProfile: i,
138
- isRefreshing: I,
139
- refreshFailed: _,
140
- refreshFailedMessage: d,
135
+ hostname: a,
136
+ port: i,
137
+ userProfile: u,
138
+ isRefreshing: v,
139
+ refreshFailed: R,
140
+ refreshFailedMessage: I,
141
141
  // Computed
142
- isAuthenticated: m,
143
- baseUrl: k,
144
- isTokenExpired: U,
145
- tokenExpiresIn: A,
142
+ isAuthenticated: F,
143
+ baseUrl: w,
144
+ isTokenExpired: A,
145
+ tokenExpiresIn: P,
146
146
  // Actions
147
- setToken: R,
148
- setRefreshTokenMarker: y,
149
- setSessionId: v,
147
+ setToken: C,
148
+ setRefreshTokenMarker: N,
149
+ setSessionId: q,
150
150
  setBaseUrl: B,
151
- setUserProfile: z,
152
- setupAutoRefresh: w,
151
+ setUserProfile: H,
152
+ setupAutoRefresh: k,
153
153
  clearRefreshFailed: M,
154
- logout: F,
155
- initialize: V
154
+ logout: m,
155
+ initialize: Q
156
156
  };
157
- }), oe = "https://auth.eagleeyenetworks.com/oauth2/authorize";
158
- function ae() {
159
- const e = ee();
157
+ }), re = "https://auth.eagleeyenetworks.com/oauth2/authorize";
158
+ function oe() {
159
+ const e = Z();
160
160
  if (!e)
161
161
  throw new Error("Client ID not configured. Call initEenToolkit() or set VITE_EEN_CLIENT_ID");
162
162
  const n = crypto.randomUUID();
@@ -168,18 +168,18 @@ function ae() {
168
168
  client_id: e,
169
169
  response_type: "code",
170
170
  scope: "vms.all",
171
- redirect_uri: N(),
171
+ redirect_uri: j(),
172
172
  state: n
173
173
  });
174
- return c("Generated auth URL with state:", n), `${oe}?${t.toString()}`;
174
+ return c("Generated auth URL with state:", n), `${re}?${t.toString()}`;
175
175
  }
176
- async function b(e) {
177
- const n = C();
176
+ async function x(e) {
177
+ const n = $();
178
178
  if (!n)
179
- return l("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
179
+ return o("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
180
180
  const t = new URLSearchParams({
181
181
  code: e,
182
- redirect_uri: N()
182
+ redirect_uri: j()
183
183
  });
184
184
  try {
185
185
  const r = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
@@ -190,20 +190,20 @@ async function b(e) {
190
190
  }
191
191
  });
192
192
  if (!r.ok) {
193
- const a = await r.text().catch(() => "Unknown error");
194
- return l("AUTH_FAILED", `Token exchange failed: ${a}`, r.status);
193
+ const i = await r.text().catch(() => "Unknown error");
194
+ return o("AUTH_FAILED", `Token exchange failed: ${i}`, r.status);
195
195
  }
196
- const o = await r.json();
197
- return c("Token received, expires in:", o.expiresIn), T(o);
196
+ const a = await r.json();
197
+ return c("Token received, expires in:", a.expiresIn), f(a);
198
198
  } catch (r) {
199
- return l("NETWORK_ERROR", `Failed to exchange code: ${String(r)}`);
199
+ return o("NETWORK_ERROR", `Failed to exchange code: ${String(r)}`);
200
200
  }
201
201
  }
202
202
  async function ie() {
203
- const e = C();
203
+ const e = $();
204
204
  if (!e)
205
- return l("AUTH_FAILED", "Proxy URL not configured");
206
- const n = E();
205
+ return o("AUTH_FAILED", "Proxy URL not configured");
206
+ const n = h();
207
207
  try {
208
208
  const t = {
209
209
  Accept: "application/json"
@@ -215,20 +215,20 @@ async function ie() {
215
215
  headers: t
216
216
  });
217
217
  if (!r.ok) {
218
- const a = await r.text().catch(() => "Unknown error");
219
- return l("AUTH_FAILED", `Token refresh failed: ${a}`, r.status);
218
+ const i = await r.text().catch(() => "Unknown error");
219
+ return o("AUTH_FAILED", `Token refresh failed: ${i}`, r.status);
220
220
  }
221
- const o = await r.json();
222
- return n.setToken(o.accessToken, o.expiresIn), c("Token refreshed, expires in:", o.expiresIn), T(o);
221
+ const a = await r.json();
222
+ return n.setToken(a.accessToken, a.expiresIn), c("Token refreshed, expires in:", a.expiresIn), f(a);
223
223
  } catch (t) {
224
- return l("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
224
+ return o("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
225
225
  }
226
226
  }
227
- async function se() {
228
- const e = C();
227
+ async function ae() {
228
+ const e = $();
229
229
  if (!e)
230
- return l("AUTH_FAILED", "Proxy URL not configured");
231
- const n = E();
230
+ return o("AUTH_FAILED", "Proxy URL not configured");
231
+ const n = h();
232
232
  try {
233
233
  const t = {
234
234
  Accept: "application/json"
@@ -240,32 +240,32 @@ async function se() {
240
240
  headers: t
241
241
  });
242
242
  if (n.logout(), !r.ok) {
243
- const o = await r.text().catch(() => "Unknown error");
244
- return l("AUTH_FAILED", `Token revocation failed: ${o}`, r.status);
243
+ const a = await r.text().catch(() => "Unknown error");
244
+ return o("AUTH_FAILED", `Token revocation failed: ${a}`, r.status);
245
245
  }
246
- return c("Token revoked"), T(void 0);
246
+ return c("Token revoked"), f(void 0);
247
247
  } catch (t) {
248
- return n.logout(), l("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
248
+ return n.logout(), o("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
249
249
  }
250
250
  }
251
- async function le(e, n) {
251
+ async function se(e, n) {
252
252
  let t = null;
253
253
  try {
254
254
  t = sessionStorage.getItem("een_oauth_state"), sessionStorage.removeItem("een_oauth_state");
255
255
  } catch {
256
256
  }
257
257
  if (!t)
258
- return l("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
259
- if (!ue(n, t))
260
- return l("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
258
+ return o("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
259
+ if (!ce(n, t))
260
+ return o("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
261
261
  c("State validated, exchanging code for token");
262
- const r = await b(e);
262
+ const r = await x(e);
263
263
  if (r.error)
264
264
  return r;
265
- const o = E(), a = r.data;
266
- return o.setToken(a.accessToken, a.expiresIn), o.setRefreshTokenMarker("present"), o.setSessionId(a.sessionId), o.setBaseUrl(a.httpsBaseUrl), c("Auth callback complete, user:", a.userEmail), T(a);
265
+ const a = h(), i = r.data;
266
+ return a.setToken(i.accessToken, i.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(i.sessionId), a.setBaseUrl(i.httpsBaseUrl), c("Auth callback complete, user:", i.userEmail), f(i);
267
267
  }
268
- function ue(e, n) {
268
+ function ce(e, n) {
269
269
  if (e.length !== n.length)
270
270
  return !1;
271
271
  let t = 0;
@@ -273,20 +273,20 @@ function ue(e, n) {
273
273
  t |= e.charCodeAt(r) ^ n.charCodeAt(r);
274
274
  return t === 0;
275
275
  }
276
- const ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
276
+ const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
277
277
  __proto__: null,
278
- getAccessToken: b,
279
- getAuthUrl: ae,
280
- handleAuthCallback: le,
278
+ getAccessToken: x,
279
+ getAuthUrl: oe,
280
+ handleAuthCallback: se,
281
281
  refreshToken: ie,
282
- revokeToken: se
282
+ revokeToken: ae
283
283
  }, Symbol.toStringTag, { value: "Module" }));
284
- async function de() {
285
- const e = E();
284
+ async function he() {
285
+ const e = h();
286
286
  if (!e.isAuthenticated)
287
- return l("AUTH_REQUIRED", "Authentication required");
287
+ return o("AUTH_REQUIRED", "Authentication required");
288
288
  if (!e.baseUrl)
289
- return l("AUTH_REQUIRED", "Base URL not configured");
289
+ return o("AUTH_REQUIRED", "Base URL not configured");
290
290
  const n = `${e.baseUrl}/api/v3.0/users/self`;
291
291
  c("Fetching current user:", n);
292
292
  try {
@@ -298,68 +298,68 @@ async function de() {
298
298
  }
299
299
  });
300
300
  if (!t.ok)
301
- return L(t);
301
+ return D(t);
302
302
  const r = await t.json();
303
- return c("Current user fetched:", r.email), e.setUserProfile(r), T(r);
303
+ return c("Current user fetched:", r.email), e.setUserProfile(r), f(r);
304
304
  } catch (t) {
305
- return l("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
305
+ return o("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
306
306
  }
307
307
  }
308
- async function fe(e) {
309
- const n = E();
308
+ async function ge(e) {
309
+ const n = h();
310
310
  if (!n.isAuthenticated)
311
- return l("AUTH_REQUIRED", "Authentication required");
311
+ return o("AUTH_REQUIRED", "Authentication required");
312
312
  if (!n.baseUrl)
313
- return l("AUTH_REQUIRED", "Base URL not configured");
313
+ return o("AUTH_REQUIRED", "Base URL not configured");
314
314
  const t = new URLSearchParams();
315
315
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.include && e.include.length > 0 && t.append("include", e.include.join(","));
316
- const r = t.toString(), o = `${n.baseUrl}/api/v3.0/users${r ? `?${r}` : ""}`;
317
- c("Fetching users:", o);
316
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/users${r ? `?${r}` : ""}`;
317
+ c("Fetching users:", a);
318
318
  try {
319
- const a = await fetch(o, {
319
+ const i = await fetch(a, {
320
320
  method: "GET",
321
321
  headers: {
322
322
  Accept: "application/json",
323
323
  Authorization: `Bearer ${n.token}`
324
324
  }
325
325
  });
326
- if (!a.ok)
327
- return L(a);
328
- const i = await a.json();
329
- return c("Users fetched:", i.results?.length ?? 0, "users"), T(i);
330
- } catch (a) {
331
- return l("NETWORK_ERROR", `Failed to fetch users: ${String(a)}`);
326
+ if (!i.ok)
327
+ return D(i);
328
+ const u = await i.json();
329
+ return c("Users fetched:", u.results?.length ?? 0, "users"), f(u);
330
+ } catch (i) {
331
+ return o("NETWORK_ERROR", `Failed to fetch users: ${String(i)}`);
332
332
  }
333
333
  }
334
- async function _e(e, n) {
335
- const t = E();
334
+ async function Re(e, n) {
335
+ const t = h();
336
336
  if (!t.isAuthenticated)
337
- return l("AUTH_REQUIRED", "Authentication required");
337
+ return o("AUTH_REQUIRED", "Authentication required");
338
338
  if (!t.baseUrl)
339
- return l("AUTH_REQUIRED", "Base URL not configured");
339
+ return o("AUTH_REQUIRED", "Base URL not configured");
340
340
  if (!e)
341
- return l("VALIDATION_ERROR", "User ID is required");
341
+ return o("VALIDATION_ERROR", "User ID is required");
342
342
  const r = new URLSearchParams();
343
343
  n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
344
- const o = r.toString(), a = `${t.baseUrl}/api/v3.0/users/${encodeURIComponent(e)}${o ? `?${o}` : ""}`;
345
- c("Fetching user:", a);
344
+ const a = r.toString(), i = `${t.baseUrl}/api/v3.0/users/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
345
+ c("Fetching user:", i);
346
346
  try {
347
- const i = await fetch(a, {
347
+ const u = await fetch(i, {
348
348
  method: "GET",
349
349
  headers: {
350
350
  Accept: "application/json",
351
351
  Authorization: `Bearer ${t.token}`
352
352
  }
353
353
  });
354
- if (!i.ok)
355
- return L(i);
356
- const f = await i.json();
357
- return c("User fetched:", f.email), T(f);
358
- } catch (i) {
359
- return l("NETWORK_ERROR", `Failed to fetch user: ${String(i)}`);
354
+ if (!u.ok)
355
+ return D(u);
356
+ const d = await u.json();
357
+ return c("User fetched:", d.email), f(d);
358
+ } catch (u) {
359
+ return o("NETWORK_ERROR", `Failed to fetch user: ${String(u)}`);
360
360
  }
361
361
  }
362
- async function L(e) {
362
+ async function D(e) {
363
363
  const n = e.status;
364
364
  let t;
365
365
  try {
@@ -370,137 +370,72 @@ async function L(e) {
370
370
  }
371
371
  switch (n) {
372
372
  case 401:
373
- return l("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
373
+ return o("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
374
374
  case 403:
375
- return l("FORBIDDEN", `Access denied: ${t}`, n);
375
+ return o("FORBIDDEN", `Access denied: ${t}`, n);
376
376
  case 404:
377
- return l("NOT_FOUND", `Not found: ${t}`, n);
377
+ return o("NOT_FOUND", `Not found: ${t}`, n);
378
378
  case 429:
379
- return l("RATE_LIMITED", `Rate limited: ${t}`, n);
379
+ return o("RATE_LIMITED", `Rate limited: ${t}`, n);
380
380
  default:
381
- return l("API_ERROR", `API error: ${t}`, n);
381
+ return o("API_ERROR", `API error: ${t}`, n);
382
382
  }
383
383
  }
384
- function pe(e) {
385
- const n = u(null), t = u(!1), r = u(null), o = async () => {
386
- t.value = !0, r.value = null;
387
- const i = await de();
388
- return i.error ? (r.value = i.error, n.value = null) : n.value = i.data, t.value = !1, i;
389
- }, a = o;
390
- return e?.immediate !== !1 && x(o), {
391
- user: n,
392
- loading: t,
393
- error: r,
394
- fetch: o,
395
- refresh: a
396
- };
397
- }
398
- function Ee(e, n) {
399
- const t = u([]), r = u(!1), o = u(null), a = u(void 0), i = u(void 0), f = u(void 0), I = p(() => !!a.value), g = p(() => !!i.value), _ = u(e ?? {}), d = async (R) => {
400
- r.value = !0, o.value = null;
401
- const y = { ..._.value, ...R }, v = await fe(y);
402
- return v.error ? (o.value = v.error, t.value = [], a.value = void 0, i.value = void 0, f.value = void 0) : (t.value = v.data.results, a.value = v.data.nextPageToken, i.value = v.data.prevPageToken, f.value = v.data.totalSize), r.value = !1, v;
403
- }, m = () => d(), k = async () => {
404
- if (a.value)
405
- return d({ ..._.value, pageToken: a.value });
406
- }, U = async () => {
407
- if (i.value)
408
- return d({ ..._.value, pageToken: i.value });
409
- }, A = (R) => {
410
- _.value = R;
411
- };
412
- return n?.immediate !== !1 && x(d), {
413
- users: t,
414
- loading: r,
415
- error: o,
416
- nextPageToken: a,
417
- prevPageToken: i,
418
- totalSize: f,
419
- hasNextPage: I,
420
- hasPrevPage: g,
421
- params: _,
422
- fetch: d,
423
- refresh: m,
424
- fetchNextPage: k,
425
- fetchPrevPage: U,
426
- setParams: A
427
- };
428
- }
429
- function Ue(e, n) {
430
- const t = u(null), r = u(!1), o = u(null), a = () => typeof e == "function" ? e() : e, i = async (I) => {
431
- const g = a();
432
- if (!g)
433
- return o.value = { code: "VALIDATION_ERROR", message: "User ID is required" }, { data: null, error: o.value };
434
- r.value = !0, o.value = null;
435
- const _ = {
436
- include: n?.include,
437
- ...I
438
- }, d = await _e(g, _);
439
- return d.error ? (o.value = d.error, t.value = null) : t.value = d.data, r.value = !1, d;
440
- }, f = () => i();
441
- return n?.immediate !== !1 && a() && x(i), {
442
- user: t,
443
- loading: r,
444
- error: o,
445
- fetch: i,
446
- refresh: f
447
- };
448
- }
449
- async function he(e) {
450
- const n = E();
384
+ async function Ie(e) {
385
+ const n = h();
451
386
  if (!n.isAuthenticated)
452
- return l("AUTH_REQUIRED", "Authentication required");
387
+ return o("AUTH_REQUIRED", "Authentication required");
453
388
  if (!n.baseUrl)
454
- return l("AUTH_REQUIRED", "Base URL not configured");
389
+ return o("AUTH_REQUIRED", "Base URL not configured");
455
390
  const t = new URLSearchParams();
456
391
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), 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?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.bridgeId__in && e.bridgeId__in.length > 0 && t.append("bridgeId__in", e.bridgeId__in.join(",")), e?.multiCameraId && t.append("multiCameraId", e.multiCameraId), e?.multiCameraId__ne && t.append("multiCameraId__ne", e.multiCameraId__ne), e?.multiCameraId__in && e.multiCameraId__in.length > 0 && t.append("multiCameraId__in", e.multiCameraId__in.join(",")), e?.tags__contains && e.tags__contains.length > 0 && t.append("tags__contains", e.tags__contains.join(",")), e?.tags__any && e.tags__any.length > 0 && t.append("tags__any", e.tags__any.join(",")), e?.packages__contains && e.packages__contains.length > 0 && t.append("packages__contains", e.packages__contains.join(",")), e?.name && t.append("name", e.name), e?.name__contains && t.append("name__contains", e.name__contains), e?.name__in && e.name__in.length > 0 && t.append("name__in", e.name__in.join(",")), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.id__notIn && e.id__notIn.length > 0 && t.append("id__notIn", e.id__notIn.join(",")), e?.id__contains && t.append("id__contains", e.id__contains), e?.layoutId && t.append("layoutId", e.layoutId), typeof e?.shared == "boolean" && t.append("shareDetails.shared", String(e.shared)), e?.sharedCameraAccount && t.append("shareDetails.accountId", e.sharedCameraAccount), typeof e?.firstResponder == "boolean" && t.append("shareDetails.firstResponder", String(e.firstResponder)), typeof e?.directToCloud == "boolean" && t.append("deviceInfo.directToCloud", String(e.directToCloud)), e?.speakerId__in && e.speakerId__in.length > 0 && t.append("speakerId__in", e.speakerId__in.join(",")), e?.q && t.append("q", e.q), typeof e?.qRelevance__gte == "number" && t.append("qRelevance__gte", String(e.qRelevance__gte)), e?.enabledAnalytics__contains && e.enabledAnalytics__contains.length > 0 && t.append("enabledAnalytics__contains", e.enabledAnalytics__contains.join(",")), e?.status__in && e.status__in.length > 0 && t.append("status__in", e.status__in.join(",")), e?.status__ne && t.append("status__ne", e.status__ne);
457
- const r = t.toString(), o = `${n.baseUrl}/api/v3.0/cameras${r ? `?${r}` : ""}`;
458
- c("Fetching cameras:", o);
392
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/cameras${r ? `?${r}` : ""}`;
393
+ c("Fetching cameras:", a);
459
394
  try {
460
- const a = await fetch(o, {
395
+ const i = await fetch(a, {
461
396
  method: "GET",
462
397
  headers: {
463
398
  Accept: "application/json",
464
399
  Authorization: `Bearer ${n.token}`
465
400
  }
466
401
  });
467
- if (!a.ok)
468
- return q(a);
469
- const i = await a.json();
470
- return c("Cameras fetched:", i.results?.length ?? 0, "cameras"), T(i);
471
- } catch (a) {
472
- return l("NETWORK_ERROR", `Failed to fetch cameras: ${String(a)}`);
402
+ if (!i.ok)
403
+ return L(i);
404
+ const u = await i.json();
405
+ return c("Cameras fetched:", u.results?.length ?? 0, "cameras"), f(u);
406
+ } catch (i) {
407
+ return o("NETWORK_ERROR", `Failed to fetch cameras: ${String(i)}`);
473
408
  }
474
409
  }
475
- async function ge(e, n) {
476
- const t = E();
410
+ async function Ee(e, n) {
411
+ const t = h();
477
412
  if (!t.isAuthenticated)
478
- return l("AUTH_REQUIRED", "Authentication required");
413
+ return o("AUTH_REQUIRED", "Authentication required");
479
414
  if (!t.baseUrl)
480
- return l("AUTH_REQUIRED", "Base URL not configured");
415
+ return o("AUTH_REQUIRED", "Base URL not configured");
481
416
  if (!e)
482
- return l("VALIDATION_ERROR", "Camera ID is required");
417
+ return o("VALIDATION_ERROR", "Camera ID is required");
483
418
  const r = new URLSearchParams();
484
419
  n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
485
- const o = r.toString(), a = `${t.baseUrl}/api/v3.0/cameras/${encodeURIComponent(e)}${o ? `?${o}` : ""}`;
486
- c("Fetching camera:", a);
420
+ const a = r.toString(), i = `${t.baseUrl}/api/v3.0/cameras/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
421
+ c("Fetching camera:", i);
487
422
  try {
488
- const i = await fetch(a, {
423
+ const u = await fetch(i, {
489
424
  method: "GET",
490
425
  headers: {
491
426
  Accept: "application/json",
492
427
  Authorization: `Bearer ${t.token}`
493
428
  }
494
429
  });
495
- if (!i.ok)
496
- return q(i);
497
- const f = await i.json();
498
- return c("Camera fetched:", f.name), T(f);
499
- } catch (i) {
500
- return l("NETWORK_ERROR", `Failed to fetch camera: ${String(i)}`);
430
+ if (!u.ok)
431
+ return L(u);
432
+ const d = await u.json();
433
+ return c("Camera fetched:", d.name), f(d);
434
+ } catch (u) {
435
+ return o("NETWORK_ERROR", `Failed to fetch camera: ${String(u)}`);
501
436
  }
502
437
  }
503
- async function q(e) {
438
+ async function L(e) {
504
439
  const n = e.status;
505
440
  let t;
506
441
  try {
@@ -511,93 +446,113 @@ async function q(e) {
511
446
  }
512
447
  switch (n) {
513
448
  case 401:
514
- return l("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
449
+ return o("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
515
450
  case 403:
516
- return l("FORBIDDEN", `Access denied: ${t}`, n);
451
+ return o("FORBIDDEN", `Access denied: ${t}`, n);
517
452
  case 404:
518
- return l("NOT_FOUND", `Not found: ${t}`, n);
453
+ return o("NOT_FOUND", `Not found: ${t}`, n);
519
454
  case 429:
520
- return l("RATE_LIMITED", `Rate limited: ${t}`, n);
455
+ return o("RATE_LIMITED", `Rate limited: ${t}`, n);
521
456
  default:
522
- return l("API_ERROR", `API error: ${t}`, n);
457
+ return o("API_ERROR", `API error: ${t}`, n);
523
458
  }
524
459
  }
525
- function Se(e, n) {
526
- const t = u([]), r = u(!1), o = u(null), a = u(void 0), i = u(void 0), f = u(void 0), I = p(() => !!a.value), g = p(() => !!i.value), _ = u(e ?? {}), d = async (R) => {
527
- r.value = !0, o.value = null;
528
- const y = { ..._.value, ...R }, v = await he(y);
529
- return v.error ? (o.value = v.error, t.value = [], a.value = void 0, i.value = void 0, f.value = void 0) : (t.value = v.data.results, a.value = v.data.nextPageToken, i.value = v.data.prevPageToken, f.value = v.data.totalSize), r.value = !1, v;
530
- }, m = () => d(), k = async () => {
531
- if (a.value)
532
- return d({ ..._.value, pageToken: a.value });
533
- }, U = async () => {
534
- if (i.value)
535
- return d({ ..._.value, pageToken: i.value });
536
- }, A = (R) => {
537
- _.value = R;
538
- };
539
- return n?.immediate !== !1 && x(d), {
540
- cameras: t,
541
- loading: r,
542
- error: o,
543
- nextPageToken: a,
544
- prevPageToken: i,
545
- totalSize: f,
546
- hasNextPage: I,
547
- hasPrevPage: g,
548
- params: _,
549
- fetch: d,
550
- refresh: m,
551
- fetchNextPage: k,
552
- fetchPrevPage: U,
553
- setParams: A
554
- };
460
+ async function Te(e) {
461
+ const n = h();
462
+ if (!n.isAuthenticated)
463
+ return o("AUTH_REQUIRED", "Authentication required");
464
+ if (!n.baseUrl)
465
+ return o("AUTH_REQUIRED", "Base URL not configured");
466
+ const t = new URLSearchParams();
467
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), 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?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.tags__contains && e.tags__contains.length > 0 && t.append("tags__contains", e.tags__contains.join(",")), e?.tags__any && e.tags__any.length > 0 && t.append("tags__any", e.tags__any.join(",")), e?.name && t.append("name", e.name), e?.name__contains && t.append("name__contains", e.name__contains), e?.name__in && e.name__in.length > 0 && t.append("name__in", e.name__in.join(",")), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.id__notIn && e.id__notIn.length > 0 && t.append("id__notIn", e.id__notIn.join(",")), e?.q && t.append("q", e.q), typeof e?.qRelevance__gte == "number" && t.append("qRelevance__gte", String(e.qRelevance__gte)), e?.status__in && e.status__in.length > 0 && t.append("status__in", e.status__in.join(",")), e?.status__ne && t.append("status__ne", e.status__ne);
468
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/bridges${r ? `?${r}` : ""}`;
469
+ c("Fetching bridges:", a);
470
+ try {
471
+ const i = await fetch(a, {
472
+ method: "GET",
473
+ headers: {
474
+ Accept: "application/json",
475
+ Authorization: `Bearer ${n.token}`
476
+ }
477
+ });
478
+ if (!i.ok)
479
+ return b(i);
480
+ const u = await i.json();
481
+ return c("Bridges fetched:", u.results?.length ?? 0, "bridges"), f(u);
482
+ } catch (i) {
483
+ return o("NETWORK_ERROR", `Failed to fetch bridges: ${String(i)}`);
484
+ }
555
485
  }
556
- function ke(e, n) {
557
- const t = u(null), r = u(!1), o = u(null), a = () => typeof e == "function" ? e() : e, i = async (I) => {
558
- const g = a();
559
- if (!g)
560
- return o.value = { code: "VALIDATION_ERROR", message: "Camera ID is required" }, { data: null, error: o.value };
561
- r.value = !0, o.value = null;
562
- const _ = {
563
- include: n?.include,
564
- ...I
565
- }, d = await ge(g, _);
566
- return d.error ? (o.value = d.error, t.value = null) : t.value = d.data, r.value = !1, d;
567
- }, f = () => i();
568
- return n?.immediate !== !1 && a() && x(i), typeof e == "function" && Z(e, (I, g) => {
569
- I && I !== g && i();
570
- }), {
571
- camera: t,
572
- loading: r,
573
- error: o,
574
- fetch: i,
575
- refresh: f
576
- };
486
+ async function pe(e, n) {
487
+ const t = h();
488
+ if (!t.isAuthenticated)
489
+ return o("AUTH_REQUIRED", "Authentication required");
490
+ if (!t.baseUrl)
491
+ return o("AUTH_REQUIRED", "Base URL not configured");
492
+ if (!e)
493
+ return o("VALIDATION_ERROR", "Bridge ID is required");
494
+ const r = new URLSearchParams();
495
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
496
+ const a = r.toString(), i = `${t.baseUrl}/api/v3.0/bridges/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
497
+ c("Fetching bridge:", i);
498
+ try {
499
+ const u = await fetch(i, {
500
+ method: "GET",
501
+ headers: {
502
+ Accept: "application/json",
503
+ Authorization: `Bearer ${t.token}`
504
+ }
505
+ });
506
+ if (!u.ok)
507
+ return b(u);
508
+ const d = await u.json();
509
+ return c("Bridge fetched:", d.name), f(d);
510
+ } catch (u) {
511
+ return o("NETWORK_ERROR", `Failed to fetch bridge: ${String(u)}`);
512
+ }
513
+ }
514
+ async function b(e) {
515
+ const n = e.status;
516
+ let t;
517
+ try {
518
+ const r = await e.json();
519
+ t = r.message ?? r.error ?? e.statusText;
520
+ } catch (r) {
521
+ c("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
522
+ }
523
+ switch (n) {
524
+ case 401:
525
+ return o("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
526
+ case 403:
527
+ return o("FORBIDDEN", `Access denied: ${t}`, n);
528
+ case 404:
529
+ return o("NOT_FOUND", `Not found: ${t}`, n);
530
+ case 429:
531
+ return o("RATE_LIMITED", `Rate limited: ${t}`, n);
532
+ default:
533
+ return o("API_ERROR", `API error: ${t}`, n);
534
+ }
577
535
  }
578
536
  export {
579
- l as failure,
580
- b as getAccessToken,
581
- ae as getAuthUrl,
582
- ge as getCamera,
583
- he as getCameras,
584
- ee as getClientId,
585
- Te as getConfig,
586
- de as getCurrentUser,
587
- C as getProxyUrl,
588
- N as getRedirectUri,
589
- _e as getUser,
590
- fe as getUsers,
591
- le as handleAuthCallback,
592
- Re as initEenToolkit,
537
+ o as failure,
538
+ x as getAccessToken,
539
+ oe as getAuthUrl,
540
+ pe as getBridge,
541
+ Te as getBridges,
542
+ Ee as getCamera,
543
+ Ie as getCameras,
544
+ Z as getClientId,
545
+ fe as getConfig,
546
+ he as getCurrentUser,
547
+ $ as getProxyUrl,
548
+ j as getRedirectUri,
549
+ Re as getUser,
550
+ ge as getUsers,
551
+ se as handleAuthCallback,
552
+ _e as initEenToolkit,
593
553
  ie as refreshToken,
594
- se as revokeToken,
595
- T as success,
596
- E as useAuthStore,
597
- ke as useCamera,
598
- Se as useCameras,
599
- pe as useCurrentUser,
600
- Ue as useUser,
601
- Ee as useUsers
554
+ ae as revokeToken,
555
+ f as success,
556
+ h as useAuthStore
602
557
  };
603
558
  //# sourceMappingURL=index.js.map