zudoku 0.3.0-dev.76 → 0.3.0-dev.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/authentication/providers/auth0.js +5 -0
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +4 -0
- package/dist/lib/authentication/providers/openid.js +7 -1
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +14 -11
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-openid.js +88 -82
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/authentication/providers/auth0.tsx +8 -0
- package/src/lib/authentication/providers/openid.tsx +12 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useAuthState } from "../state.js";
|
|
2
2
|
import { OpenIDAuthenticationProvider } from "./openid.js";
|
|
3
3
|
class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
|
|
4
|
+
onAuthorizationUrl = async (url, { isSignUp }) => {
|
|
5
|
+
if (isSignUp) {
|
|
6
|
+
url.searchParams.set("screen_hint", "signup");
|
|
7
|
+
}
|
|
8
|
+
};
|
|
4
9
|
signOut = async () => {
|
|
5
10
|
useAuthState.setState({
|
|
6
11
|
isAuthenticated: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0.js","sourceRoot":"","sources":["../../../../src/lib/authentication/providers/auth0.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,2BAA4B,SAAQ,4BAA4B;IACpE,OAAO,GAAG,KAAK,IAAmB,EAAE;QAClC,YAAY,CAAC,QAAQ,CAAC;YACpB,eAAe,EAAE,KAAK;YACtB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,SAAS;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AAS,GAEX,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAC7B,IAAI,2BAA2B,CAAC;IAC9B,GAAG,OAAO;IACV,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,WAAW,MAAM,EAAE;CAC5B,CAAC,CAAC;AAEL,eAAe,SAAS,CAAC"}
|
|
@@ -27,6 +27,10 @@ export declare class OpenIDAuthenticationProvider implements AuthenticationProvi
|
|
|
27
27
|
protected tokens: TokenState | undefined;
|
|
28
28
|
protected callbackUrlPath: string;
|
|
29
29
|
protected logoutRedirectUrlPath: string;
|
|
30
|
+
protected onAuthorizationUrl?: (authorizationUrl: URL, options: {
|
|
31
|
+
isSignIn: boolean;
|
|
32
|
+
isSignUp: boolean;
|
|
33
|
+
}) => void;
|
|
30
34
|
private readonly redirectToAfterSignUp;
|
|
31
35
|
private readonly redirectToAfterSignIn;
|
|
32
36
|
private readonly redirectToAfterSignOut;
|
|
@@ -32,6 +32,7 @@ export class OpenIDAuthenticationProvider {
|
|
|
32
32
|
tokens;
|
|
33
33
|
callbackUrlPath = "/oauth/callback";
|
|
34
34
|
logoutRedirectUrlPath = "/";
|
|
35
|
+
onAuthorizationUrl;
|
|
35
36
|
redirectToAfterSignUp;
|
|
36
37
|
redirectToAfterSignIn;
|
|
37
38
|
redirectToAfterSignOut;
|
|
@@ -90,6 +91,7 @@ export class OpenIDAuthenticationProvider {
|
|
|
90
91
|
async signUp({ redirectTo } = {}) {
|
|
91
92
|
return this.authorize({
|
|
92
93
|
redirectTo: redirectTo ?? this.redirectToAfterSignUp,
|
|
94
|
+
isSignUp: true,
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
async signIn({ redirectTo } = {}) {
|
|
@@ -97,7 +99,7 @@ export class OpenIDAuthenticationProvider {
|
|
|
97
99
|
redirectTo: redirectTo ?? this.redirectToAfterSignIn,
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
|
-
async authorize({ redirectTo, }) {
|
|
102
|
+
async authorize({ redirectTo, isSignUp = false, }) {
|
|
101
103
|
const code_challenge_method = "S256";
|
|
102
104
|
const authorizationServer = await this.getAuthServer();
|
|
103
105
|
if (!authorizationServer.authorization_endpoint) {
|
|
@@ -126,6 +128,10 @@ export class OpenIDAuthenticationProvider {
|
|
|
126
128
|
if (this.audience) {
|
|
127
129
|
authorizationUrl.searchParams.set("audience", this.audience);
|
|
128
130
|
}
|
|
131
|
+
this.onAuthorizationUrl?.(authorizationUrl, {
|
|
132
|
+
isSignIn: !isSignUp,
|
|
133
|
+
isSignUp,
|
|
134
|
+
});
|
|
129
135
|
/**
|
|
130
136
|
* We cannot be sure the AS supports PKCE so we're going to use state too. Use of PKCE is
|
|
131
137
|
* backwards compatible even if the AS doesn't support it which is why we're using it regardless.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openid.js","sourceRoot":"","sources":["../../../../src/lib/authentication/providers/openid.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAQtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAExD,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAS1C,MAAM,gBAAiB,SAAQ,oBAAoB;IAEvC;IACD;IAFT,YACU,eAAuB,EACxB,UAAuC;QAE9C,KAAK,EAAE,CAAC;QAHA,oBAAe,GAAf,eAAe,CAAQ;QACxB,eAAU,GAAV,UAAU,CAA6B;IAGhD,CAAC;IACD,SAAS;QACP,OAAO;YACL,GAAG,KAAK,CAAC,SAAS,EAAE;YACpB;gBACE,IAAI,EAAE,IAAI,CAAC,eAAe;gBAC1B,OAAO,EAAE,eAAO;aACjB;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,O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ACb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,GAEZ,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,4BAA4B,CAAC,OAAO,CAAC,CAAC;AAE3D,eAAe,UAAU,CAAC"}
|
package/lib/zudoku.auth-auth0.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
var r = Object.defineProperty;
|
|
2
|
-
var a = (
|
|
3
|
-
var n = (
|
|
2
|
+
var a = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var n = (i, t, e) => a(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { u } from "./state-DsXXkBLH.js";
|
|
5
5
|
import { OpenIDAuthenticationProvider as l } from "./zudoku.auth-openid.js";
|
|
6
|
-
class
|
|
6
|
+
class h extends l {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
|
+
n(this, "onAuthorizationUrl", async (e, { isSignUp: o }) => {
|
|
10
|
+
o && e.searchParams.set("screen_hint", "signup");
|
|
11
|
+
});
|
|
9
12
|
n(this, "signOut", async () => {
|
|
10
13
|
u.setState({
|
|
11
14
|
isAuthenticated: !1,
|
|
12
15
|
isPending: !1,
|
|
13
16
|
profile: void 0
|
|
14
17
|
}), localStorage.removeItem("auto-login");
|
|
15
|
-
const
|
|
18
|
+
const e = await this.getAuthServer(), o = new URL(
|
|
16
19
|
window.location.origin + this.logoutRedirectUrlPath
|
|
17
20
|
);
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
+
o.pathname = this.logoutRedirectUrlPath;
|
|
22
|
+
let s;
|
|
23
|
+
e.end_session_endpoint ? (s = new URL(e.end_session_endpoint), s.searchParams.set(
|
|
21
24
|
"post_logout_redirect_uri",
|
|
22
|
-
|
|
23
|
-
)) :
|
|
25
|
+
o.toString()
|
|
26
|
+
)) : s = new URL(`${this.issuer}oidc/logout`);
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
const p = ({ domain:
|
|
30
|
+
const p = ({ domain: i, ...t }) => new h({
|
|
28
31
|
...t,
|
|
29
32
|
type: "openid",
|
|
30
|
-
issuer: `https://${
|
|
33
|
+
issuer: `https://${i}`
|
|
31
34
|
});
|
|
32
35
|
export {
|
|
33
36
|
p as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zudoku.auth-auth0.js","sources":["../src/lib/authentication/providers/auth0.tsx"],"sourcesContent":["import { Auth0AuthenticationConfig } from \"../../../config/config.js\";\nimport { AuthenticationProviderInitializer } from \"../authentication.js\";\nimport { useAuthState } from \"../state.js\";\nimport { OpenIDAuthenticationProvider } from \"./openid.js\";\n\nclass Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {\n signOut = async (): Promise<void> => {\n useAuthState.setState({\n isAuthenticated: false,\n isPending: false,\n profile: undefined,\n });\n localStorage.removeItem(\"auto-login\");\n const as = await this.getAuthServer();\n\n const redirectUrl = new URL(\n window.location.origin + this.logoutRedirectUrlPath,\n );\n redirectUrl.pathname = this.logoutRedirectUrlPath;\n\n // SEE: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0\n // For Auth0 tenants created on or after 14 November 2023, RP-Initiated\n // Logout End Session Endpoint Discovery is enabled by default.\n // Otherwise we fallback to the old non-compliant logout\n\n let logoutUrl: URL;\n // The endSessionEndpoint is set, the IdP supports some form of logout,\n // so we use the IdP logout. Otherwise, just redirect the user to home\n if (as.end_session_endpoint) {\n logoutUrl = new URL(as.end_session_endpoint);\n // TODO: get id_token and set hint\n // const { id_token } = session;\n // if (id_token) {\n // logoutUrl.searchParams.set(\"id_token_hint\", id_token);\n // }\n logoutUrl.searchParams.set(\n \"post_logout_redirect_uri\",\n redirectUrl.toString(),\n );\n } else {\n logoutUrl = new URL(`${this.issuer}oidc/logout`);\n }\n };\n}\n\nconst auth0Auth: AuthenticationProviderInitializer<\n Auth0AuthenticationConfig\n> = ({ domain, ...options }) =>\n new Auth0AuthenticationProvider({\n ...options,\n type: \"openid\",\n issuer: `https://${domain}`,\n });\n\nexport default auth0Auth;\n"],"names":["Auth0AuthenticationProvider","OpenIDAuthenticationProvider","__publicField","useAuthState","as","redirectUrl","logoutUrl","auth0Auth","domain","options"],"mappings":";;;;;AAKA,MAAMA,UAAoCC,EAA6B;AAAA,EAAvE;AAAA;AACE,IAAAC,EAAA,iBAAU,YAA2B;AACnC,
|
|
1
|
+
{"version":3,"file":"zudoku.auth-auth0.js","sources":["../src/lib/authentication/providers/auth0.tsx"],"sourcesContent":["import { Auth0AuthenticationConfig } from \"../../../config/config.js\";\nimport { AuthenticationProviderInitializer } from \"../authentication.js\";\nimport { useAuthState } from \"../state.js\";\nimport { OpenIDAuthenticationProvider } from \"./openid.js\";\n\nclass Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {\n onAuthorizationUrl = async (\n url: URL,\n { isSignUp }: { isSignUp: boolean },\n ) => {\n if (isSignUp) {\n url.searchParams.set(\"screen_hint\", \"signup\");\n }\n };\n signOut = async (): Promise<void> => {\n useAuthState.setState({\n isAuthenticated: false,\n isPending: false,\n profile: undefined,\n });\n localStorage.removeItem(\"auto-login\");\n const as = await this.getAuthServer();\n\n const redirectUrl = new URL(\n window.location.origin + this.logoutRedirectUrlPath,\n );\n redirectUrl.pathname = this.logoutRedirectUrlPath;\n\n // SEE: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0\n // For Auth0 tenants created on or after 14 November 2023, RP-Initiated\n // Logout End Session Endpoint Discovery is enabled by default.\n // Otherwise we fallback to the old non-compliant logout\n\n let logoutUrl: URL;\n // The endSessionEndpoint is set, the IdP supports some form of logout,\n // so we use the IdP logout. Otherwise, just redirect the user to home\n if (as.end_session_endpoint) {\n logoutUrl = new URL(as.end_session_endpoint);\n // TODO: get id_token and set hint\n // const { id_token } = session;\n // if (id_token) {\n // logoutUrl.searchParams.set(\"id_token_hint\", id_token);\n // }\n logoutUrl.searchParams.set(\n \"post_logout_redirect_uri\",\n redirectUrl.toString(),\n );\n } else {\n logoutUrl = new URL(`${this.issuer}oidc/logout`);\n }\n };\n}\n\nconst auth0Auth: AuthenticationProviderInitializer<\n Auth0AuthenticationConfig\n> = ({ domain, ...options }) =>\n new Auth0AuthenticationProvider({\n ...options,\n type: \"openid\",\n issuer: `https://${domain}`,\n });\n\nexport default auth0Auth;\n"],"names":["Auth0AuthenticationProvider","OpenIDAuthenticationProvider","__publicField","url","isSignUp","useAuthState","as","redirectUrl","logoutUrl","auth0Auth","domain","options"],"mappings":";;;;;AAKA,MAAMA,UAAoCC,EAA6B;AAAA,EAAvE;AAAA;AACE,IAAAC,EAAA,4BAAqB,OACnBC,GACA,EAAE,UAAAC,QACC;AACH,MAAIA,KACED,EAAA,aAAa,IAAI,eAAe,QAAQ;AAAA,IAC9C;AAEF,IAAAD,EAAA,iBAAU,YAA2B;AACnC,MAAAG,EAAa,SAAS;AAAA,QACpB,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,SAAS;AAAA,MAAA,CACV,GACD,aAAa,WAAW,YAAY;AAC9B,YAAAC,IAAK,MAAM,KAAK,iBAEhBC,IAAc,IAAI;AAAA,QACtB,OAAO,SAAS,SAAS,KAAK;AAAA,MAAA;AAEhC,MAAAA,EAAY,WAAW,KAAK;AAOxB,UAAAC;AAGJ,MAAIF,EAAG,wBACOE,IAAA,IAAI,IAAIF,EAAG,oBAAoB,GAM3CE,EAAU,aAAa;AAAA,QACrB;AAAA,QACAD,EAAY,SAAS;AAAA,MAAA,KAGvBC,IAAY,IAAI,IAAI,GAAG,KAAK,MAAM,aAAa;AAAA,IACjD;AAAA;AAEJ;AAEM,MAAAC,IAEF,CAAC,EAAE,QAAAC,GAAQ,GAAGC,EAAQ,MACxB,IAAIX,EAA4B;AAAA,EAC9B,GAAGW;AAAA,EACH,MAAM;AAAA,EACN,QAAQ,WAAWD,CAAM;AAC3B,CAAC;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Ee = Object.defineProperty;
|
|
2
2
|
var Re = (t, e, n) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
-
var
|
|
3
|
+
var g = (t, e, n) => Re(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { j as Pe } from "./jsx-runtime-CJBdjYYx.js";
|
|
5
5
|
import { c as Ue, a as xe } from "./_commonjsHelpers-BVfed4GL.js";
|
|
6
6
|
import { A as Le } from "./AuthenticationPlugin-CngUn5DP.js";
|
|
@@ -36,7 +36,7 @@ var de = { exports: {} };
|
|
|
36
36
|
function y(l) {
|
|
37
37
|
return l === "debug" && (l = "log"), typeof console === n ? !1 : l === "trace" && r ? f : console[l] !== void 0 ? u(console, l) : console.log !== void 0 ? u(console, "log") : e;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function _() {
|
|
40
40
|
for (var l = this.getLevel(), p = 0; p < s.length; p++) {
|
|
41
41
|
var c = s[p];
|
|
42
42
|
this[c] = p < l ? e : this.methodFactory(c, l, this.name);
|
|
@@ -44,13 +44,13 @@ var de = { exports: {} };
|
|
|
44
44
|
if (this.log = this.debug, typeof console === n && l < this.levels.SILENT)
|
|
45
45
|
return "No console available for logging";
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function b(l) {
|
|
48
48
|
return function() {
|
|
49
|
-
typeof console !== n && (
|
|
49
|
+
typeof console !== n && (_.call(this), this[l].apply(this, arguments));
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
function h(l, p, c) {
|
|
53
|
-
return y(l) ||
|
|
53
|
+
return y(l) || b.apply(this, arguments);
|
|
54
54
|
}
|
|
55
55
|
function P(l, p) {
|
|
56
56
|
var c = this, I, H, R, v = "loglevel";
|
|
@@ -87,7 +87,7 @@ var de = { exports: {} };
|
|
|
87
87
|
return c.levels[d] === void 0 && (d = void 0), d;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function Ae() {
|
|
91
91
|
if (!(typeof window === n || !v)) {
|
|
92
92
|
try {
|
|
93
93
|
window.localStorage.removeItem(v);
|
|
@@ -115,24 +115,24 @@ var de = { exports: {} };
|
|
|
115
115
|
}, c.methodFactory = p || h, c.getLevel = function() {
|
|
116
116
|
return R ?? H ?? I;
|
|
117
117
|
}, c.setLevel = function(d, w) {
|
|
118
|
-
return R = U(d), w !== !1 && Te(R),
|
|
118
|
+
return R = U(d), w !== !1 && Te(R), _.call(c);
|
|
119
119
|
}, c.setDefaultLevel = function(d) {
|
|
120
120
|
H = U(d), X() || c.setLevel(d, !1);
|
|
121
121
|
}, c.resetLevel = function() {
|
|
122
|
-
R = null,
|
|
122
|
+
R = null, Ae(), _.call(c);
|
|
123
123
|
}, c.enableAll = function(d) {
|
|
124
124
|
c.setLevel(c.levels.TRACE, d);
|
|
125
125
|
}, c.disableAll = function(d) {
|
|
126
126
|
c.setLevel(c.levels.SILENT, d);
|
|
127
127
|
}, c.rebuild = function() {
|
|
128
|
-
if (i !== c && (I = U(i.getLevel())),
|
|
128
|
+
if (i !== c && (I = U(i.getLevel())), _.call(c), i === c)
|
|
129
129
|
for (var d in o)
|
|
130
130
|
o[d].rebuild();
|
|
131
131
|
}, I = U(
|
|
132
132
|
i ? i.getLevel() : "WARN"
|
|
133
133
|
);
|
|
134
134
|
var ee = X();
|
|
135
|
-
ee != null && (R = U(ee)),
|
|
135
|
+
ee != null && (R = U(ee)), _.call(c);
|
|
136
136
|
}
|
|
137
137
|
i = new P(), i.getLogger = function(p) {
|
|
138
138
|
if (typeof p != "symbol" && typeof p != "string" || p === "")
|
|
@@ -166,7 +166,7 @@ function G(t, e) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
const N = Symbol(), Ie = Symbol(), q = Symbol(), je = new TextEncoder(), ze = new TextDecoder();
|
|
169
|
-
function
|
|
169
|
+
function k(t) {
|
|
170
170
|
return typeof t == "string" ? je.encode(t) : ze.decode(t);
|
|
171
171
|
}
|
|
172
172
|
const oe = 32768;
|
|
@@ -187,7 +187,7 @@ function Oe(t) {
|
|
|
187
187
|
throw new a("The input to be decoded is not correctly encoded.", { cause: e });
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function A(t) {
|
|
191
191
|
return typeof t == "string" ? Oe(t) : Je(t);
|
|
192
192
|
}
|
|
193
193
|
class Ne {
|
|
@@ -286,7 +286,7 @@ async function De(t, e) {
|
|
|
286
286
|
signal: e != null && e.signal ? Y(e.signal) : null
|
|
287
287
|
}).then(V);
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function m(t) {
|
|
290
290
|
return typeof t == "string" && t.length !== 0;
|
|
291
291
|
}
|
|
292
292
|
async function He(t, e) {
|
|
@@ -305,14 +305,14 @@ async function He(t, e) {
|
|
|
305
305
|
}
|
|
306
306
|
if (!x(n))
|
|
307
307
|
throw new a('"response" body must be a top level object');
|
|
308
|
-
if (!
|
|
308
|
+
if (!m(n.issuer))
|
|
309
309
|
throw new a('"response" body "issuer" property must be a non-empty string');
|
|
310
310
|
if (new URL(n.issuer).href !== t.href)
|
|
311
311
|
throw new a('"response" body "issuer" does not match "expectedIssuer"');
|
|
312
312
|
return n;
|
|
313
313
|
}
|
|
314
314
|
function W() {
|
|
315
|
-
return
|
|
315
|
+
return A(crypto.getRandomValues(new Uint8Array(32)));
|
|
316
316
|
}
|
|
317
317
|
function $e() {
|
|
318
318
|
return W();
|
|
@@ -321,16 +321,16 @@ function Fe() {
|
|
|
321
321
|
return W();
|
|
322
322
|
}
|
|
323
323
|
async function Me(t) {
|
|
324
|
-
if (!
|
|
324
|
+
if (!m(t))
|
|
325
325
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
326
|
-
return
|
|
326
|
+
return A(await crypto.subtle.digest("SHA-256", k(t)));
|
|
327
327
|
}
|
|
328
328
|
function Be(t) {
|
|
329
329
|
if (t instanceof CryptoKey)
|
|
330
330
|
return { key: t };
|
|
331
331
|
if (!((t == null ? void 0 : t.key) instanceof CryptoKey))
|
|
332
332
|
return {};
|
|
333
|
-
if (t.kid !== void 0 && !
|
|
333
|
+
if (t.kid !== void 0 && !m(t.kid))
|
|
334
334
|
throw new TypeError('"kid" must be a non-empty string');
|
|
335
335
|
return { key: t.key, kid: t.kid };
|
|
336
336
|
}
|
|
@@ -424,19 +424,19 @@ async function Xe(t, e, n, r) {
|
|
|
424
424
|
function L(t) {
|
|
425
425
|
if (typeof t != "object" || t === null)
|
|
426
426
|
throw new TypeError('"as" must be an object');
|
|
427
|
-
if (!
|
|
427
|
+
if (!m(t.issuer))
|
|
428
428
|
throw new TypeError('"as.issuer" property must be a non-empty string');
|
|
429
429
|
return !0;
|
|
430
430
|
}
|
|
431
431
|
function C(t) {
|
|
432
432
|
if (typeof t != "object" || t === null)
|
|
433
433
|
throw new TypeError('"client" must be an object');
|
|
434
|
-
if (!
|
|
434
|
+
if (!m(t.client_id))
|
|
435
435
|
throw new TypeError('"client.client_id" property must be a non-empty string');
|
|
436
436
|
return !0;
|
|
437
437
|
}
|
|
438
438
|
function se(t) {
|
|
439
|
-
if (!
|
|
439
|
+
if (!m(t))
|
|
440
440
|
throw new TypeError('"client.client_secret" property must be a non-empty string');
|
|
441
441
|
return t;
|
|
442
442
|
}
|
|
@@ -481,7 +481,7 @@ async function et(t, e, n, r, s) {
|
|
|
481
481
|
async function ge(t, e, n) {
|
|
482
482
|
if (!n.usages.includes("sign"))
|
|
483
483
|
throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"');
|
|
484
|
-
const r = `${k(
|
|
484
|
+
const r = `${A(k(JSON.stringify(t)))}.${A(k(JSON.stringify(e)))}`, s = A(await crypto.subtle.sign(ve(n), n, k(r)));
|
|
485
485
|
return `${r}.${s}`;
|
|
486
486
|
}
|
|
487
487
|
async function tt(t, e, n, r, s, o) {
|
|
@@ -490,11 +490,11 @@ async function tt(t, e, n, r, s, o) {
|
|
|
490
490
|
throw new TypeError('"DPoP.privateKey" must be a private CryptoKey');
|
|
491
491
|
if (!We(u))
|
|
492
492
|
throw new TypeError('"DPoP.publicKey" must be a public CryptoKey');
|
|
493
|
-
if (f !== void 0 && !
|
|
493
|
+
if (f !== void 0 && !m(f))
|
|
494
494
|
throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined');
|
|
495
495
|
if (!u.extractable)
|
|
496
496
|
throw new TypeError('"DPoP.publicKey.extractable" must be true');
|
|
497
|
-
const y = Z() + s,
|
|
497
|
+
const y = Z() + s, _ = await ge({
|
|
498
498
|
alg: we(i),
|
|
499
499
|
typ: "dpop+jwt",
|
|
500
500
|
jwk: await rt(u)
|
|
@@ -504,9 +504,9 @@ async function tt(t, e, n, r, s, o) {
|
|
|
504
504
|
htm: r,
|
|
505
505
|
nonce: f,
|
|
506
506
|
htu: `${n.origin}${n.pathname}`,
|
|
507
|
-
ath: o ?
|
|
507
|
+
ath: o ? A(await crypto.subtle.digest("SHA-256", k(o))) : void 0
|
|
508
508
|
}, i);
|
|
509
|
-
t.set("dpop",
|
|
509
|
+
t.set("dpop", _);
|
|
510
510
|
}
|
|
511
511
|
let J;
|
|
512
512
|
async function nt(t) {
|
|
@@ -529,7 +529,7 @@ function B(t) {
|
|
|
529
529
|
return typeof e != "object" || Array.isArray(e) || e === null ? !1 : e.error !== void 0;
|
|
530
530
|
}
|
|
531
531
|
async function it(t, e, n, r, s, o) {
|
|
532
|
-
if (!
|
|
532
|
+
if (!m(t))
|
|
533
533
|
throw new TypeError('"accessToken" must be a non-empty string');
|
|
534
534
|
if (!(n instanceof URL))
|
|
535
535
|
throw new TypeError('"url" must be an instance of URL');
|
|
@@ -565,7 +565,7 @@ async function ye(t, e, n, r, s) {
|
|
|
565
565
|
return i.set("accept", "application/json"), at(t, e, "POST", o, r, i, s);
|
|
566
566
|
}
|
|
567
567
|
async function ct(t, e, n, r) {
|
|
568
|
-
if (L(t), C(e), !
|
|
568
|
+
if (L(t), C(e), !m(n))
|
|
569
569
|
throw new TypeError('"refreshToken" must be a non-empty string');
|
|
570
570
|
const s = new URLSearchParams(r == null ? void 0 : r.additionalParameters);
|
|
571
571
|
return s.set("refresh_token", n), ye(t, e, "refresh_token", s, r);
|
|
@@ -589,20 +589,20 @@ async function _e(t, e, n, r = !1, s = !1) {
|
|
|
589
589
|
}
|
|
590
590
|
if (!x(o))
|
|
591
591
|
throw new a('"response" body must be a top level object');
|
|
592
|
-
if (!
|
|
592
|
+
if (!m(o.access_token))
|
|
593
593
|
throw new a('"response" body "access_token" property must be a non-empty string');
|
|
594
|
-
if (!
|
|
594
|
+
if (!m(o.token_type))
|
|
595
595
|
throw new a('"response" body "token_type" property must be a non-empty string');
|
|
596
596
|
if (o.token_type = o.token_type.toLowerCase(), o.token_type !== "dpop" && o.token_type !== "bearer")
|
|
597
597
|
throw new S("unsupported `token_type` value");
|
|
598
598
|
if (o.expires_in !== void 0 && (typeof o.expires_in != "number" || o.expires_in <= 0))
|
|
599
599
|
throw new a('"response" body "expires_in" property must be a positive number');
|
|
600
|
-
if (!s && o.refresh_token !== void 0 && !
|
|
600
|
+
if (!s && o.refresh_token !== void 0 && !m(o.refresh_token))
|
|
601
601
|
throw new a('"response" body "refresh_token" property must be a non-empty string');
|
|
602
602
|
if (o.scope !== void 0 && typeof o.scope != "string")
|
|
603
603
|
throw new a('"response" body "scope" property must be a string');
|
|
604
604
|
if (!r) {
|
|
605
|
-
if (o.id_token !== void 0 && !
|
|
605
|
+
if (o.id_token !== void 0 && !m(o.id_token))
|
|
606
606
|
throw new a('"response" body "id_token" property must be a non-empty string');
|
|
607
607
|
if (o.id_token) {
|
|
608
608
|
const { claims: i } = await bt(o.id_token, vt.bind(void 0, e.id_token_signed_response_alg, t.id_token_signing_alg_values_supported), Se, D(e), Ze(e)).then(gt.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(ht.bind(void 0, t.issuer)).then(dt.bind(void 0, e.client_id));
|
|
@@ -638,9 +638,9 @@ function ft(t) {
|
|
|
638
638
|
async function pt(t, e, n, r, s, o) {
|
|
639
639
|
if (L(t), C(e), !be.has(n))
|
|
640
640
|
throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()');
|
|
641
|
-
if (!
|
|
641
|
+
if (!m(r))
|
|
642
642
|
throw new TypeError('"redirectUri" must be a non-empty string');
|
|
643
|
-
if (!
|
|
643
|
+
if (!m(s))
|
|
644
644
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
645
645
|
const i = T(n, "code");
|
|
646
646
|
if (!i)
|
|
@@ -748,7 +748,7 @@ async function bt(t, e, n, r, s) {
|
|
|
748
748
|
throw new a("Invalid JWT");
|
|
749
749
|
let y;
|
|
750
750
|
try {
|
|
751
|
-
y = JSON.parse(A(
|
|
751
|
+
y = JSON.parse(k(A(o)));
|
|
752
752
|
} catch (E) {
|
|
753
753
|
throw new a("failed to parse JWT Header body as base64url encoded JSON", { cause: E });
|
|
754
754
|
}
|
|
@@ -756,17 +756,17 @@ async function bt(t, e, n, r, s) {
|
|
|
756
756
|
throw new a("JWT Header must be a top level object");
|
|
757
757
|
if (e(y), y.crit !== void 0)
|
|
758
758
|
throw new a('unexpected JWT "crit" header parameter');
|
|
759
|
-
const
|
|
760
|
-
let
|
|
759
|
+
const _ = A(u);
|
|
760
|
+
let b;
|
|
761
761
|
if (n !== Se) {
|
|
762
|
-
|
|
762
|
+
b = await n(y);
|
|
763
763
|
const E = `${o}.${i}`;
|
|
764
|
-
if (!await crypto.subtle.verify(ve(
|
|
764
|
+
if (!await crypto.subtle.verify(ve(b), b, _, k(E)))
|
|
765
765
|
throw new a("JWT signature verification failed");
|
|
766
766
|
}
|
|
767
767
|
let h;
|
|
768
768
|
try {
|
|
769
|
-
h = JSON.parse(A(
|
|
769
|
+
h = JSON.parse(k(A(i)));
|
|
770
770
|
} catch (E) {
|
|
771
771
|
throw new a("failed to parse JWT Payload body as base64url encoded JSON", { cause: E });
|
|
772
772
|
}
|
|
@@ -791,7 +791,7 @@ async function bt(t, e, n, r, s) {
|
|
|
791
791
|
}
|
|
792
792
|
if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
|
|
793
793
|
throw new a('unexpected JWT "aud" (audience) claim type');
|
|
794
|
-
return { header: y, claims: h, signature:
|
|
794
|
+
return { header: y, claims: h, signature: _, key: b };
|
|
795
795
|
}
|
|
796
796
|
function vt(t, e, n) {
|
|
797
797
|
if (t !== void 0) {
|
|
@@ -814,7 +814,7 @@ function T(t, e) {
|
|
|
814
814
|
return n;
|
|
815
815
|
}
|
|
816
816
|
const St = Symbol(), Tt = Symbol();
|
|
817
|
-
function
|
|
817
|
+
function At(t, e, n, r) {
|
|
818
818
|
if (L(t), C(e), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
|
|
819
819
|
throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
|
|
820
820
|
if (T(n, "response"))
|
|
@@ -833,7 +833,7 @@ function kt(t, e, n, r) {
|
|
|
833
833
|
case St:
|
|
834
834
|
break;
|
|
835
835
|
default:
|
|
836
|
-
if (!
|
|
836
|
+
if (!m(r))
|
|
837
837
|
throw new a('"expectedState" must be a non-empty string');
|
|
838
838
|
if (o === void 0)
|
|
839
839
|
throw new a('response parameter "state" missing');
|
|
@@ -860,7 +860,7 @@ class ue extends O {
|
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
const F = "code-verifier";
|
|
863
|
-
class
|
|
863
|
+
class kt extends Le {
|
|
864
864
|
constructor(e, n) {
|
|
865
865
|
super(), this.callbackUrlPath = e, this.initialize = n;
|
|
866
866
|
}
|
|
@@ -885,19 +885,20 @@ class Et {
|
|
|
885
885
|
redirectToAfterSignIn: u,
|
|
886
886
|
redirectToAfterSignOut: f
|
|
887
887
|
}) {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
888
|
+
g(this, "client");
|
|
889
|
+
g(this, "issuer");
|
|
890
|
+
g(this, "authorizationEndpoint");
|
|
891
|
+
g(this, "tokenEndpoint");
|
|
892
|
+
g(this, "authorizationServer");
|
|
893
|
+
g(this, "tokens");
|
|
894
|
+
g(this, "callbackUrlPath", "/oauth/callback");
|
|
895
|
+
g(this, "logoutRedirectUrlPath", "/");
|
|
896
|
+
g(this, "onAuthorizationUrl");
|
|
897
|
+
g(this, "redirectToAfterSignUp");
|
|
898
|
+
g(this, "redirectToAfterSignIn");
|
|
899
|
+
g(this, "redirectToAfterSignOut");
|
|
900
|
+
g(this, "audience");
|
|
901
|
+
g(this, "signOut", async () => {
|
|
901
902
|
ne.setState({
|
|
902
903
|
isAuthenticated: !1,
|
|
903
904
|
isPending: !1,
|
|
@@ -913,11 +914,11 @@ class Et {
|
|
|
913
914
|
n.toString()
|
|
914
915
|
)) : r = n;
|
|
915
916
|
});
|
|
916
|
-
|
|
917
|
+
g(this, "handleCallback", async () => {
|
|
917
918
|
const e = new URL(window.location.href), n = e.searchParams.get("state"), r = sessionStorage.getItem(F);
|
|
918
919
|
if (sessionStorage.removeItem(F), !r)
|
|
919
920
|
return;
|
|
920
|
-
const s = await this.getAuthServer(), o =
|
|
921
|
+
const s = await this.getAuthServer(), o = At(
|
|
921
922
|
s,
|
|
922
923
|
this.client,
|
|
923
924
|
e.searchParams,
|
|
@@ -942,16 +943,16 @@ class Et {
|
|
|
942
943
|
u
|
|
943
944
|
);
|
|
944
945
|
this.setTokensFromResponse(f);
|
|
945
|
-
const y = await this.getAccessToken(),
|
|
946
|
+
const y = await this.getAccessToken(), b = await (await st(
|
|
946
947
|
s,
|
|
947
948
|
this.client,
|
|
948
949
|
y
|
|
949
950
|
)).json(), h = {
|
|
950
|
-
sub:
|
|
951
|
-
email:
|
|
952
|
-
name:
|
|
953
|
-
emailVerified:
|
|
954
|
-
pictureUrl:
|
|
951
|
+
sub: b.sub,
|
|
952
|
+
email: b.email,
|
|
953
|
+
name: b.name,
|
|
954
|
+
emailVerified: b.email_verified ?? !1,
|
|
955
|
+
pictureUrl: b.picture
|
|
955
956
|
};
|
|
956
957
|
return ne.setState({
|
|
957
958
|
isAuthenticated: !0,
|
|
@@ -1000,7 +1001,8 @@ class Et {
|
|
|
1000
1001
|
}
|
|
1001
1002
|
async signUp({ redirectTo: e } = {}) {
|
|
1002
1003
|
return this.authorize({
|
|
1003
|
-
redirectTo: e ?? this.redirectToAfterSignUp
|
|
1004
|
+
redirectTo: e ?? this.redirectToAfterSignUp,
|
|
1005
|
+
isSignUp: !0
|
|
1004
1006
|
});
|
|
1005
1007
|
}
|
|
1006
1008
|
async signIn({ redirectTo: e } = {}) {
|
|
@@ -1009,27 +1011,31 @@ class Et {
|
|
|
1009
1011
|
});
|
|
1010
1012
|
}
|
|
1011
1013
|
async authorize({
|
|
1012
|
-
redirectTo: e
|
|
1014
|
+
redirectTo: e,
|
|
1015
|
+
isSignUp: n = !1
|
|
1013
1016
|
}) {
|
|
1014
|
-
var
|
|
1015
|
-
const
|
|
1016
|
-
if (!
|
|
1017
|
+
var y, _;
|
|
1018
|
+
const r = "S256", s = await this.getAuthServer();
|
|
1019
|
+
if (!s.authorization_endpoint)
|
|
1017
1020
|
throw new O("No authorization endpoint");
|
|
1018
|
-
const
|
|
1019
|
-
sessionStorage.setItem(F,
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1021
|
+
const o = $e(), i = await Me(o);
|
|
1022
|
+
sessionStorage.setItem(F, o);
|
|
1023
|
+
const u = new URL(
|
|
1024
|
+
s.authorization_endpoint
|
|
1022
1025
|
);
|
|
1023
1026
|
sessionStorage.setItem("redirect-to", e);
|
|
1024
|
-
const
|
|
1025
|
-
if (
|
|
1027
|
+
const f = new URL(window.location.origin);
|
|
1028
|
+
if (f.pathname = this.callbackUrlPath, f.search = "", u.searchParams.set("client_id", this.client.client_id), u.searchParams.set("redirect_uri", f.toString()), u.searchParams.set("response_type", "code"), u.searchParams.set("scope", "openid+profile+email"), u.searchParams.set("code_challenge", i), u.searchParams.set(
|
|
1026
1029
|
"code_challenge_method",
|
|
1027
|
-
|
|
1028
|
-
), this.audience &&
|
|
1029
|
-
|
|
1030
|
-
|
|
1030
|
+
r
|
|
1031
|
+
), this.audience && u.searchParams.set("audience", this.audience), (y = this.onAuthorizationUrl) == null || y.call(this, u, {
|
|
1032
|
+
isSignIn: !n,
|
|
1033
|
+
isSignUp: n
|
|
1034
|
+
}), ((_ = s.code_challenge_methods_supported) == null ? void 0 : _.includes("S256")) !== !0) {
|
|
1035
|
+
const b = Fe();
|
|
1036
|
+
u.searchParams.set("state", b);
|
|
1031
1037
|
}
|
|
1032
|
-
location.href =
|
|
1038
|
+
location.href = u.href;
|
|
1033
1039
|
}
|
|
1034
1040
|
async getAccessToken() {
|
|
1035
1041
|
const e = await this.getAuthServer();
|
|
@@ -1052,7 +1058,7 @@ class Et {
|
|
|
1052
1058
|
return this.tokens.accessToken;
|
|
1053
1059
|
}
|
|
1054
1060
|
getAuthenticationPlugin() {
|
|
1055
|
-
return new
|
|
1061
|
+
return new kt(
|
|
1056
1062
|
this.callbackUrlPath,
|
|
1057
1063
|
async (e, n) => {
|
|
1058
1064
|
if (typeof localStorage < "u" && localStorage.getItem("auto-login"))
|