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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.76",
3
+ "version": "0.3.0-dev.77",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -4,6 +4,14 @@ import { useAuthState } from "../state.js";
4
4
  import { OpenIDAuthenticationProvider } from "./openid.js";
5
5
 
6
6
  class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
7
+ onAuthorizationUrl = async (
8
+ url: URL,
9
+ { isSignUp }: { isSignUp: boolean },
10
+ ) => {
11
+ if (isSignUp) {
12
+ url.searchParams.set("screen_hint", "signup");
13
+ }
14
+ };
7
15
  signOut = async (): Promise<void> => {
8
16
  useAuthState.setState({
9
17
  isAuthenticated: false,
@@ -49,6 +49,10 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
49
49
 
50
50
  protected callbackUrlPath = "/oauth/callback";
51
51
  protected logoutRedirectUrlPath = "/";
52
+ protected onAuthorizationUrl?: (
53
+ authorizationUrl: URL,
54
+ options: { isSignIn: boolean; isSignUp: boolean },
55
+ ) => void;
52
56
  private readonly redirectToAfterSignUp: string;
53
57
  private readonly redirectToAfterSignIn: string;
54
58
  private readonly redirectToAfterSignOut: string;
@@ -126,6 +130,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
126
130
  async signUp({ redirectTo }: { redirectTo?: string } = {}) {
127
131
  return this.authorize({
128
132
  redirectTo: redirectTo ?? this.redirectToAfterSignUp,
133
+ isSignUp: true,
129
134
  });
130
135
  }
131
136
 
@@ -137,8 +142,10 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
137
142
 
138
143
  private async authorize({
139
144
  redirectTo,
145
+ isSignUp = false,
140
146
  }: {
141
147
  redirectTo: string;
148
+ isSignUp?: boolean;
142
149
  }): Promise<void> {
143
150
  const code_challenge_method = "S256";
144
151
  const authorizationServer = await this.getAuthServer();
@@ -181,6 +188,11 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
181
188
  authorizationUrl.searchParams.set("audience", this.audience);
182
189
  }
183
190
 
191
+ this.onAuthorizationUrl?.(authorizationUrl, {
192
+ isSignIn: !isSignUp,
193
+ isSignUp,
194
+ });
195
+
184
196
  /**
185
197
  * We cannot be sure the AS supports PKCE so we're going to use state too. Use of PKCE is
186
198
  * backwards compatible even if the AS doesn't support it which is why we're using it regardless.