@smartdcc/dccboxed-keystore
Version:
DCC Boxed server keystore exposed as json db.
103 lines • 3.47 kB
TypeScript
import { X509Certificate } from 'crypto';
import { CertificateMetadata } from './certificateMetadata';
export declare const enum CertificateStatus {
Pending = "P",
'In use' = "I",
'Not In use' = "N",
Expired = "E",
Revoked = "R"
}
export declare const enum CertificateUsage {
'Digital Signing' = "DS",
'Key Agreement' = "KA"
}
export declare const enum CertificateRole {
Root = "0",
Recovery = "1",
Supplier = "2",
'Network Operator' = "3",
'Access Control Broker' = "4",
'Transitional CoS' = "5",
'WAN Provider' = "6",
'Issuing Authority' = "7",
'Load Controller' = "8",
Other = "127",
XmlSign = "135",
DspXmlSign = "137"
}
/**
* Type that is serialised into xml to retrieve a certificate.
*/
export interface CertificateDataRequest {
CertificateSerial: string;
}
/**
* General tree structure of strings to hold parsed DUIS.
*/
export interface XMLData {
[key: string]: string | string[] | XMLData | XMLData[];
}
export declare function prepareRequest(name: string, body: XMLData): string;
export type QueryResult = {
meta: CertificateMetadata;
x509: X509Certificate;
};
/**
* Parses a URL-like string and returns a properly formatted URL string
*
* @param url_like - String that may be a partial or complete URL
* @returns Properly formatted URL string with protocol and port if needed
*
* If the input string:
* - Does not contain a colon: Prepends 'http://' and appends port 8083
* - Does not contain protocol: Prepends 'http://'
* - Is already a complete URL: Returns as-is after URL validation
*/
export declare function parseUrl(url_like: string): string;
/**
* Type definition for HTTP headers that can contain:
* - Static string values
* - Functions that return string values synchronously
* - Functions that return string values asynchronously via Promise
*
* @example
* const headers: Headers = {
* 'content-type': 'application/json',
* 'authorization': () => 'Bearer ' + getToken(),
* 'x-custom-header': async () => await fetchHeaderValue()
* }
*/
export type Headers = Record<string, string | (() => string) | (() => Promise<string>)>;
/**
* Resolves a Headers object into a wider object by evaluating any function values
* and resolving any promises.
*
* @param headers - The Headers object containing string values, functions or promises
* @param implHeaders - Optional existing headers object to merge with (e.g. got's headers)
* @returns Promise resolving to a headers record with all string values
*/
export declare function resolveHeaders<T>(headers?: Headers, implHeaders?: Record<string, string | T>): Promise<Record<string, string | T>>;
/**
* queries the SMKI certificatesearch service. when entering the
* CertificateSubjectName or CertificateSubjectAltName parameters, ensure they
* follow the <code>a1-a2-a3-a4-a5-a6-a7-a8</code> format.
*
* @param sr
* @param boxedAddress
* @returns
*/
export declare function search(sr: ({
q: {
CertificateSubjectName: string;
};
CertificateRole: CertificateRole;
} | {
q: {
CertificateSubjectAltName: string;
};
}) & {
CertificateUsage: CertificateUsage;
CertificateStatus: CertificateStatus;
}, boxedAddress: string, headers?: Headers): Promise<QueryResult[]>;
export declare function query(serial: string, boxedAddress: string, headers?: Headers): Promise<QueryResult | null>;
//# sourceMappingURL=certificateSearch.d.ts.map