mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-21 16:52:00 -07:00
Finished implementation
This commit is contained in:
+4
-9
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user