Skip to content

X402#7

Merged
ehsan6sha merged 9 commits intomainfrom
x402
Jan 9, 2026
Merged

X402#7
ehsan6sha merged 9 commits intomainfrom
x402

Conversation

@ehsan6sha
Copy link
Copy Markdown
Member

Added x402 endpoints

Changed the default database path in both install.sh and config to use a shared location with the pinning service (../data/pinning.db). The install script now prompts for the shared database path, ensures the directory exists, and updates related output and environment variable handling to reflect the new shared setup.
Changed default install and data directories in install.sh and update.sh from /opt paths to /home/root/pinning-service paths. Updated prompts and documentation to reflect new defaults, and removed redundant data directory creation in update.sh.
Introduces a system key mechanism for authenticating requests from the x402 gateway by checking the 'X-System-Key' header. The manual credit adjustment endpoint now accepts either admin session or system key authentication, and audit logs reflect the caller type. Configuration and logging are updated to support the new system key.
* Basic health check endpoint.
*/
healthRoutes.get('/', (c) => {
let dbStatus: 'connected' | 'disconnected' = 'disconnected';
* Detailed health check with stats.
*/
healthRoutes.get('/detailed', (c) => {
let dbStatus: 'connected' | 'disconnected' = 'disconnected';
import { adjustPinningCredits } from '../services/pinningIntegration.js';
import { trackEphemeralObject } from '../database/repositories/ephemeralObjects.js';
import { HttpError } from '../middleware/errorHandler.js';
import { config } from '../config/index.js';
const contentType = c.req.header('Content-Type') || 'application/octet-stream';

const payment = getPaymentInfo(c);
const jwtUser = getJwtUser(c);
/**
* Decode base64 header to object
*/
function decodeHeader<T>(base64: string): T {
* Tests pricing calculations and USDC conversions.
*/

import { describe, it, expect, vi, beforeAll } from 'vitest';
Comment on lines +14 to +22
import {
createMockPaymentHeader,
createMockVerifyResponse,
createMockSettleResponse,
createMockJwt,
DEFAULT_MOCK_PAYMENT,
encodeBase64,
decodeBase64,
} from '../mocks/facilitator.js';
Comment on lines +13 to +20
import {
createMockPaymentHeader,
createMockVerifyResponse,
createMockSettleResponse,
DEFAULT_MOCK_PAYMENT,
encodeBase64,
decodeBase64,
} from '../mocks/facilitator.js';
it('should detect X-PAYMENT header', () => {
// Note: This tests the helper function directly
// In real usage, it's called within middleware context
const mockContext = {
@ehsan6sha ehsan6sha merged commit 957d3f0 into main Jan 9, 2026
2 checks passed
@ehsan6sha ehsan6sha deleted the x402 branch January 9, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant