Compare commits

..

No commits in common. "d744e26a19c2c1a6d814b3a2d49192e699f0b38e" and "3db9f4d8b8ee2c695c21350e57c1f7a73e595010" have entirely different histories.

2 changed files with 2 additions and 26 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@debros/network-ts-sdk", "name": "@debros/network-ts-sdk",
"version": "0.3.4", "version": "0.3.2",
"description": "TypeScript SDK for DeBros Network Gateway", "description": "TypeScript SDK for DeBros Network Gateway",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",

View File

@ -8,29 +8,6 @@ export interface HttpClientConfig {
fetch?: typeof fetch; fetch?: typeof fetch;
} }
/**
* Create a fetch function with proper TLS configuration for staging certificates
* In Node.js, we need to configure TLS to accept Let's Encrypt staging certificates
*/
function createFetchWithTLSConfig(): typeof fetch {
// Check if we're in a Node.js environment
if (typeof process !== "undefined" && process.versions?.node) {
// For testing/staging/development: allow staging certificates
// Let's Encrypt staging certificates are self-signed and not trusted by default
const isDevelopmentOrStaging =
process.env.NODE_ENV !== "production" ||
process.env.DEBROS_ALLOW_STAGING_CERTS === "true" ||
process.env.DEBROS_USE_HTTPS === "true";
if (isDevelopmentOrStaging) {
// Allow self-signed/staging certificates
// WARNING: Only use this in development/testing environments
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}
}
return globalThis.fetch;
}
export class HttpClient { export class HttpClient {
private baseURL: string; private baseURL: string;
private timeout: number; private timeout: number;
@ -45,8 +22,7 @@ export class HttpClient {
this.timeout = config.timeout ?? 60000; // Increased from 30s to 60s for pub/sub operations this.timeout = config.timeout ?? 60000; // Increased from 30s to 60s for pub/sub operations
this.maxRetries = config.maxRetries ?? 3; this.maxRetries = config.maxRetries ?? 3;
this.retryDelayMs = config.retryDelayMs ?? 1000; this.retryDelayMs = config.retryDelayMs ?? 1000;
// Use provided fetch or create one with proper TLS configuration for staging certificates this.fetch = config.fetch ?? globalThis.fetch;
this.fetch = config.fetch ?? createFetchWithTLSConfig();
} }
setApiKey(apiKey?: string) { setApiKey(apiKey?: string) {