Finished implementation

This commit is contained in:
Daniel Gonzalez
2026-03-18 20:26:01 -04:00
parent d29db05d5f
commit a920b4c293
9 changed files with 347 additions and 33 deletions
+4 -9
View File
@@ -16,7 +16,7 @@ import { dirname, join } from 'path'
import config from '../src/config/index.js'
import Controllers from '../src/controllers/index.js'
import wlogger from '../src/adapters/wlogger.js'
import { buildX402Routes, getX402Settings, getBasicAuthSettings } from '../src/config/x402.js'
import { buildX402Routes, getX402Settings, getBasicAuthSettings, createAuthHeader } from '../src/config/x402.js'
import { basicAuthMiddleware } from '../src/middleware/basic-auth.js'
// Load environment variables
@@ -111,10 +111,7 @@ class Server {
if (facilitatorOptions) {
facilitatorOptions = {
url: x402Settings.facilitatorUrl,
/** TODO : Auth headers for request mainnet facilitator needed */
createAuthHeaders: async () => {
return {}
}
createAuthHeaders: createAuthHeader
}
}
@@ -122,6 +119,7 @@ class Server {
// Create conditional x402 middleware that bypasses if basic auth is valid
const conditionalX402Middleware = (req, res, next) => {
// req.headers['accept'] = 'application/json';
// If basic auth is valid, bypass x402
if (req.locals?.basicAuthValid === true) {
return next()
@@ -144,10 +142,7 @@ class Server {
if (facilitatorOptions) {
facilitatorOptions = {
url: x402Settings.facilitatorUrl,
/** TODO : Auth headers for request mainnet facilitator needed */
createAuthHeaders: async () => {
return {}
}
createAuthHeaders: createAuthHeader
}
}