@insforge/react 0.2.3 → 0.2.4
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/components.js +20 -35
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +20 -35
- package/dist/components.mjs.map +1 -1
- package/dist/hooks.d.mts +5 -3
- package/dist/hooks.d.ts +5 -3
- package/dist/hooks.js +10 -29
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +10 -29
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +43 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -37
- package/dist/index.mjs.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -105,6 +105,23 @@ function InsforgeProvider({
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
}, []);
|
|
108
|
+
const getPublicAuthConfig = useCallback(async () => {
|
|
109
|
+
try {
|
|
110
|
+
const result = await insforge.auth.getPublicAuthConfig();
|
|
111
|
+
if (result.data) {
|
|
112
|
+
return result.data;
|
|
113
|
+
} else {
|
|
114
|
+
console.error("[InsforgeProvider] Failed to get public auth config:", result.error);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error(
|
|
119
|
+
"[InsforgeProvider] Failed to get public auth config:",
|
|
120
|
+
error
|
|
121
|
+
);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}, [insforge]);
|
|
108
125
|
const handleAuthSuccess = useCallback(
|
|
109
126
|
async (authToken, fallbackUser) => {
|
|
110
127
|
const userResult = await insforge.auth.getCurrentUser();
|
|
@@ -236,7 +253,10 @@ function InsforgeProvider({
|
|
|
236
253
|
);
|
|
237
254
|
const resetPassword = useCallback(
|
|
238
255
|
async (token, newPassword) => {
|
|
239
|
-
const sdkResult = await insforge.auth.resetPassword({
|
|
256
|
+
const sdkResult = await insforge.auth.resetPassword({
|
|
257
|
+
newPassword,
|
|
258
|
+
otp: token
|
|
259
|
+
});
|
|
240
260
|
return sdkResult.data;
|
|
241
261
|
},
|
|
242
262
|
[insforge]
|
|
@@ -264,7 +284,8 @@ function InsforgeProvider({
|
|
|
264
284
|
baseUrl,
|
|
265
285
|
sendPasswordResetCode,
|
|
266
286
|
resetPassword,
|
|
267
|
-
verifyEmail
|
|
287
|
+
verifyEmail,
|
|
288
|
+
getPublicAuthConfig
|
|
268
289
|
},
|
|
269
290
|
children
|
|
270
291
|
}
|
|
@@ -278,42 +299,23 @@ function useInsforge() {
|
|
|
278
299
|
return context;
|
|
279
300
|
}
|
|
280
301
|
function usePublicAuthConfig() {
|
|
281
|
-
const {
|
|
282
|
-
const [oauthProviders, setOAuthProviders] = useState([]);
|
|
302
|
+
const { getPublicAuthConfig } = useInsforge();
|
|
283
303
|
const [emailConfig, setEmailConfig] = useState(null);
|
|
284
304
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
285
305
|
useEffect(() => {
|
|
286
|
-
let mounted = true;
|
|
287
306
|
async function fetchConfig() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
setEmailConfig(null);
|
|
295
|
-
} else {
|
|
296
|
-
const data = await response.json();
|
|
297
|
-
const providerNames = data.providers?.map((p) => p.provider) || [];
|
|
298
|
-
setOAuthProviders(providerNames);
|
|
299
|
-
setEmailConfig(data.email || null);
|
|
300
|
-
}
|
|
301
|
-
setIsLoaded(true);
|
|
302
|
-
} catch (error) {
|
|
303
|
-
console.warn("[usePublicAuthConfig] Unexpected error:", error);
|
|
304
|
-
if (mounted) {
|
|
305
|
-
setOAuthProviders([]);
|
|
306
|
-
setEmailConfig(null);
|
|
307
|
-
setIsLoaded(true);
|
|
308
|
-
}
|
|
307
|
+
const result = await getPublicAuthConfig();
|
|
308
|
+
if (result) {
|
|
309
|
+
setEmailConfig(result);
|
|
310
|
+
} else {
|
|
311
|
+
console.error("[usePublicAuthConfig] Failed to get public auth config");
|
|
312
|
+
setEmailConfig(null);
|
|
309
313
|
}
|
|
314
|
+
setIsLoaded(true);
|
|
310
315
|
}
|
|
311
316
|
fetchConfig();
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
}, [baseUrl]);
|
|
316
|
-
return { oauthProviders, emailConfig, isLoaded };
|
|
317
|
+
}, [getPublicAuthConfig]);
|
|
318
|
+
return { emailConfig, isLoaded };
|
|
317
319
|
}
|
|
318
320
|
function AuthBranding() {
|
|
319
321
|
return /* @__PURE__ */ jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
@@ -1200,7 +1202,7 @@ function SignIn({
|
|
|
1200
1202
|
...uiProps
|
|
1201
1203
|
}) {
|
|
1202
1204
|
const { signIn, baseUrl } = useInsforge();
|
|
1203
|
-
const {
|
|
1205
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
1204
1206
|
const [email, setEmail] = useState("");
|
|
1205
1207
|
const [password, setPassword] = useState("");
|
|
1206
1208
|
const [error, setError] = useState("");
|
|
@@ -1252,7 +1254,9 @@ function SignIn({
|
|
|
1252
1254
|
setOauthLoading(null);
|
|
1253
1255
|
}
|
|
1254
1256
|
}
|
|
1255
|
-
if (!emailConfig)
|
|
1257
|
+
if (!emailConfig) {
|
|
1258
|
+
return null;
|
|
1259
|
+
}
|
|
1256
1260
|
return /* @__PURE__ */ jsx(
|
|
1257
1261
|
SignInForm,
|
|
1258
1262
|
{
|
|
@@ -1264,7 +1268,7 @@ function SignIn({
|
|
|
1264
1268
|
error,
|
|
1265
1269
|
loading,
|
|
1266
1270
|
oauthLoading,
|
|
1267
|
-
availableProviders:
|
|
1271
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
1268
1272
|
onOAuthClick: handleOAuth,
|
|
1269
1273
|
emailAuthConfig: emailConfig,
|
|
1270
1274
|
...uiProps
|
|
@@ -1427,7 +1431,7 @@ function SignUp({
|
|
|
1427
1431
|
...uiProps
|
|
1428
1432
|
}) {
|
|
1429
1433
|
const { signUp, baseUrl } = useInsforge();
|
|
1430
|
-
const {
|
|
1434
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
1431
1435
|
const [email, setEmail] = useState("");
|
|
1432
1436
|
const [password, setPassword] = useState("");
|
|
1433
1437
|
const [error, setError] = useState("");
|
|
@@ -1484,7 +1488,9 @@ function SignUp({
|
|
|
1484
1488
|
setOauthLoading(null);
|
|
1485
1489
|
}
|
|
1486
1490
|
}
|
|
1487
|
-
if (!emailConfig)
|
|
1491
|
+
if (!emailConfig) {
|
|
1492
|
+
return null;
|
|
1493
|
+
}
|
|
1488
1494
|
return /* @__PURE__ */ jsx(
|
|
1489
1495
|
SignUpForm,
|
|
1490
1496
|
{
|
|
@@ -1496,7 +1502,7 @@ function SignUp({
|
|
|
1496
1502
|
error,
|
|
1497
1503
|
loading,
|
|
1498
1504
|
oauthLoading,
|
|
1499
|
-
availableProviders:
|
|
1505
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
1500
1506
|
onOAuthClick: handleOAuth,
|
|
1501
1507
|
emailAuthConfig: emailConfig,
|
|
1502
1508
|
...uiProps
|