@payez/next-mvp 4.5.7 → 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.
Files changed (68) hide show
  1. package/dist/api-handlers/auth/credential-login-email-code.d.ts +24 -0
  2. package/dist/api-handlers/auth/credential-login-email-code.js +83 -0
  3. package/dist/api-handlers/auth/credential-login.d.ts +41 -0
  4. package/dist/api-handlers/auth/credential-login.js +858 -0
  5. package/dist/api-handlers/oauth/resume.d.ts +16 -0
  6. package/dist/api-handlers/oauth/resume.js +207 -0
  7. package/dist/auth/better-auth.d.ts +14 -2
  8. package/dist/auth/better-auth.js +59 -34
  9. package/dist/auth/idp-oauth.d.ts +106 -0
  10. package/dist/auth/idp-oauth.js +280 -0
  11. package/dist/auth/safe-callback.js +10 -2
  12. package/dist/client/AuthContext.d.ts +2 -0
  13. package/dist/client/AuthContext.js +14 -1
  14. package/dist/components/auth/CredentialSignInForm.d.ts +33 -0
  15. package/dist/components/auth/CredentialSignInForm.js +134 -0
  16. package/dist/components/auth/ModeAwareLoginPage.js +4 -1
  17. package/dist/components/auth/ModeAwareSignupPage.js +7 -22
  18. package/dist/lib/authorize-resume.d.ts +87 -0
  19. package/dist/lib/authorize-resume.js +190 -0
  20. package/dist/lib/bearer-fetch.d.ts +17 -0
  21. package/dist/lib/bearer-fetch.js +32 -0
  22. package/dist/lib/code-step-copy.d.ts +53 -0
  23. package/dist/lib/code-step-copy.js +73 -0
  24. package/dist/lib/credential-sign-in-client.d.ts +59 -0
  25. package/dist/lib/credential-sign-in-client.js +89 -0
  26. package/dist/lib/device-id.d.ts +37 -0
  27. package/dist/lib/device-id.js +70 -0
  28. package/dist/lib/lock-window.d.ts +29 -0
  29. package/dist/lib/lock-window.js +53 -0
  30. package/dist/lib/login-error-message.d.ts +18 -0
  31. package/dist/lib/login-error-message.js +47 -0
  32. package/dist/lib/twofa-rejection.d.ts +20 -0
  33. package/dist/lib/twofa-rejection.js +73 -0
  34. package/dist/middleware/create-middleware.d.ts +12 -1
  35. package/dist/middleware/create-middleware.js +19 -5
  36. package/dist/pages/login/page.js +11 -37
  37. package/dist/routes/auth/credential-login-email-code.d.ts +6 -0
  38. package/dist/routes/auth/credential-login-email-code.js +10 -0
  39. package/dist/routes/auth/credential-login.d.ts +6 -0
  40. package/dist/routes/auth/credential-login.js +10 -0
  41. package/dist/routes/oauth/resume.d.ts +11 -0
  42. package/dist/routes/oauth/resume.js +16 -0
  43. package/dist/types/auth.d.ts +6 -0
  44. package/package.json +1102 -1047
  45. package/src/api-handlers/auth/credential-login-email-code.ts +92 -0
  46. package/src/api-handlers/auth/credential-login.ts +948 -0
  47. package/src/api-handlers/oauth/resume.ts +182 -0
  48. package/src/auth/better-auth.ts +81 -5
  49. package/src/auth/idp-oauth.ts +310 -0
  50. package/src/auth/safe-callback.ts +11 -2
  51. package/src/client/AuthContext.tsx +14 -1
  52. package/src/components/auth/CredentialSignInForm.tsx +240 -0
  53. package/src/components/auth/ModeAwareLoginPage.tsx +21 -1
  54. package/src/components/auth/ModeAwareSignupPage.tsx +38 -108
  55. package/src/lib/authorize-resume.ts +187 -0
  56. package/src/lib/bearer-fetch.ts +31 -0
  57. package/src/lib/code-step-copy.ts +83 -0
  58. package/src/lib/credential-sign-in-client.ts +101 -0
  59. package/src/lib/device-id.ts +67 -0
  60. package/src/lib/lock-window.ts +49 -0
  61. package/src/lib/login-error-message.ts +41 -0
  62. package/src/lib/twofa-rejection.ts +91 -0
  63. package/src/middleware/create-middleware.ts +35 -4
  64. package/src/pages/login/page.tsx +20 -34
  65. package/src/routes/auth/credential-login-email-code.ts +6 -0
  66. package/src/routes/auth/credential-login.ts +6 -0
  67. package/src/routes/oauth/resume.ts +11 -0
  68. package/src/types/auth.ts +6 -0
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * Per-browser device identity — card 240566 (QAPert flag 2 on the 9c7a815 review).
4
+ *
5
+ * BEFORE: /api/auth/admin-login forwarded ONE hardcoded device-id cookie —
6
+ * `payez-PayEz-6c8201c35c1b44c9b2e823b36b95a718` — for every caller on the
7
+ * PUBLIC /sign-in password path. To the IDP's rate limiter and device
8
+ * fingerprinting, every portal user was literally the same device. Two
9
+ * consequences, both measured-by-inspection rather than hypothetical:
10
+ * 1. SHARED-FATE LOCKOUT — one attacker's failed attempts consume the
11
+ * throttle budget for every legitimate user at once.
12
+ * 2. Per-device risk signals are meaningless: "new device" and "trusted
13
+ * device" cannot distinguish anybody from anybody.
14
+ *
15
+ * The id is a routing/telemetry key, NOT a credential — the IDP must never
16
+ * grant anything on the strength of it, and nothing here assumes otherwise.
17
+ * It is client-supplied and therefore client-forgeable; that is inherent to
18
+ * device-id throttling and is why it supplements, never replaces, the
19
+ * identifier- and IP-scoped limits on the IDP side.
20
+ *
21
+ * Shape is fixed by what the IDP already accepts from
22
+ * createLoginHandler: `payez-PayEz-<32 lowercase hex>`.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.DEVICE_ID_PATTERN = exports.DEVICE_ID_HEADER = void 0;
26
+ exports.isValidDeviceId = isValidDeviceId;
27
+ exports.getDeviceId = getDeviceId;
28
+ exports.DEVICE_ID_HEADER = 'X-Device-Id';
29
+ exports.DEVICE_ID_PATTERN = /^payez-PayEz-[0-9a-f]{32}$/;
30
+ const STORAGE_KEY = 'payez.device-id';
31
+ /** True for a well-formed device id. Used on BOTH sides of the wire. */
32
+ function isValidDeviceId(value) {
33
+ return typeof value === 'string' && exports.DEVICE_ID_PATTERN.test(value);
34
+ }
35
+ function mint() {
36
+ const bytes = new Uint8Array(16);
37
+ crypto.getRandomValues(bytes);
38
+ const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');
39
+ return `payez-PayEz-${hex}`;
40
+ }
41
+ /**
42
+ * The stable per-browser device id, minted once and persisted.
43
+ *
44
+ * Browser-only. Persistence is best-effort: private windows, disabled site
45
+ * data and storage-quota failures all throw on access, so every read and
46
+ * write is guarded. A browser that cannot persist still gets a VALID id for
47
+ * this call — it simply looks like a new device each time, which is the
48
+ * honest answer for a client that refuses to be remembered, and is still
49
+ * strictly better than every user sharing one identity.
50
+ */
51
+ function getDeviceId() {
52
+ if (typeof window === 'undefined')
53
+ return mint();
54
+ try {
55
+ const existing = window.localStorage.getItem(STORAGE_KEY);
56
+ if (isValidDeviceId(existing))
57
+ return existing;
58
+ }
59
+ catch {
60
+ return mint();
61
+ }
62
+ const minted = mint();
63
+ try {
64
+ window.localStorage.setItem(STORAGE_KEY, minted);
65
+ }
66
+ catch {
67
+ /* not persistable — the minted id is still returned and used for this call */
68
+ }
69
+ return minted;
70
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * PAY-1608: a 2FA lock's window, stated as the IdP enforces it. Never a hard-coded "15 minutes".
3
+ *
4
+ * Core answers every 2FA lock with 429 code "locked" plus Retry-After: MfaController.SecondFactorLocked sends the
5
+ * full lockout (900), and VerifyTotp sends what is LEFT of the lock. The portal used to hard-code "locked for 15
6
+ * minutes" in three places (verify-code-copy.ts, twofa-rejection.ts, and the next-mvp BFF), which was true only
7
+ * while every lock was exactly 15 minutes and the user had just tripped it.
8
+ *
9
+ * The window arrives in one of two ways:
10
+ * - Door A (verify-code): next-mvp >= 4.5.2 relays it in the BFF body as `retryAfterSeconds` (a number).
11
+ * - Door B (admin-login): this route reads the IdP's Retry-After header itself.
12
+ * With no window, the sentence states NO number rather than a guessed one.
13
+ *
14
+ * Dependency-free on purpose: the verify-code page (client) and the admin-login route (server) both use it, and
15
+ * the chain gate executes it directly.
16
+ */
17
+ /** A positive whole number of seconds from the BFF body, or undefined. Anything else - a string, 0, NaN - is dropped. */
18
+ export declare function lockSecondsFromBody(value: unknown): number | undefined;
19
+ /** A Retry-After header as whole seconds. ONE implementation: the package's lib/retry-after (the portal copy was the same rule). */
20
+ export { parseRetryAfterSeconds } from './retry-after';
21
+ /**
22
+ * The window in words, rounded UP so the user is never told a shorter wait than the IdP enforces:
23
+ * 900 -> "15 minutes", 61 -> "2 minutes", 60 -> "1 minute", 45 -> "45 seconds", 7200 -> "2 hours".
24
+ */
25
+ export declare function formatLockWindow(seconds: number | undefined): string | undefined;
26
+ /** The sentence for a lock whose window was NOT sent. It says even a correct code is refused, and states no number. */
27
+ export declare const LOCKED_NO_WINDOW = "Too many incorrect codes. Verification is locked for now - even a correct code is refused until the lock ends. Wait before entering another code.";
28
+ /** The locked sentence: the IdP's real window when it sent one, otherwise LOCKED_NO_WINDOW. */
29
+ export declare function lockedSentence(seconds?: number): string;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * PAY-1608: a 2FA lock's window, stated as the IdP enforces it. Never a hard-coded "15 minutes".
4
+ *
5
+ * Core answers every 2FA lock with 429 code "locked" plus Retry-After: MfaController.SecondFactorLocked sends the
6
+ * full lockout (900), and VerifyTotp sends what is LEFT of the lock. The portal used to hard-code "locked for 15
7
+ * minutes" in three places (verify-code-copy.ts, twofa-rejection.ts, and the next-mvp BFF), which was true only
8
+ * while every lock was exactly 15 minutes and the user had just tripped it.
9
+ *
10
+ * The window arrives in one of two ways:
11
+ * - Door A (verify-code): next-mvp >= 4.5.2 relays it in the BFF body as `retryAfterSeconds` (a number).
12
+ * - Door B (admin-login): this route reads the IdP's Retry-After header itself.
13
+ * With no window, the sentence states NO number rather than a guessed one.
14
+ *
15
+ * Dependency-free on purpose: the verify-code page (client) and the admin-login route (server) both use it, and
16
+ * the chain gate executes it directly.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.LOCKED_NO_WINDOW = exports.parseRetryAfterSeconds = void 0;
20
+ exports.lockSecondsFromBody = lockSecondsFromBody;
21
+ exports.formatLockWindow = formatLockWindow;
22
+ exports.lockedSentence = lockedSentence;
23
+ /** A positive whole number of seconds from the BFF body, or undefined. Anything else - a string, 0, NaN - is dropped. */
24
+ function lockSecondsFromBody(value) {
25
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.ceil(value) : undefined;
26
+ }
27
+ /** A Retry-After header as whole seconds. ONE implementation: the package's lib/retry-after (the portal copy was the same rule). */
28
+ var retry_after_1 = require("./retry-after");
29
+ Object.defineProperty(exports, "parseRetryAfterSeconds", { enumerable: true, get: function () { return retry_after_1.parseRetryAfterSeconds; } });
30
+ /**
31
+ * The window in words, rounded UP so the user is never told a shorter wait than the IdP enforces:
32
+ * 900 -> "15 minutes", 61 -> "2 minutes", 60 -> "1 minute", 45 -> "45 seconds", 7200 -> "2 hours".
33
+ */
34
+ function formatLockWindow(seconds) {
35
+ if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds <= 0)
36
+ return undefined;
37
+ const plural = (n, unit) => `${n} ${unit}${n === 1 ? '' : 's'}`;
38
+ if (seconds < 60)
39
+ return plural(Math.ceil(seconds), 'second');
40
+ const minutes = Math.ceil(seconds / 60);
41
+ if (minutes < 120)
42
+ return plural(minutes, 'minute');
43
+ return plural(Math.ceil(minutes / 60), 'hour');
44
+ }
45
+ /** The sentence for a lock whose window was NOT sent. It says even a correct code is refused, and states no number. */
46
+ exports.LOCKED_NO_WINDOW = 'Too many incorrect codes. Verification is locked for now - even a correct code is refused until the lock ends. Wait before entering another code.';
47
+ /** The locked sentence: the IdP's real window when it sent one, otherwise LOCKED_NO_WINDOW. */
48
+ function lockedSentence(seconds) {
49
+ const window = formatLockWindow(seconds);
50
+ return window
51
+ ? `Too many incorrect codes. Verification is locked for ${window} - wait before entering another code.`
52
+ : exports.LOCKED_NO_WINDOW;
53
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PAY-2319 (4.7.2): what the login page SAYS for an `?error=` / `?oauth_error=` code, as pure functions so a test can
3
+ * execute them (the page is a client component and effects do not run in a static render).
4
+ *
5
+ * 4.7.1 mapped these codes in an effect that called setLoginError, but the page never RENDERED loginError (it only fed the
6
+ * loading gate), so no sentence was ever shown (NightHawk's walk, 73801, W1). Now that the text is displayed, a raw code from
7
+ * the URL must NOT be echoed: `/account-auth/login?error=<anything an attacker types>` would otherwise print attacker-chosen
8
+ * text on the login page (content spoofing / phishing). Known codes get their sentence; anything else gets one generic
9
+ * sentence; nothing from the URL is ever shown verbatim.
10
+ */
11
+ export declare const GENERIC_LOGIN_ERROR = "We could not sign you in. Please try again.";
12
+ /**
13
+ * The sentence for `?error=<code>`, or null when nothing should be shown.
14
+ * SessionExpired is a normal event (not an error) and shows nothing; an absent/empty code shows nothing.
15
+ */
16
+ export declare function friendlyLoginError(code: string | null | undefined): string | null;
17
+ /** `?oauth_error=<provider>`: only a plain provider-like slug is echoed (capitalised); anything else is the generic sentence. */
18
+ export declare function oauthFailureMessage(provider: string | null | undefined): string | null;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * PAY-2319 (4.7.2): what the login page SAYS for an `?error=` / `?oauth_error=` code, as pure functions so a test can
4
+ * execute them (the page is a client component and effects do not run in a static render).
5
+ *
6
+ * 4.7.1 mapped these codes in an effect that called setLoginError, but the page never RENDERED loginError (it only fed the
7
+ * loading gate), so no sentence was ever shown (NightHawk's walk, 73801, W1). Now that the text is displayed, a raw code from
8
+ * the URL must NOT be echoed: `/account-auth/login?error=<anything an attacker types>` would otherwise print attacker-chosen
9
+ * text on the login page (content spoofing / phishing). Known codes get their sentence; anything else gets one generic
10
+ * sentence; nothing from the URL is ever shown verbatim.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.GENERIC_LOGIN_ERROR = void 0;
14
+ exports.friendlyLoginError = friendlyLoginError;
15
+ exports.oauthFailureMessage = oauthFailureMessage;
16
+ exports.GENERIC_LOGIN_ERROR = 'We could not sign you in. Please try again.';
17
+ const KNOWN = {
18
+ TwoFactorTimeout: 'Your verification step timed out before the code was confirmed. Please sign in again.',
19
+ AUTHORIZE_RESUME_REFUSED: 'That sign-in request could not be continued. Please sign in again.',
20
+ ServiceUnavailable: 'Authentication service is temporarily unavailable. Please try again in a few minutes.',
21
+ CredentialsSignin: 'Invalid email or password. Please try again.',
22
+ };
23
+ /**
24
+ * The sentence for `?error=<code>`, or null when nothing should be shown.
25
+ * SessionExpired is a normal event (not an error) and shows nothing; an absent/empty code shows nothing.
26
+ */
27
+ function friendlyLoginError(code) {
28
+ if (typeof code !== 'string' || code === '')
29
+ return null;
30
+ if (code === 'SessionExpired')
31
+ return null;
32
+ if (Object.prototype.hasOwnProperty.call(KNOWN, code))
33
+ return KNOWN[code];
34
+ // The old raw-JSON parse failures the middleware/proxy could bounce here:
35
+ if (code.startsWith('Unexpected token') || code.includes('not valid JSON')) {
36
+ return 'An authentication error occurred. Please try signing in again.';
37
+ }
38
+ return exports.GENERIC_LOGIN_ERROR;
39
+ }
40
+ /** `?oauth_error=<provider>`: only a plain provider-like slug is echoed (capitalised); anything else is the generic sentence. */
41
+ function oauthFailureMessage(provider) {
42
+ if (typeof provider !== 'string' || provider === '')
43
+ return null;
44
+ if (!/^[a-z][a-z0-9_-]{0,31}$/i.test(provider))
45
+ return exports.GENERIC_LOGIN_ERROR;
46
+ return `${provider.charAt(0).toUpperCase()}${provider.slice(1)} sign-in did not complete. Please try again.`;
47
+ }
@@ -0,0 +1,20 @@
1
+ export interface TwofaLaneResult {
2
+ status: number;
3
+ body: string;
4
+ /** PAY-2284: which lane this answer came from, so a fault in the TOTP/SMS lane can offer the email lane (never offered when the EMAIL lane is the one that faulted). */
5
+ lane?: 'totp' | 'sms' | 'email';
6
+ /** PAY-1608: this lane's Retry-After header, as received. */
7
+ retryAfter?: string | null;
8
+ }
9
+ export interface TwofaRejection {
10
+ status: 400 | 429 | 502;
11
+ error: string;
12
+ retryAfter?: number;
13
+ /**
14
+ * PAY-2284: true when the authenticator (or text) lane failed on OUR side and the emailed-code lane has not faulted. The sign-in
15
+ * card then shows a real "Email me a code instead" action. Before this, the copy said "use another sign-in method" and the screen
16
+ * offered none, and a TOTP holder - for whom the door sends NOTHING at sign-in - was stuck (Jon, 12 Oct, dev-93 key version 57).
17
+ */
18
+ offerEmailCode?: true;
19
+ }
20
+ export declare function classifyTwofaRejection(lanes: TwofaLaneResult[], retryAfterHeader?: string | null): TwofaRejection;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyTwofaRejection = classifyTwofaRejection;
4
+ /**
5
+ * Door B (/api/auth/admin-login) twofa verify: what to tell the user when every lane refused.
6
+ *
7
+ * Classification is by the MOST BLOCKING outcome across lanes (268121 ruling), in this order:
8
+ * 429 from the IdP, or any lane answering code `locked` -> 429 lockout (PAY-903)
9
+ * any 5xx, or a lane answering code server_error / service_unavailable (PAY-1589) -> 502 "our side, not your code"
10
+ * otherwise -> 400 wrong / expired code
11
+ *
12
+ * PAY-903: MfaController.VerifyTotp returns 400 {message, code:"locked"} for a 15-minute lockout
13
+ * (MfaTotpService ErrorCode "locked"). Status-only classification read that as "wrong code, try again" -
14
+ * coaching a locked-out user to spend attempts. The body is inspected for EVERY lane, because with lane
15
+ * order [totp, email] the last response is the email lane's and never carries the TOTP lockout.
16
+ * Disclosing the lockout here is safe: this step is post-password (the caller already proved the account).
17
+ *
18
+ * PAY-1608: the lockout states the LOCKED LANE's own Retry-After (Core sends one on every 2FA lock; VerifyTotp sends
19
+ * what is LEFT of it). It used to hard-code 15 minutes / 900 s. With no usable header, no number is stated and
20
+ * `retryAfter` is omitted rather than invented.
21
+ */
22
+ const lock_window_1 = require("./lock-window");
23
+ /** Every code the IdP body carries: flat {code}, envelope {error:{code}}, or {error:{details:{code}}}. */
24
+ function laneCodes(body) {
25
+ try {
26
+ const j = JSON.parse(body);
27
+ if (!j || typeof j !== 'object')
28
+ return [];
29
+ const err = (j.error && typeof j.error === 'object' ? j.error : null);
30
+ const details = (err?.details && typeof err.details === 'object' ? err.details : null);
31
+ return [j.code, err?.code, details?.code].filter((c) => typeof c === 'string').map((c) => c.toLowerCase());
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ function classifyTwofaRejection(lanes, retryAfterHeader) {
38
+ const lockedLane = lanes.find((l) => laneCodes(l.body).includes('locked'));
39
+ if (lockedLane) {
40
+ const secs = (0, lock_window_1.parseRetryAfterSeconds)(lockedLane.retryAfter);
41
+ return { status: 429, error: (0, lock_window_1.lockedSentence)(secs), ...(secs ? { retryAfter: secs } : {}) };
42
+ }
43
+ if (lanes.some((l) => l.status === 429)) {
44
+ const parsed = retryAfterHeader ? parseInt(retryAfterHeader, 10) : NaN;
45
+ return {
46
+ status: 429,
47
+ error: 'Too many attempts. Your code is still valid - wait before trying again.',
48
+ retryAfter: Number.isFinite(parsed) && parsed > 0 ? parsed : 60,
49
+ };
50
+ }
51
+ // PAY-1589: an IdP-side fault that arrives as 400 + code (TOTP secret cannot be decrypted -> server_error;
52
+ // replay store down -> service_unavailable). It is not the user's code and does not count toward the lockout,
53
+ // so calling it "not right" sends them round a loop that cannot succeed. Email may still work, so say so.
54
+ const faulted = (l) => laneCodes(l.body).some((c) => c === 'server_error' || c === 'service_unavailable');
55
+ if (lanes.some(faulted)) {
56
+ const emailLaneFaulted = lanes.some((l) => l.lane === 'email' && (faulted(l) || l.status >= 500));
57
+ const offer = !emailLaneFaulted && lanes.some((l) => faulted(l) && (l.lane === 'totp' || l.lane === 'sms'));
58
+ return {
59
+ status: 502,
60
+ error: offer
61
+ ? 'We could not check your code just now - this is a problem on our side, not with your code. You can have us email you a code instead.'
62
+ : 'We could not check your code just now - this is a problem on our side, not with your code. Try again shortly.',
63
+ ...(offer ? { offerEmailCode: true } : {}),
64
+ };
65
+ }
66
+ if (lanes.some((l) => l.status >= 500)) {
67
+ return {
68
+ status: 502,
69
+ error: 'We could not check your code just now - this is a problem on our side, not with your code. Try again shortly.',
70
+ };
71
+ }
72
+ return { status: 400, error: 'That code is not right or has expired. Try again.' };
73
+ }
@@ -136,6 +136,17 @@ export interface MvpMiddlewareOptions {
136
136
  * is signed out for not implementing the check).
137
137
  */
138
138
  revocationFailMode?: 'closed' | 'open';
139
+ /**
140
+ * PAY-2302 cut 1c (BAPert 73585): this app has NO revocation source - for example a development environment
141
+ * provisioned without a vibe client id / HMAC key - and says so EXPLICITLY. Under it a viability answer of
142
+ * `revocationStatus: 'not_configured'` is viable, and a loud warning is logged once at startup.
143
+ *
144
+ * It relaxes ONLY 'not_configured'. 'unknown' (a revocation read that FAILED) and 'revoked' stay closed whatever
145
+ * `revocationFailMode` says, and the default (option absent) is unchanged: 'not_configured' fails closed, because
146
+ * for an app that HAS a vibe client it means a misconfiguration (BAPert 66356). Do not use this to paper over a
147
+ * misconfigured production app; remove it when the environment has a vibe client + HMAC key.
148
+ */
149
+ noRevocationSource?: boolean;
139
150
  }
140
151
  /**
141
152
  * PAY-2136 Rule A: a speculative request (router prefetch) must NEVER mutate cookies.
@@ -166,4 +177,4 @@ export declare function decideForceInvalid(data: {
166
177
  revocationStatus?: unknown;
167
178
  forceInvalid?: unknown;
168
179
  revoked?: unknown;
169
- }, revocationFailMode: 'closed' | 'open'): boolean;
180
+ }, revocationFailMode: 'closed' | 'open', noRevocationSource?: boolean): boolean;
@@ -60,8 +60,12 @@ const defaultLogger = {
60
60
  // =============================================================================
61
61
  const LOGIN_PAGE = '/account-auth/login';
62
62
  const VERIFY_CODE_PAGE = '/account-auth/verify-code';
63
+ // PAY-2315 (4.7.1): /login is a public alias of the login page. It used to take the 'public: allow' arm and never reached the
64
+ // 'already_authenticated' redirect, so a signed-in user was shown the sign-in form. It is the login page for every arm now.
65
+ // (safe-callback refuses /login as a destination, so this cannot redirect to itself.)
66
+ const LOGIN_ALIAS = '/login';
63
67
  function isLoginPage(pathname) {
64
- return pathname === LOGIN_PAGE;
68
+ return pathname === LOGIN_PAGE || pathname === LOGIN_ALIAS;
65
69
  }
66
70
  /**
67
71
  * Ensures callback URLs never point to auth pages (prevents redirect loops) AND
@@ -378,6 +382,13 @@ function createMvpMiddleware(options = {}) {
378
382
  const rbacExemptPaths = options.rbacExemptPaths || [];
379
383
  // PAY-1882 step 4: default 'closed' (Jon's option A / BAPert 66316).
380
384
  const revocationFailMode = options.revocationFailMode || 'closed';
385
+ // PAY-2302 cut 1c: strictly `=== true`, so a truthy string in a config file cannot switch revocation off.
386
+ const noRevocationSource = options.noRevocationSource === true;
387
+ if (noRevocationSource) {
388
+ log.warn('[next-mvp] noRevocationSource is ON: sessions of this app CANNOT be revoked server-side (no vibe client / HMAC key). ' +
389
+ "revocationStatus 'not_configured' is treated as viable; 'unknown' and 'revoked' still sign the user out. " +
390
+ 'Remove this option once the environment has a vibe client id and HMAC key.');
391
+ }
381
392
  const sessionResetRoute = options.sessionResetRoute === true ? session_reset_link_1.DEFAULT_SESSION_RESET_ROUTE
382
393
  : typeof options.sessionResetRoute === 'string' && options.sessionResetRoute ? options.sessionResetRoute
383
394
  : undefined;
@@ -430,7 +441,7 @@ function createMvpMiddleware(options = {}) {
430
441
  // Has cookie - continue to viability check for 2FA enforcement
431
442
  }
432
443
  // --- Fetch session viability from internal API ---
433
- const { sessionStatus, sessionPointer } = await checkViability(request, viabilityEndpoint, log, revocationFailMode);
444
+ const { sessionStatus, sessionPointer } = await checkViability(request, viabilityEndpoint, log, revocationFailMode, noRevocationSource);
434
445
  // --- Stale session (cookie exists but session doesn't): OBSERVE ONLY, DO NOT DECIDE ---
435
446
  //
436
447
  // *** CARD 349607. THIS BLOCK USED TO `return` HERE, AND THAT RETURN WAS A BYPASS. ***
@@ -505,13 +516,16 @@ function createMvpMiddleware(options = {}) {
505
516
  * 'unknown'/'not_configured'. The booleans are read ONLY when revocationStatus is
506
517
  * absent (idealresume.online's older boolean-only route).
507
518
  */
508
- function decideForceInvalid(data, revocationFailMode) {
519
+ function decideForceInvalid(data, revocationFailMode, noRevocationSource = false) {
509
520
  const status = data.revocationStatus;
510
521
  if (typeof status === 'string') {
511
522
  if (status === 'revoked')
512
523
  return true;
513
524
  if (status === 'active')
514
525
  return false;
526
+ // PAY-2302 cut 1c: an app that declared it has no revocation source. ONLY the exact 'not_configured' string.
527
+ if (status === 'not_configured' && noRevocationSource === true)
528
+ return false;
515
529
  // S1 (NightHawk 66409): ANY other string - 'unknown', 'not_configured', a
516
530
  // typo like 'Revoked', 'error', or '' - is treated as 'unknown' (fail mode
517
531
  // applies), NEVER as 'active'. Returning false here would let the first
@@ -534,7 +548,7 @@ function hasSessionCookie(request) {
534
548
  return !!(request.cookies.get((0, app_slug_1.getSessionCookieName)())?.value || request.cookies.get((0, app_slug_1.getSecureSessionCookieName)())?.value);
535
549
  }
536
550
  /** Check session viability via internal API */
537
- async function checkViability(request, endpoint, log, revocationFailMode) {
551
+ async function checkViability(request, endpoint, log, revocationFailMode, noRevocationSource = false) {
538
552
  const sessionStatus = {
539
553
  exists: false,
540
554
  forceInvalid: false,
@@ -606,7 +620,7 @@ async function checkViability(request, endpoint, log, revocationFailMode) {
606
620
  // revocations status, decide from it + failMode and ignore the folded
607
621
  // booleans for unknown/not_configured. The booleans are read ONLY when
608
622
  // revocationStatus is ABSENT (idealresume.online's older boolean route).
609
- sessionStatus.forceInvalid = decideForceInvalid(data, revocationFailMode);
623
+ sessionStatus.forceInvalid = decideForceInvalid(data, revocationFailMode, noRevocationSource);
610
624
  // PAY-2216: a STALE session - the cookie resolved to a token, but no store holds the session - used to set
611
625
  // pointer.exists=false, so makeAuthDecision took no_session (login, cookie NOT cleared) and its stale_session
612
626
  // arm (clearCookies) was unreachable: a dead cookie lingered and re-ran viability on every request.
@@ -29,6 +29,7 @@ const better_auth_client_1 = require("../../client/better-auth-client");
29
29
  const navigation_1 = require("next/navigation");
30
30
  const react_2 = require("react");
31
31
  const useTheme_1 = require("../../theme/useTheme");
32
+ const login_error_message_1 = require("../../lib/login-error-message");
32
33
  function LoginForm({ altAuthSlot }) {
33
34
  const searchParams = (0, navigation_1.useSearchParams)();
34
35
  const callbackUrl = searchParams?.get('callbackUrl') || '/dashboard';
@@ -110,46 +111,19 @@ function LoginForm({ altAuthSlot }) {
110
111
  // Atomic state management - only ONE can be true at a time
111
112
  const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
112
113
  const [loginSuccess, setLoginSuccess] = (0, react_1.useState)(false);
113
- const [loginError, setLoginError] = (0, react_1.useState)(null);
114
+ // undefined = the user has not acted yet (show what the URL says); null/string = an explicit state set by a handler below.
115
+ const [loginError, setLoginError] = (0, react_1.useState)(undefined);
114
116
  const [loading, setLoading] = (0, react_1.useState)(false);
115
117
  const [showRecoveryOptions, setShowRecoveryOptions] = (0, react_1.useState)(false);
116
118
  // Force show form after timeout if stuck in loading
117
119
  const [forceShowForm, setForceShowForm] = (0, react_1.useState)(false);
118
- // Surface OAuth failures the Better Auth mount bounced back here.
120
+ // PAY-2319 (4.7.2): what the URL says, derived at render (no effect) so it is shown on the FIRST paint and in a static render.
121
+ // 4.7.1 mapped these in effects that only set loginError, which was never rendered. Unknown codes are NOT echoed (see lib/login-error-message).
122
+ const urlMessage = (0, login_error_message_1.oauthFailureMessage)(oauthError) ?? (0, login_error_message_1.friendlyLoginError)(urlError);
123
+ const shownError = loginError !== undefined ? loginError : urlMessage;
119
124
  (0, react_1.useEffect)(() => {
120
- if (oauthError) {
121
- const name = oauthError.charAt(0).toUpperCase() + oauthError.slice(1);
122
- setLoginError(`${name} sign-in did not complete. Please try again.`);
123
- }
124
- }, [oauthError]);
125
- // Handle URL errors with user-friendly messages
126
- (0, react_1.useEffect)(() => {
127
- if (urlError) {
128
- let friendlyError = urlError;
129
- if (urlError === 'SessionExpired') {
130
- // Session expiration is normal - don't show as error
131
- console.log('[LOGIN] SessionExpired detected - normal behavior');
132
- friendlyError = null;
133
- }
134
- else if (urlError === 'TwoFactorTimeout') {
135
- // PAY-884: the sign-in expired while the verification code was outstanding. Unlike
136
- // SessionExpired this is NOT silent - the user was mid-2FA and must know why they are here.
137
- friendlyError = 'Your verification step timed out before the code was confirmed. Please sign in again.';
138
- }
139
- else if (urlError === 'ServiceUnavailable') {
140
- friendlyError = 'Authentication service is temporarily unavailable. Please try again in a few minutes.';
141
- }
142
- else if (urlError.startsWith("Unexpected token")) {
143
- friendlyError = 'An authentication error occurred. Please try signing in again.';
144
- }
145
- else if (urlError.includes('not valid JSON')) {
146
- friendlyError = 'An authentication error occurred. Please try signing in again.';
147
- }
148
- else if (urlError === 'CredentialsSignin') {
149
- friendlyError = 'Invalid email or password. Please try again.';
150
- }
151
- setLoginError(friendlyError);
152
- }
125
+ if (urlError === 'SessionExpired')
126
+ console.log('[LOGIN] SessionExpired detected - normal behavior');
153
127
  }, [urlError]);
154
128
  // Timeout to prevent infinite loading states
155
129
  (0, react_1.useEffect)(() => {
@@ -175,7 +149,7 @@ function LoginForm({ altAuthSlot }) {
175
149
  // authClient.signIn.email, which better-auth always rejected because this
176
150
  // package never configures emailAndPassword. See the note at the render site.
177
151
  // Show loading spinner for initial loads
178
- if (!forceShowForm && !loginError && (loading || (status === 'loading' && !session))) {
152
+ if (!forceShowForm && !shownError && (loading || (status === 'loading' && !session))) {
179
153
  return ((0, jsx_runtime_1.jsxs)("div", { className: `flex flex-col items-center justify-center min-h-screen ${colors.background}`, children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin h-6 w-6", style: { color: buttonColor }, viewBox: "0 0 24 24", fill: "none", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] }), (0, jsx_runtime_1.jsx)("p", { className: `mt-4 text-sm ${colors.muted}`, children: status === 'loading' ? 'Loading...' : 'Authenticating...' })] }));
180
154
  }
181
155
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: `
@@ -206,7 +180,7 @@ function LoginForm({ altAuthSlot }) {
206
180
  .themed-status-submitting svg {
207
181
  color: ${buttonColor} !important;
208
182
  }
209
- ` } }), (0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center px-4 ${colors.background}`, children: (0, jsx_runtime_1.jsx)("div", { className: "max-w-md w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: `rounded-2xl shadow-xl p-8 ${colors.card} ${colors.border} text-gray-800`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-center mb-8", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-3xl font-bold mb-2", style: { color: 'inherit' }, children: branding.tagline || 'Welcome Back' }), (0, jsx_runtime_1.jsx)("p", { className: colors.muted, children: "Sign in to your account" })] }), googleEnabled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => void handleGoogleSignIn(), disabled: googleLoading || isSubmitting, "data-testid": "google-sign-in", className: "w-full px-4 py-3 mb-6 rounded-lg border border-gray-300 font-semibold transition-colors flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50", style: { backgroundColor: 'white', color: '#1f2937' }, children: [googleLoading ? ((0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin w-5 h-5", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] })) : ((0, jsx_runtime_1.jsxs)("svg", { className: "w-5 h-5", viewBox: "0 0 24 24", fill: "currentColor", children: [(0, jsx_runtime_1.jsx)("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }), (0, jsx_runtime_1.jsx)("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })] })), googleLoading ? 'Redirecting to Google…' : 'Continue with Google'] }) })), altAuthSlot && (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: altAuthSlot }), (0, jsx_runtime_1.jsx)("div", { className: `mt-6 text-center text-sm ${colors.muted}`, children: (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/recovery", className: "themed-link hover:underline", children: "Start account recovery" }) })] }) }) })] }));
183
+ ` } }), (0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center px-4 ${colors.background}`, children: (0, jsx_runtime_1.jsx)("div", { className: "max-w-md w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: `rounded-2xl shadow-xl p-8 ${colors.card} ${colors.border} text-gray-800`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-center mb-8", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-3xl font-bold mb-2", style: { color: 'inherit' }, children: branding.tagline || 'Welcome Back' }), (0, jsx_runtime_1.jsx)("p", { className: colors.muted, children: "Sign in to your account" })] }), shownError && ((0, jsx_runtime_1.jsx)("div", { role: "alert", "data-testid": "login-error", className: "mb-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700", children: shownError })), googleEnabled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => void handleGoogleSignIn(), disabled: googleLoading || isSubmitting, "data-testid": "google-sign-in", className: "w-full px-4 py-3 mb-6 rounded-lg border border-gray-300 font-semibold transition-colors flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50", style: { backgroundColor: 'white', color: '#1f2937' }, children: [googleLoading ? ((0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin w-5 h-5", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] })) : ((0, jsx_runtime_1.jsxs)("svg", { className: "w-5 h-5", viewBox: "0 0 24 24", fill: "currentColor", children: [(0, jsx_runtime_1.jsx)("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }), (0, jsx_runtime_1.jsx)("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })] })), googleLoading ? 'Redirecting to Google…' : 'Continue with Google'] }) })), altAuthSlot && (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: altAuthSlot }), (0, jsx_runtime_1.jsx)("div", { className: `mt-6 text-center text-sm ${colors.muted}`, children: (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/recovery", className: "themed-link hover:underline", children: "Start account recovery" }) })] }) }) })] }));
210
184
  }
211
185
  function LoginPageFallback() {
212
186
  const colors = (0, useTheme_1.useColors)();
@@ -0,0 +1,6 @@
1
+ /**
2
+ * PAY-2302 cut 1: ask the IdP to email a code when the authenticator lane failed on our side.
3
+ * The handler lives in api-handlers/auth/credential-login-email-code.ts (moved from VibeID-Customer-Portal src/app/api/auth/admin-login/email-code/route.ts). A consuming app's route file
4
+ * re-exports POST and writes `export const runtime = 'nodejs'` literally.
5
+ */
6
+ export { POST } from '../../api-handlers/auth/credential-login-email-code';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST = void 0;
4
+ /**
5
+ * PAY-2302 cut 1: ask the IdP to email a code when the authenticator lane failed on our side.
6
+ * The handler lives in api-handlers/auth/credential-login-email-code.ts (moved from VibeID-Customer-Portal src/app/api/auth/admin-login/email-code/route.ts). A consuming app's route file
7
+ * re-exports POST and writes `export const runtime = 'nodejs'` literally.
8
+ */
9
+ var credential_login_email_code_1 = require("../../api-handlers/auth/credential-login-email-code");
10
+ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { return credential_login_email_code_1.POST; } });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * PAY-2302 cut 1: password sign-in route (IdP ExternalAuth/login, session written via lib/session-store, 2FA-outstanding handling).
3
+ * The handler lives in api-handlers/auth/credential-login.ts (moved from VibeID-Customer-Portal src/app/api/auth/admin-login/route.ts). A consuming app's route file
4
+ * re-exports POST and writes `export const runtime = 'nodejs'` literally.
5
+ */
6
+ export { POST } from '../../api-handlers/auth/credential-login';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST = void 0;
4
+ /**
5
+ * PAY-2302 cut 1: password sign-in route (IdP ExternalAuth/login, session written via lib/session-store, 2FA-outstanding handling).
6
+ * The handler lives in api-handlers/auth/credential-login.ts (moved from VibeID-Customer-Portal src/app/api/auth/admin-login/route.ts). A consuming app's route file
7
+ * re-exports POST and writes `export const runtime = 'nodejs'` literally.
8
+ */
9
+ var credential_login_1 = require("../../api-handlers/auth/credential-login");
10
+ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { return credential_login_1.POST; } });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * PAY-2302 cut 2: post-2FA OAuth authorize resume route. The handler lives in api-handlers/oauth/resume.ts
3
+ * (moved from VibeID-Customer-Portal src/app/api/oauth/resume/route.ts). A consuming app's route file re-exports GET
4
+ * and writes `export const runtime = 'nodejs'` literally.
5
+ *
6
+ * 4.7.3: `createOAuthResumeHandler({ refusalLocation })` and `DEFAULT_REFUSAL_LOCATION` are re-exported HERE because a consumer can only
7
+ * import what `package.json` `exports` lists, and this route module is the entry. An app whose sign-in page is not
8
+ * /account-auth/login (the portal uses /sign-in) writes `export const GET = createOAuthResumeHandler({ refusalLocation: '/sign-in?error=AUTHORIZE_RESUME_REFUSED' });`.
9
+ */
10
+ export { GET, createOAuthResumeHandler, DEFAULT_REFUSAL_LOCATION } from '../../api-handlers/oauth/resume';
11
+ export type { OAuthResumeOptions, OAuthResumeDeps } from '../../api-handlers/oauth/resume';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_REFUSAL_LOCATION = exports.createOAuthResumeHandler = exports.GET = void 0;
4
+ /**
5
+ * PAY-2302 cut 2: post-2FA OAuth authorize resume route. The handler lives in api-handlers/oauth/resume.ts
6
+ * (moved from VibeID-Customer-Portal src/app/api/oauth/resume/route.ts). A consuming app's route file re-exports GET
7
+ * and writes `export const runtime = 'nodejs'` literally.
8
+ *
9
+ * 4.7.3: `createOAuthResumeHandler({ refusalLocation })` and `DEFAULT_REFUSAL_LOCATION` are re-exported HERE because a consumer can only
10
+ * import what `package.json` `exports` lists, and this route module is the entry. An app whose sign-in page is not
11
+ * /account-auth/login (the portal uses /sign-in) writes `export const GET = createOAuthResumeHandler({ refusalLocation: '/sign-in?error=AUTHORIZE_RESUME_REFUSED' });`.
12
+ */
13
+ var resume_1 = require("../../api-handlers/oauth/resume");
14
+ Object.defineProperty(exports, "GET", { enumerable: true, get: function () { return resume_1.GET; } });
15
+ Object.defineProperty(exports, "createOAuthResumeHandler", { enumerable: true, get: function () { return resume_1.createOAuthResumeHandler; } });
16
+ Object.defineProperty(exports, "DEFAULT_REFUSAL_LOCATION", { enumerable: true, get: function () { return resume_1.DEFAULT_REFUSAL_LOCATION; } });
@@ -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;