@payez/next-mvp 4.7.9 → 4.7.10

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.
@@ -9,6 +9,8 @@ interface AuthProviderProps {
9
9
  */
10
10
  useDynamicProviders?: boolean;
11
11
  }
12
+ /** PAY-2334: how long /api/auth/settings may take before the sign-in card stops waiting and says it could not load. */
13
+ export declare const SETTINGS_FETCH_TIMEOUT_MS = 10000;
12
14
  export declare function AuthProvider({ children, config, useDynamicProviders }: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
13
15
  export declare function useAuthConfig(): AuthConfig;
14
16
  export declare function useAuthMode(): AuthMode;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  'use client';
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SETTINGS_FETCH_TIMEOUT_MS = void 0;
4
5
  exports.AuthProvider = AuthProvider;
5
6
  exports.useAuthConfig = useAuthConfig;
6
7
  exports.useAuthMode = useAuthMode;
@@ -29,9 +30,14 @@ const PROVIDER_MAP = {
29
30
  };
30
31
  // OAuth providers we support in UI (excludes credentials)
31
32
  const OAUTH_PROVIDER_IDS = ['google', 'apple', 'facebook', 'github', 'azure-ad', 'microsoft-entra-id'];
33
+ /** PAY-2334: how long /api/auth/settings may take before the sign-in card stops waiting and says it could not load. */
34
+ exports.SETTINGS_FETCH_TIMEOUT_MS = 10000;
32
35
  function AuthProvider({ children, config, useDynamicProviders = true }) {
33
36
  const [dynamicProviders, setDynamicProviders] = (0, react_1.useState)([]);
34
37
  const [providersLoaded, setProvidersLoaded] = (0, react_1.useState)(!useDynamicProviders);
38
+ // PAY-2334: providersLoaded is true on failure too (it only means "stop waiting"), so it cannot tell an empty answer from
39
+ // no answer. This can: loading -> ready (answered) | failed (non-2xx, thrown, timed out).
40
+ const [settingsStatus, setSettingsStatus] = (0, react_1.useState)(useDynamicProviders ? 'loading' : 'ready');
35
41
  // What the IDP says this client offers. null until /api/auth/settings answers.
36
42
  const [serverSettings, setServerSettings] = (0, react_1.useState)(null);
37
43
  // Create QueryClient instance for React Query - used internally by MVP hooks
@@ -50,6 +56,9 @@ function AuthProvider({ children, config, useDynamicProviders = true }) {
50
56
  return;
51
57
  let mounted = true;
52
58
  async function fetchDynamicProviders() {
59
+ const controller = new AbortController();
60
+ const timer = setTimeout(() => controller.abort(), exports.SETTINGS_FETCH_TIMEOUT_MS);
61
+ let status = 'failed';
53
62
  try {
54
63
  // READ THE IDP. This used to be a hardcoded literal:
55
64
  // const result = { google: { id: 'google', name: 'Google' } };
@@ -59,7 +68,7 @@ function AuthProvider({ children, config, useDynamicProviders = true }) {
59
68
  //
60
69
  // /api/auth/settings already serves the real answer (enabledProviders,
61
70
  // allowFederatedLogin, enablePasswordReset) and nothing consumed it.
62
- const response = await fetch('/api/auth/settings');
71
+ const response = await fetch('/api/auth/settings', { signal: controller.signal });
63
72
  if (!response.ok) {
64
73
  // No silent substitution. Absent settings means we do not know what this
65
74
  // client offers, and inventing a provider list is how a tenant ends up with a
@@ -79,6 +88,7 @@ function AuthProvider({ children, config, useDynamicProviders = true }) {
79
88
  .filter(id => OAUTH_PROVIDER_IDS.includes(id))
80
89
  .map(id => PROVIDER_MAP[id])
81
90
  .filter((p) => p !== undefined);
91
+ status = 'ready';
82
92
  setDynamicProviders(oauthProviders);
83
93
  setServerSettings({
84
94
  allowFederatedLogin: settings?.allowFederatedLogin !== false,
@@ -92,7 +102,9 @@ function AuthProvider({ children, config, useDynamicProviders = true }) {
92
102
  console.error('[AuthProvider] could not read /api/auth/settings:', err);
93
103
  }
94
104
  finally {
105
+ clearTimeout(timer);
95
106
  if (mounted) {
107
+ setSettingsStatus(status);
96
108
  setProvidersLoaded(true);
97
109
  }
98
110
  }
@@ -110,6 +122,7 @@ function AuthProvider({ children, config, useDynamicProviders = true }) {
110
122
  ...defaultConfig,
111
123
  ...config,
112
124
  providers, // from the IDP when useDynamicProviders is on
125
+ settingsStatus: useDynamicProviders ? settingsStatus : 'ready',
113
126
  // THE SERVER DECIDES, THE SITE MAY OVERRIDE. A site that passes an explicit value
114
127
  // still wins; absent that, what the tenant's IDP reports is what renders. A client
115
128
  // hardcoding its own auth mode is how a sign-in screen and its IDP disagree.
@@ -37,7 +37,10 @@ function ModeAwareLoginPage({ onFederatedSignIn, onTraditionalSignIn, onForgotPa
37
37
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [error && ((0, jsx_runtime_1.jsx)("div", { className: "mb-6 px-4 py-3 rounded-lg", style: {
38
38
  background: 'var(--color-error, #ef4444)',
39
39
  color: 'white',
40
- }, children: error })), isFederated && ((0, jsx_runtime_1.jsx)(FederatedAuthSection_1.FederatedAuthSection, { providers: config.providers, onProviderClick: handleFederatedClick, isLoading: totalLoading })), isFederated && isTraditional && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3 my-6", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("span", { className: "h-px flex-1", style: { background: 'var(--border-default, #e5e7eb)' } }), (0, jsx_runtime_1.jsx)("span", { className: "text-xs uppercase tracking-wide", style: { color: 'var(--text-muted, #6b7280)' }, children: "or" }), (0, jsx_runtime_1.jsx)("span", { className: "h-px flex-1", style: { background: 'var(--border-default, #e5e7eb)' } })] })), isTraditional && ((0, jsx_runtime_1.jsx)(TraditionalAuthSection_1.TraditionalAuthSection, { email: email, password: password, onEmailChange: setEmail, onPasswordChange: setPassword, onSubmit: handleTraditionalSubmit, isLoading: totalLoading, buttonText: "Sign In", showForgotPassword: config.enableRecovery, onForgotPassword: onForgotPassword })), !isFederated && !isTraditional && ((0, jsx_runtime_1.jsxs)("div", { role: "alert", className: "px-4 py-3 rounded-lg text-sm text-left", style: {
40
+ }, children: error })), isFederated && ((0, jsx_runtime_1.jsx)(FederatedAuthSection_1.FederatedAuthSection, { providers: config.providers, onProviderClick: handleFederatedClick, isLoading: totalLoading })), isFederated && isTraditional && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-3 my-6", "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)("span", { className: "h-px flex-1", style: { background: 'var(--border-default, #e5e7eb)' } }), (0, jsx_runtime_1.jsx)("span", { className: "text-xs uppercase tracking-wide", style: { color: 'var(--text-muted, #6b7280)' }, children: "or" }), (0, jsx_runtime_1.jsx)("span", { className: "h-px flex-1", style: { background: 'var(--border-default, #e5e7eb)' } })] })), isTraditional && ((0, jsx_runtime_1.jsx)(TraditionalAuthSection_1.TraditionalAuthSection, { email: email, password: password, onEmailChange: setEmail, onPasswordChange: setPassword, onSubmit: handleTraditionalSubmit, isLoading: totalLoading, buttonText: "Sign In", showForgotPassword: config.enableRecovery, onForgotPassword: onForgotPassword })), !isFederated && !isTraditional && config.settingsStatus === 'loading' && ((0, jsx_runtime_1.jsx)("div", { role: "status", className: "px-4 py-3 rounded-lg text-sm text-left", style: { color: 'var(--text-secondary, #6b7280)' }, children: (0, jsx_runtime_1.jsx)("p", { children: "Loading sign-in options\u2026" }) })), !isFederated && !isTraditional && config.settingsStatus === 'failed' && ((0, jsx_runtime_1.jsxs)("div", { role: "alert", className: "px-4 py-3 rounded-lg text-sm text-left", style: {
41
+ border: '1px solid var(--border-default, #e5e7eb)',
42
+ color: 'var(--text-primary, #111827)',
43
+ }, children: [(0, jsx_runtime_1.jsx)("p", { className: "font-semibold", children: "Could not load sign-in options." }), (0, jsx_runtime_1.jsx)("p", { className: "mt-1", children: "Please reload the page. If it keeps happening, contact an administrator." })] })), !isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && ((0, jsx_runtime_1.jsxs)("div", { role: "alert", className: "px-4 py-3 rounded-lg text-sm text-left", style: {
41
44
  border: '1px solid var(--border-default, #e5e7eb)',
42
45
  color: 'var(--text-primary, #111827)',
43
46
  }, children: [(0, jsx_runtime_1.jsx)("p", { className: "font-semibold", children: "Sign-in is not available for this application." }), (0, jsx_runtime_1.jsx)("p", { className: "mt-1", children: "No sign-in method is enabled for this client. An administrator needs to enable a federated provider or username and password sign-in." })] }))] }));
@@ -56,26 +56,11 @@ function ModeAwareSignupPage({ onFederatedSignUp, onTraditionalSignUp, isLoading
56
56
  border: '1px solid var(--border-default)',
57
57
  color: 'white',
58
58
  background: 'var(--color-primary, #10b981)',
59
- }, children: totalLoading ? 'Creating Account...' : 'Create Account' })] })), isFederated === false && isTraditional === false && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FederatedAuthSection_1.FederatedAuthSection, { providers: config.providers, onProviderClick: handleFederatedClick, isLoading: totalLoading }), config.providers.length > 0 && config.enableEmailSignup && ((0, jsx_runtime_1.jsxs)("div", { className: "relative my-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 flex items-center", children: (0, jsx_runtime_1.jsx)("div", { className: "w-full", style: {
60
- borderTop: '1px solid var(--border-default)',
61
- } }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex justify-center text-sm", children: (0, jsx_runtime_1.jsx)("span", { className: "px-2", style: {
62
- background: 'var(--bg-card)',
63
- color: 'var(--text-secondary)',
64
- }, children: "Or sign up with email" }) })] })), config.enableEmailSignup && ((0, jsx_runtime_1.jsxs)("form", { onSubmit: handleTraditionalSubmit, className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium mb-2", style: { color: 'var(--text-primary)' }, children: "Email Address" }), (0, jsx_runtime_1.jsx)("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: "you@example.com", disabled: totalLoading, required: true, className: "w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50", style: {
65
- border: '1px solid var(--border-default)',
66
- color: 'var(--text-primary)',
67
- background: 'var(--bg-default)',
68
- } })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium mb-2", style: { color: 'var(--text-primary)' }, children: "Password" }), (0, jsx_runtime_1.jsx)("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", disabled: totalLoading, required: true, className: "w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50", style: {
69
- border: '1px solid var(--border-default)',
70
- color: 'var(--text-primary)',
71
- background: 'var(--bg-default)',
72
- } })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium mb-2", style: { color: 'var(--text-primary)' }, children: "Confirm Password" }), (0, jsx_runtime_1.jsx)("input", { type: "password", value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", disabled: totalLoading, required: true, className: "w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50", style: {
73
- border: '1px solid var(--border-default)',
74
- color: 'var(--text-primary)',
75
- background: 'var(--bg-default)',
76
- } })] }), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: totalLoading, className: "w-full py-3 px-4 rounded-lg font-semibold focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors mt-6", style: {
77
- border: '1px solid var(--border-default)',
78
- color: 'white',
79
- background: 'var(--color-primary, #10b981)',
80
- }, children: totalLoading ? 'Creating Account...' : 'Create Account' })] }))] }))] }));
59
+ }, children: totalLoading ? 'Creating Account...' : 'Create Account' })] })), !isFederated && !isTraditional && config.settingsStatus === 'loading' && ((0, jsx_runtime_1.jsx)("div", { role: "status", className: "px-4 py-3 rounded-lg text-sm text-left", style: { color: 'var(--text-secondary, #6b7280)' }, children: (0, jsx_runtime_1.jsx)("p", { children: "Loading sign-up options\u2026" }) })), !isFederated && !isTraditional && config.settingsStatus === 'failed' && ((0, jsx_runtime_1.jsxs)("div", { role: "alert", className: "px-4 py-3 rounded-lg text-sm text-left", style: {
60
+ border: '1px solid var(--border-default, #e5e7eb)',
61
+ color: 'var(--text-primary, #111827)',
62
+ }, children: [(0, jsx_runtime_1.jsx)("p", { className: "font-semibold", children: "Could not load sign-up options." }), (0, jsx_runtime_1.jsx)("p", { className: "mt-1", children: "Please reload the page. If it keeps happening, contact an administrator." })] })), !isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && ((0, jsx_runtime_1.jsxs)("div", { role: "alert", className: "px-4 py-3 rounded-lg text-sm text-left", style: {
63
+ border: '1px solid var(--border-default, #e5e7eb)',
64
+ color: 'var(--text-primary, #111827)',
65
+ }, children: [(0, jsx_runtime_1.jsx)("p", { className: "font-semibold", children: "Sign-up is not available for this application." }), (0, jsx_runtime_1.jsx)("p", { className: "mt-1", children: "No sign-up method is enabled for this client. An administrator needs to enable a federated provider or username and password sign-in." })] }))] }));
81
66
  }
@@ -21,6 +21,12 @@ export interface AuthConfig {
21
21
  * An OAuth-only client is a deliberate choice, never the default.
22
22
  */
23
23
  allowTraditionalLogin?: boolean;
24
+ /**
25
+ * PAY-2334: where /api/auth/settings stands. 'loading' = not answered yet, 'ready' = answered (or nothing to ask:
26
+ * useDynamicProviders off), 'failed' = non-2xx, thrown, or timed out. Absent means 'ready'. A page must not tell the user
27
+ * "sign-in is not available" while this is 'loading', and must say a failed read is a failed read, not an empty answer.
28
+ */
29
+ settingsStatus?: 'loading' | 'ready' | 'failed';
24
30
  providers: FederatedProvider[];
25
31
  enableRecovery: boolean;
26
32
  enableEmailSignup: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "4.7.9",
3
+ "version": "4.7.10",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,9 +38,15 @@ interface AuthProviderProps {
38
38
  useDynamicProviders?: boolean;
39
39
  }
40
40
 
41
+ /** PAY-2334: how long /api/auth/settings may take before the sign-in card stops waiting and says it could not load. */
42
+ export const SETTINGS_FETCH_TIMEOUT_MS = 10000;
43
+
41
44
  export function AuthProvider({ children, config, useDynamicProviders = true }: AuthProviderProps) {
42
45
  const [dynamicProviders, setDynamicProviders] = useState<FederatedProvider[]>([]);
43
46
  const [providersLoaded, setProvidersLoaded] = useState(!useDynamicProviders);
47
+ // PAY-2334: providersLoaded is true on failure too (it only means "stop waiting"), so it cannot tell an empty answer from
48
+ // no answer. This can: loading -> ready (answered) | failed (non-2xx, thrown, timed out).
49
+ const [settingsStatus, setSettingsStatus] = useState<'loading' | 'ready' | 'failed'>(useDynamicProviders ? 'loading' : 'ready');
44
50
 
45
51
  // What the IDP says this client offers. null until /api/auth/settings answers.
46
52
  const [serverSettings, setServerSettings] = useState<{
@@ -66,6 +72,9 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
66
72
  let mounted = true;
67
73
 
68
74
  async function fetchDynamicProviders() {
75
+ const controller = new AbortController();
76
+ const timer = setTimeout(() => controller.abort(), SETTINGS_FETCH_TIMEOUT_MS);
77
+ let status: 'ready' | 'failed' = 'failed';
69
78
  try {
70
79
  // READ THE IDP. This used to be a hardcoded literal:
71
80
  // const result = { google: { id: 'google', name: 'Google' } };
@@ -75,7 +84,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
75
84
  //
76
85
  // /api/auth/settings already serves the real answer (enabledProviders,
77
86
  // allowFederatedLogin, enablePasswordReset) and nothing consumed it.
78
- const response = await fetch('/api/auth/settings');
87
+ const response = await fetch('/api/auth/settings', { signal: controller.signal });
79
88
  if (!response.ok) {
80
89
  // No silent substitution. Absent settings means we do not know what this
81
90
  // client offers, and inventing a provider list is how a tenant ends up with a
@@ -98,6 +107,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
98
107
  .map(id => PROVIDER_MAP[id])
99
108
  .filter((p): p is FederatedProvider => p !== undefined);
100
109
 
110
+ status = 'ready';
101
111
  setDynamicProviders(oauthProviders);
102
112
  setServerSettings({
103
113
  allowFederatedLogin: settings?.allowFederatedLogin !== false,
@@ -109,7 +119,9 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
109
119
  } catch (err) {
110
120
  console.error('[AuthProvider] could not read /api/auth/settings:', err);
111
121
  } finally {
122
+ clearTimeout(timer);
112
123
  if (mounted) {
124
+ setSettingsStatus(status);
113
125
  setProvidersLoaded(true);
114
126
  }
115
127
  }
@@ -130,6 +142,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
130
142
  ...defaultConfig,
131
143
  ...config,
132
144
  providers, // from the IDP when useDynamicProviders is on
145
+ settingsStatus: useDynamicProviders ? settingsStatus : 'ready',
133
146
  // THE SERVER DECIDES, THE SITE MAY OVERRIDE. A site that passes an explicit value
134
147
  // still wins; absent that, what the tenant's IDP reports is what renders. A client
135
148
  // hardcoding its own auth mode is how a sign-in screen and its IDP disagree.
@@ -105,7 +105,27 @@ export function ModeAwareLoginPage({
105
105
  and rendered BOTH sections on the same condition - so a client configured with
106
106
  no sign-in method at all got the full form. Say so instead: a blank card leaves
107
107
  the user pressing nothing, and the operator with no idea what is wrong. */}
108
- {!isFederated && !isTraditional && (
108
+ {!isFederated && !isTraditional && config.settingsStatus === 'loading' && (
109
+ <div role="status" className="px-4 py-3 rounded-lg text-sm text-left" style={{ color: 'var(--text-secondary, #6b7280)' }}>
110
+ <p>Loading sign-in options…</p>
111
+ </div>
112
+ )}
113
+
114
+ {!isFederated && !isTraditional && config.settingsStatus === 'failed' && (
115
+ <div
116
+ role="alert"
117
+ className="px-4 py-3 rounded-lg text-sm text-left"
118
+ style={{
119
+ border: '1px solid var(--border-default, #e5e7eb)',
120
+ color: 'var(--text-primary, #111827)',
121
+ }}
122
+ >
123
+ <p className="font-semibold">Could not load sign-in options.</p>
124
+ <p className="mt-1">Please reload the page. If it keeps happening, contact an administrator.</p>
125
+ </div>
126
+ )}
127
+
128
+ {!isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && (
109
129
  <div
110
130
  role="alert"
111
131
  className="px-4 py-3 rounded-lg text-sm text-left"
@@ -154,116 +154,46 @@ export function ModeAwareSignupPage({
154
154
  </form>
155
155
  )}
156
156
 
157
- {/* Hybrid Mode - Show both */}
158
- {isFederated === false && isTraditional === false && (
159
- <>
160
- <FederatedAuthSection
161
- providers={config.providers}
162
- onProviderClick={handleFederatedClick}
163
- isLoading={totalLoading}
164
- />
165
-
166
- {config.providers.length > 0 && config.enableEmailSignup && (
167
- <div className="relative my-6">
168
- <div className="absolute inset-0 flex items-center">
169
- <div
170
- className="w-full"
171
- style={{
172
- borderTop: '1px solid var(--border-default)',
173
- }}
174
- ></div>
175
- </div>
176
- <div className="relative flex justify-center text-sm">
177
- <span
178
- className="px-2"
179
- style={{
180
- background: 'var(--bg-card)',
181
- color: 'var(--text-secondary)',
182
- }}
183
- >
184
- Or sign up with email
185
- </span>
186
- </div>
187
- </div>
188
- )}
189
-
190
- {config.enableEmailSignup && (
191
- <form onSubmit={handleTraditionalSubmit} className="space-y-4">
192
- <div>
193
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
194
- Email Address
195
- </label>
196
- <input
197
- type="email"
198
- value={email}
199
- onChange={(e) => setEmail(e.target.value)}
200
- placeholder="you@example.com"
201
- disabled={totalLoading}
202
- required
203
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
204
- style={{
205
- border: '1px solid var(--border-default)',
206
- color: 'var(--text-primary)',
207
- background: 'var(--bg-default)',
208
- }}
209
- />
210
- </div>
211
-
212
- <div>
213
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
214
- Password
215
- </label>
216
- <input
217
- type="password"
218
- value={password}
219
- onChange={(e) => setPassword(e.target.value)}
220
- placeholder="••••••••"
221
- disabled={totalLoading}
222
- required
223
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
224
- style={{
225
- border: '1px solid var(--border-default)',
226
- color: 'var(--text-primary)',
227
- background: 'var(--bg-default)',
228
- }}
229
- />
230
- </div>
157
+ {/* PAY-2334: same three states as the login page. Not answered yet -> neutral text; read failed -> say so;
158
+ only an ANSWERED "nothing offered" falls through to the branch below. */}
159
+ {!isFederated && !isTraditional && config.settingsStatus === 'loading' && (
160
+ <div role="status" className="px-4 py-3 rounded-lg text-sm text-left" style={{ color: 'var(--text-secondary, #6b7280)' }}>
161
+ <p>Loading sign-up options…</p>
162
+ </div>
163
+ )}
231
164
 
232
- <div>
233
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
234
- Confirm Password
235
- </label>
236
- <input
237
- type="password"
238
- value={confirmPassword}
239
- onChange={(e) => setConfirmPassword(e.target.value)}
240
- placeholder="••••••••"
241
- disabled={totalLoading}
242
- required
243
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
244
- style={{
245
- border: '1px solid var(--border-default)',
246
- color: 'var(--text-primary)',
247
- background: 'var(--bg-default)',
248
- }}
249
- />
250
- </div>
165
+ {!isFederated && !isTraditional && config.settingsStatus === 'failed' && (
166
+ <div
167
+ role="alert"
168
+ className="px-4 py-3 rounded-lg text-sm text-left"
169
+ style={{
170
+ border: '1px solid var(--border-default, #e5e7eb)',
171
+ color: 'var(--text-primary, #111827)',
172
+ }}
173
+ >
174
+ <p className="font-semibold">Could not load sign-up options.</p>
175
+ <p className="mt-1">Please reload the page. If it keeps happening, contact an administrator.</p>
176
+ </div>
177
+ )}
251
178
 
252
- <button
253
- type="submit"
254
- disabled={totalLoading}
255
- className="w-full py-3 px-4 rounded-lg font-semibold focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors mt-6"
256
- style={{
257
- border: '1px solid var(--border-default)',
258
- color: 'white',
259
- background: 'var(--color-primary, #10b981)',
260
- }}
261
- >
262
- {totalLoading ? 'Creating Account...' : 'Create Account'}
263
- </button>
264
- </form>
265
- )}
266
- </>
179
+ {/* PAY-2341: ANSWERED, and nothing is offered. This branch used to be labelled "Hybrid Mode - Show both" and
180
+ rendered the federated section plus the email sign-up form on the same "neither" condition, so a client with no
181
+ sign-up method showed a working-looking form. Say so, as the login page does (ModeAwareLoginPage). */}
182
+ {!isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && (
183
+ <div
184
+ role="alert"
185
+ className="px-4 py-3 rounded-lg text-sm text-left"
186
+ style={{
187
+ border: '1px solid var(--border-default, #e5e7eb)',
188
+ color: 'var(--text-primary, #111827)',
189
+ }}
190
+ >
191
+ <p className="font-semibold">Sign-up is not available for this application.</p>
192
+ <p className="mt-1">
193
+ No sign-up method is enabled for this client. An administrator needs to enable
194
+ a federated provider or username and password sign-in.
195
+ </p>
196
+ </div>
267
197
  )}
268
198
  </>
269
199
  );
package/src/types/auth.ts CHANGED
@@ -25,6 +25,12 @@ export interface AuthConfig {
25
25
  * An OAuth-only client is a deliberate choice, never the default.
26
26
  */
27
27
  allowTraditionalLogin?: boolean;
28
+ /**
29
+ * PAY-2334: where /api/auth/settings stands. 'loading' = not answered yet, 'ready' = answered (or nothing to ask:
30
+ * useDynamicProviders off), 'failed' = non-2xx, thrown, or timed out. Absent means 'ready'. A page must not tell the user
31
+ * "sign-in is not available" while this is 'loading', and must say a failed read is a failed read, not an empty answer.
32
+ */
33
+ settingsStatus?: 'loading' | 'ready' | 'failed';
28
34
  providers: FederatedProvider[];
29
35
  enableRecovery: boolean;
30
36
  enableEmailSignup: boolean;