@smartdcc/duis-sign-wrap
Version:
Wrapper library for signing/validating DUIS
42 lines • 1.7 kB
TypeScript
export declare const port: number;
export declare function setLogger(f?: (msg: string) => void): void;
export declare function startBackend(): Promise<void>;
export declare function checkPort(port: number): Promise<boolean>;
export declare function stopBackend(): void;
export interface HttpOptions {
/**
* Unsigned DUIS xml string
*/
xml: string | Buffer;
/**
* Preserve counter value in RequestID when signing
*/
preserveCounter?: boolean;
/**
* Http server backend, set to true to automatically manage a server instance
*/
backend: true | URL;
/**
* Additional http headers to pass to backend
*/
headers?: Record<string, string>;
}
export declare function buildUrl(backend: true | URL, mode: 'sign' | 'verify'): URL;
export declare function makeRequest(url: URL, options: Omit<HttpOptions, 'backend'>): Promise<string>;
/**
* Signs a DUIS message using the HTTP backend.
*
* @param options - Configuration options including XML content and backend URL
* @returns Promise resolving to the signed DUIS XML string
* @throws Error if the backend returns a non-200 status or invalid response
*/
export declare function makeSignDuisRequest(options: HttpOptions): Promise<string>;
/**
* Validates and verifies a signed DUIS message using the HTTP backend.
*
* @param options - Configuration options including XML content and backend URL
* @returns Promise resolving to the validated DUIS XML string without signature
* @throws Error if the backend returns a non-200 status or invalid response
*/
export declare function makeVerifyDuisRequest(options: HttpOptions): Promise<string>;
//# sourceMappingURL=server.d.ts.map