Files
smom-dbis-138/packages/integration-foundation/dist/hybx/HttpHybxClient.js
defiQUG d717b504a6
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m12s
CI/CD Pipeline / Security Scanning (push) Successful in 2m21s
CI/CD Pipeline / Lint and Format (push) Failing after 36s
CI/CD Pipeline / Terraform Validation (push) Failing after 22s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 25s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 23s
Validation / validate-genesis (push) Successful in 26s
Validation / validate-terraform (push) Failing after 21s
Validation / validate-kubernetes (push) Failing after 9s
Validation / validate-smart-contracts (push) Failing after 8s
Validation / validate-security (push) Failing after 1m15s
Validation / validate-documentation (push) Failing after 15s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (push) Failing after 26s
Verify Deployment / Verify Deployment (push) Failing after 56s
feat(omnl): settlement terminal, compliance gates, and HYBX integration foundation
Add operator settlement terminal UI/API, swift-listener service, compliance
idempotency gates, GRU reserve dashboards, and @dbis/integration-foundation
for typed HYBX/ISO adapter contracts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 21:51:32 -07:00

73 lines
2.7 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpHybxClient = void 0;
const config_1 = require("./config");
/**
* HTTP HYBX client — sandbox/staging only until official API spec is available.
* Does not implement request signing; paths are placeholders.
*/
class HttpHybxClient {
environment;
config;
constructor(options) {
this.config = options?.config ?? (0, config_1.loadHybxConfig)({ testMode: options?.testMode ?? true });
this.environment = this.config.environment;
if (this.config.environment === 'production') {
throw new Error('HttpHybxClient refuses production until official HYBX spec is 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;