Files
smom-dbis-138/packages/integration-foundation/dist/hybx/HttpHybxClient.js
defiQUG 11c97777d4
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m11s
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Lint and Format (push) Has been cancelled
CI/CD Pipeline / Terraform Validation (push) Has been cancelled
CI/CD Pipeline / Kubernetes Validation (push) Has been cancelled
Validation / validate-genesis (push) Has been cancelled
Validation / validate-terraform (push) Has been cancelled
Validation / validate-kubernetes (push) Has been cancelled
Validation / validate-smart-contracts (push) Has been cancelled
Validation / validate-security (push) Has been cancelled
Validation / validate-documentation (push) Has been cancelled
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 1m4s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 31s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 29s
Verify Deployment / Verify Deployment (push) Failing after 57s
feat(chain138): Monad CCIP, token aggregation OMNL gates, HYBX client, and PMM deploy updates.
Relay router, reserve system, oracle publisher, token-aggregation compliance middleware, and Monad deployment scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 00:11:33 -07:00

74 lines
2.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpHybxClient = void 0;
const config_1 = require("./config");
/**
* HTTP HYBX client — uses api-fineract-unified spec (Volume 20).
* Production allowed when HYBX_UNIFIED_API_OK=1 and unified manifest exists.
*/
class HttpHybxClient {
environment;
config;
constructor(options) {
this.config = options?.config ?? (0, config_1.loadHybxConfig)({ testMode: options?.testMode ?? true });
this.environment = this.config.environment;
const unifiedOk = process.env.HYBX_UNIFIED_API_OK === '1' || options?.allowProduction === true;
if (this.config.environment === 'production' && !unifiedOk) {
throw new Error('HttpHybxClient production requires HYBX_UNIFIED_API_OK=1 (api-fineract-unified.v1.openapi.yaml integrated)');
}
}
async postJson(path, body) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), this.config.requestTimeoutMs);
try {
const res = await fetch(`${this.config.baseUrl}${path}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': this.config.apiKey,
Authorization: `Bearer ${this.config.clientSecret}`,
},
body: JSON.stringify(body),
signal: controller.signal,
});
if (!res.ok) {
throw new Error(`HYBX HTTP ${res.status}: ${await res.text()}`);
}
return (await res.json());
}
finally {
clearTimeout(timeout);
}
}
async initiatePayment(request) {
return this.postJson('/v1/payments', request);
}
async getPaymentStatus(paymentId) {
const res = await fetch(`${this.config.baseUrl}/v1/payments/${paymentId}`, {
headers: { 'X-API-Key': this.config.apiKey },
});
if (!res.ok)
throw new Error(`HYBX HTTP ${res.status}`);
return (await res.json());
}
async listSettlementEvents(since) {
const q = since ? `?since=${encodeURIComponent(since)}` : '';
const res = await fetch(`${this.config.baseUrl}/v1/settlement-events${q}`, {
headers: { 'X-API-Key': this.config.apiKey },
});
if (!res.ok)
throw new Error(`HYBX HTTP ${res.status}`);
return (await res.json());
}
parseWebhookPayload(body) {
const parsed = JSON.parse(body);
return {
eventType: String(parsed.eventType ?? 'unknown'),
eventId: String(parsed.eventId ?? ''),
timestamp: String(parsed.timestamp ?? new Date().toISOString()),
data: parsed.data ?? parsed,
};
}
}
exports.HttpHybxClient = HttpHybxClient;