myinvois-sdk
Version:
TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API
114 lines (113 loc) • 2.98 kB
TypeScript
/**
* Certificate configuration interface
*/
interface CertificateConfig {
certificatePath: string;
privateKeyPath: string;
privateKeyPassphrase: string;
}
/**
* Certificate information interface
*/
export interface Certificate {
subject: string;
issuer: string;
serialNumber: string;
validFrom: Date;
validTo: Date;
raw: Buffer;
}
/**
* Handles certificate operations for document signing
*/
export declare class CertificateHandler {
private certificates;
private config;
private privateKey;
/**
* Creates a new certificate handler
* @param config The certificate configuration
*/
constructor(config: CertificateConfig);
/**
* Initializes the certificate handler by loading the certificate chain and private key
*/
initialize(): Promise<void>;
/**
* Formats a serial number
* @param serialNumber The serial number to format
* @returns The formatted serial number
*/
formatSerialNumber(serialNumber: string): string;
/**
* Loads the certificate chain from the certificate path
*/
loadCertificateChain(): Promise<void>;
/**
* Validates the certificate chain
*/
private validateCertificateChain;
/**
* Normalizes a distinguished name for comparison
* @param dn The distinguished name to normalize
* @returns The normalized distinguished name
*/
private normalizeDN;
/**
* Gets the signing certificate
* @returns The signing certificate
*/
getSigningCertificate(): Certificate;
/**
* Gets the intermediate certificate
* @returns The intermediate certificate
*/
getIntermediateCertificate(): Certificate;
/**
* Gets the root certificate
* @returns The root certificate
*/
getRootCertificate(): Certificate;
/**
* Formats a distinguished name according to LHDN format
* @param dn The distinguished name to format
* @returns The formatted distinguished name
*/
formatDistinguishedName(dn: string): string;
/**
* Generates certificate information for document signing
* @returns The certificate information
*/
generateCertificateInfo(): {
X509Certificate: Array<{
_: string;
}>;
X509SubjectName: Array<{
_: string;
}>;
X509IssuerSerial: Array<{
X509IssuerName: Array<{
_: string;
}>;
X509SerialNumber: Array<{
_: string;
}>;
}>;
};
/**
* Generates a certificate hash for document signing
* @returns The certificate hash
*/
generateCertificateHash(): string;
/**
* Loads the private key
*/
private loadPrivateKey;
/**
* Signs data with the private key
* @param data The data to sign
* @returns The signature
*/
signData(data: string): string;
}
export {};