@cored3v/web-core 1.0.3 → 1.0.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/README.md
CHANGED
|
@@ -7,11 +7,13 @@ It supports **Express.js**, **Next.js**, **Nuxt (H3)**, and generic Node.js envi
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **License Enforcement**: Protect your source code by enforcing valid license keys.
|
|
10
|
-
- **JWT Authentication**:
|
|
11
|
-
- **Database Management**:
|
|
10
|
+
- **JWT Authentication**: Optional, built-in JWT verification helper and middleware.
|
|
11
|
+
- **Database Management**: Optional, automatic Postgres connection pooling and lifecycle management.
|
|
12
12
|
- **Security Defaults**: Pre-configured Helmet and CORS for Express.
|
|
13
13
|
- **Multi-Framework**: First-class adapters for Express, Next.js, and H3.
|
|
14
14
|
|
|
15
|
+
> **Note**: Only **License Enforcement** and **Routes** are mandatory. Auth and Database modules are opt-in and handled via configuration.
|
|
16
|
+
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
17
19
|
```bash
|
|
@@ -98,10 +100,13 @@ The library uses `dotenv` to load configuration. Ensure you have a `.env` file o
|
|
|
98
100
|
| Variable | Description | Required | Default |
|
|
99
101
|
|----------|-------------|----------|---------|
|
|
100
102
|
| `LICENSE_PATH` | Path to the `license.json` file | No | `./license.json` |
|
|
101
|
-
| `JWT_SECRET` | Secret key for JWT verification | **Yes** | - |
|
|
103
|
+
| `JWT_SECRET` | Secret key for JWT verification | **Yes** (if auth used) | - |
|
|
102
104
|
| `DATABASE_URL` | Postgres Connection String | No | - |
|
|
103
105
|
| `PORT` | Http Port (Express only) | No | `3000` |
|
|
104
106
|
|
|
107
|
+
**Note:**
|
|
108
|
+
`license.json` is mandatory for the app to work. However, if the file exists in root directory, then LICENSE_PATH env variable is not required.
|
|
109
|
+
|
|
105
110
|
## License
|
|
106
111
|
|
|
107
112
|
Private / Proprietary.
|
|
@@ -65,7 +65,10 @@ async function createApp(opts) {
|
|
|
65
65
|
// 5) DB (non-optional if declared)
|
|
66
66
|
const db = await (0, index_js_2.initDb)(opts.db);
|
|
67
67
|
// 6) AUTH
|
|
68
|
-
|
|
68
|
+
let auth;
|
|
69
|
+
if (opts.auth) {
|
|
70
|
+
auth = (0, jwt_js_1.initJwtAuth)(config);
|
|
71
|
+
}
|
|
69
72
|
// 7) ROUTES
|
|
70
73
|
if (opts.routes) {
|
|
71
74
|
opts.routes({ app, router, db, auth, config });
|
|
@@ -7,13 +7,13 @@ exports.verifySignature = verifySignature;
|
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const PUBLIC_KEY = `
|
|
9
9
|
-----BEGIN PUBLIC KEY-----
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCxkEU67ODBGA9LQbMrm
|
|
11
|
+
mquTktu9xme2nJKPoPce1cYqjTOt/NJ2a+LDuhM7t8PHVye18+RJq+mFOkOSgilo
|
|
12
|
+
qpsoM/45NqN4doBkfajZqXtCSjiYg2F4O/zppElzTlsFxc7vtKs+KoTE91s0w0e6
|
|
13
|
+
xTrgdpqwZnUQ9q+16tuCIKPdxJ4mwqZbnUXdE3WKfedbnI2DNE0CfpJFrLkpSsnK
|
|
14
|
+
s/gcPBCi4obvE2RJWNqWoMULW6iLXSNqwDmxE+o87hwCTGfpZ/bxyirRbBCSq/hY
|
|
15
|
+
SdVQJlDhE2ta6CoITROp0c3+xffpCvlYnADp544nuz5IlTZk7LN9X5mF27VcTPc6
|
|
16
|
+
bwIDAQAB
|
|
17
17
|
-----END PUBLIC KEY-----
|
|
18
18
|
`;
|
|
19
19
|
function verifySignature(payload, signature) {
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -26,7 +26,10 @@ export async function createApp(opts) {
|
|
|
26
26
|
// 5) DB (non-optional if declared)
|
|
27
27
|
const db = await initDb(opts.db);
|
|
28
28
|
// 6) AUTH
|
|
29
|
-
|
|
29
|
+
let auth;
|
|
30
|
+
if (opts.auth) {
|
|
31
|
+
auth = initJwtAuth(config);
|
|
32
|
+
}
|
|
30
33
|
// 7) ROUTES
|
|
31
34
|
if (opts.routes) {
|
|
32
35
|
opts.routes({ app, router, db, auth, config });
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import crypto from "crypto";
|
|
2
2
|
const PUBLIC_KEY = `
|
|
3
3
|
-----BEGIN PUBLIC KEY-----
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCxkEU67ODBGA9LQbMrm
|
|
5
|
+
mquTktu9xme2nJKPoPce1cYqjTOt/NJ2a+LDuhM7t8PHVye18+RJq+mFOkOSgilo
|
|
6
|
+
qpsoM/45NqN4doBkfajZqXtCSjiYg2F4O/zppElzTlsFxc7vtKs+KoTE91s0w0e6
|
|
7
|
+
xTrgdpqwZnUQ9q+16tuCIKPdxJ4mwqZbnUXdE3WKfedbnI2DNE0CfpJFrLkpSsnK
|
|
8
|
+
s/gcPBCi4obvE2RJWNqWoMULW6iLXSNqwDmxE+o87hwCTGfpZ/bxyirRbBCSq/hY
|
|
9
|
+
SdVQJlDhE2ta6CoITROp0c3+xffpCvlYnADp544nuz5IlTZk7LN9X5mF27VcTPc6
|
|
10
|
+
bwIDAQAB
|
|
11
11
|
-----END PUBLIC KEY-----
|
|
12
12
|
`;
|
|
13
13
|
export function verifySignature(payload, signature) {
|
package/dist/esm/types.d.ts
CHANGED