Files
DefinitelyTyped/types/cadesplugin/common.d.ts
andrew0687 69fbeb9d46 🤖 Merge PR #56762 [cadesplugin] Added new types by @andrew0687
* Added CPSigner.AuthenticatedAttributes2 collection
Added Certificate.PrivateKey property
Added Certificate.ExtendedKeyUsage property
Added methods SignHash & VerifyHash for CadesSignedData

* Added CPSigner.AuthenticatedAttributes2 collection
Added Certificate.PrivateKey property
Added Certificate.ExtendedKeyUsage property

* Added CPSigner.AuthenticatedAttributes2 collection
Added Certificate.PrivateKey property
Added Certificate.ExtendedKeyUsage property

* Added CPSigner.AuthenticatedAttributes2 collection
Added Certificate.PrivateKey property
Added Certificate.ExtendedKeyUsage property

* Changed type argument `algorithm` method's CPHashedDataAsync.propset_Algorithm

docs: https://docs.cryptopro.ru/cades/reference/cadescom/cadescom_class/cphasheddata

* Changed type argument `algorithm` method's CPHashedDataAsync.propset_Algorithm

docs: https://docs.cryptopro.ru/cades/reference/cadescom/cadescom_class/cphasheddata

* Changed type argument `algorithm` method's CPHashedDataAsync.propset_Algorithm

docs: https://docs.cryptopro.ru/cades/reference/cadescom/cadescom_class/cphasheddata

* Changed type argument `algorithm` method's CPHashedDataAsync.propset_Algorithm

docs: https://docs.cryptopro.ru/cades/reference/cadescom/cadescom_class/cphasheddata

* Changed type argument `algorithm` method's CPHashedDataAsync.propset_Algorithm

docs: https://docs.cryptopro.ru/cades/reference/cadescom/cadescom_class/cphasheddata

Co-authored-by: andreiRUS39 <andrew_06_87@mail.ru>
2021-11-07 22:30:30 -08:00

32 lines
1.5 KiB
TypeScript

declare namespace CADES_Common {
type ValuesOf<T> = T[keyof T];
type VarDate = object;
// Extracts the type if wrapped by a Promise
type Unpacked<T> = T extends Promise<infer U> ? U :
T extends CAPICOM.Certificate ? CAPICOM.CertificateAsync :
T extends CAPICOM.Certificates ? CAPICOM.CertificatesAsync :
T extends CAdESCOM.CPSigner ? CAdESCOM.CPSignerAsync :
T extends CAdESCOM.CPHashedData ? CAdESCOM.CPHashedDataAsync :
T extends CAdESCOM.Version ? CAdESCOM.VersionAsync :
T extends CAPICOM.OID ? CAPICOM.OIDAsync :
T extends CAPICOM.EncodedData ? CAPICOM.EncodedDataAsync :
T extends CAPICOM.PublicKey ? CAPICOM.PublicKeyAsync :
T extends CAPICOM.PrivateKey ? CAPICOM.PrivateKeyAsync :
T extends CAPICOM.ExtendedKeyUsage ? CAPICOM.ExtendedKeyUsageAsync :
T extends CAPICOM.EKUs ? CAPICOM.EKUsAsync :
T extends CAPICOM.EKU ? CAPICOM.EKUAsync :
T extends CAdESCOM.CPAttribute ? CAdESCOM.CPAttributeAsync :
T extends CAdESCOM.CPAuthenticatedAttributes2 ? CAdESCOM.CPAuthenticatedAttributes2Async :
T;
type PromisifiedFunction<T extends Function> = // tslint:disable-line ban-types
T extends (...args: infer A) => infer U ? (...args: { [K in keyof A]: Unpacked<A[K]> }) => Promise<Unpacked<U>> :
T;
type Async<T> = {
readonly [K in keyof T]: T[K] extends Function ? PromisifiedFunction<T[K]> : // tslint:disable-line ban-types
Promise<Unpacked<T[K]>>;
};
}