@versini/auth-common 3.4.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,9 +17,10 @@ declare const BODY: {
17
17
  declare const JWT: {
18
18
  ALG: string;
19
19
  USER_ID_KEY: string;
20
+ USERNAME_KEY: string;
21
+ EMAIL_KEY: string;
20
22
  TOKEN_ID_KEY: string;
21
23
  NONCE_KEY: string;
22
- USERNAME_KEY: string;
23
24
  AUTH_TYPE_KEY: string;
24
25
  EXPIRES_AT_KEY: string;
25
26
  CREATED_AT_KEY: string;
@@ -34,9 +35,10 @@ declare const TOKEN_EXPIRATION: {
34
35
  REFRESH: string;
35
36
  };
36
37
  declare const API_TYPE: {
37
- AUTHENTICATE: string;
38
38
  CODE: string;
39
39
  LOGOUT: string;
40
+ LOGIN: string;
41
+ REFRESH: string;
40
42
  };
41
43
 
42
44
  declare const verifyAndExtractToken: (token: string) => Promise<jose.JWTVerifyResult<jose.JWTPayload> | undefined>;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
- @versini/auth-common v3.4.0
2
+ @versini/auth-common v4.1.0
3
3
  © 2024 gizmette.com
4
4
  */
5
5
  try {
6
6
  window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
7
- version: "3.4.0",
8
- buildTime: "08/19/2024 11:57 AM EDT",
7
+ version: "4.1.0",
8
+ buildTime: "09/01/2024 04:15 PM EDT",
9
9
  homepage: "https://github.com/aversini/auth-client",
10
10
  license: "MIT"
11
11
  });
@@ -25,9 +25,10 @@ const et = {
25
25
  }, R = {
26
26
  ALG: "RS256",
27
27
  USER_ID_KEY: "sub",
28
+ USERNAME_KEY: "username",
29
+ EMAIL_KEY: "email",
28
30
  TOKEN_ID_KEY: "__raw",
29
31
  NONCE_KEY: "_nonce",
30
- USERNAME_KEY: "username",
31
32
  AUTH_TYPE_KEY: "auth_type",
32
33
  EXPIRES_AT_KEY: "exp",
33
34
  CREATED_AT_KEY: "iat",
@@ -47,10 +48,11 @@ awIDAQAB
47
48
  ID: "90d",
48
49
  REFRESH: "90d"
49
50
  }, nt = {
50
- AUTHENTICATE: "authenticate",
51
51
  CODE: "code",
52
- LOGOUT: "logout"
53
- }, O = crypto, G = (e) => e instanceof CryptoKey, T = new TextEncoder(), C = new TextDecoder();
52
+ LOGOUT: "logout",
53
+ LOGIN: "login",
54
+ REFRESH: "refresh"
55
+ }, O = crypto, G = (e) => e instanceof CryptoKey, _ = new TextEncoder(), C = new TextDecoder();
54
56
  function oe(...e) {
55
57
  const t = e.reduce((a, { length: o }) => a + o, 0), r = new Uint8Array(t);
56
58
  let n = 0;
@@ -140,7 +142,7 @@ class se extends A {
140
142
  function m(e, t = "algorithm.name") {
141
143
  return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
142
144
  }
143
- function _(e, t) {
145
+ function v(e, t) {
144
146
  return e.name === t;
145
147
  }
146
148
  function W(e) {
@@ -173,7 +175,7 @@ function le(e, t, ...r) {
173
175
  case "HS256":
174
176
  case "HS384":
175
177
  case "HS512": {
176
- if (!_(e.algorithm, "HMAC"))
178
+ if (!v(e.algorithm, "HMAC"))
177
179
  throw m("HMAC");
178
180
  const n = parseInt(t.slice(2), 10);
179
181
  if (W(e.algorithm.hash) !== n)
@@ -183,7 +185,7 @@ function le(e, t, ...r) {
183
185
  case "RS256":
184
186
  case "RS384":
185
187
  case "RS512": {
186
- if (!_(e.algorithm, "RSASSA-PKCS1-v1_5"))
188
+ if (!v(e.algorithm, "RSASSA-PKCS1-v1_5"))
187
189
  throw m("RSASSA-PKCS1-v1_5");
188
190
  const n = parseInt(t.slice(2), 10);
189
191
  if (W(e.algorithm.hash) !== n)
@@ -193,7 +195,7 @@ function le(e, t, ...r) {
193
195
  case "PS256":
194
196
  case "PS384":
195
197
  case "PS512": {
196
- if (!_(e.algorithm, "RSA-PSS"))
198
+ if (!v(e.algorithm, "RSA-PSS"))
197
199
  throw m("RSA-PSS");
198
200
  const n = parseInt(t.slice(2), 10);
199
201
  if (W(e.algorithm.hash) !== n)
@@ -208,7 +210,7 @@ function le(e, t, ...r) {
208
210
  case "ES256":
209
211
  case "ES384":
210
212
  case "ES512": {
211
- if (!_(e.algorithm, "ECDSA"))
213
+ if (!v(e.algorithm, "ECDSA"))
212
214
  throw m("ECDSA");
213
215
  const n = de(t);
214
216
  if (e.algorithm.namedCurve !== n)
@@ -458,7 +460,7 @@ const I = (e) => e == null ? void 0 : e[Symbol.toStringTag], Ce = (e, t) => {
458
460
  if (t.type !== "secret")
459
461
  throw new TypeError(`${I(t)} instances for symmetric algorithms must be of type "secret"`);
460
462
  }
461
- }, Te = (e, t, r) => {
463
+ }, _e = (e, t, r) => {
462
464
  if (!X(t))
463
465
  throw new TypeError(z(e, t, ...P));
464
466
  if (t.type === "secret")
@@ -467,10 +469,10 @@ const I = (e) => e == null ? void 0 : e[Symbol.toStringTag], Ce = (e, t) => {
467
469
  throw new TypeError(`${I(t)} instances for asymmetric algorithm verifying must be of type "public"`);
468
470
  if (t.algorithm && r === "encrypt" && t.type === "private")
469
471
  throw new TypeError(`${I(t)} instances for asymmetric algorithm encryption must be of type "public"`);
470
- }, _e = (e, t, r) => {
471
- e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Ce(e, t) : Te(e, t, r);
472
+ }, ve = (e, t, r) => {
473
+ e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Ce(e, t) : _e(e, t, r);
472
474
  };
473
- function ve(e, t, r, n, a) {
475
+ function Te(e, t, r, n, a) {
474
476
  if (a.crit !== void 0 && (n == null ? void 0 : n.crit) === void 0)
475
477
  throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
476
478
  if (!n || n.crit === void 0)
@@ -566,7 +568,7 @@ async function Oe(e, t, r) {
566
568
  const a = {
567
569
  ...n,
568
570
  ...e.header
569
- }, o = ve(u, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, n, a);
571
+ }, o = Te(u, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, n, a);
570
572
  let i = !0;
571
573
  if (o.has("b64") && (i = n.b64, typeof i != "boolean"))
572
574
  throw new u('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
@@ -582,8 +584,8 @@ async function Oe(e, t, r) {
582
584
  } else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
583
585
  throw new u("JWS Payload must be a string or an Uint8Array instance");
584
586
  let p = !1;
585
- typeof t == "function" && (t = await t(n, e), p = !0), _e(c, t, "verify");
586
- const g = oe(T.encode(e.protected ?? ""), T.encode("."), typeof e.payload == "string" ? T.encode(e.payload) : e.payload);
587
+ typeof t == "function" && (t = await t(n, e), p = !0), ve(c, t, "verify");
588
+ const g = oe(_.encode(e.protected ?? ""), _.encode("."), typeof e.payload == "string" ? _.encode(e.payload) : e.payload);
587
589
  let f;
588
590
  try {
589
591
  f = b(e.signature);
@@ -599,7 +601,7 @@ async function Oe(e, t, r) {
599
601
  } catch {
600
602
  throw new u("Failed to base64url decode the payload");
601
603
  }
602
- else typeof e.payload == "string" ? y = T.encode(e.payload) : y = e.payload;
604
+ else typeof e.payload == "string" ? y = _.encode(e.payload) : y = e.payload;
603
605
  const l = { payload: y };
604
606
  return e.protected !== void 0 && (l.protectedHeader = n), e.header !== void 0 && (l.unprotectedHeader = e.header), p ? { ...l, key: t } : l;
605
607
  }
@@ -772,11 +774,11 @@ for (var H = 0; H < 256; ++H)
772
774
  function Be(e, t = 0) {
773
775
  return (d[e[t + 0]] + d[e[t + 1]] + d[e[t + 2]] + d[e[t + 3]] + "-" + d[e[t + 4]] + d[e[t + 5]] + "-" + d[e[t + 6]] + d[e[t + 7]] + "-" + d[e[t + 8]] + d[e[t + 9]] + "-" + d[e[t + 10]] + d[e[t + 11]] + d[e[t + 12]] + d[e[t + 13]] + d[e[t + 14]] + d[e[t + 15]]).toLowerCase();
774
776
  }
775
- var v, Fe = new Uint8Array(16);
777
+ var T, Fe = new Uint8Array(16);
776
778
  function Ye() {
777
- if (!v && (v = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !v))
779
+ if (!T && (T = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !T))
778
780
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
779
- return v(Fe);
781
+ return T(Fe);
780
782
  }
781
783
  var Ve = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
782
784
  const F = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth-common",
3
- "version": "3.4.0",
3
+ "version": "4.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  "test:coverage": "vitest run --coverage"
34
34
  },
35
35
  "dependencies": {
36
- "jose": "5.6.3",
36
+ "jose": "5.7.0",
37
37
  "uuid": "10.0.0"
38
38
  },
39
- "gitHead": "fc7db509578caa068384544279e347f089720ebe"
39
+ "gitHead": "74132e69a7def29f79c3d6a089611972dbfdfb63"
40
40
  }