zudoku 0.3.0-dev.55 → 0.3.0-dev.57

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 (181) hide show
  1. package/dist/app/demo.js +6 -1
  2. package/dist/app/demo.js.map +1 -1
  3. package/dist/app/entry.client.d.ts +1 -1
  4. package/dist/app/entry.client.js +1 -1
  5. package/dist/app/entry.client.js.map +1 -1
  6. package/dist/app/entry.server.d.ts +1 -1
  7. package/dist/app/entry.server.js +1 -1
  8. package/dist/app/entry.server.js.map +1 -1
  9. package/dist/app/main.d.ts +1 -1
  10. package/dist/app/main.js +9 -2
  11. package/dist/app/main.js.map +1 -1
  12. package/dist/app/standalone.js +6 -1
  13. package/dist/app/standalone.js.map +1 -1
  14. package/dist/config/validators/validate.d.ts +77 -17
  15. package/dist/config/validators/validate.js +7 -1
  16. package/dist/config/validators/validate.js.map +1 -1
  17. package/dist/lib/components/DeveloperHint.d.ts +5 -0
  18. package/dist/lib/components/DeveloperHint.js +10 -0
  19. package/dist/lib/components/DeveloperHint.js.map +1 -0
  20. package/dist/lib/components/Header.js +1 -1
  21. package/dist/lib/components/Header.js.map +1 -1
  22. package/dist/lib/components/NotFoundPage.js +2 -2
  23. package/dist/lib/components/NotFoundPage.js.map +1 -1
  24. package/dist/lib/components/navigation/SideNavigationCategory.js +2 -2
  25. package/dist/lib/components/navigation/SideNavigationCategory.js.map +1 -1
  26. package/dist/lib/core/DevPortalContext.d.ts +8 -1
  27. package/dist/lib/core/DevPortalContext.js.map +1 -1
  28. package/dist/lib/oas/graphql/index.js +5 -3
  29. package/dist/lib/oas/graphql/index.js.map +1 -1
  30. package/dist/lib/plugins/api-keys/ProtectedRoute.d.ts +1 -0
  31. package/dist/lib/plugins/api-keys/ProtectedRoute.js +14 -0
  32. package/dist/lib/plugins/api-keys/ProtectedRoute.js.map +1 -0
  33. package/dist/lib/plugins/api-keys/index.js +2 -12
  34. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  35. package/dist/lib/plugins/openapi/OperationList.js +4 -3
  36. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  37. package/dist/lib/plugins/openapi/StaggeredRender.d.ts +5 -0
  38. package/dist/lib/plugins/openapi/StaggeredRender.js +13 -0
  39. package/dist/lib/plugins/openapi/StaggeredRender.js.map +1 -0
  40. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +3 -3
  41. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  42. package/dist/vite/plugin-custom-css.js +2 -3
  43. package/dist/vite/plugin-custom-css.js.map +1 -1
  44. package/lib/AnchorLink-GNsUeGSX.js +705 -0
  45. package/lib/{AnchorLink-BaXHjhF-.js.map → AnchorLink-GNsUeGSX.js.map} +1 -1
  46. package/lib/Button-DpHMZvVs.js +4571 -0
  47. package/lib/Button-DpHMZvVs.js.map +1 -0
  48. package/lib/DevPortalProvider-Do9oJqme.js +1081 -0
  49. package/lib/{DevPortalProvider-GjdO0Xr-.js.map → DevPortalProvider-Do9oJqme.js.map} +1 -1
  50. package/lib/Markdown-DtLFdxD1.js +15031 -0
  51. package/lib/Markdown-DtLFdxD1.js.map +1 -0
  52. package/lib/MdxPage-CbwYRKf5.js +190 -0
  53. package/lib/{MdxPage-Dlujuj-J.js.map → MdxPage-CbwYRKf5.js.map} +1 -1
  54. package/lib/OperationList-DypxLtSC.js +5578 -0
  55. package/lib/OperationList-DypxLtSC.js.map +1 -0
  56. package/lib/Route-C1LyvITr.js +13 -0
  57. package/lib/{Route-CR6TEwVC.js.map → Route-C1LyvITr.js.map} +1 -1
  58. package/lib/Spinner-Bhbs5aPI.js +182 -0
  59. package/lib/Spinner-Bhbs5aPI.js.map +1 -0
  60. package/lib/_commonjsHelpers-BVfed4GL.js +29 -0
  61. package/lib/_commonjsHelpers-BVfed4GL.js.map +1 -0
  62. package/lib/assets/index-BPdJm2ty.js +4765 -0
  63. package/lib/assets/{index-CpIig0AX.js.map → index-BPdJm2ty.js.map} +1 -1
  64. package/lib/assets/worker-BWwCA-wk.js +14900 -0
  65. package/lib/assets/{worker-B5k2aBV9.js.map → worker-BWwCA-wk.js.map} +1 -1
  66. package/lib/context-_fYfJFgk.js +14 -0
  67. package/lib/{context-BoN_3uxi.js.map → context-_fYfJFgk.js.map} +1 -1
  68. package/lib/hook-Biq3zYel.js +92 -0
  69. package/lib/hook-Biq3zYel.js.map +1 -0
  70. package/lib/{index-Dih8IAqw.js → index-Bg82-bqR.js} +83 -103
  71. package/lib/{index-Dih8IAqw.js.map → index-Bg82-bqR.js.map} +1 -1
  72. package/lib/index-gsAuUwQh.js +418 -0
  73. package/lib/index-gsAuUwQh.js.map +1 -0
  74. package/lib/index-pI9JkN46.js +4765 -0
  75. package/lib/{index-Bn03IPZt.js.map → index-pI9JkN46.js.map} +1 -1
  76. package/lib/jsx-runtime-CJZJivg2.js +1526 -0
  77. package/lib/{jsx-runtime-DvZ6OKMM.js.map → jsx-runtime-CJZJivg2.js.map} +1 -1
  78. package/lib/prism-bash.min-DadFsM4Z.js +7 -0
  79. package/lib/{prism-bash.min-BtBk0onv.js.map → prism-bash.min-DadFsM4Z.js.map} +1 -1
  80. package/lib/prism-csharp.min-Yizuc34Y.js +35 -0
  81. package/lib/{prism-csharp.min-Cv7D49bv.js.map → prism-csharp.min-Yizuc34Y.js.map} +1 -1
  82. package/lib/prism-java.min-d5iT_mOd.js +7 -0
  83. package/lib/{prism-java.min-tNK-JX6x.js.map → prism-java.min-d5iT_mOd.js.map} +1 -1
  84. package/lib/prism-json.min-B1GJqK1k.js +2 -0
  85. package/lib/{prism-json.min-Cdtv-CME.js.map → prism-json.min-B1GJqK1k.js.map} +1 -1
  86. package/lib/prism-markup-templating-DZrrEs0A.js +62 -0
  87. package/lib/{prism-markup-templating-iotg2sCU.js.map → prism-markup-templating-DZrrEs0A.js.map} +1 -1
  88. package/lib/prism-objectivec.min-BXSWqpJJ.js +2 -0
  89. package/lib/{prism-objectivec.min-CY4WGixz.js.map → prism-objectivec.min-BXSWqpJJ.js.map} +1 -1
  90. package/lib/prism-php.min-o7FpoMP_.js +11 -0
  91. package/lib/{prism-php.min-T6sIVgED.js.map → prism-php.min-o7FpoMP_.js.map} +1 -1
  92. package/lib/prism-ruby.min-C7LwcKyz.js +10 -0
  93. package/lib/{prism-ruby.min-B-2KAa4y.js.map → prism-ruby.min-C7LwcKyz.js.map} +1 -1
  94. package/lib/router-CBw2vqJE.js +2973 -0
  95. package/lib/{router-ButO1QyY.js.map → router-CBw2vqJE.js.map} +1 -1
  96. package/lib/slugify-CiPVjteN.js +28 -0
  97. package/lib/{slugify-CmS97Vy8.js.map → slugify-CiPVjteN.js.map} +1 -1
  98. package/lib/state-DKdaQzvh.js +288 -0
  99. package/lib/{state-CmGfNKhR.js.map → state-DKdaQzvh.js.map} +1 -1
  100. package/lib/urql-DMlBWUKL.js +1592 -0
  101. package/lib/{urql-DtVKPBx_.js.map → urql-DMlBWUKL.js.map} +1 -1
  102. package/lib/util-_jwUlTBU.js +41 -0
  103. package/lib/{util-B5KX4h4M.js.map → util-_jwUlTBU.js.map} +1 -1
  104. package/lib/zudoku.auth-auth0.js +18 -24
  105. package/lib/zudoku.auth-auth0.js.map +1 -1
  106. package/lib/zudoku.auth-clerk.js +34 -43
  107. package/lib/zudoku.auth-clerk.js.map +1 -1
  108. package/lib/zudoku.auth-openid.js +734 -1121
  109. package/lib/zudoku.auth-openid.js.map +1 -1
  110. package/lib/zudoku.components.js +830 -1076
  111. package/lib/zudoku.components.js.map +1 -1
  112. package/lib/zudoku.openapi-worker.js +9689 -13781
  113. package/lib/zudoku.openapi-worker.js.map +1 -1
  114. package/lib/zudoku.plugin-api-keys.js +171 -208
  115. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  116. package/lib/zudoku.plugin-markdown.js +33 -41
  117. package/lib/zudoku.plugin-markdown.js.map +1 -1
  118. package/lib/zudoku.plugin-openapi.js +6 -6
  119. package/lib/zudoku.plugin-redirect.js +8 -10
  120. package/lib/zudoku.plugin-redirect.js.map +1 -1
  121. package/package.json +2 -2
  122. package/src/app/demo.tsx +6 -1
  123. package/src/app/entry.client.tsx +1 -1
  124. package/src/app/entry.server.tsx +1 -1
  125. package/src/app/main.tsx +11 -2
  126. package/src/app/standalone.tsx +6 -1
  127. package/src/lib/components/DeveloperHint.tsx +25 -0
  128. package/src/lib/components/Header.tsx +6 -1
  129. package/src/lib/components/NotFoundPage.tsx +8 -14
  130. package/src/lib/components/navigation/SideNavigationCategory.tsx +3 -3
  131. package/src/lib/core/DevPortalContext.ts +8 -1
  132. package/src/lib/oas/graphql/index.ts +7 -3
  133. package/src/lib/plugins/api-keys/ProtectedRoute.tsx +29 -0
  134. package/src/lib/plugins/api-keys/index.tsx +2 -21
  135. package/src/lib/plugins/openapi/OperationList.tsx +14 -14
  136. package/src/lib/plugins/openapi/StaggeredRender.tsx +17 -0
  137. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +3 -5
  138. package/lib/AnchorLink-BaXHjhF-.js +0 -989
  139. package/lib/Combination-BfufJFkX.js +0 -1365
  140. package/lib/Combination-BfufJFkX.js.map +0 -1
  141. package/lib/DevPortalProvider-GjdO0Xr-.js +0 -1610
  142. package/lib/Markdown-B8nPVql1.js +0 -19708
  143. package/lib/Markdown-B8nPVql1.js.map +0 -1
  144. package/lib/MdxPage-Dlujuj-J.js +0 -223
  145. package/lib/OperationList-krPgt6sE.js +0 -8041
  146. package/lib/OperationList-krPgt6sE.js.map +0 -1
  147. package/lib/Playground-DOHxca0P.js +0 -539
  148. package/lib/Playground-DOHxca0P.js.map +0 -1
  149. package/lib/Route-CR6TEwVC.js +0 -13
  150. package/lib/Select-Boi_pe3L.js +0 -5298
  151. package/lib/Select-Boi_pe3L.js.map +0 -1
  152. package/lib/Spinner-oU0QJmi_.js +0 -16
  153. package/lib/Spinner-oU0QJmi_.js.map +0 -1
  154. package/lib/_commonjsHelpers-BxmBWJD2.js +0 -34
  155. package/lib/_commonjsHelpers-BxmBWJD2.js.map +0 -1
  156. package/lib/assets/index-CpIig0AX.js +0 -6341
  157. package/lib/assets/worker-B5k2aBV9.js +0 -18921
  158. package/lib/context-BoN_3uxi.js +0 -17
  159. package/lib/hook-CIuFuyBT.js +0 -90
  160. package/lib/hook-CIuFuyBT.js.map +0 -1
  161. package/lib/index-BL1P4Gqq.js +0 -280
  162. package/lib/index-BL1P4Gqq.js.map +0 -1
  163. package/lib/index-Bn03IPZt.js +0 -6341
  164. package/lib/index-FprhHF51.js +0 -253
  165. package/lib/index-FprhHF51.js.map +0 -1
  166. package/lib/jsx-runtime-DvZ6OKMM.js +0 -2110
  167. package/lib/mutation-DWY9x2Uc.js +0 -250
  168. package/lib/mutation-DWY9x2Uc.js.map +0 -1
  169. package/lib/prism-bash.min-BtBk0onv.js +0 -7
  170. package/lib/prism-csharp.min-Cv7D49bv.js +0 -30
  171. package/lib/prism-java.min-tNK-JX6x.js +0 -7
  172. package/lib/prism-json.min-Cdtv-CME.js +0 -2
  173. package/lib/prism-markup-templating-iotg2sCU.js +0 -94
  174. package/lib/prism-objectivec.min-CY4WGixz.js +0 -2
  175. package/lib/prism-php.min-T6sIVgED.js +0 -11
  176. package/lib/prism-ruby.min-B-2KAa4y.js +0 -8
  177. package/lib/router-ButO1QyY.js +0 -4062
  178. package/lib/slugify-CmS97Vy8.js +0 -50
  179. package/lib/state-CmGfNKhR.js +0 -436
  180. package/lib/urql-DtVKPBx_.js +0 -2567
  181. package/lib/util-B5KX4h4M.js +0 -55
@@ -1,529 +1,348 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var _a, _b;
5
- import { a as useNavigate, j as jsxRuntimeExports } from "./jsx-runtime-DvZ6OKMM.js";
6
- import { c as commonjsGlobal, a as getDefaultExportFromCjs } from "./_commonjsHelpers-BxmBWJD2.js";
7
- import { useRef, useState, useEffect } from "react";
8
- import { u as useAuthState } from "./state-CmGfNKhR.js";
9
- var loglevel = { exports: {} };
10
- (function(module) {
11
- (function(root, definition) {
12
- if (module.exports) {
13
- module.exports = definition();
14
- } else {
15
- root.log = definition();
16
- }
17
- })(commonjsGlobal, function() {
18
- var noop = function() {
19
- };
20
- var undefinedType = "undefined";
21
- var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
22
- var logMethods = [
1
+ var Re = Object.defineProperty;
2
+ var xe = (e, t, n) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var S = (e, t, n) => xe(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { a as Pe, j as T } from "./jsx-runtime-CJZJivg2.js";
5
+ import { c as Le, a as Ue } from "./_commonjsHelpers-BVfed4GL.js";
6
+ import { useRef as Ce, useState as je, useEffect as ze } from "react";
7
+ import { u as re } from "./state-DKdaQzvh.js";
8
+ var he = { exports: {} };
9
+ (function(e) {
10
+ (function(t, n) {
11
+ e.exports ? e.exports = n() : t.log = n();
12
+ })(Le, function() {
13
+ var t = function() {
14
+ }, n = "undefined", o = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
23
15
  "trace",
24
16
  "debug",
25
17
  "info",
26
18
  "warn",
27
19
  "error"
28
- ];
29
- var _loggersByName = {};
30
- var defaultLogger = null;
31
- function bindMethod(obj, methodName) {
32
- var method = obj[methodName];
33
- if (typeof method.bind === "function") {
34
- return method.bind(obj);
35
- } else {
36
- try {
37
- return Function.prototype.bind.call(method, obj);
38
- } catch (e) {
39
- return function() {
40
- return Function.prototype.apply.apply(method, [obj, arguments]);
41
- };
42
- }
20
+ ], r = {}, i = null;
21
+ function d(u, f) {
22
+ var c = u[f];
23
+ if (typeof c.bind == "function")
24
+ return c.bind(u);
25
+ try {
26
+ return Function.prototype.bind.call(c, u);
27
+ } catch {
28
+ return function() {
29
+ return Function.prototype.apply.apply(c, [u, arguments]);
30
+ };
43
31
  }
44
32
  }
45
- function traceForIE() {
46
- if (console.log) {
47
- if (console.log.apply) {
48
- console.log.apply(console, arguments);
49
- } else {
50
- Function.prototype.apply.apply(console.log, [console, arguments]);
51
- }
52
- }
53
- if (console.trace) console.trace();
33
+ function g() {
34
+ console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
54
35
  }
55
- function realMethod(methodName) {
56
- if (methodName === "debug") {
57
- methodName = "log";
58
- }
59
- if (typeof console === undefinedType) {
60
- return false;
61
- } else if (methodName === "trace" && isIE) {
62
- return traceForIE;
63
- } else if (console[methodName] !== void 0) {
64
- return bindMethod(console, methodName);
65
- } else if (console.log !== void 0) {
66
- return bindMethod(console, "log");
67
- } else {
68
- return noop;
69
- }
36
+ function m(u) {
37
+ return u === "debug" && (u = "log"), typeof console === n ? !1 : u === "trace" && o ? g : console[u] !== void 0 ? d(console, u) : console.log !== void 0 ? d(console, "log") : t;
70
38
  }
71
- function replaceLoggingMethods() {
72
- var level = this.getLevel();
73
- for (var i = 0; i < logMethods.length; i++) {
74
- var methodName = logMethods[i];
75
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
39
+ function _() {
40
+ for (var u = this.getLevel(), f = 0; f < s.length; f++) {
41
+ var c = s[f];
42
+ this[c] = f < u ? t : this.methodFactory(c, u, this.name);
76
43
  }
77
- this.log = this.debug;
78
- if (typeof console === undefinedType && level < this.levels.SILENT) {
44
+ if (this.log = this.debug, typeof console === n && u < this.levels.SILENT)
79
45
  return "No console available for logging";
80
- }
81
46
  }
82
- function enableLoggingWhenConsoleArrives(methodName) {
47
+ function y(u) {
83
48
  return function() {
84
- if (typeof console !== undefinedType) {
85
- replaceLoggingMethods.call(this);
86
- this[methodName].apply(this, arguments);
87
- }
49
+ typeof console !== n && (_.call(this), this[u].apply(this, arguments));
88
50
  };
89
51
  }
90
- function defaultMethodFactory(methodName, _level, _loggerName) {
91
- return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
52
+ function h(u, f, c) {
53
+ return m(u) || y.apply(this, arguments);
92
54
  }
93
- function Logger(name, factory) {
94
- var self = this;
95
- var inheritedLevel;
96
- var defaultLevel;
97
- var userLevel;
98
- var storageKey = "loglevel";
99
- if (typeof name === "string") {
100
- storageKey += ":" + name;
101
- } else if (typeof name === "symbol") {
102
- storageKey = void 0;
103
- }
104
- function persistLevelIfPossible(levelNum) {
105
- var levelName = (logMethods[levelNum] || "silent").toUpperCase();
106
- if (typeof window === undefinedType || !storageKey) return;
107
- try {
108
- window.localStorage[storageKey] = levelName;
109
- return;
110
- } catch (ignore) {
111
- }
112
- try {
113
- window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
114
- } catch (ignore) {
55
+ function L(u, f) {
56
+ var c = this, J, $, x, b = "loglevel";
57
+ typeof u == "string" ? b += ":" + u : typeof u == "symbol" && (b = void 0);
58
+ function ke(l) {
59
+ var p = (s[l] || "silent").toUpperCase();
60
+ if (!(typeof window === n || !b)) {
61
+ try {
62
+ window.localStorage[b] = p;
63
+ return;
64
+ } catch {
65
+ }
66
+ try {
67
+ window.document.cookie = encodeURIComponent(b) + "=" + p + ";";
68
+ } catch {
69
+ }
115
70
  }
116
71
  }
117
- function getPersistedLevel() {
118
- var storedLevel;
119
- if (typeof window === undefinedType || !storageKey) return;
120
- try {
121
- storedLevel = window.localStorage[storageKey];
122
- } catch (ignore) {
123
- }
124
- if (typeof storedLevel === undefinedType) {
72
+ function ee() {
73
+ var l;
74
+ if (!(typeof window === n || !b)) {
125
75
  try {
126
- var cookie = window.document.cookie;
127
- var cookieName = encodeURIComponent(storageKey);
128
- var location2 = cookie.indexOf(cookieName + "=");
129
- if (location2 !== -1) {
130
- storedLevel = /^([^;]+)/.exec(
131
- cookie.slice(location2 + cookieName.length + 1)
132
- )[1];
133
- }
134
- } catch (ignore) {
76
+ l = window.localStorage[b];
77
+ } catch {
135
78
  }
79
+ if (typeof l === n)
80
+ try {
81
+ var p = window.document.cookie, O = encodeURIComponent(b), ne = p.indexOf(O + "=");
82
+ ne !== -1 && (l = /^([^;]+)/.exec(
83
+ p.slice(ne + O.length + 1)
84
+ )[1]);
85
+ } catch {
86
+ }
87
+ return c.levels[l] === void 0 && (l = void 0), l;
136
88
  }
137
- if (self.levels[storedLevel] === void 0) {
138
- storedLevel = void 0;
139
- }
140
- return storedLevel;
141
89
  }
142
- function clearPersistedLevel() {
143
- if (typeof window === undefinedType || !storageKey) return;
144
- try {
145
- window.localStorage.removeItem(storageKey);
146
- } catch (ignore) {
147
- }
148
- try {
149
- window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
150
- } catch (ignore) {
90
+ function Te() {
91
+ if (!(typeof window === n || !b)) {
92
+ try {
93
+ window.localStorage.removeItem(b);
94
+ } catch {
95
+ }
96
+ try {
97
+ window.document.cookie = encodeURIComponent(b) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
98
+ } catch {
99
+ }
151
100
  }
152
101
  }
153
- function normalizeLevel(input) {
154
- var level = input;
155
- if (typeof level === "string" && self.levels[level.toUpperCase()] !== void 0) {
156
- level = self.levels[level.toUpperCase()];
157
- }
158
- if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
159
- return level;
160
- } else {
161
- throw new TypeError("log.setLevel() called with invalid level: " + input);
162
- }
102
+ function U(l) {
103
+ var p = l;
104
+ if (typeof p == "string" && c.levels[p.toUpperCase()] !== void 0 && (p = c.levels[p.toUpperCase()]), typeof p == "number" && p >= 0 && p <= c.levels.SILENT)
105
+ return p;
106
+ throw new TypeError("log.setLevel() called with invalid level: " + l);
163
107
  }
164
- self.name = name;
165
- self.levels = {
166
- "TRACE": 0,
167
- "DEBUG": 1,
168
- "INFO": 2,
169
- "WARN": 3,
170
- "ERROR": 4,
171
- "SILENT": 5
172
- };
173
- self.methodFactory = factory || defaultMethodFactory;
174
- self.getLevel = function() {
175
- if (userLevel != null) {
176
- return userLevel;
177
- } else if (defaultLevel != null) {
178
- return defaultLevel;
179
- } else {
180
- return inheritedLevel;
181
- }
182
- };
183
- self.setLevel = function(level, persist) {
184
- userLevel = normalizeLevel(level);
185
- if (persist !== false) {
186
- persistLevelIfPossible(userLevel);
187
- }
188
- return replaceLoggingMethods.call(self);
189
- };
190
- self.setDefaultLevel = function(level) {
191
- defaultLevel = normalizeLevel(level);
192
- if (!getPersistedLevel()) {
193
- self.setLevel(level, false);
194
- }
195
- };
196
- self.resetLevel = function() {
197
- userLevel = null;
198
- clearPersistedLevel();
199
- replaceLoggingMethods.call(self);
200
- };
201
- self.enableAll = function(persist) {
202
- self.setLevel(self.levels.TRACE, persist);
203
- };
204
- self.disableAll = function(persist) {
205
- self.setLevel(self.levels.SILENT, persist);
206
- };
207
- self.rebuild = function() {
208
- if (defaultLogger !== self) {
209
- inheritedLevel = normalizeLevel(defaultLogger.getLevel());
210
- }
211
- replaceLoggingMethods.call(self);
212
- if (defaultLogger === self) {
213
- for (var childName in _loggersByName) {
214
- _loggersByName[childName].rebuild();
215
- }
216
- }
217
- };
218
- inheritedLevel = normalizeLevel(
219
- defaultLogger ? defaultLogger.getLevel() : "WARN"
108
+ c.name = u, c.levels = {
109
+ TRACE: 0,
110
+ DEBUG: 1,
111
+ INFO: 2,
112
+ WARN: 3,
113
+ ERROR: 4,
114
+ SILENT: 5
115
+ }, c.methodFactory = f || h, c.getLevel = function() {
116
+ return x ?? $ ?? J;
117
+ }, c.setLevel = function(l, p) {
118
+ return x = U(l), p !== !1 && ke(x), _.call(c);
119
+ }, c.setDefaultLevel = function(l) {
120
+ $ = U(l), ee() || c.setLevel(l, !1);
121
+ }, c.resetLevel = function() {
122
+ x = null, Te(), _.call(c);
123
+ }, c.enableAll = function(l) {
124
+ c.setLevel(c.levels.TRACE, l);
125
+ }, c.disableAll = function(l) {
126
+ c.setLevel(c.levels.SILENT, l);
127
+ }, c.rebuild = function() {
128
+ if (i !== c && (J = U(i.getLevel())), _.call(c), i === c)
129
+ for (var l in r)
130
+ r[l].rebuild();
131
+ }, J = U(
132
+ i ? i.getLevel() : "WARN"
220
133
  );
221
- var initialLevel = getPersistedLevel();
222
- if (initialLevel != null) {
223
- userLevel = normalizeLevel(initialLevel);
224
- }
225
- replaceLoggingMethods.call(self);
134
+ var te = ee();
135
+ te != null && (x = U(te)), _.call(c);
226
136
  }
227
- defaultLogger = new Logger();
228
- defaultLogger.getLogger = function getLogger(name) {
229
- if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
137
+ i = new L(), i.getLogger = function(f) {
138
+ if (typeof f != "symbol" && typeof f != "string" || f === "")
230
139
  throw new TypeError("You must supply a name when creating a logger.");
231
- }
232
- var logger2 = _loggersByName[name];
233
- if (!logger2) {
234
- logger2 = _loggersByName[name] = new Logger(
235
- name,
236
- defaultLogger.methodFactory
237
- );
238
- }
239
- return logger2;
240
- };
241
- var _log = typeof window !== undefinedType ? window.log : void 0;
242
- defaultLogger.noConflict = function() {
243
- if (typeof window !== undefinedType && window.log === defaultLogger) {
244
- window.log = _log;
245
- }
246
- return defaultLogger;
140
+ var c = r[f];
141
+ return c || (c = r[f] = new L(
142
+ f,
143
+ i.methodFactory
144
+ )), c;
247
145
  };
248
- defaultLogger.getLoggers = function getLoggers() {
249
- return _loggersByName;
250
- };
251
- defaultLogger["default"] = defaultLogger;
252
- return defaultLogger;
146
+ var R = typeof window !== n ? window.log : void 0;
147
+ return i.noConflict = function() {
148
+ return typeof window !== n && window.log === i && (window.log = R), i;
149
+ }, i.getLoggers = function() {
150
+ return r;
151
+ }, i.default = i, i;
253
152
  });
254
- })(loglevel);
255
- var loglevelExports = loglevel.exports;
256
- const logger = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
257
- let USER_AGENT;
258
- if (typeof navigator === "undefined" || !((_b = (_a = navigator.userAgent) == null ? void 0 : _a.startsWith) == null ? void 0 : _b.call(_a, "Mozilla/5.0 "))) {
259
- const NAME = "oauth4webapi";
260
- const VERSION = "v2.11.1";
261
- USER_AGENT = `${NAME}/${VERSION}`;
262
- }
263
- function looseInstanceOf(input, expected) {
264
- if (input == null) {
265
- return false;
266
- }
153
+ })(he);
154
+ var Je = he.exports;
155
+ const oe = /* @__PURE__ */ Ue(Je);
156
+ let M;
157
+ var I, de;
158
+ (typeof navigator > "u" || !((de = (I = navigator.userAgent) == null ? void 0 : I.startsWith) != null && de.call(I, "Mozilla/5.0 "))) && (M = "oauth4webapi/v2.11.1");
159
+ function q(e, t) {
160
+ if (e == null)
161
+ return !1;
267
162
  try {
268
- return input instanceof expected || Object.getPrototypeOf(input)[Symbol.toStringTag] === expected.prototype[Symbol.toStringTag];
163
+ return e instanceof t || Object.getPrototypeOf(e)[Symbol.toStringTag] === t.prototype[Symbol.toStringTag];
269
164
  } catch {
270
- return false;
165
+ return !1;
271
166
  }
272
167
  }
273
- const clockSkew = Symbol();
274
- const clockTolerance = Symbol();
275
- const customFetch = Symbol();
276
- const encoder = new TextEncoder();
277
- const decoder = new TextDecoder();
278
- function buf(input) {
279
- if (typeof input === "string") {
280
- return encoder.encode(input);
281
- }
282
- return decoder.decode(input);
168
+ const K = Symbol(), Oe = Symbol(), V = Symbol(), Ie = new TextEncoder(), Ne = new TextDecoder();
169
+ function A(e) {
170
+ return typeof e == "string" ? Ie.encode(e) : Ne.decode(e);
283
171
  }
284
- const CHUNK_SIZE = 32768;
285
- function encodeBase64Url(input) {
286
- if (input instanceof ArrayBuffer) {
287
- input = new Uint8Array(input);
288
- }
289
- const arr = [];
290
- for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) {
291
- arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
292
- }
293
- return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
172
+ const ie = 32768;
173
+ function Ke(e) {
174
+ e instanceof ArrayBuffer && (e = new Uint8Array(e));
175
+ const t = [];
176
+ for (let n = 0; n < e.byteLength; n += ie)
177
+ t.push(String.fromCharCode.apply(null, e.subarray(n, n + ie)));
178
+ return btoa(t.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
294
179
  }
295
- function decodeBase64Url(input) {
180
+ function We(e) {
296
181
  try {
297
- const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
298
- const bytes = new Uint8Array(binary.length);
299
- for (let i = 0; i < binary.length; i++) {
300
- bytes[i] = binary.charCodeAt(i);
301
- }
302
- return bytes;
303
- } catch (cause) {
304
- throw new OPE("The input to be decoded is not correctly encoded.", { cause });
182
+ const t = atob(e.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), n = new Uint8Array(t.length);
183
+ for (let o = 0; o < t.length; o++)
184
+ n[o] = t.charCodeAt(o);
185
+ return n;
186
+ } catch (t) {
187
+ throw new a("The input to be decoded is not correctly encoded.", { cause: t });
305
188
  }
306
189
  }
307
- function b64u(input) {
308
- if (typeof input === "string") {
309
- return decodeBase64Url(input);
310
- }
311
- return encodeBase64Url(input);
190
+ function k(e) {
191
+ return typeof e == "string" ? We(e) : Ke(e);
312
192
  }
313
- class LRU {
314
- constructor(maxSize) {
315
- this.cache = /* @__PURE__ */ new Map();
316
- this._cache = /* @__PURE__ */ new Map();
317
- this.maxSize = maxSize;
193
+ class De {
194
+ constructor(t) {
195
+ this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize = t;
318
196
  }
319
- get(key) {
320
- let v = this.cache.get(key);
321
- if (v) {
322
- return v;
323
- }
324
- if (v = this._cache.get(key)) {
325
- this.update(key, v);
326
- return v;
327
- }
328
- return void 0;
197
+ get(t) {
198
+ let n = this.cache.get(t);
199
+ if (n)
200
+ return n;
201
+ if (n = this._cache.get(t))
202
+ return this.update(t, n), n;
329
203
  }
330
- has(key) {
331
- return this.cache.has(key) || this._cache.has(key);
204
+ has(t) {
205
+ return this.cache.has(t) || this._cache.has(t);
332
206
  }
333
- set(key, value) {
334
- if (this.cache.has(key)) {
335
- this.cache.set(key, value);
336
- } else {
337
- this.update(key, value);
338
- }
339
- return this;
207
+ set(t, n) {
208
+ return this.cache.has(t) ? this.cache.set(t, n) : this.update(t, n), this;
340
209
  }
341
- delete(key) {
342
- if (this.cache.has(key)) {
343
- return this.cache.delete(key);
344
- }
345
- if (this._cache.has(key)) {
346
- return this._cache.delete(key);
347
- }
348
- return false;
210
+ delete(t) {
211
+ return this.cache.has(t) ? this.cache.delete(t) : this._cache.has(t) ? this._cache.delete(t) : !1;
349
212
  }
350
- update(key, value) {
351
- this.cache.set(key, value);
352
- if (this.cache.size >= this.maxSize) {
353
- this._cache = this.cache;
354
- this.cache = /* @__PURE__ */ new Map();
355
- }
213
+ update(t, n) {
214
+ this.cache.set(t, n), this.cache.size >= this.maxSize && (this._cache = this.cache, this.cache = /* @__PURE__ */ new Map());
356
215
  }
357
216
  }
358
- class UnsupportedOperationError extends Error {
359
- constructor(message) {
360
- var _a2;
361
- super(message ?? "operation not supported");
362
- this.name = this.constructor.name;
363
- (_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
217
+ class v extends Error {
218
+ constructor(t) {
219
+ var n;
220
+ super(t ?? "operation not supported"), this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
364
221
  }
365
222
  }
366
- class OperationProcessingError extends Error {
367
- constructor(message, options) {
368
- var _a2;
369
- super(message, options);
370
- this.name = this.constructor.name;
371
- (_a2 = Error.captureStackTrace) == null ? void 0 : _a2.call(Error, this, this.constructor);
223
+ class He extends Error {
224
+ constructor(t, n) {
225
+ var o;
226
+ super(t, n), this.name = this.constructor.name, (o = Error.captureStackTrace) == null || o.call(Error, this, this.constructor);
372
227
  }
373
228
  }
374
- const OPE = OperationProcessingError;
375
- const dpopNonces = new LRU(100);
376
- function isCryptoKey(key) {
377
- return key instanceof CryptoKey;
229
+ const a = He, fe = new De(100);
230
+ function pe(e) {
231
+ return e instanceof CryptoKey;
378
232
  }
379
- function isPrivateKey(key) {
380
- return isCryptoKey(key) && key.type === "private";
233
+ function we(e) {
234
+ return pe(e) && e.type === "private";
381
235
  }
382
- function isPublicKey(key) {
383
- return isCryptoKey(key) && key.type === "public";
236
+ function $e(e) {
237
+ return pe(e) && e.type === "public";
384
238
  }
385
- function processDpopNonce(response) {
239
+ function Y(e) {
386
240
  try {
387
- const nonce = response.headers.get("dpop-nonce");
388
- if (nonce) {
389
- dpopNonces.set(new URL(response.url).origin, nonce);
390
- }
241
+ const t = e.headers.get("dpop-nonce");
242
+ t && fe.set(new URL(e.url).origin, t);
391
243
  } catch {
392
244
  }
393
- return response;
245
+ return e;
394
246
  }
395
- function isJsonObject(input) {
396
- if (input === null || typeof input !== "object" || Array.isArray(input)) {
397
- return false;
398
- }
399
- return true;
247
+ function C(e) {
248
+ return !(e === null || typeof e != "object" || Array.isArray(e));
400
249
  }
401
- function prepareHeaders(input) {
402
- if (looseInstanceOf(input, Headers)) {
403
- input = Object.fromEntries(input.entries());
404
- }
405
- const headers = new Headers(input);
406
- if (USER_AGENT && !headers.has("user-agent")) {
407
- headers.set("user-agent", USER_AGENT);
408
- }
409
- if (headers.has("authorization")) {
250
+ function W(e) {
251
+ q(e, Headers) && (e = Object.fromEntries(e.entries()));
252
+ const t = new Headers(e);
253
+ if (M && !t.has("user-agent") && t.set("user-agent", M), t.has("authorization"))
410
254
  throw new TypeError('"options.headers" must not include the "authorization" header name');
411
- }
412
- if (headers.has("dpop")) {
255
+ if (t.has("dpop"))
413
256
  throw new TypeError('"options.headers" must not include the "dpop" header name');
414
- }
415
- return headers;
257
+ return t;
416
258
  }
417
- function signal(value) {
418
- if (typeof value === "function") {
419
- value = value();
420
- }
421
- if (!(value instanceof AbortSignal)) {
259
+ function Z(e) {
260
+ if (typeof e == "function" && (e = e()), !(e instanceof AbortSignal))
422
261
  throw new TypeError('"options.signal" must return or be an instance of AbortSignal');
423
- }
424
- return value;
262
+ return e;
425
263
  }
426
- async function discoveryRequest(issuerIdentifier, options) {
427
- if (!(issuerIdentifier instanceof URL)) {
264
+ async function Fe(e, t) {
265
+ if (!(e instanceof URL))
428
266
  throw new TypeError('"issuerIdentifier" must be an instance of URL');
429
- }
430
- if (issuerIdentifier.protocol !== "https:" && issuerIdentifier.protocol !== "http:") {
267
+ if (e.protocol !== "https:" && e.protocol !== "http:")
431
268
  throw new TypeError('"issuer.protocol" must be "https:" or "http:"');
432
- }
433
- const url = new URL(issuerIdentifier.href);
434
- switch (options == null ? void 0 : options.algorithm) {
269
+ const n = new URL(e.href);
270
+ switch (t == null ? void 0 : t.algorithm) {
435
271
  case void 0:
436
272
  case "oidc":
437
- url.pathname = `${url.pathname}/.well-known/openid-configuration`.replace("//", "/");
273
+ n.pathname = `${n.pathname}/.well-known/openid-configuration`.replace("//", "/");
438
274
  break;
439
275
  case "oauth2":
440
- if (url.pathname === "/") {
441
- url.pathname = ".well-known/oauth-authorization-server";
442
- } else {
443
- url.pathname = `.well-known/oauth-authorization-server/${url.pathname}`.replace("//", "/");
444
- }
276
+ n.pathname === "/" ? n.pathname = ".well-known/oauth-authorization-server" : n.pathname = `.well-known/oauth-authorization-server/${n.pathname}`.replace("//", "/");
445
277
  break;
446
278
  default:
447
279
  throw new TypeError('"options.algorithm" must be "oidc" (default), or "oauth2"');
448
280
  }
449
- const headers = prepareHeaders(options == null ? void 0 : options.headers);
450
- headers.set("accept", "application/json");
451
- return ((options == null ? void 0 : options[customFetch]) || fetch)(url.href, {
452
- headers: Object.fromEntries(headers.entries()),
281
+ const o = W(t == null ? void 0 : t.headers);
282
+ return o.set("accept", "application/json"), ((t == null ? void 0 : t[V]) || fetch)(n.href, {
283
+ headers: Object.fromEntries(o.entries()),
453
284
  method: "GET",
454
285
  redirect: "manual",
455
- signal: (options == null ? void 0 : options.signal) ? signal(options.signal) : null
456
- }).then(processDpopNonce);
286
+ signal: t != null && t.signal ? Z(t.signal) : null
287
+ }).then(Y);
457
288
  }
458
- function validateString(input) {
459
- return typeof input === "string" && input.length !== 0;
289
+ function w(e) {
290
+ return typeof e == "string" && e.length !== 0;
460
291
  }
461
- async function processDiscoveryResponse(expectedIssuerIdentifier, response) {
462
- if (!(expectedIssuerIdentifier instanceof URL)) {
292
+ async function Me(e, t) {
293
+ if (!(e instanceof URL))
463
294
  throw new TypeError('"expectedIssuer" must be an instance of URL');
464
- }
465
- if (!looseInstanceOf(response, Response)) {
295
+ if (!q(t, Response))
466
296
  throw new TypeError('"response" must be an instance of Response');
467
- }
468
- if (response.status !== 200) {
469
- throw new OPE('"response" is not a conform Authorization Server Metadata response');
470
- }
471
- assertReadableResponse(response);
472
- let json;
297
+ if (t.status !== 200)
298
+ throw new a('"response" is not a conform Authorization Server Metadata response');
299
+ X(t);
300
+ let n;
473
301
  try {
474
- json = await response.json();
475
- } catch (cause) {
476
- throw new OPE('failed to parse "response" body as JSON', { cause });
477
- }
478
- if (!isJsonObject(json)) {
479
- throw new OPE('"response" body must be a top level object');
480
- }
481
- if (!validateString(json.issuer)) {
482
- throw new OPE('"response" body "issuer" property must be a non-empty string');
302
+ n = await t.json();
303
+ } catch (o) {
304
+ throw new a('failed to parse "response" body as JSON', { cause: o });
483
305
  }
484
- if (new URL(json.issuer).href !== expectedIssuerIdentifier.href) {
485
- throw new OPE('"response" body "issuer" does not match "expectedIssuer"');
486
- }
487
- return json;
306
+ if (!C(n))
307
+ throw new a('"response" body must be a top level object');
308
+ if (!w(n.issuer))
309
+ throw new a('"response" body "issuer" property must be a non-empty string');
310
+ if (new URL(n.issuer).href !== e.href)
311
+ throw new a('"response" body "issuer" does not match "expectedIssuer"');
312
+ return n;
488
313
  }
489
- function randomBytes() {
490
- return b64u(crypto.getRandomValues(new Uint8Array(32)));
314
+ function D() {
315
+ return k(crypto.getRandomValues(new Uint8Array(32)));
491
316
  }
492
- function generateRandomCodeVerifier() {
493
- return randomBytes();
317
+ function Be() {
318
+ return D();
494
319
  }
495
- function generateRandomState() {
496
- return randomBytes();
320
+ function Ge() {
321
+ return D();
497
322
  }
498
- async function calculatePKCECodeChallenge(codeVerifier) {
499
- if (!validateString(codeVerifier)) {
323
+ async function qe(e) {
324
+ if (!w(e))
500
325
  throw new TypeError('"codeVerifier" must be a non-empty string');
501
- }
502
- return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
326
+ return k(await crypto.subtle.digest("SHA-256", A(e)));
503
327
  }
504
- function getKeyAndKid(input) {
505
- if (input instanceof CryptoKey) {
506
- return { key: input };
507
- }
508
- if (!((input == null ? void 0 : input.key) instanceof CryptoKey)) {
328
+ function Ve(e) {
329
+ if (e instanceof CryptoKey)
330
+ return { key: e };
331
+ if (!((e == null ? void 0 : e.key) instanceof CryptoKey))
509
332
  return {};
510
- }
511
- if (input.kid !== void 0 && !validateString(input.kid)) {
333
+ if (e.kid !== void 0 && !w(e.kid))
512
334
  throw new TypeError('"kid" must be a non-empty string');
513
- }
514
- return { key: input.key, kid: input.kid };
335
+ return { key: e.key, kid: e.kid };
515
336
  }
516
- function formUrlEncode(token) {
517
- return encodeURIComponent(token).replace(/%20/g, "+");
337
+ function se(e) {
338
+ return encodeURIComponent(e).replace(/%20/g, "+");
518
339
  }
519
- function clientSecretBasic(clientId, clientSecret) {
520
- const username = formUrlEncode(clientId);
521
- const password = formUrlEncode(clientSecret);
522
- const credentials = btoa(`${username}:${password}`);
523
- return `Basic ${credentials}`;
340
+ function Ye(e, t) {
341
+ const n = se(e), o = se(t);
342
+ return `Basic ${btoa(`${n}:${o}`)}`;
524
343
  }
525
- function psAlg(key) {
526
- switch (key.algorithm.hash.name) {
344
+ function Ze(e) {
345
+ switch (e.algorithm.hash.name) {
527
346
  case "SHA-256":
528
347
  return "PS256";
529
348
  case "SHA-384":
@@ -531,11 +350,11 @@ function psAlg(key) {
531
350
  case "SHA-512":
532
351
  return "PS512";
533
352
  default:
534
- throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name");
353
+ throw new v("unsupported RsaHashedKeyAlgorithm hash name");
535
354
  }
536
355
  }
537
- function rsAlg(key) {
538
- switch (key.algorithm.hash.name) {
356
+ function Qe(e) {
357
+ switch (e.algorithm.hash.name) {
539
358
  case "SHA-256":
540
359
  return "RS256";
541
360
  case "SHA-384":
@@ -543,11 +362,11 @@ function rsAlg(key) {
543
362
  case "SHA-512":
544
363
  return "RS512";
545
364
  default:
546
- throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name");
365
+ throw new v("unsupported RsaHashedKeyAlgorithm hash name");
547
366
  }
548
367
  }
549
- function esAlg(key) {
550
- switch (key.algorithm.namedCurve) {
368
+ function Xe(e) {
369
+ switch (e.algorithm.namedCurve) {
551
370
  case "P-256":
552
371
  return "ES256";
553
372
  case "P-384":
@@ -555,367 +374,281 @@ function esAlg(key) {
555
374
  case "P-521":
556
375
  return "ES512";
557
376
  default:
558
- throw new UnsupportedOperationError("unsupported EcKeyAlgorithm namedCurve");
377
+ throw new v("unsupported EcKeyAlgorithm namedCurve");
559
378
  }
560
379
  }
561
- function keyToJws(key) {
562
- switch (key.algorithm.name) {
380
+ function ge(e) {
381
+ switch (e.algorithm.name) {
563
382
  case "RSA-PSS":
564
- return psAlg(key);
383
+ return Ze(e);
565
384
  case "RSASSA-PKCS1-v1_5":
566
- return rsAlg(key);
385
+ return Qe(e);
567
386
  case "ECDSA":
568
- return esAlg(key);
387
+ return Xe(e);
569
388
  case "Ed25519":
570
389
  case "Ed448":
571
390
  return "EdDSA";
572
391
  default:
573
- throw new UnsupportedOperationError("unsupported CryptoKey algorithm name");
392
+ throw new v("unsupported CryptoKey algorithm name");
574
393
  }
575
394
  }
576
- function getClockSkew(client) {
577
- const skew = client == null ? void 0 : client[clockSkew];
578
- return typeof skew === "number" && Number.isFinite(skew) ? skew : 0;
395
+ function H(e) {
396
+ const t = e == null ? void 0 : e[K];
397
+ return typeof t == "number" && Number.isFinite(t) ? t : 0;
579
398
  }
580
- function getClockTolerance(client) {
581
- const tolerance = client == null ? void 0 : client[clockTolerance];
582
- return typeof tolerance === "number" && Number.isFinite(tolerance) && Math.sign(tolerance) !== -1 ? tolerance : 30;
399
+ function et(e) {
400
+ const t = e == null ? void 0 : e[Oe];
401
+ return typeof t == "number" && Number.isFinite(t) && Math.sign(t) !== -1 ? t : 30;
583
402
  }
584
- function epochTime() {
403
+ function Q() {
585
404
  return Math.floor(Date.now() / 1e3);
586
405
  }
587
- function clientAssertion(as, client) {
588
- const now = epochTime() + getClockSkew(client);
406
+ function tt(e, t) {
407
+ const n = Q() + H(t);
589
408
  return {
590
- jti: randomBytes(),
591
- aud: [as.issuer, as.token_endpoint],
592
- exp: now + 60,
593
- iat: now,
594
- nbf: now,
595
- iss: client.client_id,
596
- sub: client.client_id
409
+ jti: D(),
410
+ aud: [e.issuer, e.token_endpoint],
411
+ exp: n + 60,
412
+ iat: n,
413
+ nbf: n,
414
+ iss: t.client_id,
415
+ sub: t.client_id
597
416
  };
598
417
  }
599
- async function privateKeyJwt(as, client, key, kid) {
600
- return jwt({
601
- alg: keyToJws(key),
602
- kid
603
- }, clientAssertion(as, client), key);
418
+ async function nt(e, t, n, o) {
419
+ return me({
420
+ alg: ge(n),
421
+ kid: o
422
+ }, tt(e, t), n);
604
423
  }
605
- function assertAs(as) {
606
- if (typeof as !== "object" || as === null) {
424
+ function j(e) {
425
+ if (typeof e != "object" || e === null)
607
426
  throw new TypeError('"as" must be an object');
608
- }
609
- if (!validateString(as.issuer)) {
427
+ if (!w(e.issuer))
610
428
  throw new TypeError('"as.issuer" property must be a non-empty string');
611
- }
612
- return true;
429
+ return !0;
613
430
  }
614
- function assertClient(client) {
615
- if (typeof client !== "object" || client === null) {
431
+ function z(e) {
432
+ if (typeof e != "object" || e === null)
616
433
  throw new TypeError('"client" must be an object');
617
- }
618
- if (!validateString(client.client_id)) {
434
+ if (!w(e.client_id))
619
435
  throw new TypeError('"client.client_id" property must be a non-empty string');
620
- }
621
- return true;
436
+ return !0;
622
437
  }
623
- function assertClientSecret(clientSecret) {
624
- if (!validateString(clientSecret)) {
438
+ function ae(e) {
439
+ if (!w(e))
625
440
  throw new TypeError('"client.client_secret" property must be a non-empty string');
626
- }
627
- return clientSecret;
441
+ return e;
628
442
  }
629
- function assertNoClientPrivateKey(clientAuthMethod, clientPrivateKey) {
630
- if (clientPrivateKey !== void 0) {
631
- throw new TypeError(`"options.clientPrivateKey" property must not be provided when ${clientAuthMethod} client authentication method is used.`);
632
- }
443
+ function F(e, t) {
444
+ if (t !== void 0)
445
+ throw new TypeError(`"options.clientPrivateKey" property must not be provided when ${e} client authentication method is used.`);
633
446
  }
634
- function assertNoClientSecret(clientAuthMethod, clientSecret) {
635
- if (clientSecret !== void 0) {
636
- throw new TypeError(`"client.client_secret" property must not be provided when ${clientAuthMethod} client authentication method is used.`);
637
- }
447
+ function ce(e, t) {
448
+ if (t !== void 0)
449
+ throw new TypeError(`"client.client_secret" property must not be provided when ${e} client authentication method is used.`);
638
450
  }
639
- async function clientAuthentication(as, client, body, headers, clientPrivateKey) {
640
- body.delete("client_secret");
641
- body.delete("client_assertion_type");
642
- body.delete("client_assertion");
643
- switch (client.token_endpoint_auth_method) {
451
+ async function rt(e, t, n, o, s) {
452
+ switch (n.delete("client_secret"), n.delete("client_assertion_type"), n.delete("client_assertion"), t.token_endpoint_auth_method) {
644
453
  case void 0:
645
454
  case "client_secret_basic": {
646
- assertNoClientPrivateKey("client_secret_basic", clientPrivateKey);
647
- headers.set("authorization", clientSecretBasic(client.client_id, assertClientSecret(client.client_secret)));
455
+ F("client_secret_basic", s), o.set("authorization", Ye(t.client_id, ae(t.client_secret)));
648
456
  break;
649
457
  }
650
458
  case "client_secret_post": {
651
- assertNoClientPrivateKey("client_secret_post", clientPrivateKey);
652
- body.set("client_id", client.client_id);
653
- body.set("client_secret", assertClientSecret(client.client_secret));
459
+ F("client_secret_post", s), n.set("client_id", t.client_id), n.set("client_secret", ae(t.client_secret));
654
460
  break;
655
461
  }
656
462
  case "private_key_jwt": {
657
- assertNoClientSecret("private_key_jwt", client.client_secret);
658
- if (clientPrivateKey === void 0) {
463
+ if (ce("private_key_jwt", t.client_secret), s === void 0)
659
464
  throw new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"');
660
- }
661
- const { key, kid } = getKeyAndKid(clientPrivateKey);
662
- if (!isPrivateKey(key)) {
465
+ const { key: r, kid: i } = Ve(s);
466
+ if (!we(r))
663
467
  throw new TypeError('"options.clientPrivateKey.key" must be a private CryptoKey');
664
- }
665
- body.set("client_id", client.client_id);
666
- body.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");
667
- body.set("client_assertion", await privateKeyJwt(as, client, key, kid));
468
+ n.set("client_id", t.client_id), n.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.set("client_assertion", await nt(e, t, r, i));
668
469
  break;
669
470
  }
670
471
  case "tls_client_auth":
671
472
  case "self_signed_tls_client_auth":
672
473
  case "none": {
673
- assertNoClientSecret(client.token_endpoint_auth_method, client.client_secret);
674
- assertNoClientPrivateKey(client.token_endpoint_auth_method, clientPrivateKey);
675
- body.set("client_id", client.client_id);
474
+ ce(t.token_endpoint_auth_method, t.client_secret), F(t.token_endpoint_auth_method, s), n.set("client_id", t.client_id);
676
475
  break;
677
476
  }
678
477
  default:
679
- throw new UnsupportedOperationError("unsupported client token_endpoint_auth_method");
478
+ throw new v("unsupported client token_endpoint_auth_method");
680
479
  }
681
480
  }
682
- async function jwt(header, claimsSet, key) {
683
- if (!key.usages.includes("sign")) {
481
+ async function me(e, t, n) {
482
+ if (!n.usages.includes("sign"))
684
483
  throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"');
685
- }
686
- const input = `${b64u(buf(JSON.stringify(header)))}.${b64u(buf(JSON.stringify(claimsSet)))}`;
687
- const signature = b64u(await crypto.subtle.sign(keyToSubtle(key), key, buf(input)));
688
- return `${input}.${signature}`;
484
+ const o = `${k(A(JSON.stringify(e)))}.${k(A(JSON.stringify(t)))}`, s = k(await crypto.subtle.sign(Se(n), n, A(o)));
485
+ return `${o}.${s}`;
689
486
  }
690
- async function dpopProofJwt(headers, options, url, htm, clockSkew2, accessToken) {
691
- const { privateKey, publicKey, nonce = dpopNonces.get(url.origin) } = options;
692
- if (!isPrivateKey(privateKey)) {
487
+ async function ot(e, t, n, o, s, r) {
488
+ const { privateKey: i, publicKey: d, nonce: g = fe.get(n.origin) } = t;
489
+ if (!we(i))
693
490
  throw new TypeError('"DPoP.privateKey" must be a private CryptoKey');
694
- }
695
- if (!isPublicKey(publicKey)) {
491
+ if (!$e(d))
696
492
  throw new TypeError('"DPoP.publicKey" must be a public CryptoKey');
697
- }
698
- if (nonce !== void 0 && !validateString(nonce)) {
493
+ if (g !== void 0 && !w(g))
699
494
  throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined');
700
- }
701
- if (!publicKey.extractable) {
495
+ if (!d.extractable)
702
496
  throw new TypeError('"DPoP.publicKey.extractable" must be true');
703
- }
704
- const now = epochTime() + clockSkew2;
705
- const proof = await jwt({
706
- alg: keyToJws(privateKey),
497
+ const m = Q() + s, _ = await me({
498
+ alg: ge(i),
707
499
  typ: "dpop+jwt",
708
- jwk: await publicJwk(publicKey)
500
+ jwk: await st(d)
709
501
  }, {
710
- iat: now,
711
- jti: randomBytes(),
712
- htm,
713
- nonce,
714
- htu: `${url.origin}${url.pathname}`,
715
- ath: accessToken ? b64u(await crypto.subtle.digest("SHA-256", buf(accessToken))) : void 0
716
- }, privateKey);
717
- headers.set("dpop", proof);
718
- }
719
- let jwkCache;
720
- async function getSetPublicJwkCache(key) {
721
- const { kty, e, n, x, y, crv } = await crypto.subtle.exportKey("jwk", key);
722
- const jwk = { kty, e, n, x, y, crv };
723
- jwkCache.set(key, jwk);
724
- return jwk;
725
- }
726
- async function publicJwk(key) {
727
- jwkCache || (jwkCache = /* @__PURE__ */ new WeakMap());
728
- return jwkCache.get(key) || getSetPublicJwkCache(key);
729
- }
730
- function validateEndpoint(value, endpoint, options) {
731
- if (typeof value !== "string") {
732
- throw new TypeError(`"as.${endpoint}" must be a string`);
733
- }
734
- return new URL(value);
735
- }
736
- function resolveEndpoint(as, endpoint, options) {
737
- return validateEndpoint(as[endpoint], endpoint);
738
- }
739
- function isOAuth2Error(input) {
740
- const value = input;
741
- if (typeof value !== "object" || Array.isArray(value) || value === null) {
742
- return false;
743
- }
744
- return value.error !== void 0;
745
- }
746
- async function protectedResourceRequest(accessToken, method, url, headers, body, options) {
747
- if (!validateString(accessToken)) {
502
+ iat: m,
503
+ jti: D(),
504
+ htm: o,
505
+ nonce: g,
506
+ htu: `${n.origin}${n.pathname}`,
507
+ ath: r ? k(await crypto.subtle.digest("SHA-256", A(r))) : void 0
508
+ }, i);
509
+ e.set("dpop", _);
510
+ }
511
+ let N;
512
+ async function it(e) {
513
+ const { kty: t, e: n, n: o, x: s, y: r, crv: i } = await crypto.subtle.exportKey("jwk", e), d = { kty: t, e: n, n: o, x: s, y: r, crv: i };
514
+ return N.set(e, d), d;
515
+ }
516
+ async function st(e) {
517
+ return N || (N = /* @__PURE__ */ new WeakMap()), N.get(e) || it(e);
518
+ }
519
+ function at(e, t, n) {
520
+ if (typeof e != "string")
521
+ throw new TypeError(`"as.${t}" must be a string`);
522
+ return new URL(e);
523
+ }
524
+ function ye(e, t, n) {
525
+ return at(e[t], t);
526
+ }
527
+ function B(e) {
528
+ const t = e;
529
+ return typeof t != "object" || Array.isArray(t) || t === null ? !1 : t.error !== void 0;
530
+ }
531
+ async function ct(e, t, n, o, s, r) {
532
+ if (!w(e))
748
533
  throw new TypeError('"accessToken" must be a non-empty string');
749
- }
750
- if (!(url instanceof URL)) {
534
+ if (!(n instanceof URL))
751
535
  throw new TypeError('"url" must be an instance of URL');
752
- }
753
- headers = prepareHeaders(headers);
754
- if ((options == null ? void 0 : options.DPoP) === void 0) {
755
- headers.set("authorization", `Bearer ${accessToken}`);
756
- } else {
757
- await dpopProofJwt(headers, options.DPoP, url, "GET", getClockSkew({ [clockSkew]: options == null ? void 0 : options[clockSkew] }), accessToken);
758
- headers.set("authorization", `DPoP ${accessToken}`);
759
- }
760
- return ((options == null ? void 0 : options[customFetch]) || fetch)(url.href, {
761
- body,
762
- headers: Object.fromEntries(headers.entries()),
763
- method,
536
+ return o = W(o), (r == null ? void 0 : r.DPoP) === void 0 ? o.set("authorization", `Bearer ${e}`) : (await ot(o, r.DPoP, n, "GET", H({ [K]: r == null ? void 0 : r[K] }), e), o.set("authorization", `DPoP ${e}`)), ((r == null ? void 0 : r[V]) || fetch)(n.href, {
537
+ body: s,
538
+ headers: Object.fromEntries(o.entries()),
539
+ method: t,
764
540
  redirect: "manual",
765
- signal: (options == null ? void 0 : options.signal) ? signal(options.signal) : null
766
- }).then(processDpopNonce);
767
- }
768
- async function userInfoRequest(as, client, accessToken, options) {
769
- assertAs(as);
770
- assertClient(client);
771
- const url = resolveEndpoint(as, "userinfo_endpoint");
772
- const headers = prepareHeaders(options == null ? void 0 : options.headers);
773
- if (client.userinfo_signed_response_alg) {
774
- headers.set("accept", "application/jwt");
775
- } else {
776
- headers.set("accept", "application/json");
777
- headers.append("accept", "application/jwt");
778
- }
779
- return protectedResourceRequest(accessToken, "GET", url, headers, null, {
780
- ...options,
781
- [clockSkew]: getClockSkew(client)
541
+ signal: r != null && r.signal ? Z(r.signal) : null
542
+ }).then(Y);
543
+ }
544
+ async function ut(e, t, n, o) {
545
+ j(e), z(t);
546
+ const s = ye(e, "userinfo_endpoint"), r = W(o == null ? void 0 : o.headers);
547
+ return t.userinfo_signed_response_alg ? r.set("accept", "application/jwt") : (r.set("accept", "application/json"), r.append("accept", "application/jwt")), ct(n, "GET", s, r, null, {
548
+ ...o,
549
+ [K]: H(t)
782
550
  });
783
551
  }
784
- async function authenticatedRequest(as, client, method, url, body, headers, options) {
785
- await clientAuthentication(as, client, body, headers, options == null ? void 0 : options.clientPrivateKey);
786
- headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
787
- return ((options == null ? void 0 : options[customFetch]) || fetch)(url.href, {
788
- body,
789
- headers: Object.fromEntries(headers.entries()),
790
- method,
552
+ async function lt(e, t, n, o, s, r, i) {
553
+ return await rt(e, t, s, r, i == null ? void 0 : i.clientPrivateKey), r.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), ((i == null ? void 0 : i[V]) || fetch)(o.href, {
554
+ body: s,
555
+ headers: Object.fromEntries(r.entries()),
556
+ method: n,
791
557
  redirect: "manual",
792
- signal: (options == null ? void 0 : options.signal) ? signal(options.signal) : null
793
- }).then(processDpopNonce);
794
- }
795
- async function tokenEndpointRequest(as, client, grantType, parameters, options) {
796
- const url = resolveEndpoint(as, "token_endpoint");
797
- parameters.set("grant_type", grantType);
798
- const headers = prepareHeaders(options == null ? void 0 : options.headers);
799
- headers.set("accept", "application/json");
800
- return authenticatedRequest(as, client, "POST", url, parameters, headers, options);
801
- }
802
- async function refreshTokenGrantRequest(as, client, refreshToken, options) {
803
- assertAs(as);
804
- assertClient(client);
805
- if (!validateString(refreshToken)) {
558
+ signal: i != null && i.signal ? Z(i.signal) : null
559
+ }).then(Y);
560
+ }
561
+ async function _e(e, t, n, o, s) {
562
+ const r = ye(e, "token_endpoint");
563
+ o.set("grant_type", n);
564
+ const i = W(s == null ? void 0 : s.headers);
565
+ return i.set("accept", "application/json"), lt(e, t, "POST", r, o, i, s);
566
+ }
567
+ async function dt(e, t, n, o) {
568
+ if (j(e), z(t), !w(n))
806
569
  throw new TypeError('"refreshToken" must be a non-empty string');
807
- }
808
- const parameters = new URLSearchParams(options == null ? void 0 : options.additionalParameters);
809
- parameters.set("refresh_token", refreshToken);
810
- return tokenEndpointRequest(as, client, "refresh_token", parameters, options);
811
- }
812
- const idTokenClaims = /* @__PURE__ */ new WeakMap();
813
- async function processGenericAccessTokenResponse(as, client, response, ignoreIdToken = false, ignoreRefreshToken = false) {
814
- assertAs(as);
815
- assertClient(client);
816
- if (!looseInstanceOf(response, Response)) {
570
+ const s = new URLSearchParams(o == null ? void 0 : o.additionalParameters);
571
+ return s.set("refresh_token", n), _e(e, t, "refresh_token", s, o);
572
+ }
573
+ const ht = /* @__PURE__ */ new WeakMap();
574
+ async function be(e, t, n, o = !1, s = !1) {
575
+ if (j(e), z(t), !q(n, Response))
817
576
  throw new TypeError('"response" must be an instance of Response');
818
- }
819
- if (response.status !== 200) {
820
- let err;
821
- if (err = await handleOAuthBodyError(response)) {
822
- return err;
823
- }
824
- throw new OPE('"response" is not a conform Token Endpoint response');
825
- }
826
- assertReadableResponse(response);
827
- let json;
577
+ if (n.status !== 200) {
578
+ let i;
579
+ if (i = await vt(n))
580
+ return i;
581
+ throw new a('"response" is not a conform Token Endpoint response');
582
+ }
583
+ X(n);
584
+ let r;
828
585
  try {
829
- json = await response.json();
830
- } catch (cause) {
831
- throw new OPE('failed to parse "response" body as JSON', { cause });
832
- }
833
- if (!isJsonObject(json)) {
834
- throw new OPE('"response" body must be a top level object');
835
- }
836
- if (!validateString(json.access_token)) {
837
- throw new OPE('"response" body "access_token" property must be a non-empty string');
838
- }
839
- if (!validateString(json.token_type)) {
840
- throw new OPE('"response" body "token_type" property must be a non-empty string');
841
- }
842
- json.token_type = json.token_type.toLowerCase();
843
- if (json.token_type !== "dpop" && json.token_type !== "bearer") {
844
- throw new UnsupportedOperationError("unsupported `token_type` value");
845
- }
846
- if (json.expires_in !== void 0 && (typeof json.expires_in !== "number" || json.expires_in <= 0)) {
847
- throw new OPE('"response" body "expires_in" property must be a positive number');
848
- }
849
- if (!ignoreRefreshToken && json.refresh_token !== void 0 && !validateString(json.refresh_token)) {
850
- throw new OPE('"response" body "refresh_token" property must be a non-empty string');
851
- }
852
- if (json.scope !== void 0 && typeof json.scope !== "string") {
853
- throw new OPE('"response" body "scope" property must be a string');
854
- }
855
- if (!ignoreIdToken) {
856
- if (json.id_token !== void 0 && !validateString(json.id_token)) {
857
- throw new OPE('"response" body "id_token" property must be a non-empty string');
858
- }
859
- if (json.id_token) {
860
- const { claims } = await validateJwt(json.id_token, checkSigningAlgorithm.bind(void 0, client.id_token_signed_response_alg, as.id_token_signing_alg_values_supported), noSignatureCheck, getClockSkew(client), getClockTolerance(client)).then(validatePresence.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(validateIssuer.bind(void 0, as.issuer)).then(validateAudience.bind(void 0, client.client_id));
861
- if (Array.isArray(claims.aud) && claims.aud.length !== 1 && claims.azp !== client.client_id) {
862
- throw new OPE('unexpected ID Token "azp" (authorized party) claim value');
863
- }
864
- if (claims.auth_time !== void 0 && (!Number.isFinite(claims.auth_time) || Math.sign(claims.auth_time) !== 1)) {
865
- throw new OPE('ID Token "auth_time" (authentication time) must be a positive number');
866
- }
867
- idTokenClaims.set(json, claims);
586
+ r = await n.json();
587
+ } catch (i) {
588
+ throw new a('failed to parse "response" body as JSON', { cause: i });
589
+ }
590
+ if (!C(r))
591
+ throw new a('"response" body must be a top level object');
592
+ if (!w(r.access_token))
593
+ throw new a('"response" body "access_token" property must be a non-empty string');
594
+ if (!w(r.token_type))
595
+ throw new a('"response" body "token_type" property must be a non-empty string');
596
+ if (r.token_type = r.token_type.toLowerCase(), r.token_type !== "dpop" && r.token_type !== "bearer")
597
+ throw new v("unsupported `token_type` value");
598
+ if (r.expires_in !== void 0 && (typeof r.expires_in != "number" || r.expires_in <= 0))
599
+ throw new a('"response" body "expires_in" property must be a positive number');
600
+ if (!s && r.refresh_token !== void 0 && !w(r.refresh_token))
601
+ throw new a('"response" body "refresh_token" property must be a non-empty string');
602
+ if (r.scope !== void 0 && typeof r.scope != "string")
603
+ throw new a('"response" body "scope" property must be a string');
604
+ if (!o) {
605
+ if (r.id_token !== void 0 && !w(r.id_token))
606
+ throw new a('"response" body "id_token" property must be a non-empty string');
607
+ if (r.id_token) {
608
+ const { claims: i } = await Et(r.id_token, kt.bind(void 0, t.id_token_signed_response_alg, e.id_token_signing_alg_values_supported), Ee, H(t), et(t)).then(_t.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(wt.bind(void 0, e.issuer)).then(pt.bind(void 0, t.client_id));
609
+ if (Array.isArray(i.aud) && i.aud.length !== 1 && i.azp !== t.client_id)
610
+ throw new a('unexpected ID Token "azp" (authorized party) claim value');
611
+ if (i.auth_time !== void 0 && (!Number.isFinite(i.auth_time) || Math.sign(i.auth_time) !== 1))
612
+ throw new a('ID Token "auth_time" (authentication time) must be a positive number');
613
+ ht.set(r, i);
868
614
  }
869
615
  }
870
- return json;
616
+ return r;
871
617
  }
872
- async function processRefreshTokenResponse(as, client, response) {
873
- return processGenericAccessTokenResponse(as, client, response);
618
+ async function ft(e, t, n) {
619
+ return be(e, t, n);
874
620
  }
875
- function validateAudience(expected, result) {
876
- if (Array.isArray(result.claims.aud)) {
877
- if (!result.claims.aud.includes(expected)) {
878
- throw new OPE('unexpected JWT "aud" (audience) claim value');
879
- }
880
- } else if (result.claims.aud !== expected) {
881
- throw new OPE('unexpected JWT "aud" (audience) claim value');
882
- }
883
- return result;
621
+ function pt(e, t) {
622
+ if (Array.isArray(t.claims.aud)) {
623
+ if (!t.claims.aud.includes(e))
624
+ throw new a('unexpected JWT "aud" (audience) claim value');
625
+ } else if (t.claims.aud !== e)
626
+ throw new a('unexpected JWT "aud" (audience) claim value');
627
+ return t;
884
628
  }
885
- function validateIssuer(expected, result) {
886
- if (result.claims.iss !== expected) {
887
- throw new OPE('unexpected JWT "iss" (issuer) claim value');
888
- }
889
- return result;
629
+ function wt(e, t) {
630
+ if (t.claims.iss !== e)
631
+ throw new a('unexpected JWT "iss" (issuer) claim value');
632
+ return t;
890
633
  }
891
- const branded = /* @__PURE__ */ new WeakSet();
892
- function brand(searchParams) {
893
- branded.add(searchParams);
894
- return searchParams;
634
+ const ve = /* @__PURE__ */ new WeakSet();
635
+ function gt(e) {
636
+ return ve.add(e), e;
895
637
  }
896
- async function authorizationCodeGrantRequest(as, client, callbackParameters, redirectUri, codeVerifier, options) {
897
- assertAs(as);
898
- assertClient(client);
899
- if (!branded.has(callbackParameters)) {
638
+ async function mt(e, t, n, o, s, r) {
639
+ if (j(e), z(t), !ve.has(n))
900
640
  throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()');
901
- }
902
- if (!validateString(redirectUri)) {
641
+ if (!w(o))
903
642
  throw new TypeError('"redirectUri" must be a non-empty string');
904
- }
905
- if (!validateString(codeVerifier)) {
643
+ if (!w(s))
906
644
  throw new TypeError('"codeVerifier" must be a non-empty string');
907
- }
908
- const code = getURLSearchParameter(callbackParameters, "code");
909
- if (!code) {
910
- throw new OPE('no authorization code in "callbackParameters"');
911
- }
912
- const parameters = new URLSearchParams(options == null ? void 0 : options.additionalParameters);
913
- parameters.set("redirect_uri", redirectUri);
914
- parameters.set("code_verifier", codeVerifier);
915
- parameters.set("code", code);
916
- return tokenEndpointRequest(as, client, "authorization_code", parameters, options);
645
+ const i = E(n, "code");
646
+ if (!i)
647
+ throw new a('no authorization code in "callbackParameters"');
648
+ const d = new URLSearchParams(r == null ? void 0 : r.additionalParameters);
649
+ return d.set("redirect_uri", o), d.set("code_verifier", s), d.set("code", i), _e(e, t, "authorization_code", d, r);
917
650
  }
918
- const jwtClaimNames = {
651
+ const yt = {
919
652
  aud: "audience",
920
653
  c_hash: "code hash",
921
654
  client_id: "client id",
@@ -931,64 +664,44 @@ const jwtClaimNames = {
931
664
  htu: "http uri",
932
665
  cnf: "confirmation"
933
666
  };
934
- function validatePresence(required, result) {
935
- for (const claim of required) {
936
- if (result.claims[claim] === void 0) {
937
- throw new OPE(`JWT "${claim}" (${jwtClaimNames[claim]}) claim missing`);
938
- }
939
- }
940
- return result;
941
- }
942
- async function processAuthorizationCodeOAuth2Response(as, client, response) {
943
- const result = await processGenericAccessTokenResponse(as, client, response, true);
944
- if (isOAuth2Error(result)) {
945
- return result;
946
- }
947
- if (result.id_token !== void 0) {
948
- if (typeof result.id_token === "string" && result.id_token.length) {
949
- throw new OPE("Unexpected ID Token returned, use processAuthorizationCodeOpenIDResponse() for OpenID Connect callback processing");
950
- }
951
- delete result.id_token;
952
- }
953
- return result;
954
- }
955
- function assertReadableResponse(response) {
956
- if (response.bodyUsed) {
667
+ function _t(e, t) {
668
+ for (const n of e)
669
+ if (t.claims[n] === void 0)
670
+ throw new a(`JWT "${n}" (${yt[n]}) claim missing`);
671
+ return t;
672
+ }
673
+ async function bt(e, t, n) {
674
+ const o = await be(e, t, n, !0);
675
+ if (B(o))
676
+ return o;
677
+ if (o.id_token !== void 0) {
678
+ if (typeof o.id_token == "string" && o.id_token.length)
679
+ throw new a("Unexpected ID Token returned, use processAuthorizationCodeOpenIDResponse() for OpenID Connect callback processing");
680
+ delete o.id_token;
681
+ }
682
+ return o;
683
+ }
684
+ function X(e) {
685
+ if (e.bodyUsed)
957
686
  throw new TypeError('"response" body has been used already');
958
- }
959
687
  }
960
- async function handleOAuthBodyError(response) {
961
- if (response.status > 399 && response.status < 500) {
962
- assertReadableResponse(response);
688
+ async function vt(e) {
689
+ if (e.status > 399 && e.status < 500) {
690
+ X(e);
963
691
  try {
964
- const json = await response.json();
965
- if (isJsonObject(json) && typeof json.error === "string" && json.error.length) {
966
- if (json.error_description !== void 0 && typeof json.error_description !== "string") {
967
- delete json.error_description;
968
- }
969
- if (json.error_uri !== void 0 && typeof json.error_uri !== "string") {
970
- delete json.error_uri;
971
- }
972
- if (json.algs !== void 0 && typeof json.algs !== "string") {
973
- delete json.algs;
974
- }
975
- if (json.scope !== void 0 && typeof json.scope !== "string") {
976
- delete json.scope;
977
- }
978
- return json;
979
- }
692
+ const t = await e.json();
693
+ if (C(t) && typeof t.error == "string" && t.error.length)
694
+ return t.error_description !== void 0 && typeof t.error_description != "string" && delete t.error_description, t.error_uri !== void 0 && typeof t.error_uri != "string" && delete t.error_uri, t.algs !== void 0 && typeof t.algs != "string" && delete t.algs, t.scope !== void 0 && typeof t.scope != "string" && delete t.scope, t;
980
695
  } catch {
981
696
  }
982
697
  }
983
- return void 0;
984
698
  }
985
- function checkRsaKeyAlgorithm(algorithm) {
986
- if (typeof algorithm.modulusLength !== "number" || algorithm.modulusLength < 2048) {
987
- throw new OPE(`${algorithm.name} modulusLength must be at least 2048 bits`);
988
- }
699
+ function ue(e) {
700
+ if (typeof e.modulusLength != "number" || e.modulusLength < 2048)
701
+ throw new a(`${e.name} modulusLength must be at least 2048 bits`);
989
702
  }
990
- function ecdsaHashName(namedCurve) {
991
- switch (namedCurve) {
703
+ function St(e) {
704
+ switch (e) {
992
705
  case "P-256":
993
706
  return "SHA-256";
994
707
  case "P-384":
@@ -996,453 +709,353 @@ function ecdsaHashName(namedCurve) {
996
709
  case "P-521":
997
710
  return "SHA-512";
998
711
  default:
999
- throw new UnsupportedOperationError();
712
+ throw new v();
1000
713
  }
1001
714
  }
1002
- function keyToSubtle(key) {
1003
- switch (key.algorithm.name) {
715
+ function Se(e) {
716
+ switch (e.algorithm.name) {
1004
717
  case "ECDSA":
1005
718
  return {
1006
- name: key.algorithm.name,
1007
- hash: ecdsaHashName(key.algorithm.namedCurve)
719
+ name: e.algorithm.name,
720
+ hash: St(e.algorithm.namedCurve)
1008
721
  };
1009
- case "RSA-PSS": {
1010
- checkRsaKeyAlgorithm(key.algorithm);
1011
- switch (key.algorithm.hash.name) {
722
+ case "RSA-PSS":
723
+ switch (ue(e.algorithm), e.algorithm.hash.name) {
1012
724
  case "SHA-256":
1013
725
  case "SHA-384":
1014
726
  case "SHA-512":
1015
727
  return {
1016
- name: key.algorithm.name,
1017
- saltLength: parseInt(key.algorithm.hash.name.slice(-3), 10) >> 3
728
+ name: e.algorithm.name,
729
+ saltLength: parseInt(e.algorithm.hash.name.slice(-3), 10) >> 3
1018
730
  };
1019
731
  default:
1020
- throw new UnsupportedOperationError();
732
+ throw new v();
1021
733
  }
1022
- }
1023
734
  case "RSASSA-PKCS1-v1_5":
1024
- checkRsaKeyAlgorithm(key.algorithm);
1025
- return key.algorithm.name;
735
+ return ue(e.algorithm), e.algorithm.name;
1026
736
  case "Ed448":
1027
737
  case "Ed25519":
1028
- return key.algorithm.name;
1029
- }
1030
- throw new UnsupportedOperationError();
1031
- }
1032
- const noSignatureCheck = Symbol();
1033
- async function validateJwt(jws, checkAlg, getKey, clockSkew2, clockTolerance2) {
1034
- const { 0: protectedHeader, 1: payload, 2: encodedSignature, length } = jws.split(".");
1035
- if (length === 5) {
1036
- throw new UnsupportedOperationError("JWE structure JWTs are not supported");
1037
- }
1038
- if (length !== 3) {
1039
- throw new OPE("Invalid JWT");
1040
- }
1041
- let header;
738
+ return e.algorithm.name;
739
+ }
740
+ throw new v();
741
+ }
742
+ const Ee = Symbol();
743
+ async function Et(e, t, n, o, s) {
744
+ const { 0: r, 1: i, 2: d, length: g } = e.split(".");
745
+ if (g === 5)
746
+ throw new v("JWE structure JWTs are not supported");
747
+ if (g !== 3)
748
+ throw new a("Invalid JWT");
749
+ let m;
1042
750
  try {
1043
- header = JSON.parse(buf(b64u(protectedHeader)));
1044
- } catch (cause) {
1045
- throw new OPE("failed to parse JWT Header body as base64url encoded JSON", { cause });
1046
- }
1047
- if (!isJsonObject(header)) {
1048
- throw new OPE("JWT Header must be a top level object");
1049
- }
1050
- checkAlg(header);
1051
- if (header.crit !== void 0) {
1052
- throw new OPE('unexpected JWT "crit" header parameter');
1053
- }
1054
- const signature = b64u(encodedSignature);
1055
- let key;
1056
- if (getKey !== noSignatureCheck) {
1057
- key = await getKey(header);
1058
- const input = `${protectedHeader}.${payload}`;
1059
- const verified = await crypto.subtle.verify(keyToSubtle(key), key, signature, buf(input));
1060
- if (!verified) {
1061
- throw new OPE("JWT signature verification failed");
1062
- }
1063
- }
1064
- let claims;
751
+ m = JSON.parse(A(k(r)));
752
+ } catch (R) {
753
+ throw new a("failed to parse JWT Header body as base64url encoded JSON", { cause: R });
754
+ }
755
+ if (!C(m))
756
+ throw new a("JWT Header must be a top level object");
757
+ if (t(m), m.crit !== void 0)
758
+ throw new a('unexpected JWT "crit" header parameter');
759
+ const _ = k(d);
760
+ let y;
761
+ if (n !== Ee) {
762
+ y = await n(m);
763
+ const R = `${r}.${i}`;
764
+ if (!await crypto.subtle.verify(Se(y), y, _, A(R)))
765
+ throw new a("JWT signature verification failed");
766
+ }
767
+ let h;
1065
768
  try {
1066
- claims = JSON.parse(buf(b64u(payload)));
1067
- } catch (cause) {
1068
- throw new OPE("failed to parse JWT Payload body as base64url encoded JSON", { cause });
1069
- }
1070
- if (!isJsonObject(claims)) {
1071
- throw new OPE("JWT Payload must be a top level object");
1072
- }
1073
- const now = epochTime() + clockSkew2;
1074
- if (claims.exp !== void 0) {
1075
- if (typeof claims.exp !== "number") {
1076
- throw new OPE('unexpected JWT "exp" (expiration time) claim type');
1077
- }
1078
- if (claims.exp <= now - clockTolerance2) {
1079
- throw new OPE('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
1080
- }
1081
- }
1082
- if (claims.iat !== void 0) {
1083
- if (typeof claims.iat !== "number") {
1084
- throw new OPE('unexpected JWT "iat" (issued at) claim type');
1085
- }
1086
- }
1087
- if (claims.iss !== void 0) {
1088
- if (typeof claims.iss !== "string") {
1089
- throw new OPE('unexpected JWT "iss" (issuer) claim type');
1090
- }
1091
- }
1092
- if (claims.nbf !== void 0) {
1093
- if (typeof claims.nbf !== "number") {
1094
- throw new OPE('unexpected JWT "nbf" (not before) claim type');
1095
- }
1096
- if (claims.nbf > now + clockTolerance2) {
1097
- throw new OPE('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
1098
- }
1099
- }
1100
- if (claims.aud !== void 0) {
1101
- if (typeof claims.aud !== "string" && !Array.isArray(claims.aud)) {
1102
- throw new OPE('unexpected JWT "aud" (audience) claim type');
1103
- }
1104
- }
1105
- return { header, claims, signature, key };
1106
- }
1107
- function checkSigningAlgorithm(client, issuer, header) {
1108
- if (client !== void 0) {
1109
- if (header.alg !== client) {
1110
- throw new OPE('unexpected JWT "alg" header parameter');
1111
- }
769
+ h = JSON.parse(A(k(i)));
770
+ } catch (R) {
771
+ throw new a("failed to parse JWT Payload body as base64url encoded JSON", { cause: R });
772
+ }
773
+ if (!C(h))
774
+ throw new a("JWT Payload must be a top level object");
775
+ const L = Q() + o;
776
+ if (h.exp !== void 0) {
777
+ if (typeof h.exp != "number")
778
+ throw new a('unexpected JWT "exp" (expiration time) claim type');
779
+ if (h.exp <= L - s)
780
+ throw new a('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
781
+ }
782
+ if (h.iat !== void 0 && typeof h.iat != "number")
783
+ throw new a('unexpected JWT "iat" (issued at) claim type');
784
+ if (h.iss !== void 0 && typeof h.iss != "string")
785
+ throw new a('unexpected JWT "iss" (issuer) claim type');
786
+ if (h.nbf !== void 0) {
787
+ if (typeof h.nbf != "number")
788
+ throw new a('unexpected JWT "nbf" (not before) claim type');
789
+ if (h.nbf > L + s)
790
+ throw new a('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
791
+ }
792
+ if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
793
+ throw new a('unexpected JWT "aud" (audience) claim type');
794
+ return { header: m, claims: h, signature: _, key: y };
795
+ }
796
+ function kt(e, t, n) {
797
+ if (e !== void 0) {
798
+ if (n.alg !== e)
799
+ throw new a('unexpected JWT "alg" header parameter');
1112
800
  return;
1113
801
  }
1114
- if (Array.isArray(issuer)) {
1115
- if (!issuer.includes(header.alg)) {
1116
- throw new OPE('unexpected JWT "alg" header parameter');
1117
- }
802
+ if (Array.isArray(t)) {
803
+ if (!t.includes(n.alg))
804
+ throw new a('unexpected JWT "alg" header parameter');
1118
805
  return;
1119
806
  }
1120
- if (header.alg !== "RS256") {
1121
- throw new OPE('unexpected JWT "alg" header parameter');
1122
- }
807
+ if (n.alg !== "RS256")
808
+ throw new a('unexpected JWT "alg" header parameter');
1123
809
  }
1124
- function getURLSearchParameter(parameters, name) {
1125
- const { 0: value, length } = parameters.getAll(name);
1126
- if (length > 1) {
1127
- throw new OPE(`"${name}" parameter must be provided only once`);
1128
- }
1129
- return value;
1130
- }
1131
- const skipStateCheck = Symbol();
1132
- const expectNoState = Symbol();
1133
- function validateAuthResponse(as, client, parameters, expectedState) {
1134
- assertAs(as);
1135
- assertClient(client);
1136
- if (parameters instanceof URL) {
1137
- parameters = parameters.searchParams;
1138
- }
1139
- if (!(parameters instanceof URLSearchParams)) {
810
+ function E(e, t) {
811
+ const { 0: n, length: o } = e.getAll(t);
812
+ if (o > 1)
813
+ throw new a(`"${t}" parameter must be provided only once`);
814
+ return n;
815
+ }
816
+ const Tt = Symbol(), At = Symbol();
817
+ function Rt(e, t, n, o) {
818
+ if (j(e), z(t), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
1140
819
  throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
1141
- }
1142
- if (getURLSearchParameter(parameters, "response")) {
1143
- throw new OPE('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()');
1144
- }
1145
- const iss = getURLSearchParameter(parameters, "iss");
1146
- const state = getURLSearchParameter(parameters, "state");
1147
- if (!iss && as.authorization_response_iss_parameter_supported) {
1148
- throw new OPE('response parameter "iss" (issuer) missing');
1149
- }
1150
- if (iss && iss !== as.issuer) {
1151
- throw new OPE('unexpected "iss" (issuer) response parameter value');
1152
- }
1153
- switch (expectedState) {
820
+ if (E(n, "response"))
821
+ throw new a('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()');
822
+ const s = E(n, "iss"), r = E(n, "state");
823
+ if (!s && e.authorization_response_iss_parameter_supported)
824
+ throw new a('response parameter "iss" (issuer) missing');
825
+ if (s && s !== e.issuer)
826
+ throw new a('unexpected "iss" (issuer) response parameter value');
827
+ switch (o) {
1154
828
  case void 0:
1155
- case expectNoState:
1156
- if (state !== void 0) {
1157
- throw new OPE('unexpected "state" response parameter encountered');
1158
- }
829
+ case At:
830
+ if (r !== void 0)
831
+ throw new a('unexpected "state" response parameter encountered');
1159
832
  break;
1160
- case skipStateCheck:
833
+ case Tt:
1161
834
  break;
1162
835
  default:
1163
- if (!validateString(expectedState)) {
1164
- throw new OPE('"expectedState" must be a non-empty string');
1165
- }
1166
- if (state === void 0) {
1167
- throw new OPE('response parameter "state" missing');
1168
- }
1169
- if (state !== expectedState) {
1170
- throw new OPE('unexpected "state" response parameter value');
1171
- }
1172
- }
1173
- const error = getURLSearchParameter(parameters, "error");
1174
- if (error) {
836
+ if (!w(o))
837
+ throw new a('"expectedState" must be a non-empty string');
838
+ if (r === void 0)
839
+ throw new a('response parameter "state" missing');
840
+ if (r !== o)
841
+ throw new a('unexpected "state" response parameter value');
842
+ }
843
+ const i = E(n, "error");
844
+ if (i)
1175
845
  return {
1176
- error,
1177
- error_description: getURLSearchParameter(parameters, "error_description"),
1178
- error_uri: getURLSearchParameter(parameters, "error_uri")
846
+ error: i,
847
+ error_description: E(n, "error_description"),
848
+ error_uri: E(n, "error_uri")
1179
849
  };
1180
- }
1181
- const id_token = getURLSearchParameter(parameters, "id_token");
1182
- const token = getURLSearchParameter(parameters, "token");
1183
- if (id_token !== void 0 || token !== void 0) {
1184
- throw new UnsupportedOperationError("implicit and hybrid flows are not supported");
1185
- }
1186
- return brand(new URLSearchParams(parameters));
850
+ const d = E(n, "id_token"), g = E(n, "token");
851
+ if (d !== void 0 || g !== void 0)
852
+ throw new v("implicit and hybrid flows are not supported");
853
+ return gt(new URLSearchParams(n));
1187
854
  }
1188
- class AuthorizationError extends Error {
855
+ class P extends Error {
1189
856
  }
1190
- class OAuthAuthorizationError extends AuthorizationError {
1191
- constructor(message, error, options) {
1192
- super(message, options);
1193
- this.error = error;
857
+ class G extends P {
858
+ constructor(t, n, o) {
859
+ super(t, o), this.error = n;
1194
860
  }
1195
861
  }
1196
- function Callback({
1197
- handleCallback
862
+ function xt({
863
+ handleCallback: e
1198
864
  }) {
1199
- const didInitialize = useRef(false);
1200
- const [error, setError] = useState(void 0);
1201
- const navigate = useNavigate();
1202
- useEffect(() => {
1203
- if (didInitialize.current) {
1204
- return;
1205
- }
1206
- didInitialize.current = true;
1207
- handleCallback().then(() => {
1208
- navigate("/");
1209
- }).catch((err) => {
1210
- setError(err);
1211
- });
1212
- }, []);
1213
- if (error) {
1214
- if (error instanceof OAuthAuthorizationError) {
1215
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1216
- /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { children: "Error" }),
1217
- /* @__PURE__ */ jsxRuntimeExports.jsxs("pre", { children: [
1218
- error.error.error,
1219
- error.error.error_description,
1220
- error.error.error_uri
1221
- ] })
1222
- ] });
1223
- }
1224
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1225
- /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { children: "Error" }),
1226
- /* @__PURE__ */ jsxRuntimeExports.jsxs("pre", { children: [
1227
- error.message,
1228
- error.stack
1229
- ] })
1230
- ] });
1231
- }
1232
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
1233
- }
1234
- const CODE_VERIFIER_KEY = "code-verifier";
1235
- class OpenIDAuthenticationProvider {
865
+ const t = Ce(!1), [n, o] = je(void 0), s = Pe();
866
+ return ze(() => {
867
+ t.current || (t.current = !0, e().then(() => {
868
+ s("/");
869
+ }).catch((r) => {
870
+ o(r);
871
+ }));
872
+ }, []), n ? n instanceof G ? /* @__PURE__ */ T.jsxs("div", { children: [
873
+ /* @__PURE__ */ T.jsx("h2", { children: "Error" }),
874
+ /* @__PURE__ */ T.jsxs("pre", { children: [
875
+ n.error.error,
876
+ n.error.error_description,
877
+ n.error.error_uri
878
+ ] })
879
+ ] }) : /* @__PURE__ */ T.jsxs("div", { children: [
880
+ /* @__PURE__ */ T.jsx("h2", { children: "Error" }),
881
+ /* @__PURE__ */ T.jsxs("pre", { children: [
882
+ n.message,
883
+ n.stack
884
+ ] })
885
+ ] }) : /* @__PURE__ */ T.jsx("div", { children: "Loading..." });
886
+ }
887
+ const le = "code-verifier";
888
+ class Pt {
1236
889
  constructor({
1237
- issuer,
1238
- authorizationEndpoint,
1239
- tokenEndpoint,
1240
- clientId
890
+ issuer: t,
891
+ authorizationEndpoint: n,
892
+ tokenEndpoint: o,
893
+ clientId: s
1241
894
  }) {
1242
- __publicField(this, "client");
1243
- __publicField(this, "issuer");
1244
- __publicField(this, "authorizationEndpoint");
1245
- __publicField(this, "tokenEndpoint");
1246
- __publicField(this, "authorizationServer");
1247
- __publicField(this, "tokens");
1248
- __publicField(this, "callbackUrlPath", "/oauth/callback");
1249
- __publicField(this, "logoutRedirectUrlPath", "/");
1250
- __publicField(this, "handleCallback", async () => {
1251
- const url = new URL(window.location.href);
1252
- const state = url.searchParams.get("state");
1253
- const codeVerifier = localStorage.getItem(CODE_VERIFIER_KEY);
1254
- if (!codeVerifier) {
1255
- throw new AuthorizationError(
895
+ S(this, "client");
896
+ S(this, "issuer");
897
+ S(this, "authorizationEndpoint");
898
+ S(this, "tokenEndpoint");
899
+ S(this, "authorizationServer");
900
+ S(this, "tokens");
901
+ S(this, "callbackUrlPath", "/oauth/callback");
902
+ S(this, "logoutRedirectUrlPath", "/");
903
+ S(this, "handleCallback", async () => {
904
+ const t = new URL(window.location.href), n = t.searchParams.get("state"), o = localStorage.getItem(le);
905
+ if (!o)
906
+ throw new P(
1256
907
  "Code verifier not found. Invalid auth state."
1257
908
  );
1258
- }
1259
- const authServer = await this.getAuthServer();
1260
- const params = validateAuthResponse(
1261
- authServer,
909
+ const s = await this.getAuthServer(), r = Rt(
910
+ s,
1262
911
  this.client,
1263
- url.searchParams,
1264
- state ?? void 0
912
+ t.searchParams,
913
+ n ?? void 0
1265
914
  );
1266
- if (isOAuth2Error(params)) {
1267
- logger.error("Error validating OAuth response", params);
1268
- throw new OAuthAuthorizationError(
915
+ if (B(r))
916
+ throw oe.error("Error validating OAuth response", r), new G(
1269
917
  "Error validating OAuth response",
1270
- params
918
+ r
1271
919
  );
1272
- }
1273
- const redirectUrl = new URL(url);
1274
- redirectUrl.pathname = this.callbackUrlPath;
1275
- redirectUrl.search = "";
1276
- const response = await authorizationCodeGrantRequest(
1277
- authServer,
920
+ const i = new URL(t);
921
+ i.pathname = this.callbackUrlPath, i.search = "";
922
+ const d = await mt(
923
+ s,
1278
924
  this.client,
1279
- params,
1280
- redirectUrl.toString(),
1281
- codeVerifier
1282
- );
1283
- const oauthResult = await processAuthorizationCodeOAuth2Response(
1284
- authServer,
925
+ r,
926
+ i.toString(),
927
+ o
928
+ ), g = await bt(
929
+ s,
1285
930
  this.client,
1286
- response
931
+ d
1287
932
  );
1288
- this.setTokensFromResponse(oauthResult);
1289
- const accessToken = await this.getAccessToken();
1290
- const userInfoResponse = await userInfoRequest(
1291
- authServer,
933
+ this.setTokensFromResponse(g);
934
+ const m = await this.getAccessToken(), y = await (await ut(
935
+ s,
1292
936
  this.client,
1293
- accessToken
1294
- );
1295
- const userInfo = await userInfoResponse.json();
1296
- const profile = {
1297
- sub: userInfo.sub,
1298
- email: userInfo.email,
1299
- name: userInfo.name,
1300
- emailVerified: userInfo.email_verified ?? false,
1301
- pictureUrl: userInfo.picture
937
+ m
938
+ )).json(), h = {
939
+ sub: y.sub,
940
+ email: y.email,
941
+ name: y.name,
942
+ emailVerified: y.email_verified ?? !1,
943
+ pictureUrl: y.picture
1302
944
  };
1303
- useAuthState.setState({
1304
- isAuthenticated: true,
1305
- isPending: false,
1306
- profile
945
+ re.setState({
946
+ isAuthenticated: !0,
947
+ isPending: !1,
948
+ profile: h
1307
949
  });
1308
950
  });
1309
951
  this.client = {
1310
- client_id: clientId,
952
+ client_id: s,
1311
953
  token_endpoint_auth_method: "none"
1312
- };
1313
- this.issuer = issuer;
1314
- this.authorizationEndpoint = authorizationEndpoint;
1315
- this.tokenEndpoint = tokenEndpoint;
954
+ }, this.issuer = t, this.authorizationEndpoint = n, this.tokenEndpoint = o;
1316
955
  }
1317
956
  async getAuthServer() {
1318
- if (!this.authorizationServer) {
1319
- if (this.tokenEndpoint && this.authorizationEndpoint) {
957
+ if (!this.authorizationServer)
958
+ if (this.tokenEndpoint && this.authorizationEndpoint)
1320
959
  this.authorizationServer = {
1321
960
  issuer: new URL(this.authorizationEndpoint).origin,
1322
961
  authorization_endpoint: this.authorizationEndpoint,
1323
962
  token_endpoint: this.tokenEndpoint,
1324
963
  code_challenge_methods_supported: []
1325
964
  };
1326
- } else {
1327
- const issuerUrl = new URL(this.issuer);
1328
- const response = await discoveryRequest(issuerUrl);
1329
- this.authorizationServer = await processDiscoveryResponse(
1330
- issuerUrl,
1331
- response
965
+ else {
966
+ const t = new URL(this.issuer), n = await Fe(t);
967
+ this.authorizationServer = await Me(
968
+ t,
969
+ n
1332
970
  );
1333
971
  }
1334
- }
1335
972
  return this.authorizationServer;
1336
973
  }
1337
974
  /**
1338
975
  * Sets the tokens from various OAuth responses
1339
976
  * @param response
1340
977
  */
1341
- setTokensFromResponse(response) {
1342
- if (isOAuth2Error(response)) {
1343
- logger.error("Bad Token Response", response);
1344
- throw new OAuthAuthorizationError("Bad Token Response", response);
1345
- }
1346
- if (!response.expires_in) {
1347
- throw new AuthorizationError("No expires_in in response");
1348
- }
978
+ setTokensFromResponse(t) {
979
+ if (B(t))
980
+ throw oe.error("Bad Token Response", t), new G("Bad Token Response", t);
981
+ if (!t.expires_in)
982
+ throw new P("No expires_in in response");
1349
983
  this.tokens = {
1350
- accessToken: response.access_token,
1351
- refreshToken: response.refresh_token,
1352
- expiresOn: new Date(Date.now() + response.expires_in * 1e3),
1353
- tokenType: response.token_type
984
+ accessToken: t.access_token,
985
+ refreshToken: t.refresh_token,
986
+ expiresOn: new Date(Date.now() + t.expires_in * 1e3),
987
+ tokenType: t.token_type
1354
988
  };
1355
989
  }
1356
990
  async initialize() {
1357
991
  }
1358
992
  async login() {
1359
- var _a2;
1360
- const code_challenge_method = "S256";
1361
- const authorizationServer = await this.getAuthServer();
1362
- if (!authorizationServer.authorization_endpoint) {
1363
- throw new AuthorizationError("No authorization endpoint");
1364
- }
1365
- const codeVerifier = generateRandomCodeVerifier();
1366
- const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
1367
- localStorage.setItem(CODE_VERIFIER_KEY, codeVerifier);
1368
- const authorizationUrl = new URL(
1369
- authorizationServer.authorization_endpoint
1370
- );
1371
- const redirectUrl = new URL(window.location.href);
1372
- redirectUrl.pathname = this.callbackUrlPath;
1373
- redirectUrl.search = "";
1374
- authorizationUrl.searchParams.set("client_id", this.client.client_id);
1375
- authorizationUrl.searchParams.set("redirect_uri", redirectUrl.toString());
1376
- authorizationUrl.searchParams.set("response_type", "code");
1377
- authorizationUrl.searchParams.set("scope", "openid+profile+email");
1378
- authorizationUrl.searchParams.set("code_challenge", codeChallenge);
1379
- authorizationUrl.searchParams.set(
993
+ var d;
994
+ const t = "S256", n = await this.getAuthServer();
995
+ if (!n.authorization_endpoint)
996
+ throw new P("No authorization endpoint");
997
+ const o = Be(), s = await qe(o);
998
+ localStorage.setItem(le, o);
999
+ const r = new URL(
1000
+ n.authorization_endpoint
1001
+ ), i = new URL(window.location.href);
1002
+ if (i.pathname = this.callbackUrlPath, i.search = "", r.searchParams.set("client_id", this.client.client_id), r.searchParams.set("redirect_uri", i.toString()), r.searchParams.set("response_type", "code"), r.searchParams.set("scope", "openid+profile+email"), r.searchParams.set("code_challenge", s), r.searchParams.set(
1380
1003
  "code_challenge_method",
1381
- code_challenge_method
1382
- );
1383
- if (((_a2 = authorizationServer.code_challenge_methods_supported) == null ? void 0 : _a2.includes("S256")) !== true) {
1384
- const state = generateRandomState();
1385
- authorizationUrl.searchParams.set("state", state);
1004
+ t
1005
+ ), ((d = n.code_challenge_methods_supported) == null ? void 0 : d.includes("S256")) !== !0) {
1006
+ const g = Ge();
1007
+ r.searchParams.set("state", g);
1386
1008
  }
1387
- location.href = authorizationUrl.href;
1009
+ location.href = r.href;
1388
1010
  }
1389
1011
  async getAccessToken() {
1390
- const as = await this.getAuthServer();
1391
- if (!this.tokens) {
1392
- throw new AuthorizationError("User is not authenticated");
1393
- }
1012
+ const t = await this.getAuthServer();
1013
+ if (!this.tokens)
1014
+ throw new P("User is not authenticated");
1394
1015
  if (this.tokens.expiresOn < /* @__PURE__ */ new Date()) {
1395
- if (!this.tokens.refreshToken) {
1396
- throw new AuthorizationError(
1016
+ if (!this.tokens.refreshToken)
1017
+ throw new P(
1397
1018
  "Token expired and no refresh token available"
1398
1019
  );
1399
- }
1400
- const request = await refreshTokenGrantRequest(
1401
- as,
1020
+ const n = await dt(
1021
+ t,
1402
1022
  this.client,
1403
1023
  this.tokens.refreshToken
1404
- );
1405
- const response = await processRefreshTokenResponse(
1406
- as,
1024
+ ), o = await ft(
1025
+ t,
1407
1026
  this.client,
1408
- request
1027
+ n
1409
1028
  );
1410
- this.setTokensFromResponse(response);
1029
+ this.setTokensFromResponse(o);
1411
1030
  }
1412
1031
  return this.tokens.accessToken;
1413
1032
  }
1414
1033
  async logout() {
1415
- useAuthState.setState({
1416
- isAuthenticated: false,
1417
- isPending: false,
1034
+ re.setState({
1035
+ isAuthenticated: !1,
1036
+ isPending: !1,
1418
1037
  profile: void 0
1419
1038
  });
1420
- const as = await this.getAuthServer();
1421
- const redirectUrl = new URL(window.location.href);
1422
- redirectUrl.pathname = this.logoutRedirectUrlPath;
1423
- let logoutUrl;
1424
- if (as.end_session_endpoint) {
1425
- logoutUrl = new URL(as.end_session_endpoint);
1426
- logoutUrl.searchParams.set(
1427
- "post_logout_redirect_uri",
1428
- redirectUrl.toString()
1429
- );
1430
- } else {
1431
- logoutUrl = redirectUrl;
1432
- }
1039
+ const t = await this.getAuthServer(), n = new URL(window.location.href);
1040
+ n.pathname = this.logoutRedirectUrlPath;
1041
+ let o;
1042
+ t.end_session_endpoint ? (o = new URL(t.end_session_endpoint), o.searchParams.set(
1043
+ "post_logout_redirect_uri",
1044
+ n.toString()
1045
+ )) : o = n;
1433
1046
  }
1434
1047
  getRoutes() {
1435
1048
  return [
1436
1049
  {
1437
1050
  path: this.callbackUrlPath,
1438
- element: /* @__PURE__ */ jsxRuntimeExports.jsx(Callback, { handleCallback: this.handleCallback })
1051
+ element: /* @__PURE__ */ T.jsx(xt, { handleCallback: this.handleCallback })
1439
1052
  }
1440
1053
  ];
1441
1054
  }
1442
1055
  }
1443
- const openIDAuth = (options) => new OpenIDAuthenticationProvider(options);
1056
+ const Jt = (e) => new Pt(e);
1444
1057
  export {
1445
- OpenIDAuthenticationProvider,
1446
- openIDAuth as default
1058
+ Pt as OpenIDAuthenticationProvider,
1059
+ Jt as default
1447
1060
  };
1448
1061
  //# sourceMappingURL=zudoku.auth-openid.js.map