mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-21 16:52:00 -07:00
Add multi-facilitator support with Dexter integration
- Add Dexter as secondary facilitator option (no API keys required) - Create FACILITATORS config with CDP and Dexter settings - Update server middleware to support multiple facilitators - Add PRIMARY_FACILITATOR environment variable - Create example client for Dexter payments - Document Dexter features: 600K+ free tx/month, gas sponsored Dexter has ~50% market share and requires no authentication, making it an ideal backup/secondary facilitator option.
This commit is contained in:
+10
-7
@@ -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, createAuthHeader } from '../src/config/x402.js'
|
||||
import { buildX402Routes, getX402Settings, getBasicAuthSettings, createAuthHeader, getFacilitatorConfig } from '../src/config/x402.js'
|
||||
import { basicAuthMiddleware } from '../src/middleware/basic-auth.js'
|
||||
|
||||
// Load environment variables
|
||||
@@ -109,14 +109,17 @@ class Server {
|
||||
const routes = buildX402Routes(this.config.apiPrefix)
|
||||
let facilitatorOptions = x402Settings.facilitatorUrl
|
||||
|
||||
if (facilitatorOptions) {
|
||||
facilitatorOptions = {
|
||||
url: x402Settings.facilitatorUrl,
|
||||
createAuthHeaders: createAuthHeader
|
||||
}
|
||||
// Support for multiple facilitators (CDP and Dexter)
|
||||
const primaryFacilitator = x402Settings.primaryFacilitator || 'cdp'
|
||||
const facilitatorConfig = getFacilitatorConfig(primaryFacilitator)
|
||||
|
||||
// Use configured facilitator URL
|
||||
facilitatorOptions = {
|
||||
url: facilitatorConfig.url,
|
||||
createAuthHeaders: facilitatorConfig.requiresAuth ? createAuthHeader : null
|
||||
}
|
||||
|
||||
wlogger.info(`x402 middleware enabled with basic auth bypass; enforcing ${x402Settings.priceUSDC} satoshis per request (unless basic auth provided)`)
|
||||
wlogger.info(`x402 middleware enabled with basic auth bypass; enforcing ${x402Settings.priceUSDC} USDC per request (unless basic auth provided) [facilitator: ${facilitatorConfig.name}]`)
|
||||
|
||||
// Create conditional x402 middleware that bypasses if basic auth is valid
|
||||
const conditionalX402Middleware = (req, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user