feat: integrate eTradeInfo component for auto-filling company information and enhance TIN input handling

This commit is contained in:
Marshal
2026-06-20 10:39:53 +00:00
parent 1f92a04ecf
commit 72b6c9875d
3 changed files with 55 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
import { Injectable, BadRequestException } from "@nestjs/common";
import { HttpService } from "@nestjs/axios";
import { Agent } from "https";
import { firstValueFrom } from "rxjs";
import {
ETradeCompanyInfo,
@@ -12,6 +13,14 @@ export class ETradeService {
private readonly baseUrl = "https://etrade.gov.et/api";
private readonly referer = "https://etrade.gov.et/business-license-checker";
/**
* The eTrade server serves an incomplete TLS chain (it omits the intermediate
* CA cert), so Node rejects the handshake with UNABLE_TO_GET_ISSUER_CERT.
* Scope a relaxed agent to these outbound calls only — the rest of the app
* keeps full certificate verification.
*/
private readonly httpsAgent = new Agent({ rejectUnauthorized: false });
constructor(private readonly httpService: HttpService) {}
async getCompanyInfoByTin(tin: string): Promise<ETradeCompanyInfo> {
@@ -20,6 +29,7 @@ export class ETradeService {
const response = await firstValueFrom(
this.httpService.get<ETradeCompanyInfo>(url, {
headers: { Referer: this.referer },
httpsAgent: this.httpsAgent,
}),
);
return response.data;
@@ -44,6 +54,7 @@ export class ETradeService {
Lang: "en",
},
headers: { Referer: this.referer },
httpsAgent: this.httpsAgent,
}),
);
return response.data;