@nsshunt/stsoauth2plugin 1.0.40 → 1.0.41

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.
@@ -48,10 +48,10 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
48
48
  function getDefaultExportFromCjs(x) {
49
49
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
50
50
  }
51
- function getAugmentedNamespace(n2) {
52
- if (n2.__esModule)
53
- return n2;
54
- var f = n2.default;
51
+ function getAugmentedNamespace(n) {
52
+ if (n.__esModule)
53
+ return n;
54
+ var f = n.default;
55
55
  if (typeof f == "function") {
56
56
  var a = function a2() {
57
57
  if (this instanceof a2) {
@@ -63,12 +63,12 @@ function getAugmentedNamespace(n2) {
63
63
  } else
64
64
  a = {};
65
65
  Object.defineProperty(a, "__esModule", { value: true });
66
- Object.keys(n2).forEach(function(k) {
67
- var d = Object.getOwnPropertyDescriptor(n2, k);
66
+ Object.keys(n).forEach(function(k) {
67
+ var d = Object.getOwnPropertyDescriptor(n, k);
68
68
  Object.defineProperty(a, k, d.get ? d : {
69
69
  enumerable: true,
70
70
  get: function() {
71
- return n2[k];
71
+ return n[k];
72
72
  }
73
73
  });
74
74
  });
@@ -475,7 +475,7 @@ function requireCore() {
475
475
  stringify: function(wordArray) {
476
476
  try {
477
477
  return decodeURIComponent(escape(Latin1.stringify(wordArray)));
478
- } catch (e2) {
478
+ } catch (e) {
479
479
  throw new Error("Malformed UTF-8 data");
480
480
  }
481
481
  },
@@ -707,29 +707,29 @@ function requireCore() {
707
707
  var H = [];
708
708
  var K = [];
709
709
  (function() {
710
- function isPrime(n3) {
711
- var sqrtN = Math2.sqrt(n3);
710
+ function isPrime(n2) {
711
+ var sqrtN = Math2.sqrt(n2);
712
712
  for (var factor = 2; factor <= sqrtN; factor++) {
713
- if (!(n3 % factor)) {
713
+ if (!(n2 % factor)) {
714
714
  return false;
715
715
  }
716
716
  }
717
717
  return true;
718
718
  }
719
- function getFractionalBits(n3) {
720
- return (n3 - (n3 | 0)) * 4294967296 | 0;
719
+ function getFractionalBits(n2) {
720
+ return (n2 - (n2 | 0)) * 4294967296 | 0;
721
721
  }
722
- var n2 = 2;
722
+ var n = 2;
723
723
  var nPrime = 0;
724
724
  while (nPrime < 64) {
725
- if (isPrime(n2)) {
725
+ if (isPrime(n)) {
726
726
  if (nPrime < 8) {
727
- H[nPrime] = getFractionalBits(Math2.pow(n2, 1 / 2));
727
+ H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
728
728
  }
729
- K[nPrime] = getFractionalBits(Math2.pow(n2, 1 / 3));
729
+ K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
730
730
  nPrime++;
731
731
  }
732
- n2++;
732
+ n++;
733
733
  }
734
734
  })();
735
735
  var W = [];
@@ -743,7 +743,7 @@ function requireCore() {
743
743
  var b = H2[1];
744
744
  var c = H2[2];
745
745
  var d = H2[3];
746
- var e2 = H2[4];
746
+ var e = H2[4];
747
747
  var f = H2[5];
748
748
  var g = H2[6];
749
749
  var h = H2[7];
@@ -757,16 +757,16 @@ function requireCore() {
757
757
  var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
758
758
  W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
759
759
  }
760
- var ch = e2 & f ^ ~e2 & g;
760
+ var ch = e & f ^ ~e & g;
761
761
  var maj = a & b ^ a & c ^ b & c;
762
762
  var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
763
- var sigma1 = (e2 << 26 | e2 >>> 6) ^ (e2 << 21 | e2 >>> 11) ^ (e2 << 7 | e2 >>> 25);
763
+ var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
764
764
  var t1 = h + sigma1 + ch + K[i] + W[i];
765
765
  var t2 = sigma0 + maj;
766
766
  h = g;
767
767
  g = f;
768
- f = e2;
769
- e2 = d + t1 | 0;
768
+ f = e;
769
+ e = d + t1 | 0;
770
770
  d = c;
771
771
  c = b;
772
772
  b = a;
@@ -776,7 +776,7 @@ function requireCore() {
776
776
  H2[1] = H2[1] + b | 0;
777
777
  H2[2] = H2[2] + c | 0;
778
778
  H2[3] = H2[3] + d | 0;
779
- H2[4] = H2[4] + e2 | 0;
779
+ H2[4] = H2[4] + e | 0;
780
780
  H2[5] = H2[5] + f | 0;
781
781
  H2[6] = H2[6] + g | 0;
782
782
  H2[7] = H2[7] + h | 0;
@@ -1002,57 +1002,60 @@ var IOauth2ListenerCommand = /* @__PURE__ */ ((IOauth2ListenerCommand2) => {
1002
1002
  IOauth2ListenerCommand2["EXECUTE_REFRESH_TOKEN"] = "__EXECUTE_REFRESH_TOKEN";
1003
1003
  return IOauth2ListenerCommand2;
1004
1004
  })(IOauth2ListenerCommand || {});
1005
- function e(e2) {
1006
- this.message = e2;
1005
+ class InvalidTokenError extends Error {
1007
1006
  }
1008
- e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
1009
- var r = "undefined" != typeof window && window.atob && window.atob.bind(window) || function(r2) {
1010
- var t2 = String(r2).replace(/=+$/, "");
1011
- if (t2.length % 4 == 1)
1012
- throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
1013
- for (var n2, o2, a = 0, i = 0, c = ""; o2 = t2.charAt(i++); ~o2 && (n2 = a % 4 ? 64 * n2 + o2 : o2, a++ % 4) ? c += String.fromCharCode(255 & n2 >> (-2 * a & 6)) : 0)
1014
- o2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o2);
1015
- return c;
1016
- };
1017
- function t(e2) {
1018
- var t2 = e2.replace(/-/g, "+").replace(/_/g, "/");
1019
- switch (t2.length % 4) {
1007
+ InvalidTokenError.prototype.name = "InvalidTokenError";
1008
+ function b64DecodeUnicode(str) {
1009
+ return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
1010
+ let code = p.charCodeAt(0).toString(16).toUpperCase();
1011
+ if (code.length < 2) {
1012
+ code = "0" + code;
1013
+ }
1014
+ return "%" + code;
1015
+ }));
1016
+ }
1017
+ function base64UrlDecode(str) {
1018
+ let output = str.replace(/-/g, "+").replace(/_/g, "/");
1019
+ switch (output.length % 4) {
1020
1020
  case 0:
1021
1021
  break;
1022
1022
  case 2:
1023
- t2 += "==";
1023
+ output += "==";
1024
1024
  break;
1025
1025
  case 3:
1026
- t2 += "=";
1026
+ output += "=";
1027
1027
  break;
1028
1028
  default:
1029
- throw "Illegal base64url string!";
1029
+ throw new Error("base64 string is not of the correct length");
1030
1030
  }
1031
1031
  try {
1032
- return function(e3) {
1033
- return decodeURIComponent(r(e3).replace(/(.)/g, function(e4, r2) {
1034
- var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
1035
- return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
1036
- }));
1037
- }(t2);
1038
- } catch (e3) {
1039
- return r(t2);
1032
+ return b64DecodeUnicode(output);
1033
+ } catch (err) {
1034
+ return atob(output);
1040
1035
  }
1041
1036
  }
1042
- function n(e2) {
1043
- this.message = e2;
1044
- }
1045
- function o(e2, r2) {
1046
- if ("string" != typeof e2)
1047
- throw new n("Invalid token specified");
1048
- var o2 = true === (r2 = r2 || {}).header ? 0 : 1;
1037
+ function jwtDecode(token, options) {
1038
+ if (typeof token !== "string") {
1039
+ throw new InvalidTokenError("Invalid token specified: must be a string");
1040
+ }
1041
+ options || (options = {});
1042
+ const pos = options.header === true ? 0 : 1;
1043
+ const part = token.split(".")[pos];
1044
+ if (typeof part !== "string") {
1045
+ throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
1046
+ }
1047
+ let decoded;
1048
+ try {
1049
+ decoded = base64UrlDecode(part);
1050
+ } catch (e) {
1051
+ throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
1052
+ }
1049
1053
  try {
1050
- return JSON.parse(t(e2.split(".")[o2]));
1051
- } catch (e3) {
1052
- throw new n("Invalid token specified: " + e3.message);
1054
+ return JSON.parse(decoded);
1055
+ } catch (e) {
1056
+ throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
1053
1057
  }
1054
1058
  }
1055
- n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
1056
1059
  const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
1057
1060
  state: () => {
1058
1061
  return {
@@ -1087,7 +1090,7 @@ const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
1087
1090
  UserDetails: (state) => {
1088
1091
  if (state.id_token) {
1089
1092
  const id_token = state.id_token;
1090
- const decodedIdToken = o(id_token);
1093
+ const decodedIdToken = jwtDecode(id_token);
1091
1094
  return decodedIdToken;
1092
1095
  } else {
1093
1096
  return null;
@@ -1975,7 +1978,7 @@ class STSOAuth2Worker {
1975
1978
  const currentSessionData = sessionData.tokenResponse;
1976
1979
  const refresh_token = currentSessionData.refresh_token;
1977
1980
  console.log(refresh_token);
1978
- const decodedRefreshToken = o(refresh_token);
1981
+ const decodedRefreshToken = jwtDecode(refresh_token);
1979
1982
  console.log(decodedRefreshToken);
1980
1983
  const sessionId = decodedRefreshToken.sts_session;
1981
1984
  console.log(sessionId);