@versini/auth-provider 2.0.0 → 2.0.1

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 (2) hide show
  1. package/dist/index.js +31 -31
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { jsx as V } from "react/jsx-runtime";
1
+ import { jsx as P } from "react/jsx-runtime";
2
2
  import { useCallback as p, useState as U, useEffect as w, useRef as _, useLayoutEffect as z, createContext as M, useContext as F } from "react";
3
3
  /*!
4
- @versini/auth-provider v2.0.0
4
+ @versini/auth-provider v2.0.1
5
5
  © 2024 gizmette.com
6
6
  */
7
7
  try {
8
8
  window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
9
- version: "2.0.0",
10
- buildTime: "06/17/2024 04:39 PM EDT",
9
+ version: "2.0.1",
10
+ buildTime: "06/18/2024 11:21 AM EDT",
11
11
  homepage: "https://github.com/aversini/auth-client",
12
12
  license: "MIT"
13
13
  });
@@ -20,7 +20,7 @@ try {
20
20
  try {
21
21
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
22
22
  version: "2.0.0",
23
- buildTime: "06/17/2024 04:39 PM EDT",
23
+ buildTime: "06/18/2024 11:21 AM EDT",
24
24
  homepage: "https://github.com/aversini/auth-client",
25
25
  license: "MIT"
26
26
  });
@@ -32,7 +32,7 @@ const H = {
32
32
  CLIENT_ID: "X-Auth-ClientId"
33
33
  };
34
34
  var D = typeof window < "u" ? z : w;
35
- function N(e, t, n, r) {
35
+ function A(e, t, n, r) {
36
36
  const c = _(t);
37
37
  D(() => {
38
38
  c.current = t;
@@ -48,7 +48,7 @@ function N(e, t, n, r) {
48
48
  };
49
49
  }, [e, n, r]);
50
50
  }
51
- function A(e) {
51
+ function N(e) {
52
52
  const t = _(() => {
53
53
  throw new Error("Cannot call an event handler while rendering.");
54
54
  });
@@ -71,13 +71,13 @@ function E(e, t, n = {}) {
71
71
  if (o === "undefined")
72
72
  return;
73
73
  const a = t instanceof Function ? t() : t;
74
- let g;
74
+ let T;
75
75
  try {
76
- g = JSON.parse(o);
76
+ T = JSON.parse(o);
77
77
  } catch (v) {
78
78
  return console.error("Error parsing JSON:", v), a;
79
79
  }
80
- return g;
80
+ return T;
81
81
  },
82
82
  [n, t]
83
83
  ), u = p(() => {
@@ -90,37 +90,37 @@ function E(e, t, n = {}) {
90
90
  } catch (a) {
91
91
  return console.warn(`Error reading localStorage key “${e}”:`, a), o;
92
92
  }
93
- }, [t, e, l]), [h, T] = U(() => r ? u() : t instanceof Function ? t() : t), m = A((o) => {
93
+ }, [t, e, l]), [h, g] = U(() => r ? u() : t instanceof Function ? t() : t), k = N((o) => {
94
94
  I && console.warn(
95
95
  `Tried setting localStorage key “${e}” even though environment is not a client`
96
96
  );
97
97
  try {
98
98
  const a = o instanceof Function ? o(u()) : o;
99
- window.localStorage.setItem(e, c(a)), T(a), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
99
+ window.localStorage.setItem(e, c(a)), g(a), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
100
100
  } catch (a) {
101
101
  console.warn(`Error setting localStorage key “${e}”:`, a);
102
102
  }
103
- }), i = A(() => {
103
+ }), i = N(() => {
104
104
  I && console.warn(
105
105
  `Tried removing localStorage key “${e}” even though environment is not a client`
106
106
  );
107
107
  const o = t instanceof Function ? t() : t;
108
- window.localStorage.removeItem(e), T(o), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
108
+ window.localStorage.removeItem(e), g(o), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
109
109
  });
110
110
  w(() => {
111
- T(u());
111
+ g(u());
112
112
  }, [e]);
113
113
  const y = p(
114
114
  (o) => {
115
- o.key && o.key !== e || T(u());
115
+ o.key && o.key !== e || g(u());
116
116
  },
117
117
  [e, u]
118
118
  );
119
- return N("storage", y), N("local-storage", y), [h, m, i];
119
+ return A("storage", y), A("local-storage", y), [h, k, i];
120
120
  }
121
121
  const J = "Oops! It looks like your session has expired. For your security, please log in again to continue.", X = "You forgot to wrap your component in <AuthProvider>.", R = {
122
122
  dev: "https://auth.gizmette.local.com:3003",
123
- prod: "https://auth.gizmette.com"
123
+ prod: "https://mylogin.gizmette.com"
124
124
  };
125
125
  var s = [];
126
126
  for (var f = 0; f < 256; ++f)
@@ -128,11 +128,11 @@ for (var f = 0; f < 256; ++f)
128
128
  function K(e, t = 0) {
129
129
  return (s[e[t + 0]] + s[e[t + 1]] + s[e[t + 2]] + s[e[t + 3]] + "-" + s[e[t + 4]] + s[e[t + 5]] + "-" + s[e[t + 6]] + s[e[t + 7]] + "-" + s[e[t + 8]] + s[e[t + 9]] + "-" + s[e[t + 10]] + s[e[t + 11]] + s[e[t + 12]] + s[e[t + 13]] + s[e[t + 14]] + s[e[t + 15]]).toLowerCase();
130
130
  }
131
- var k, W = new Uint8Array(16);
131
+ var m, W = new Uint8Array(16);
132
132
  function Y() {
133
- if (!k && (k = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !k))
133
+ if (!m && (m = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !m))
134
134
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
135
- return k(W);
135
+ return m(W);
136
136
  }
137
137
  var q = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
138
138
  const C = {
@@ -196,13 +196,13 @@ const O = () => {
196
196
  const [c, l, u] = E(
197
197
  `@@auth@@::${n}::@@access@@`,
198
198
  ""
199
- ), [h, T, m] = E(
199
+ ), [h, g, k] = E(
200
200
  `@@auth@@::${n}::@@refresh@@`,
201
201
  ""
202
202
  ), [i, y, o] = E(
203
203
  `@@auth@@::${n}::@@user@@`,
204
204
  ""
205
- ), [a, g] = U({
205
+ ), [a, T] = U({
206
206
  isAuthenticated: !!i,
207
207
  accessToken: c,
208
208
  refreshToken: h,
@@ -211,14 +211,14 @@ const O = () => {
211
211
  userId: ""
212
212
  }), v = ee(i) || "";
213
213
  w(() => {
214
- v !== i && i !== "" ? g({
214
+ v !== i && i !== "" ? T({
215
215
  isAuthenticated: !0,
216
216
  accessToken: c,
217
217
  refreshToken: h,
218
218
  idToken: i,
219
219
  logoutReason: "",
220
220
  userId: a.userId
221
- }) : v !== i && i === "" && g({
221
+ }) : v !== i && i === "" && T({
222
222
  isAuthenticated: !1,
223
223
  accessToken: "",
224
224
  refreshToken: "",
@@ -227,18 +227,18 @@ const O = () => {
227
227
  userId: ""
228
228
  });
229
229
  }, [c, h, i, v, a.userId]);
230
- const $ = async (P, L) => {
230
+ const $ = async (L, V) => {
231
231
  var S;
232
232
  const d = await Z({
233
233
  params: {
234
234
  type: r || H.ID_TOKEN,
235
- username: P,
236
- password: L,
235
+ username: L,
236
+ password: V,
237
237
  sessionExpiration: t,
238
238
  clientId: n
239
239
  }
240
240
  });
241
- return (S = d.data) != null && S.idToken ? (y(d.data.idToken), d.data.accessToken && l(d.data.accessToken), d.data.refreshToken && T(d.data.refreshToken), g({
241
+ return (S = d.data) != null && S.idToken ? (y(d.data.idToken), d.data.accessToken && l(d.data.accessToken), d.data.refreshToken && g(d.data.refreshToken), T({
242
242
  isAuthenticated: !0,
243
243
  idToken: d.data.idToken,
244
244
  accessToken: d.data.accessToken,
@@ -247,9 +247,9 @@ const O = () => {
247
247
  logoutReason: ""
248
248
  }), !0) : !1;
249
249
  }, b = () => {
250
- u(), m(), o();
250
+ u(), k(), o();
251
251
  };
252
- return /* @__PURE__ */ V(x.Provider, { value: { ...a, login: $, logout: b }, children: e });
252
+ return /* @__PURE__ */ P(x.Provider, { value: { ...a, login: $, logout: b }, children: e });
253
253
  }, re = (e = x) => F(e);
254
254
  export {
255
255
  oe as AuthProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth-provider",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -48,5 +48,5 @@
48
48
  "@versini/ui-hooks": "3.0.0",
49
49
  "uuid": "10.0.0"
50
50
  },
51
- "gitHead": "3dbd373d2db89d99a1ca36e0bbe1bc987d8eaaae"
51
+ "gitHead": "396698b2ecd3da3881a4b226a99eff3003501a27"
52
52
  }