@authowl/react 0.21.1 → 0.21.2
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.
|
@@ -381,7 +381,7 @@ function warnPublicConfigFailed(resolved, error) {
|
|
|
381
381
|
warnedConfigProjects.add(key);
|
|
382
382
|
const reason = error instanceof Error ? error.message : String(error);
|
|
383
383
|
console.warn(
|
|
384
|
-
`[AuthOwl] Could not load this project's public config from ${origin} (${reason}).
|
|
384
|
+
`[AuthOwl] Could not load this project's public config from ${origin} (${reason}). Authentication UI is unavailable until the request succeeds. Likely causes: the API is unreachable, \`apiUrl\` is wrong, or the publishable key points at a missing/mismatched project. Check \`apiUrl\` and \`publishableKey\` on <AuthOwlProvider>. (This warning is dev-only.)`
|
|
385
385
|
);
|
|
386
386
|
}
|
|
387
387
|
var Context = React4.createContext(null);
|
|
@@ -418,6 +418,8 @@ function AuthOwlProvider({
|
|
|
418
418
|
const client = React4.useMemo(() => createAuthOwlClient(resolved), [resolved]);
|
|
419
419
|
const [config, setConfig] = React4.useState(null);
|
|
420
420
|
const [configState, setConfigState] = React4.useState("loading");
|
|
421
|
+
const [configAttempt, setConfigAttempt] = React4.useState(0);
|
|
422
|
+
const retryPublicConfig = React4.useCallback(() => setConfigAttempt((attempt) => attempt + 1), []);
|
|
421
423
|
React4.useEffect(() => {
|
|
422
424
|
let active = true;
|
|
423
425
|
setConfigState("loading");
|
|
@@ -434,7 +436,7 @@ function AuthOwlProvider({
|
|
|
434
436
|
return () => {
|
|
435
437
|
active = false;
|
|
436
438
|
};
|
|
437
|
-
}, [resolved]);
|
|
439
|
+
}, [resolved, configAttempt]);
|
|
438
440
|
const merged = resolveAppearance(appearance, config);
|
|
439
441
|
const [autoLocale, setAutoLocale] = React4.useState(null);
|
|
440
442
|
React4.useEffect(() => {
|
|
@@ -445,8 +447,8 @@ function AuthOwlProvider({
|
|
|
445
447
|
captureInvitationClaim();
|
|
446
448
|
}, []);
|
|
447
449
|
const ctxValue = React4.useMemo(
|
|
448
|
-
() => ({ client, appearance, config, configState, locale }),
|
|
449
|
-
[client, appearance, config, configState, locale]
|
|
450
|
+
() => ({ client, appearance, config, configState, retryPublicConfig, locale }),
|
|
451
|
+
[client, appearance, config, configState, retryPublicConfig, locale]
|
|
450
452
|
);
|
|
451
453
|
return /* @__PURE__ */ jsx4(Context.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxs3(
|
|
452
454
|
"div",
|
|
@@ -489,11 +491,12 @@ function useAccount() {
|
|
|
489
491
|
return useAuthClient().account;
|
|
490
492
|
}
|
|
491
493
|
function usePublicConfig() {
|
|
492
|
-
const { config, configState } = useAuthOwlContext();
|
|
494
|
+
const { config, configState, retryPublicConfig } = useAuthOwlContext();
|
|
493
495
|
return {
|
|
494
496
|
config,
|
|
495
497
|
isLoading: configState === "loading",
|
|
496
|
-
isError: configState === "error"
|
|
498
|
+
isError: configState === "error",
|
|
499
|
+
retry: retryPublicConfig
|
|
497
500
|
};
|
|
498
501
|
}
|
|
499
502
|
function useSession() {
|