prostgles-client 4.0.422 → 4.0.425

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.
@@ -0,0 +1,7 @@
1
+ import { type AuthInput, type AuthOperation, type AuthOutput, type CommonAuthFailure } from "prostgles-types";
2
+ export declare const authRequest: <Operation extends AuthOperation>(operation: Operation, path: string, data: AuthInput<Operation>, method: "GET" | "POST", { credentials, redirect }: Pick<Partial<Request>, "credentials" | "redirect">) => Promise<ClientAuthResponse<Operation>>;
3
+ export type ClientAuthResponse<Operation extends AuthOperation> = (AuthOutput<Operation> | CommonAuthFailure) & {
4
+ /** Obtained from the HTTP redirect, rather than the response body. */
5
+ redirect_url?: string;
6
+ };
7
+ //# sourceMappingURL=authRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authRequest.d.ts","sourceRoot":"","sources":["../../lib/auth/authRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,WAAW,GAAU,SAAS,SAAS,aAAa,EAC/D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,MAAM,SAAS,CAAC,SAAS,CAAC,EAC1B,QAAQ,KAAK,GAAG,MAAM,EACtB,2BAA2B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,UAAU,CAAC,KAC5E,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAqDvC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,aAAa,IAAI,CAC9D,UAAU,CAAC,SAAS,CAAC,GACrB,iBAAiB,CACpB,GAAG;IACF,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authRequest = void 0;
4
+ const prostgles_types_1 = require("prostgles-types");
5
+ const authRequest = async (operation, path, data, method, { credentials, redirect }) => {
6
+ const rawResponse = await fetch(path, {
7
+ method,
8
+ headers: {
9
+ Accept: "application/json",
10
+ "Content-Type": "application/json",
11
+ },
12
+ ...(method !== "GET" && { body: JSON.stringify(data) }),
13
+ credentials,
14
+ redirect,
15
+ });
16
+ const responseText = await rawResponse.text();
17
+ let response;
18
+ try {
19
+ response = JSON.parse(responseText);
20
+ }
21
+ catch {
22
+ if (rawResponse.ok && rawResponse.redirected) {
23
+ response = { success: true };
24
+ }
25
+ else {
26
+ return {
27
+ success: false,
28
+ code: "something-went-wrong",
29
+ message: responseText || rawResponse.statusText,
30
+ };
31
+ }
32
+ }
33
+ if (rawResponse.ok &&
34
+ rawResponse.redirected &&
35
+ (!(0, prostgles_types_1.isObject)(response) || !("success" in response))) {
36
+ response = { success: true };
37
+ }
38
+ const validation = (0, prostgles_types_1.getJSONBSchemaValidationError)(prostgles_types_1.authContract[operation].response, response, { allowExtraProperties: true });
39
+ if (validation.error !== undefined || (!rawResponse.ok && validation.data.success)) {
40
+ return {
41
+ success: false,
42
+ code: "something-went-wrong",
43
+ message: "Unexpected authentication response was sent by the server: " + validation.error,
44
+ };
45
+ }
46
+ return {
47
+ ...validation.data,
48
+ ...(rawResponse.redirected && { redirect_url: rawResponse.url }),
49
+ };
50
+ };
51
+ exports.authRequest = authRequest;
@@ -0,0 +1,7 @@
1
+ import type { AuthCalls, AuthOperation } from "prostgles-types";
2
+ import { authRequest, type ClientAuthResponse } from "./authRequest";
3
+ export declare const getAuthCalls: (routes: Record<AuthOperation, string | undefined>, getRequestURL: (route: string) => string, options: Parameters<typeof authRequest>[4]) => ClientAuthCalls;
4
+ export type ClientAuthCalls = {
5
+ [Operation in AuthOperation]: (...args: Parameters<AuthCalls[Operation]>) => Promise<ClientAuthResponse<Operation>>;
6
+ };
7
+ //# sourceMappingURL=getAuthCalls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAuthCalls.d.ts","sourceRoot":"","sources":["../../lib/auth/getAuthCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,eAAO,MAAM,YAAY,GACvB,QAAQ,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,EACjD,eAAe,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACxC,SAAS,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,KACzC,eAeF,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;KAC3B,SAAS,IAAI,aAAa,GAAG,CAC5B,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KACtC,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAuthCalls = void 0;
4
+ const authRequest_1 = require("./authRequest");
5
+ const getAuthCalls = (routes, getRequestURL, options) => {
6
+ const createCall = (operation) => async (data) => {
7
+ const route = routes[operation];
8
+ if (!route)
9
+ throw new Error("Unexpected");
10
+ return (0, authRequest_1.authRequest)(operation, getRequestURL(route), data, "POST", options);
11
+ };
12
+ return {
13
+ login: createCall("login"),
14
+ register: createCall("register"),
15
+ magicLinkOrOTP: createCall("magicLinkOrOTP"),
16
+ logout: createCall("logout"),
17
+ };
18
+ };
19
+ exports.getAuthCalls = getAuthCalls;
@@ -1,5 +1,4 @@
1
- import { type AuthResponse } from "prostgles-types";
2
- import type { AuthHandler, PasswordLogin, PasswordRegister } from "../getAuthHandler";
1
+ import type { AuthHandler } from "../getAuthHandler";
3
2
  export declare const useAuthState: ({ auth }: {
4
3
  auth: AuthHandler;
5
4
  }) => {
@@ -25,51 +24,263 @@ export declare const useAuthState: ({ auth }: {
25
24
  totpRecoveryCode: boolean;
26
25
  emailVerificationCode: boolean;
27
26
  };
28
- onCall: PasswordLogin | undefined;
27
+ onCall: ((data: import("prostgles-types").JSONB.GetObjectType<{
28
+ readonly remember_me: {
29
+ readonly type: "boolean";
30
+ readonly optional: true;
31
+ };
32
+ readonly totp_token: {
33
+ readonly type: "string";
34
+ readonly optional: true;
35
+ };
36
+ readonly totp_recovery_code: {
37
+ readonly type: "string";
38
+ readonly optional: true;
39
+ };
40
+ readonly username: "string";
41
+ readonly password: {
42
+ readonly type: "string";
43
+ readonly optional: true;
44
+ };
45
+ }>) => Promise<import("./authRequest").ClientAuthResponse<"login">>) | undefined;
29
46
  } | {
30
- onCall: PasswordRegister;
31
- result: (import("prostgles-types").CommonAuthFailure & {
47
+ onCall: (data: import("prostgles-types").JSONB.GetObjectType<{
48
+ readonly invitationToken: {
49
+ readonly type: "string";
50
+ readonly optional: true;
51
+ };
52
+ readonly totpTokenConfirmation: {
53
+ readonly type: "string";
54
+ readonly optional: true;
55
+ };
56
+ readonly username: "string";
57
+ readonly password: {
58
+ readonly type: "string";
59
+ readonly optional: true;
60
+ };
61
+ }>) => Promise<import("./authRequest").ClientAuthResponse<"register">>;
62
+ result: ({
63
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong";
64
+ success: false;
65
+ } & {
66
+ message?: string | undefined;
67
+ } & {
32
68
  redirect_url?: string;
33
69
  }) | ({
70
+ success: true;
71
+ } & {
72
+ code?: undefined;
73
+ message?: string | undefined;
74
+ token?: string | undefined;
75
+ } & {
76
+ redirect_url?: string;
77
+ }) | ({
78
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
34
79
  success: false;
35
- code: "no-match";
36
- message?: string;
80
+ } & {
81
+ message?: string | undefined;
82
+ } & {
83
+ redirect_url?: string;
84
+ }) | ({
85
+ code: "email-verification-code-sent" | "magic-link-sent";
86
+ success: true;
87
+ } & {
88
+ message?: string | undefined;
37
89
  } & {
38
90
  redirect_url?: string;
39
91
  }) | ({
92
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
40
93
  success: false;
41
- code: "inactive-account";
42
- message?: string;
94
+ } & {
95
+ message?: string | undefined;
43
96
  } & {
44
97
  redirect_url?: string;
45
98
  }) | ({
99
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "provider-issue";
46
100
  success: false;
47
- code: "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
48
- message?: string;
101
+ } & {
102
+ message?: string | undefined;
49
103
  } & {
50
104
  redirect_url?: string;
51
- }) | (AuthResponse.AuthSuccess & {
105
+ }) | ({
106
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
107
+ success: false;
108
+ } & {
109
+ message?: string | undefined;
110
+ } & {
52
111
  redirect_url?: string;
53
- }) | (AuthResponse.MagicLinkAuthSuccess & {
112
+ }) | ({
113
+ code: "email-verification-code-sent" | "already-registered-but-did-not-confirm-email" | "email-verified";
114
+ success: true;
115
+ } & {
116
+ message?: string | undefined;
117
+ } & {
54
118
  redirect_url?: string;
55
119
  }) | ({
120
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "inactive-account" | "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code";
56
121
  success: false;
57
- code: "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
58
- message?: string;
122
+ } & {
123
+ message?: string | undefined;
59
124
  } & {
60
125
  redirect_url?: string;
61
126
  }) | ({
127
+ success: true;
128
+ } & {
129
+ code?: undefined;
130
+ message?: string | undefined;
131
+ token?: string | undefined;
132
+ } & {
133
+ redirect_url?: string;
134
+ }) | ({
135
+ code: "email-verified";
136
+ success: true;
137
+ } & {
138
+ message?: string | undefined;
139
+ } & {
140
+ redirect_url?: string;
141
+ }) | ({
142
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
62
143
  success: false;
63
- code: "provider-issue";
64
- message?: string;
144
+ } & {
145
+ message?: string | undefined;
65
146
  } & {
66
147
  redirect_url?: string;
67
- }) | (AuthResponse.PasswordRegisterSuccess & {
148
+ }) | ({
149
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
150
+ success: false;
151
+ } & {
152
+ message?: string | undefined;
153
+ } & {
68
154
  redirect_url?: string;
69
155
  }) | ({
156
+ code: "invalid-email";
70
157
  success: false;
71
- code: "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code" | "inactive-account";
72
- message?: string;
158
+ } & {
159
+ message?: string | undefined;
160
+ } & {
161
+ redirect_url?: string;
162
+ }) | undefined;
163
+ state: "login" | "loginTotp" | "loginTotpRecovery" | "registerWithPassword" | "registerWithPasswordConfirmationCode";
164
+ username: string;
165
+ setUsername: import("react").Dispatch<import("react").SetStateAction<string>>;
166
+ password: string;
167
+ setPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
168
+ totpToken: string;
169
+ setTotpToken: import("react").Dispatch<import("react").SetStateAction<string>>;
170
+ totpRecoveryCode: string;
171
+ setTotpRecoveryCode: import("react").Dispatch<import("react").SetStateAction<string>>;
172
+ confirmPassword: string;
173
+ setConfirmPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
174
+ emailVerificationCode: string;
175
+ setEmailVerificationCode: import("react").Dispatch<import("react").SetStateAction<string>>;
176
+ show: {
177
+ username: boolean;
178
+ password: boolean;
179
+ confirmPassword: boolean;
180
+ totpCode: boolean;
181
+ totpRecoveryCode: boolean;
182
+ emailVerificationCode: boolean;
183
+ };
184
+ } | {
185
+ onCall: () => Promise<import("./authRequest").ClientAuthResponse<"magicLinkOrOTP">>;
186
+ result: ({
187
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong";
188
+ success: false;
189
+ } & {
190
+ message?: string | undefined;
191
+ } & {
192
+ redirect_url?: string;
193
+ }) | ({
194
+ success: true;
195
+ } & {
196
+ code?: undefined;
197
+ message?: string | undefined;
198
+ token?: string | undefined;
199
+ } & {
200
+ redirect_url?: string;
201
+ }) | ({
202
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
203
+ success: false;
204
+ } & {
205
+ message?: string | undefined;
206
+ } & {
207
+ redirect_url?: string;
208
+ }) | ({
209
+ code: "email-verification-code-sent" | "magic-link-sent";
210
+ success: true;
211
+ } & {
212
+ message?: string | undefined;
213
+ } & {
214
+ redirect_url?: string;
215
+ }) | ({
216
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
217
+ success: false;
218
+ } & {
219
+ message?: string | undefined;
220
+ } & {
221
+ redirect_url?: string;
222
+ }) | ({
223
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "provider-issue";
224
+ success: false;
225
+ } & {
226
+ message?: string | undefined;
227
+ } & {
228
+ redirect_url?: string;
229
+ }) | ({
230
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
231
+ success: false;
232
+ } & {
233
+ message?: string | undefined;
234
+ } & {
235
+ redirect_url?: string;
236
+ }) | ({
237
+ code: "email-verification-code-sent" | "already-registered-but-did-not-confirm-email" | "email-verified";
238
+ success: true;
239
+ } & {
240
+ message?: string | undefined;
241
+ } & {
242
+ redirect_url?: string;
243
+ }) | ({
244
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "inactive-account" | "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code";
245
+ success: false;
246
+ } & {
247
+ message?: string | undefined;
248
+ } & {
249
+ redirect_url?: string;
250
+ }) | ({
251
+ success: true;
252
+ } & {
253
+ code?: undefined;
254
+ message?: string | undefined;
255
+ token?: string | undefined;
256
+ } & {
257
+ redirect_url?: string;
258
+ }) | ({
259
+ code: "email-verified";
260
+ success: true;
261
+ } & {
262
+ message?: string | undefined;
263
+ } & {
264
+ redirect_url?: string;
265
+ }) | ({
266
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
267
+ success: false;
268
+ } & {
269
+ message?: string | undefined;
270
+ } & {
271
+ redirect_url?: string;
272
+ }) | ({
273
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
274
+ success: false;
275
+ } & {
276
+ message?: string | undefined;
277
+ } & {
278
+ redirect_url?: string;
279
+ }) | ({
280
+ code: "invalid-email";
281
+ success: false;
282
+ } & {
283
+ message?: string | undefined;
73
284
  } & {
74
285
  redirect_url?: string;
75
286
  }) | undefined;
@@ -99,89 +310,164 @@ export declare const useAuthState: ({ auth }: {
99
310
  setState: import("react").Dispatch<import("react").SetStateAction<"login" | "loginTotp" | "loginTotpRecovery" | "registerWithPassword" | "registerWithPasswordConfirmationCode">>;
100
311
  state: "login" | "loginTotp" | "loginTotpRecovery" | "registerWithPassword" | "registerWithPasswordConfirmationCode";
101
312
  loading: boolean;
102
- onAuthCall: () => Promise<void | (import("prostgles-types").CommonAuthFailure & {
313
+ onAuthCall: () => Promise<void | ({
314
+ success: true;
315
+ } & {
316
+ code?: undefined;
317
+ message?: string | undefined;
318
+ token?: string | undefined;
319
+ } & {
103
320
  redirect_url?: string;
104
321
  }) | ({
322
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
105
323
  success: false;
106
- code: "no-match";
107
- message?: string;
324
+ } & {
325
+ message?: string | undefined;
108
326
  } & {
109
327
  redirect_url?: string;
110
328
  }) | ({
111
- success: false;
112
- code: "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
113
- message?: string;
329
+ code: "email-verification-code-sent" | "magic-link-sent";
330
+ success: true;
331
+ } & {
332
+ message?: string | undefined;
114
333
  } & {
115
334
  redirect_url?: string;
116
- }) | (AuthResponse.AuthSuccess & {
117
- redirect_url?: string;
118
- }) | (AuthResponse.MagicLinkAuthSuccess & {
335
+ }) | ({
336
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
337
+ success: false;
338
+ } & {
339
+ message?: string | undefined;
340
+ } & {
119
341
  redirect_url?: string;
120
342
  }) | ({
343
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "provider-issue";
121
344
  success: false;
122
- code: "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
123
- message?: string;
345
+ } & {
346
+ message?: string | undefined;
124
347
  } & {
125
348
  redirect_url?: string;
126
349
  }) | ({
350
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
127
351
  success: false;
128
- code: "provider-issue";
129
- message?: string;
352
+ } & {
353
+ message?: string | undefined;
130
354
  } & {
131
355
  redirect_url?: string;
132
- }) | (AuthResponse.PasswordRegisterSuccess & {
356
+ }) | ({
357
+ code: "email-verification-code-sent" | "already-registered-but-did-not-confirm-email" | "email-verified";
358
+ success: true;
359
+ } & {
360
+ message?: string | undefined;
361
+ } & {
133
362
  redirect_url?: string;
134
363
  }) | ({
364
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "inactive-account" | "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code";
135
365
  success: false;
136
- code: "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code" | "inactive-account";
137
- message?: string;
366
+ } & {
367
+ message?: string | undefined;
138
368
  } & {
139
369
  redirect_url?: string;
140
370
  })>;
141
371
  isOnLogin: boolean;
142
372
  registerTypeAllowed: "registerWithPassword";
143
- result: (import("prostgles-types").CommonAuthFailure & {
373
+ result: ({
374
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong";
375
+ success: false;
376
+ } & {
377
+ message?: string | undefined;
378
+ } & {
379
+ redirect_url?: string;
380
+ }) | ({
381
+ success: true;
382
+ } & {
383
+ code?: undefined;
384
+ message?: string | undefined;
385
+ token?: string | undefined;
386
+ } & {
144
387
  redirect_url?: string;
145
388
  }) | ({
389
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
146
390
  success: false;
147
- code: "no-match";
148
- message?: string;
391
+ } & {
392
+ message?: string | undefined;
149
393
  } & {
150
394
  redirect_url?: string;
151
395
  }) | ({
396
+ code: "email-verification-code-sent" | "magic-link-sent";
397
+ success: true;
398
+ } & {
399
+ message?: string | undefined;
400
+ } & {
401
+ redirect_url?: string;
402
+ }) | ({
403
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
152
404
  success: false;
153
- code: "inactive-account";
154
- message?: string;
405
+ } & {
406
+ message?: string | undefined;
155
407
  } & {
156
408
  redirect_url?: string;
157
409
  }) | ({
410
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "provider-issue";
158
411
  success: false;
159
- code: "totp-token-missing" | "invalid-username" | "username-missing" | "invalid-email" | "password-missing" | "invalid-password" | "is-from-OAuth" | "is-from-magic-link" | "invalid-totp-recovery-code" | "invalid-totp-code" | "email-not-confirmed";
160
- message?: string;
412
+ } & {
413
+ message?: string | undefined;
161
414
  } & {
162
415
  redirect_url?: string;
163
- }) | (AuthResponse.AuthSuccess & {
416
+ }) | ({
417
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
418
+ success: false;
419
+ } & {
420
+ message?: string | undefined;
421
+ } & {
164
422
  redirect_url?: string;
165
- }) | (AuthResponse.MagicLinkAuthSuccess & {
423
+ }) | ({
424
+ code: "email-verification-code-sent" | "already-registered-but-did-not-confirm-email" | "email-verified";
425
+ success: true;
426
+ } & {
427
+ message?: string | undefined;
428
+ } & {
166
429
  redirect_url?: string;
167
430
  }) | ({
431
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "inactive-account" | "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code";
168
432
  success: false;
169
- code: "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
170
- message?: string;
433
+ } & {
434
+ message?: string | undefined;
435
+ } & {
436
+ redirect_url?: string;
437
+ }) | ({
438
+ success: true;
439
+ } & {
440
+ code?: undefined;
441
+ message?: string | undefined;
442
+ token?: string | undefined;
171
443
  } & {
172
444
  redirect_url?: string;
173
445
  }) | ({
446
+ code: "email-verified";
447
+ success: true;
448
+ } & {
449
+ message?: string | undefined;
450
+ } & {
451
+ redirect_url?: string;
452
+ }) | ({
453
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "expired-magic-link" | "invalid-magic-link" | "used-magic-link";
174
454
  success: false;
175
- code: "provider-issue";
176
- message?: string;
455
+ } & {
456
+ message?: string | undefined;
177
457
  } & {
178
458
  redirect_url?: string;
179
- }) | (AuthResponse.PasswordRegisterSuccess & {
459
+ }) | ({
460
+ code: "server-error" | "rate-limit-exceeded" | "something-went-wrong" | "no-match" | "inactive-account" | "invalid-otp-code" | "expired-otp-code";
461
+ success: false;
462
+ } & {
463
+ message?: string | undefined;
464
+ } & {
180
465
  redirect_url?: string;
181
466
  }) | ({
467
+ code: "invalid-email";
182
468
  success: false;
183
- code: "username-missing" | "password-missing" | "weak-password" | "user-already-registered" | "invalid-email-confirmation-code" | "expired-email-confirmation-code" | "inactive-account";
184
- message?: string;
469
+ } & {
470
+ message?: string | undefined;
185
471
  } & {
186
472
  redirect_url?: string;
187
473
  }) | undefined;
@@ -215,5 +501,8 @@ export declare const ERR_CODE_MESSAGES: {
215
501
  "invalid-magic-link": string;
216
502
  "used-magic-link": string;
217
503
  "invalid-email": string;
504
+ "invalid-otp-code": string;
505
+ "expired-otp-code": string;
506
+ "provider-issue": string;
218
507
  };
219
508
  //# sourceMappingURL=useAuthState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../lib/auth/useAuthState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA2BtF,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa/C,OAAO;iBACP,MAAM;;;CAoNlB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;CA8B7B,CAAC"}
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,OAAO;iBACP,MAAM;;;CAoNlB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC7B,CAAC"}
@@ -163,7 +163,7 @@ const useAuthState = ({ auth }) => {
163
163
  }
164
164
  else if (res.code !== "password-missing") {
165
165
  const errorMessage = res.message ?? (0, prostgles_types_1.getProperty)(exports.ERR_CODE_MESSAGES, res.code);
166
- setErrorWithInfo(errorMessage ?? "Error");
166
+ setErrorWithInfo(errorMessage);
167
167
  }
168
168
  }
169
169
  else {
@@ -233,6 +233,9 @@ exports.ERR_CODE_MESSAGES = {
233
233
  "invalid-magic-link": "Invalid magic link",
234
234
  "used-magic-link": "Magic link already used",
235
235
  "invalid-email": "Invalid or missing email",
236
+ "invalid-otp-code": "Invalid code",
237
+ "expired-otp-code": "Code expired",
238
+ "provider-issue": "Authentication provider error",
236
239
  };
237
240
  const SIGNUP_CODE_MESSAGES = {
238
241
  "already-registered-but-did-not-confirm-email": "Email verification re-sent. Open the verification url or enter the code to confirm your email",