@payez/next-mvp 4.8.7 → 4.8.8
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/README.md +1 -1
- package/dist/lib/require-idp-url.d.ts +12 -0
- package/dist/lib/require-idp-url.js +26 -0
- package/dist/routes/account/masked-info.d.ts +1 -1
- package/dist/routes/account/masked-info.js +1 -1
- package/dist/routes/account/send-code.d.ts +1 -1
- package/dist/routes/account/send-code.js +1 -1
- package/dist/routes/account/verify-email.d.ts +1 -1
- package/dist/routes/account/verify-email.js +1 -1
- package/dist/routes/account/verify-sms.d.ts +1 -1
- package/dist/routes/account/verify-sms.js +1 -1
- package/package.json +6 -1
- package/src/lib/require-idp-url.ts +27 -0
- package/src/routes/account/masked-info.ts +1 -1
- package/src/routes/account/send-code.ts +1 -1
- package/src/routes/account/verify-email.ts +1 -1
- package/src/routes/account/verify-sms.ts +1 -1
package/README.md
CHANGED
|
@@ -548,7 +548,7 @@ import { POST as logout } from '@payez/next-mvp/routes/auth/logout';
|
|
|
548
548
|
| Variable | Required | Description |
|
|
549
549
|
|----------|----------|-------------|
|
|
550
550
|
| `CLIENT_ID` | ✅ Yes | Your PayEz IDP client ID (string slug, e.g., `payez_idp_admin_web`) |
|
|
551
|
-
| `IDP_URL` | ✅ Yes | PayEz IDP base URL (e.g., `https://idp.payez.net` or `http://localhost:32785`) |
|
|
551
|
+
| `IDP_URL` | ✅ Yes | PayEz IDP base URL (e.g., `https://idp.payez.net` or `http://localhost:32785`). **No default in code.** Call `requireIdpUrl()` from `@payez/next-mvp/lib/require-idp-url` in your `instrumentation.ts` (4.8.8) and the server refuses to start, with one fixed sentence, when it is missing or not a full http(s) address. The quickstart generator writes the production address into `.env.local` and adds that file for you. |
|
|
552
552
|
| `AUTH_TRUST_HOST` | ✅ Yes | Must be `true` - NextAuth derives OAuth URLs from request headers |
|
|
553
553
|
| `NEXTAUTH_SECRET` | 🔄 Broker | **Do NOT set** - fetched automatically from IDP at startup (see below) |
|
|
554
554
|
| `CLIENT_SECRET` | ⚠️ Legacy | Not needed with broker mode - IDP handles signing |
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4.8.8 (item 24, Jon: "fast and loud are how i like my config errors"): the app REQUIRES IDP_URL and says so at START.
|
|
3
|
+
*
|
|
4
|
+
* There is no default in code. The quickstart generator writes the production sign-in service address into the app's .env.local
|
|
5
|
+
* at generation time; rigs override that file. When the value is missing, empty or not an absolute http(s) address, the server
|
|
6
|
+
* refuses to come up - printed once, in one fixed sentence, exit code 1 - instead of booting and failing on the first sign-in.
|
|
7
|
+
*
|
|
8
|
+
* A leaf module: no imports, so a generated `instrumentation.ts` can load it without pulling the session store or the logger.
|
|
9
|
+
*/
|
|
10
|
+
export declare const IDP_URL_REQUIRED_SENTENCE = "IDP_URL is not set to a full http(s) address. This app has no default sign-in service: set IDP_URL in .env.local and start again.";
|
|
11
|
+
/** True when IDP_URL is present and absolute. Otherwise logs the fixed sentence and calls `exit(1)`; returns false if `exit` returns. */
|
|
12
|
+
export declare function requireIdpUrl(env?: Record<string, string | undefined>, exit?: (code: number) => unknown, log?: (line: string) => void): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDP_URL_REQUIRED_SENTENCE = void 0;
|
|
4
|
+
exports.requireIdpUrl = requireIdpUrl;
|
|
5
|
+
/**
|
|
6
|
+
* 4.8.8 (item 24, Jon: "fast and loud are how i like my config errors"): the app REQUIRES IDP_URL and says so at START.
|
|
7
|
+
*
|
|
8
|
+
* There is no default in code. The quickstart generator writes the production sign-in service address into the app's .env.local
|
|
9
|
+
* at generation time; rigs override that file. When the value is missing, empty or not an absolute http(s) address, the server
|
|
10
|
+
* refuses to come up - printed once, in one fixed sentence, exit code 1 - instead of booting and failing on the first sign-in.
|
|
11
|
+
*
|
|
12
|
+
* A leaf module: no imports, so a generated `instrumentation.ts` can load it without pulling the session store or the logger.
|
|
13
|
+
*/
|
|
14
|
+
exports.IDP_URL_REQUIRED_SENTENCE = 'IDP_URL is not set to a full http(s) address. This app has no default sign-in service: set IDP_URL in .env.local and start again.';
|
|
15
|
+
/** True when IDP_URL is present and absolute. Otherwise logs the fixed sentence and calls `exit(1)`; returns false if `exit` returns. */
|
|
16
|
+
function requireIdpUrl(env = process.env, exit = (code) => process.exit(code), log = (line) => console.error(line)) {
|
|
17
|
+
const value = (env.IDP_URL ?? '').trim();
|
|
18
|
+
if (/^https?:\/\/[^/\s]+/i.test(value))
|
|
19
|
+
return true;
|
|
20
|
+
log('');
|
|
21
|
+
log('[STARTUP FAILED - REFUSING TO SERVE]');
|
|
22
|
+
log(` ${exports.IDP_URL_REQUIRED_SENTENCE}`);
|
|
23
|
+
log('');
|
|
24
|
+
exit(1);
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
@@ -22,7 +22,7 @@ export { POST } from '../../api-handlers/account/masked-info';
|
|
|
22
22
|
* email/phone options to the user.
|
|
23
23
|
*
|
|
24
24
|
* Environment variables used:
|
|
25
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
25
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
26
26
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
27
27
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
28
28
|
*
|
|
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { re
|
|
|
28
28
|
* email/phone options to the user.
|
|
29
29
|
*
|
|
30
30
|
* Environment variables used:
|
|
31
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
31
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
32
32
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
33
33
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
34
34
|
*
|
|
@@ -26,7 +26,7 @@ export { POST } from '../../api-handlers/account/send-code';
|
|
|
26
26
|
* - contactId: string - ID of the masked contact to send to
|
|
27
27
|
*
|
|
28
28
|
* Environment variables used:
|
|
29
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
29
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
30
30
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
31
31
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
32
32
|
*
|
|
@@ -31,7 +31,7 @@ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { re
|
|
|
31
31
|
* - contactId: string - ID of the masked contact to send to
|
|
32
32
|
*
|
|
33
33
|
* Environment variables used:
|
|
34
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
34
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
35
35
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
36
36
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
37
37
|
*
|
|
@@ -25,7 +25,7 @@ export { POST } from '../../api-handlers/account/verify-email';
|
|
|
25
25
|
* - emailId: string - ID of the email address used
|
|
26
26
|
*
|
|
27
27
|
* Environment variables used:
|
|
28
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
28
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
29
29
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
30
30
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
31
31
|
*
|
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { re
|
|
|
30
30
|
* - emailId: string - ID of the email address used
|
|
31
31
|
*
|
|
32
32
|
* Environment variables used:
|
|
33
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
33
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
34
34
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
35
35
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
36
36
|
*
|
|
@@ -25,7 +25,7 @@ export { POST } from '../../api-handlers/account/verify-sms';
|
|
|
25
25
|
* - phoneId: string - ID of the phone number used
|
|
26
26
|
*
|
|
27
27
|
* Environment variables used:
|
|
28
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
28
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
29
29
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
30
30
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
31
31
|
*
|
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "POST", { enumerable: true, get: function () { re
|
|
|
30
30
|
* - phoneId: string - ID of the phone number used
|
|
31
31
|
*
|
|
32
32
|
* Environment variables used:
|
|
33
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
33
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
34
34
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
35
35
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
36
36
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payez/next-mvp",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.8",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -179,6 +179,11 @@
|
|
|
179
179
|
"require": "./dist/lib/api-handler.js",
|
|
180
180
|
"default": "./dist/lib/api-handler.js"
|
|
181
181
|
},
|
|
182
|
+
"./lib/require-idp-url": {
|
|
183
|
+
"types": "./dist/lib/require-idp-url.d.ts",
|
|
184
|
+
"require": "./dist/lib/require-idp-url.js",
|
|
185
|
+
"default": "./dist/lib/require-idp-url.js"
|
|
186
|
+
},
|
|
182
187
|
"./lib/startup-init": {
|
|
183
188
|
"types": "./dist/lib/startup-init.d.ts",
|
|
184
189
|
"require": "./dist/lib/startup-init.js",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4.8.8 (item 24, Jon: "fast and loud are how i like my config errors"): the app REQUIRES IDP_URL and says so at START.
|
|
3
|
+
*
|
|
4
|
+
* There is no default in code. The quickstart generator writes the production sign-in service address into the app's .env.local
|
|
5
|
+
* at generation time; rigs override that file. When the value is missing, empty or not an absolute http(s) address, the server
|
|
6
|
+
* refuses to come up - printed once, in one fixed sentence, exit code 1 - instead of booting and failing on the first sign-in.
|
|
7
|
+
*
|
|
8
|
+
* A leaf module: no imports, so a generated `instrumentation.ts` can load it without pulling the session store or the logger.
|
|
9
|
+
*/
|
|
10
|
+
export const IDP_URL_REQUIRED_SENTENCE =
|
|
11
|
+
'IDP_URL is not set to a full http(s) address. This app has no default sign-in service: set IDP_URL in .env.local and start again.';
|
|
12
|
+
|
|
13
|
+
/** True when IDP_URL is present and absolute. Otherwise logs the fixed sentence and calls `exit(1)`; returns false if `exit` returns. */
|
|
14
|
+
export function requireIdpUrl(
|
|
15
|
+
env: Record<string, string | undefined> = process.env,
|
|
16
|
+
exit: (code: number) => unknown = (code) => process.exit(code),
|
|
17
|
+
log: (line: string) => void = (line) => console.error(line),
|
|
18
|
+
): boolean {
|
|
19
|
+
const value = (env.IDP_URL ?? '').trim();
|
|
20
|
+
if (/^https?:\/\/[^/\s]+/i.test(value)) return true;
|
|
21
|
+
log('');
|
|
22
|
+
log('[STARTUP FAILED - REFUSING TO SERVE]');
|
|
23
|
+
log(` ${IDP_URL_REQUIRED_SENTENCE}`);
|
|
24
|
+
log('');
|
|
25
|
+
exit(1);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
@@ -26,7 +26,7 @@ export { POST } from '../../api-handlers/account/masked-info';
|
|
|
26
26
|
* email/phone options to the user.
|
|
27
27
|
*
|
|
28
28
|
* Environment variables used:
|
|
29
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
29
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
30
30
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
31
31
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
32
32
|
*
|
|
@@ -29,7 +29,7 @@ export { POST } from '../../api-handlers/account/send-code';
|
|
|
29
29
|
* - contactId: string - ID of the masked contact to send to
|
|
30
30
|
*
|
|
31
31
|
* Environment variables used:
|
|
32
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
32
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
33
33
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
34
34
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
35
35
|
*
|
|
@@ -28,7 +28,7 @@ export { POST } from '../../api-handlers/account/verify-email';
|
|
|
28
28
|
* - emailId: string - ID of the email address used
|
|
29
29
|
*
|
|
30
30
|
* Environment variables used:
|
|
31
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
31
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
32
32
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
33
33
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
34
34
|
*
|
|
@@ -28,7 +28,7 @@ export { POST } from '../../api-handlers/account/verify-sms';
|
|
|
28
28
|
* - phoneId: string - ID of the phone number used
|
|
29
29
|
*
|
|
30
30
|
* Environment variables used:
|
|
31
|
-
* - IDP_URL or NEXT_PUBLIC_IDP_URL (
|
|
31
|
+
* - IDP_URL or NEXT_PUBLIC_IDP_URL (REQUIRED: there is no default in code)
|
|
32
32
|
* - CLIENT_ID or NEXT_PUBLIC_IDP_CLIENT_ID (required)
|
|
33
33
|
* - BETTER_AUTH_SECRET (required — fetched from IDP at startup)
|
|
34
34
|
*
|