@xenterprises/fastify-xconfig 1.1.7 → 1.1.9
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/package.json +2 -2
- package/src/auth/admin.js +4 -1
- package/src/auth/portal.js +4 -1
- package/src/middleware/cors.js +8 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenterprises/fastify-xconfig",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.9",
|
|
5
5
|
"description": "Fastify configuration plugin for setting up middleware, services, and route handling.",
|
|
6
6
|
"main": "src/xConfig.js",
|
|
7
7
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@fastify/rate-limit": "^9.1.0",
|
|
27
27
|
"@fastify/sensible": "^5.6.0",
|
|
28
28
|
"@fastify/under-pressure": "^8.0.1",
|
|
29
|
-
"@prisma/client": "^6.
|
|
29
|
+
"@prisma/client": "^6.17.1",
|
|
30
30
|
"@sendgrid/client": "^8.1.3",
|
|
31
31
|
"@sendgrid/mail": "^8.1.3",
|
|
32
32
|
"check-disk-space": "^3.4.0",
|
package/src/auth/admin.js
CHANGED
|
@@ -27,7 +27,10 @@ export async function setupAdminAuth(fastify, options) {
|
|
|
27
27
|
const jwksUrl = `${stackAuthBaseUrl}/projects/${projectId}/.well-known/jwks.json`;
|
|
28
28
|
|
|
29
29
|
// Create JWKS for token verification
|
|
30
|
-
const jwks = jose.createRemoteJWKSet(new URL(jwksUrl)
|
|
30
|
+
const jwks = jose.createRemoteJWKSet(new URL(jwksUrl), {
|
|
31
|
+
cooldownDuration: 30000, // 30 seconds between refetches
|
|
32
|
+
cacheMaxAge: 1800000, // 5 minutes cache duration
|
|
33
|
+
});
|
|
31
34
|
|
|
32
35
|
// Helper for Stack Auth API headers
|
|
33
36
|
fastify.decorate('getAdminStackAuthHeaders', function (accessType = "server") {
|
package/src/auth/portal.js
CHANGED
|
@@ -28,7 +28,10 @@ export async function setupAuth(fastify, options) {
|
|
|
28
28
|
const jwksUrl = `${stackAuthBaseUrl}/projects/${projectId}/.well-known/jwks.json`;
|
|
29
29
|
|
|
30
30
|
// Create JWKS for token verification
|
|
31
|
-
const jwks = jose.createRemoteJWKSet(new URL(jwksUrl)
|
|
31
|
+
const jwks = jose.createRemoteJWKSet(new URL(jwksUrl), {
|
|
32
|
+
cooldownDuration: 30000, // 30 seconds between refetches
|
|
33
|
+
cacheMaxAge: 1800000, // 5 minutes cache duration
|
|
34
|
+
});
|
|
32
35
|
|
|
33
36
|
// Helper for Stack Auth API headers
|
|
34
37
|
fastify.decorate('getStackAuthHeaders', function (accessType = "server") {
|
package/src/middleware/cors.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export async function setupCors(fastify, options) {
|
|
2
2
|
if (options.active !== false) {
|
|
3
|
+
// Extract active flag and pass all other options directly to the CORS plugin
|
|
4
|
+
const { active, ...corsOptions } = options;
|
|
5
|
+
|
|
3
6
|
await fastify.register(await import("@fastify/cors"), {
|
|
4
|
-
origin:
|
|
5
|
-
credentials:
|
|
6
|
-
methods:
|
|
7
|
+
origin: corsOptions.origin || ["https://getx.io", "http://localhost:3000"],
|
|
8
|
+
credentials: corsOptions.credentials !== undefined ? corsOptions.credentials : true,
|
|
9
|
+
methods: corsOptions.methods || ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
10
|
+
...corsOptions // This will include ignorePaths: ['/public'] in the preflight config
|
|
7
11
|
});
|
|
8
12
|
console.info(" ✅ CORS Enabled");
|
|
9
13
|
}
|
|
10
|
-
}
|
|
14
|
+
}
|