prostgles-client 4.0.425 → 4.0.427

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.
@@ -1,6 +1,31 @@
1
- import type { AuthHandler } from "../getAuthHandler";
2
- export declare const useAuthState: ({ auth }: {
1
+ import type { AuthHandler, ConfirmEmail, PasswordLogin, PasswordRegister } from "../getAuthHandler";
2
+ type PasswordLoginDataAndFunc = {
3
+ onCall: PasswordLogin;
4
+ result: undefined | Awaited<ReturnType<PasswordLogin>>;
5
+ } & Parameters<PasswordLogin>[0];
6
+ type PasswordRegisterDataAndFunc = {
7
+ onCall: PasswordRegister;
8
+ result: undefined | Awaited<ReturnType<PasswordRegister>>;
9
+ } & Parameters<PasswordRegister>[0];
10
+ type FormData = ({
11
+ type: "login";
12
+ } & PasswordLoginDataAndFunc) | ({
13
+ type: "loginTotp";
14
+ } & PasswordLoginDataAndFunc) | ({
15
+ type: "loginTotpRecovery";
16
+ } & PasswordLoginDataAndFunc) | ({
17
+ type: "registerWithPassword";
18
+ } & PasswordRegisterDataAndFunc) | ({
19
+ type: "registerWithPasswordConfirmationCode";
20
+ onCall: ConfirmEmail;
21
+ result: undefined | Awaited<ReturnType<ConfirmEmail>>;
22
+ } & Parameters<ConfirmEmail>[0]);
23
+ type FormStates = FormData["type"];
24
+ export declare const useAuthState: ({ auth, initialState, initialUsername, invitationToken, }: {
3
25
  auth: AuthHandler;
26
+ initialState?: FormStates;
27
+ initialUsername?: string;
28
+ invitationToken?: string;
4
29
  }) => {
5
30
  formHandlers: {
6
31
  state: "login" | "loginTotp" | "loginTotpRecovery" | "registerWithPassword" | "registerWithPasswordConfirmationCode";
@@ -44,7 +69,7 @@ export declare const useAuthState: ({ auth }: {
44
69
  };
45
70
  }>) => Promise<import("./authRequest").ClientAuthResponse<"login">>) | undefined;
46
71
  } | {
47
- onCall: (data: import("prostgles-types").JSONB.GetObjectType<{
72
+ onCall: ((data: import("prostgles-types").JSONB.GetObjectType<{
48
73
  readonly invitationToken: {
49
74
  readonly type: "string";
50
75
  readonly optional: true;
@@ -58,7 +83,7 @@ export declare const useAuthState: ({ auth }: {
58
83
  readonly type: "string";
59
84
  readonly optional: true;
60
85
  };
61
- }>) => Promise<import("./authRequest").ClientAuthResponse<"register">>;
86
+ }>) => Promise<import("./authRequest").ClientAuthResponse<"register">>) | undefined;
62
87
  result: ({
63
88
  code: "server-error" | "rate-limit-exceeded" | "something-went-wrong";
64
89
  success: false;
@@ -505,4 +530,5 @@ export declare const ERR_CODE_MESSAGES: {
505
530
  "expired-otp-code": string;
506
531
  "provider-issue": string;
507
532
  };
533
+ export {};
508
534
  //# sourceMappingURL=useAuthState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../lib/auth/useAuthState.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAiD,MAAM,mBAAmB,CAAC;AA6BpG,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa/C,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AAQ,CAAC,MAAM,CAAC,CAAC;AAInC,eAAO,MAAM,YAAY,GAAI,2DAK1B;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAaY,OAAO;iBACP,MAAM;;;CAwNlB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC7B,CAAC"}
@@ -5,10 +5,10 @@ const prostgles_types_1 = require("prostgles-types");
5
5
  const reactImports_1 = require("../hooks/reactImports");
6
6
  const { useEffect, useState } = reactImports_1.reactImports;
7
7
  const loginStates = ["login", "loginTotp", "loginTotpRecovery"];
8
- const useAuthState = ({ auth }) => {
8
+ const useAuthState = ({ auth, initialState = "login", initialUsername = "", invitationToken, }) => {
9
9
  const [loading, setIsLoading] = useState(false);
10
- const [state, setState] = useState("login");
11
- const [username, setUsername] = useState("");
10
+ const [state, setState] = useState(initialState);
11
+ const [username, setUsername] = useState(initialUsername);
12
12
  const [password, setPassword] = useState("");
13
13
  const [emailVerificationCode, setEmailVerificationCode] = useState("");
14
14
  const [totpToken, setTotpToken] = useState("");
@@ -30,16 +30,18 @@ const useAuthState = ({ auth }) => {
30
30
  useEffect(() => {
31
31
  _setError("");
32
32
  }, [username, password, totpToken, totpRecoveryCode, confirmPassword]);
33
- const showPassword = (state === "registerWithPassword" && auth.signupWithEmailAndPassword) ||
33
+ const canRegister = auth.signupWithEmail && (!auth.signupWithEmailOptions?.requireInvitation || invitationToken);
34
+ const requiresPassword = auth.signupWithEmailOptions?.requirePassword ?? true;
35
+ const showPassword = (state === "registerWithPassword" && canRegister && requiresPassword) ||
34
36
  (state === "login" && auth.loginType === "email" && usernamesWithPassword.includes(username)) ||
35
37
  (state === "login" && auth.loginType === "email+password");
36
- const showUsername = (state === "registerWithPassword" && auth.signupWithEmailAndPassword) ||
38
+ const showUsername = (state === "registerWithPassword" && canRegister) ||
37
39
  (state === "login" && auth.loginType === "email") ||
38
40
  (state === "login" && auth.loginType === "email+password");
39
- const showConfirmPassword = state === "registerWithPassword" && auth.signupWithEmailAndPassword;
41
+ const showConfirmPassword = state === "registerWithPassword" && showPassword;
40
42
  const showTotpCode = state === "loginTotp" && auth.login;
41
43
  const showTotpRecoveryCode = state === "loginTotpRecovery" && auth.login;
42
- const showEmailVerificationCode = state === "registerWithPasswordConfirmationCode" && auth.signupWithEmailAndPassword;
44
+ const showEmailVerificationCode = state === "registerWithPasswordConfirmationCode" && auth.confirmEmail;
43
45
  const show = {
44
46
  username: Boolean(showUsername),
45
47
  password: Boolean(showPassword),
@@ -69,13 +71,13 @@ const useAuthState = ({ auth }) => {
69
71
  : state === "login" && auth.loginType === "email+password" ? commonFormHandlers
70
72
  : state === "loginTotp" && auth.login ? commonFormHandlers
71
73
  : state === "loginTotpRecovery" && auth.login ? commonFormHandlers
72
- : state === "registerWithPassword" && auth.signupWithEmailAndPassword ?
74
+ : state === "registerWithPassword" && canRegister ?
73
75
  {
74
76
  ...commonFormHandlers,
75
- onCall: auth.signupWithEmailAndPassword,
77
+ onCall: auth.signupWithEmail,
76
78
  result,
77
79
  }
78
- : state === "registerWithPasswordConfirmationCode" && auth.signupWithEmailAndPassword ?
80
+ : state === "registerWithPasswordConfirmationCode" && auth.confirmEmail ?
79
81
  {
80
82
  ...commonFormHandlers,
81
83
  onCall: () => {
@@ -101,6 +103,7 @@ const useAuthState = ({ auth }) => {
101
103
  remember_me: false,
102
104
  totp_token: isOnlyShowingUsername ? undefined : totpToken,
103
105
  totp_recovery_code: isOnlyShowingUsername ? undefined : totpRecoveryCode,
106
+ ...(state === "registerWithPassword" && invitationToken && { invitationToken }),
104
107
  };
105
108
  const errorMap = {
106
109
  "no match": "Invalid credentials",
@@ -135,7 +138,7 @@ const useAuthState = ({ auth }) => {
135
138
  if (!username) {
136
139
  return setError("Email cannot be empty");
137
140
  }
138
- if (formHandlers.state === "registerWithPassword") {
141
+ if (formHandlers.state === "registerWithPassword" && requiresPassword) {
139
142
  if (!password) {
140
143
  return setError("Password cannot be empty");
141
144
  }
@@ -171,7 +174,7 @@ const useAuthState = ({ auth }) => {
171
174
  window.location.href = res.redirect_url;
172
175
  }
173
176
  if (state === "registerWithPassword") {
174
- setState("registerWithPasswordConfirmationCode");
177
+ setState(res.code === "email-verified" ? "login" : "registerWithPasswordConfirmationCode");
175
178
  }
176
179
  let message = (res.code && SIGNUP_CODE_MESSAGES[res.code]) ?? res.message ?? "Success";
177
180
  if (formHandlers.state === "registerWithPasswordConfirmationCode") {
@@ -23,6 +23,9 @@ type LoginSignupOptions = Pick<AuthSocketSchema, "providers" | "preferredLogin">
23
23
  loginWithProvider: undefined | WithProviderLogin;
24
24
  login: undefined | PasswordLogin;
25
25
  loginType: LocalLoginMode | undefined;
26
+ signupWithEmail: undefined | ClientAuthCalls["register"];
27
+ signupWithEmailOptions: AuthSocketSchema["signupWithEmail"];
28
+ /** @deprecated Use signupWithEmail and signupWithEmailOptions.requireInvitation. */
26
29
  signupWithEmailAndPassword: undefined | PasswordRegister;
27
30
  confirmEmail: undefined | ConfirmEmail;
28
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getAuthHandler.d.ts","sourceRoot":"","sources":["../lib/getAuthHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE5D,KAAK,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,aAAa,GAAG,UAAU,CAAC,GAAG;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACvC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC;AAEzE,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAChE,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC,UAAU,C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gB,CAAC,GAAG;IACjF,iBAAiB,EAAE,SAAS,GAAG,iBAAiB,CAAC;IACjD,KAAK,EAAE,SAAS,GAAG,aAAa,CAAC;IACjC,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,eAAe,EAAE,SAAS,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzD,sBAAsB,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAC5D,oFAAoF;IACpF,0BAA0B,EAAE,SAAS,GAAG,gBAAgB,CAAC;IACzD,YAAY,EAAE,SAAS,GAAG,YAAY,CAAC;CACxC,CAAC;AAEF,KAAK,kBAAkB,GAAG,kBAAkB,GAAG;IAC7C,UAAU,EAAE,KAAK,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,kBAAkB,GAAG;IAC3E,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,kBAAkB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAEnG,eAAO,MAAM,cAAc,GAAI,mEAM5B,IAAI,KAAG,WAkGT,CAAC"}
@@ -14,10 +14,17 @@ const getAuthHandler = ({ authData: authConfig, socket, onReload, endpoint, ...a
14
14
  url = `${endpoint}${url}`;
15
15
  return url;
16
16
  };
17
+ const legacySignupWithEmail = authConfig?.signupWithEmailAndPassword;
18
+ const signupWithEmailOptions = authConfig?.signupWithEmail ??
19
+ (legacySignupWithEmail && {
20
+ ...legacySignupWithEmail,
21
+ requirePassword: true,
22
+ requireInvitation: false,
23
+ });
17
24
  const authCalls = (0, getAuthCalls_1.getAuthCalls)({
18
25
  login: authConfig?.login?.loginRoute,
19
- register: authConfig?.signupWithEmailAndPassword?.url,
20
- magicLinkOrOTP: authConfig?.signupWithEmailAndPassword?.emailConfirmationRoute,
26
+ register: signupWithEmailOptions?.url,
27
+ magicLinkOrOTP: signupWithEmailOptions?.emailConfirmationRoute,
21
28
  logout: authConfig?.login?.logoutRoute,
22
29
  }, urlWithEndpointAndSearch, authOpts);
23
30
  if (authConfig?.pathGuard && prostgles_1.isClientSide) {
@@ -46,12 +53,14 @@ const getAuthHandler = ({ authData: authConfig, socket, onReload, endpoint, ...a
46
53
  login: undefined,
47
54
  preferredLogin: authConfig?.preferredLogin,
48
55
  loginWithProvider: undefined,
56
+ signupWithEmail: signupWithEmailOptions && authCalls.register,
57
+ signupWithEmailOptions,
49
58
  signupWithEmailAndPassword: undefined,
50
59
  confirmEmail: undefined,
51
60
  providers: authConfig?.providers,
52
61
  };
53
62
  if (authConfig) {
54
- const { providers, signupWithEmailAndPassword, login } = authConfig;
63
+ const { providers, login } = authConfig;
55
64
  loginSignupOptions.loginWithProvider =
56
65
  (0, prostgles_types_1.isEmpty)(providers) ? undefined : (providers &&
57
66
  Object.entries(providers).reduce((acc, [provider, { url }]) => {
@@ -62,8 +71,10 @@ const getAuthHandler = ({ authData: authConfig, socket, onReload, endpoint, ...a
62
71
  }, {}));
63
72
  loginSignupOptions.login = login && authCalls.login;
64
73
  loginSignupOptions.signupWithEmailAndPassword =
65
- signupWithEmailAndPassword && authCalls.register;
66
- loginSignupOptions.confirmEmail = signupWithEmailAndPassword && authCalls.magicLinkOrOTP;
74
+ signupWithEmailOptions && !signupWithEmailOptions.requireInvitation ?
75
+ authCalls.register
76
+ : undefined;
77
+ loginSignupOptions.confirmEmail = signupWithEmailOptions && authCalls.magicLinkOrOTP;
67
78
  }
68
79
  if (!authConfig?.user) {
69
80
  return {