oidc-spa 8.3.2 → 8.3.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/core/createOidc.js +3 -1
- package/core/createOidc.js.map +1 -1
- package/esm/core/createOidc.js +3 -1
- package/esm/core/createOidc.js.map +1 -1
- package/esm/tanstack-start/react/createOidcSpaApi.js +4 -4
- package/esm/tanstack-start/react/createOidcSpaApi.js.map +1 -1
- package/esm/tanstack-start/react/disableSsrIfLoginEnforced.d.ts +5 -0
- package/esm/tanstack-start/react/disableSsrIfLoginEnforced.js +19 -0
- package/esm/tanstack-start/react/disableSsrIfLoginEnforced.js.map +1 -0
- package/esm/tanstack-start/react/index.d.ts +1 -0
- package/esm/tanstack-start/react/index.js +1 -0
- package/esm/tanstack-start/react/index.js.map +1 -1
- package/esm/tools/ensureNonBlankPaint.d.ts +1 -0
- package/esm/tools/ensureNonBlankPaint.js +10 -0
- package/esm/tools/ensureNonBlankPaint.js.map +1 -0
- package/package.json +1 -11
- package/src/core/createOidc.ts +3 -0
- package/src/tanstack-start/react/createOidcSpaApi.tsx +4 -4
- package/src/tanstack-start/react/disableSsrIfLoginEnforced.tsx +29 -0
- package/src/tanstack-start/react/index.ts +1 -0
- package/src/tools/ensureNonBlankPaint.ts +12 -0
- package/src/vite-plugin/handleClientEntrypoint.ts +0 -4
- package/src/vite-plugin/transformTanstackRouterCreateFileRoute.ts +6 -6
- package/tools/ensureNonBlankPaint.d.ts +1 -0
- package/tools/ensureNonBlankPaint.js +13 -0
- package/tools/ensureNonBlankPaint.js.map +1 -0
- package/vite-plugin/handleClientEntrypoint.js +0 -4
- package/vite-plugin/handleClientEntrypoint.js.map +1 -1
- package/vite-plugin/transformTanstackRouterCreateFileRoute.js +6 -6
- package/vite-plugin/transformTanstackRouterCreateFileRoute.js.map +1 -1
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.d.ts +0 -4
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.js +0 -8
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.js.map +0 -1
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.d.ts +0 -4
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.js +0 -86
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.js.map +0 -1
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.d.ts +0 -1
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.js +0 -13
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.js.map +0 -1
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.d.ts +0 -2
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.js +0 -3
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.js.map +0 -1
- package/esm/tools/inferIsViteDev.d.ts +0 -1
- package/esm/tools/inferIsViteDev.js +0 -6
- package/esm/tools/inferIsViteDev.js.map +0 -1
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.ts +0 -8
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.tsx +0 -127
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.ts +0 -15
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.ts +0 -2
- package/src/tools/inferIsViteDev.ts +0 -6
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { type createFileRoute, useRouter } from "@tanstack/react-router";
|
|
3
|
-
import { ERROR_MESSAGE_SINGULAR_STRING } from "./UnifiedClientRetryForSsrLoadersError";
|
|
4
|
-
import { inferIsViteDev } from "../../../tools/inferIsViteDev";
|
|
5
|
-
|
|
6
|
-
type OptionsOfCreateFileRoute = NonNullable<Parameters<ReturnType<typeof createFileRoute>>[0]>;
|
|
7
|
-
|
|
8
|
-
export function enableUnifiedClientRetryForSsrLoaders<Options extends OptionsOfCreateFileRoute>(
|
|
9
|
-
options: Options
|
|
10
|
-
): Options {
|
|
11
|
-
if (options.ssr === false) {
|
|
12
|
-
return options;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
common_case_exception: {
|
|
16
|
-
const { beforeLoad } = options;
|
|
17
|
-
|
|
18
|
-
if (beforeLoad === undefined) {
|
|
19
|
-
break common_case_exception;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
if (!beforeLoad.__isOidcSpaEnforceLogin) {
|
|
24
|
-
break common_case_exception;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
...options,
|
|
29
|
-
ssr: false
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function ErrorComponentWithUnifiedClientRetryForSsrLoader(
|
|
34
|
-
props: Parameters<
|
|
35
|
-
Exclude<OptionsOfCreateFileRoute["errorComponent"], null | false | undefined>
|
|
36
|
-
>[0]
|
|
37
|
-
) {
|
|
38
|
-
unified_client_retry: {
|
|
39
|
-
const { error } = props;
|
|
40
|
-
|
|
41
|
-
const isSentinelError =
|
|
42
|
-
error instanceof Error && error.message.includes(ERROR_MESSAGE_SINGULAR_STRING);
|
|
43
|
-
|
|
44
|
-
const router = useRouter();
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!isSentinelError) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const isDev = inferIsViteDev();
|
|
52
|
-
|
|
53
|
-
console.info(
|
|
54
|
-
[
|
|
55
|
-
`oidc-spa: The '500 (Internal Server Error)'${
|
|
56
|
-
!isDev ? "" : " and 'Warning: Error in route match'"
|
|
57
|
-
} above can be safely ignored.`,
|
|
58
|
-
"\nIt's not a real error, but an expected and recoverable case.",
|
|
59
|
-
"\nThis happens when a server action requires user authentication",
|
|
60
|
-
"before the client has finished establishing it."
|
|
61
|
-
].join(" ")
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
router.invalidate();
|
|
65
|
-
}, []);
|
|
66
|
-
|
|
67
|
-
if (!isSentinelError) {
|
|
68
|
-
break unified_client_retry;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const PendingComponent = options.pendingComponent;
|
|
72
|
-
|
|
73
|
-
if (PendingComponent === undefined) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return <PendingComponent />;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Default behavior
|
|
81
|
-
{
|
|
82
|
-
const { errorComponent } = options;
|
|
83
|
-
|
|
84
|
-
if (errorComponent === false) {
|
|
85
|
-
queueMicrotask(() => {
|
|
86
|
-
throw props.error;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (errorComponent === null || errorComponent === undefined) {
|
|
93
|
-
throw props.error;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const ErrorComponent = errorComponent;
|
|
97
|
-
|
|
98
|
-
return <ErrorComponent {...props} />;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
forward_properties: {
|
|
103
|
-
const { errorComponent } = options;
|
|
104
|
-
|
|
105
|
-
if (!errorComponent) {
|
|
106
|
-
ErrorComponentWithUnifiedClientRetryForSsrLoader.displayName =
|
|
107
|
-
ErrorComponentWithUnifiedClientRetryForSsrLoader.name;
|
|
108
|
-
break forward_properties;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const ErrorComponent = errorComponent;
|
|
112
|
-
|
|
113
|
-
ErrorComponentWithUnifiedClientRetryForSsrLoader.displayName = `${
|
|
114
|
-
(ErrorComponent as any).displayName ?? ErrorComponent.name ?? "ErrorComponent"
|
|
115
|
-
}WithUnifiedClientRetryForSsrLoader`;
|
|
116
|
-
|
|
117
|
-
if (ErrorComponent.preload !== undefined) {
|
|
118
|
-
ErrorComponentWithUnifiedClientRetryForSsrLoader.preload =
|
|
119
|
-
ErrorComponent.preload.bind(ErrorComponent);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
...options,
|
|
125
|
-
errorComponent: ErrorComponentWithUnifiedClientRetryForSsrLoader
|
|
126
|
-
};
|
|
127
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ERROR_MESSAGE_SINGULAR_STRING } from "./UnifiedClientRetryForSsrLoadersError";
|
|
2
|
-
|
|
3
|
-
export function preventConsoleLoggingOfUnifiedClientRetryForSsrLoadersError() {
|
|
4
|
-
const originalConsoleError = console.error;
|
|
5
|
-
|
|
6
|
-
console.error = function error(...args) {
|
|
7
|
-
for (const arg of args) {
|
|
8
|
-
if (arg instanceof Error && arg.message.includes(ERROR_MESSAGE_SINGULAR_STRING)) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
originalConsoleError.call(console, ...args);
|
|
14
|
-
};
|
|
15
|
-
}
|