@mehdad67/apitogo 0.1.28 → 0.1.30
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/cli/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -58,6 +58,11 @@ export class DevPortalAuthenticationProvider
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async initialize(_context: ZudokuContext): Promise<void> {
|
|
61
|
+
// Node SSR cannot reach local HTTPS backends with self-signed certs.
|
|
62
|
+
if (typeof window === "undefined") {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
await this.syncBackendAvailability();
|
|
62
67
|
if (!this.backendAvailable) {
|
|
63
68
|
this.setPreviewState();
|
|
@@ -68,6 +73,11 @@ export class DevPortalAuthenticationProvider
|
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
onPageLoad = async () => {
|
|
76
|
+
if (typeof window === "undefined") {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await this.syncBackendAvailability();
|
|
71
81
|
if (!this.backendAvailable) {
|
|
72
82
|
this.setPreviewState();
|
|
73
83
|
return;
|
|
@@ -134,9 +144,15 @@ export class DevPortalAuthenticationProvider
|
|
|
134
144
|
method: "GET",
|
|
135
145
|
headers: { Accept: "application/json" },
|
|
136
146
|
credentials: "include",
|
|
147
|
+
redirect: "manual",
|
|
137
148
|
});
|
|
138
149
|
|
|
139
|
-
|
|
150
|
+
// Backends may still respond with 302 to the IdP; treat as unauthenticated.
|
|
151
|
+
if (
|
|
152
|
+
response.type === "opaqueredirect" ||
|
|
153
|
+
response.status === 302 ||
|
|
154
|
+
response.status === 401
|
|
155
|
+
) {
|
|
140
156
|
useAuthState.setState({
|
|
141
157
|
isAuthenticated: false,
|
|
142
158
|
isPending: false,
|
|
@@ -77,12 +77,25 @@ export const authState = create<AuthState>()(
|
|
|
77
77
|
}),
|
|
78
78
|
{
|
|
79
79
|
merge: (persistedState, currentState) => {
|
|
80
|
+
const persisted =
|
|
81
|
+
typeof persistedState === "object" && persistedState !== null
|
|
82
|
+
? (persistedState as Partial<AuthState>)
|
|
83
|
+
: {};
|
|
84
|
+
|
|
85
|
+
// Cookie/session auth is refreshed from the backend on load. Do not
|
|
86
|
+
// restore identity fields from localStorage or OIDC return looks logged out.
|
|
80
87
|
return {
|
|
81
88
|
...currentState,
|
|
82
89
|
isPending: false,
|
|
83
|
-
|
|
90
|
+
isBackendAvailable:
|
|
91
|
+
persisted.isBackendAvailable ?? currentState.isBackendAvailable,
|
|
92
|
+
authMode: persisted.authMode ?? currentState.authMode,
|
|
84
93
|
};
|
|
85
94
|
},
|
|
95
|
+
partialize: (state) => ({
|
|
96
|
+
isBackendAvailable: state.isBackendAvailable,
|
|
97
|
+
authMode: state.authMode,
|
|
98
|
+
}),
|
|
86
99
|
name: "auth-state",
|
|
87
100
|
storage: createJSONStorage(() => localStorage),
|
|
88
101
|
},
|