diff --git a/types/cadesplugin/index.d.ts b/types/cadesplugin/index.d.ts new file mode 100644 index 0000000000..e34bbe50d0 --- /dev/null +++ b/types/cadesplugin/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for cadesplugin 2.0 +// Project: https://www.npmjs.com/package/cadesplugin +// Definitions by: Delagen , +// kvmi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +declare const cadesplugin: any; diff --git a/types/cadesplugin/package.json b/types/cadesplugin/package.json new file mode 100644 index 0000000000..bb80441dc0 --- /dev/null +++ b/types/cadesplugin/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "types": "index", + "typesVersions": { + ">=3.1.0-0": { "*": ["ts3.1/*"] } + } +} diff --git a/types/cadesplugin/ts3.1/cadescom.d.ts b/types/cadesplugin/ts3.1/cadescom.d.ts new file mode 100644 index 0000000000..a721b54d97 --- /dev/null +++ b/types/cadesplugin/ts3.1/cadescom.d.ts @@ -0,0 +1,97 @@ +declare namespace CAdESCOM { + interface CPSigner { + Certificate: CAPICOM.Certificate; + CheckCertificate: boolean; + + KeyPin: string; + Options: CADES_Common.ValuesOf; + readonly SignatureTimeStampTime: CADES_Common.VarDate; + readonly SigningTime: CADES_Common.VarDate; + TSAAddress: string; + + Display(hwndParent?: number, title?: string): void; + + Load(fileName: string, password?: string): void; + } + + interface CadesSignedData { + readonly Certificates: CAPICOM.Certificates; + Content: string; + ContentEncoding: CADES_Common.ValuesOf; + + DisplayData: CADES_Common.ValuesOf; + + Display(hwndParent?: number, title?: string): void; + + EnhanceCades(cadesType?: CADES_Common.ValuesOf, TSAAddress?: string, encodingType?: CADES_Common.ValuesOf): string; + + SignCades(signer?: CPSigner, CadesType?: CADES_Common.ValuesOf, bDetached?: boolean, EncodingType?: CADES_Common.ValuesOf): string; + + VerifyCades(SignedMessage: string, CadesType?: CADES_Common.ValuesOf, bDetached?: boolean): void; + } + + interface Version { + readonly BuildVersion: number; + readonly MajorVersion: number; + readonly MinorVersion: number; + readonly toStringDefault: string; + + toString(): string; + } + + interface About { + readonly BuildVersion: number; + readonly MajorVersion: number; + readonly MinorVersion: number; + readonly PluginVersion: Version; + readonly Version: string; + + CSPName(ProviderType?: number): string; + + CSPVersion(ProviderName?: string, ProviderType?: number): Version; + + ProviderVersion(ProviderName?: string, ProviderType?: number): string; + + toString(): string; + } + + interface CPSigners { + readonly Count: number; + + Item(index: number): CPSigner; + } + + interface SignedXML { + Content: string; + DigestMethod: string; + SignatureMethod: string; + SignatureType: CADES_Common.ValuesOf; + readonly Signers: CAPICOM.Signers; + + Sign(signer?: CPSigner, XPath?: string): string; + + Verify(SignedMessage: string, XPath?: string): void; + } + + interface CPHashedData { + Algorithm: CADES_Common.ValuesOf; + DataEncoding: CADES_Common.ValuesOf; + Value: string; + + Hash(newVal: string): void; + + SetHashValue(newVal: string): void; + } + + interface CPAttribute { + Name: CADES_Common.ValuesOf; + Value: any; + ValueEncoding: CADES_Common.ValuesOf; + } + + interface RawSignature { + SignHash(hash: CPHashedData, certificate?: string): string; + + VerifyHash(hash: CPHashedData, certificate: CAPICOM.Certificate, signature: string): void; + } +} diff --git a/types/cadesplugin/ts3.1/cadescom_async.d.ts b/types/cadesplugin/ts3.1/cadescom_async.d.ts new file mode 100644 index 0000000000..94e95b2acc --- /dev/null +++ b/types/cadesplugin/ts3.1/cadescom_async.d.ts @@ -0,0 +1,57 @@ +declare namespace CAdESCOM { + interface CPSignerAsync extends CADES_Common.Async { + propset_Certificate(certificate: CAPICOM.CertificateAsync): Promise; + + propset_CheckCertificate(checkCertificate: boolean): Promise; + + propset_KeyPin(keyPin: string): Promise; + + propset_Options(options: CADES_Common.ValuesOf): Promise; + + propset_TSAAddress(TSAAddress: string): Promise; + } + + interface CadesSignedDataAsync extends CADES_Common.Async { + propset_DisplayData(displayData: CADES_Common.ValuesOf): Promise; + + propset_Content(content: string): Promise; + + propset_ContentEncoding(contentEncoding: CADES_Common.ValuesOf): Promise; + } + + interface VersionAsync extends CADES_Common.Async { + } + + interface AboutAsync extends CADES_Common.Async { + } + + interface CPSignersAsync extends CADES_Common.Async { + } + + interface SignedXMLAsync extends CADES_Common.Async { + propset_Content(content: string): Promise; + + propset_DigestMethod(digestMethod: string): Promise; + + propset_SignatureMethod(signatureMethod: string): Promise; + + propset_SignatureType(signatureType: CADES_Common.ValuesOf): Promise; + } + + interface CPHashedDataAsync extends CADES_Common.Async { + propset_Algorithm(algorithm: CADES_Common.ValuesOf): Promise; + + propset_DataEncoding(dataEncoding: CADES_Common.ValuesOf): Promise; + } + + interface CPAttributeAsync extends CADES_Common.Async { + propset_Name(name: CADES_Common.ValuesOf): Promise; + + propset_Value(value: any): Promise; + + propset_ValueEncoding(valueEncoding: CADES_Common.ValuesOf): Promise; + } + + interface RawSignatureAsync extends CADES_Common.Async { + } +} diff --git a/types/cadesplugin/ts3.1/cadescom_enums.d.ts b/types/cadesplugin/ts3.1/cadescom_enums.d.ts new file mode 100644 index 0000000000..918803a47d --- /dev/null +++ b/types/cadesplugin/ts3.1/cadescom_enums.d.ts @@ -0,0 +1,74 @@ +declare namespace CAdESCOM { + interface StoreLocationPlugin { + readonly CADESCOM_LOCAL_MACHINE_STORE: 1; + readonly CADESCOM_CURRENT_USER_STORE: 2; + readonly CADESCOM_CONTAINER_STORE: 100; + } + + interface CADESCOM_STORE_LOCATION extends StoreLocationPlugin { + readonly CADESCOM_MEMORY_STORE: 0; + readonly CADESCOM_ACTIVE_DIRECTORY_USER_STORE: 3; + readonly CADESCOM_SMART_CARD_USER_STORE: 4; + } + + interface CADESCOM_CADES_TYPE { + readonly CADESCOM_CADES_BES: 1; + readonly CADESCOM_CADES_DEFAULT: 0; + readonly CADESCOM_CADES_T: 5; + readonly CADESCOM_CADES_X_LONG_TYPE_1: 93; + } + + interface CADESCOM_CONTENT_ENCODING_TYPE { + readonly CADESCOM_BASE64_TO_BINARY: 1; + readonly CADESCOM_STRING_TO_UCS2LE: 0; + } + + interface CADESCOM_XML_SIGNATURE_TYPE { + readonly CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED: 0; + readonly CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING: 1; + readonly CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE: 2; + } + + interface CADESCOM_ENCRYPTION_ALGORITHM { + readonly CADESCOM_ENCRYPTION_ALGORITHM_RC2: 0; + readonly CADESCOM_ENCRYPTION_ALGORITHM_RC4: 1; + readonly CADESCOM_ENCRYPTION_ALGORITHM_DES: 2; + readonly CADESCOM_ENCRYPTION_ALGORITHM_3DES: 3; + readonly CADESCOM_ENCRYPTION_ALGORITHM_AES: 4; + readonly CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89: 25; + } + + interface CADESCOM_HASH_ALGORITHM { + readonly CADESCOM_HASH_ALGORITHM_SHA1: 0; + readonly CADESCOM_HASH_ALGORITHM_MD2: 1; + readonly CADESCOM_HASH_ALGORITHM_MD4: 2; + readonly CADESCOM_HASH_ALGORITHM_MD5: 3; + readonly CADESCOM_HASH_ALGORITHM_SHA_256: 4; + readonly CADESCOM_HASH_ALGORITHM_SHA_384: 5; + readonly CADESCOM_HASH_ALGORITHM_SHA_512: 6; + readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411: 100; + readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256: 101; + readonly CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512: 102; + } + + interface CADESCOM_ATTRIBUTE { + readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME: 0; + readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME: 1; + readonly CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION: 2; + readonly CADESCOM_ATTRIBUTE_OTHER: -1; + } + + interface CADESCOM_DISPLAY_DATA { + readonly CADESCOM_DISPLAY_DATA_NONE: 0; + readonly CADESCOM_DISPLAY_DATA_CONTENT: 1; + readonly CADESCOM_DISPLAY_DATA_ATTRIBUTE: 2; + } + + interface CADESCOM_InstallResponseRestrictionFlags { + readonly CADESCOM_AllowNone: 0; + readonly CADESCOM_AllowNoOutstandingRequest: 1; + readonly CADESCOM_AllowUntrustedCertificate: 2; + readonly CADESCOM_AllowUntrustedRoot: 4; + readonly CADESCOM_SkipInstallToStore: 0x10000000; + } +} diff --git a/types/cadesplugin/ts3.1/cadesplugin-tests.ts b/types/cadesplugin/ts3.1/cadesplugin-tests.ts new file mode 100644 index 0000000000..c9784f1671 --- /dev/null +++ b/types/cadesplugin/ts3.1/cadesplugin-tests.ts @@ -0,0 +1,12 @@ +cadesplugin.then(async () => { + if ("CreateObjectAsync" in cadesplugin) { + const pluginAsync: CADESPluginAsync = cadesplugin; + const oAbout = await pluginAsync.CreateObjectAsync("CAdESCOM.About"); + const oVersion = await oAbout.CSPVersion(); + await oVersion.toString(); + } + if ("CreateObject" in cadesplugin) { + const pluginSync: CADESPluginSync = cadesplugin; + pluginSync.CreateObject("CAdESCOM.About").CSPVersion().toString(); + } +}); diff --git a/types/cadesplugin/ts3.1/cadesplugin.d.ts b/types/cadesplugin/ts3.1/cadesplugin.d.ts new file mode 100644 index 0000000000..53bba7e1bd --- /dev/null +++ b/types/cadesplugin/ts3.1/cadesplugin.d.ts @@ -0,0 +1,80 @@ +declare namespace CADES_Plugin { + interface ObjectNames { + "CAPICOM.Store": CAPICOM.Store; + "CAdESCOM.CPSigner": CAdESCOM.CPSigner; + "CAdESCOM.About": CAdESCOM.About; + "CAdESCOM.SignedXML": CAdESCOM.SignedXML; + "CAdESCOM.HashedData": CAdESCOM.CPHashedData; + "CAdESCOM.CadesSignedData": CAdESCOM.CadesSignedData; + "CAdESCOM.CPAttribute": CAdESCOM.CPAttribute; + "CAdESCOM.RawSignature": CAdESCOM.RawSignature; + } + + interface ObjectNamesAsync { + "CAdESCOM.Store": CAPICOM.StoreAsync; + "CAdESCOM.CPSigner": CAdESCOM.CPSignerAsync; + "CAdESCOM.About": CAdESCOM.AboutAsync; + "CAdESCOM.SignedXML": CAdESCOM.SignedXMLAsync; + "CAdESCOM.HashedData": CAdESCOM.CPHashedDataAsync; + "CAdESCOM.CadesSignedData": CAdESCOM.CadesSignedDataAsync; + "CAdESCOM.CPAttribute": CAdESCOM.CPAttributeAsync; + "CAdESCOM.RawSignature": CAdESCOM.RawSignatureAsync; + } + + interface LogLevel { + readonly LOG_LEVEL_DEBUG: 4; + readonly LOG_LEVEL_INFO: 2; + readonly LOG_LEVEL_ERROR: 1; + } + + interface SignedXmlUrls { + readonly XmlDsigGost3410Url: "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411"; + readonly XmlDsigGost3410UrlObsolete: "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"; + readonly XmlDsigGost3411Url: "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411"; + readonly XmlDsigGost3411UrlObsolete: "http://www.w3.org/2001/04/xmldsig-more#gostr3411"; + } + + interface EncodingType { + readonly CADESCOM_ENCODE_ANY: -1; + readonly CADESCOM_ENCODE_BASE64: 0; + readonly CADESCOM_ENCODE_BINARY: 1; + } +} + +interface CADESPluginBase extends Promise, + CAPICOM.StoreLocationPlugin, CAdESCOM.StoreLocationPlugin, CAPICOM.StoreNamePlugin, + CAPICOM.StoreOpenModePlugin, CAPICOM.CAPICOM_CERTIFICATE_FIND_TYPE, + CADES_Plugin.LogLevel, CAdESCOM.CADESCOM_XML_SIGNATURE_TYPE, + CADES_Plugin.SignedXmlUrls, CAdESCOM.CADESCOM_CADES_TYPE, + CADES_Plugin.EncodingType, CAPICOM.CAPICOM_CERTIFICATE_INCLUDE_OPTION, + CAPICOM.CertIntoTypePlugin, CAPICOM.KeyUsagePlugin, + CAPICOM.PropIDPlugin, CAPICOM.OIDPlugin, CAPICOM.EKUPlugin, + CAPICOM.CAPICOM_ATTRIBUTE, CAdESCOM.CADESCOM_ATTRIBUTE, + CAdESCOM.CADESCOM_CONTENT_ENCODING_TYPE, CAdESCOM.CADESCOM_DISPLAY_DATA, + CAdESCOM.CADESCOM_ENCRYPTION_ALGORITHM, CAdESCOM.CADESCOM_HASH_ALGORITHM, + CAdESCOM.CADESCOM_InstallResponseRestrictionFlags { + readonly JSModuleVersion: string; + readonly current_log_level: number; + + async_spawn(generatorFun: (...args: any[]) => Iterator): T; + + set(obj: CADESPluginBase): void; + + set_log_level(level: CADES_Common.ValuesOf): void; + + getLastError(exception: Error): string; + + is_capilite_enabled(): boolean; +} + +interface CADESPluginAsync extends CADESPluginBase { + CreateObjectAsync(objName: T): Promise; + + ReleasePluginObjects(): Promise; +} + +interface CADESPluginSync extends CADESPluginBase { + CreateObject(objName: T): CADES_Plugin.ObjectNames[T]; +} + +type CADESPlugin = CADESPluginAsync | CADESPluginSync; diff --git a/types/cadesplugin/ts3.1/capicom.d.ts b/types/cadesplugin/ts3.1/capicom.d.ts new file mode 100644 index 0000000000..02bb6f05b5 --- /dev/null +++ b/types/cadesplugin/ts3.1/capicom.d.ts @@ -0,0 +1,83 @@ +declare namespace CAPICOM { + interface EncodedData { + readonly Format: string; + + Value(EncodingType?: CAPICOM_ENCODING_TYPE): string; + } + + interface OID { + FriendlyName: string; + Name: CAPICOM_OID; + Value: string; + } + + interface PublicKey { + readonly Algorithm: OID; + readonly EncodedKey: EncodedData; + readonly EncodedParameters: EncodedData; + readonly Length: number; + } + + interface Certificate { + readonly Version: number; + readonly Thumbprint: string; + readonly SubjectName: string; + readonly SerialNumber: string; + readonly IssuerName: string; + readonly ValidFromDate: CADES_Common.VarDate; + readonly ValidToDate: CADES_Common.VarDate; + + HasPrivateKey(): boolean; + + GetInfo(infoType: CAPICOM_CERT_INFO_TYPE): string; + + IsValid(): CertificateStatus; + + Display(): void; + + PublicKey(): PublicKey; + + Export(EncodingType: CADES_Common.ValuesOf): string; + } + + interface CertificateStatus { + Result: boolean; + } + + interface Certificates { + readonly Count: number; + + Item(index: number): Certificate; + + Find(findType: CADES_Common.ValuesOf, varCriteria?: any, bFindValidOnly?: boolean): Certificates; + + Select(title?: string, displayString?: string, bMultiSelect?: boolean): Certificates; + } + + interface Store { + readonly Certificates: Certificates; + readonly Location: CADES_Common.ValuesOf; + readonly Name: string; + + Open(location?: CADES_Common.ValuesOf, name?: CADES_Common.ValuesOf, openMode?: CADES_Common.ValuesOf): void; + + Close(): void; + + Delete(): boolean; + + Import(encodedStore: string): void; + } + + interface Signers { + readonly Count: number; + + Item(index: number): Signer; + } + + interface Signer { + Certificate: Certificate; + Options: CAPICOM_CERTIFICATE_INCLUDE_OPTION; + + Load(fileName: string, password?: string): void; + } +} diff --git a/types/cadesplugin/ts3.1/capicom_async.d.ts b/types/cadesplugin/ts3.1/capicom_async.d.ts new file mode 100644 index 0000000000..5ab775aba2 --- /dev/null +++ b/types/cadesplugin/ts3.1/capicom_async.d.ts @@ -0,0 +1,19 @@ +declare namespace CAPICOM { + interface CertificateAsync extends CADES_Common.Async { + } + + interface CertificatesAsync extends CADES_Common.Async { + } + + interface StoreAsync extends CADES_Common.Async { + } + + interface EncodedDataAsync extends CADES_Common.Async { + } + + interface OIDAsync extends CADES_Common.Async { + } + + interface PublicKeyAsync extends CADES_Common.Async { + } +} diff --git a/types/cadesplugin/ts3.1/capicom_enums.d.ts b/types/cadesplugin/ts3.1/capicom_enums.d.ts new file mode 100644 index 0000000000..aada08bfe2 --- /dev/null +++ b/types/cadesplugin/ts3.1/capicom_enums.d.ts @@ -0,0 +1,226 @@ +declare namespace CAPICOM { + interface StoreLocationPlugin { + readonly CAPICOM_LOCAL_MACHINE_STORE: 1; + readonly CAPICOM_CURRENT_USER_STORE: 2; + } + + interface CAPICOM_STORE_LOCATION { + readonly CAPICOM_MEMORY_STORE: 0; + readonly CAPICOM_LOCAL_MACHINE_STORE: 1; + readonly CAPICOM_CURRENT_USER_STORE: 2; + readonly CAPICOM_ACTIVE_DIRECTORY_USER_STORE: 3; + readonly CAPICOM_SMART_CARD_USER_STORE: 4; + } + + interface StoreNamePlugin { + readonly CAPICOM_MY_STORE: "My"; + } + + interface CAPICOM_STORE_NAME extends StoreNamePlugin { + readonly CAPICOM_CA_STORE: "Ca"; + readonly CAPICOM_OTHER_STORE: "AddressBook"; + readonly CAPICOM_ROOT_STORE: "Root"; + } + + interface StoreOpenModePlugin { + readonly CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED: 2; + } + + interface CAPICOM_STORE_OPEN_MODE extends StoreOpenModePlugin { + readonly CAPICOM_STORE_OPEN_READ_ONLY: 0; + readonly CAPICOM_STORE_OPEN_READ_WRITE: 1; + readonly CAPICOM_STORE_OPEN_EXISTING_ONLY: 128; + readonly CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED: 256; + } + + interface CAPICOM_CERTIFICATE_FIND_TYPE { + readonly CAPICOM_CERTIFICATE_FIND_SHA1_HASH: 0; + readonly CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME: 1; + readonly CAPICOM_CERTIFICATE_FIND_ISSUER_NAME: 2; + readonly CAPICOM_CERTIFICATE_FIND_ROOT_NAME: 3; + readonly CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME: 4; + readonly CAPICOM_CERTIFICATE_FIND_EXTENSION: 5; + readonly CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY: 6; + readonly CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY: 7; + readonly CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY: 8; + readonly CAPICOM_CERTIFICATE_FIND_TIME_VALID: 9; + readonly CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID: 10; + readonly CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED: 11; + readonly CAPICOM_CERTIFICATE_FIND_KEY_USAGE: 12; + } + + interface CAPICOM_CERTIFICATE_INCLUDE_OPTION { + readonly CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT: 0; + readonly CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY: 2; + readonly CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN: 1; + } + + interface CertIntoTypePlugin { + readonly CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME: 0; + readonly CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME: 1; + } + + interface CAPICOM_CERT_INFO_TYPE extends CertIntoTypePlugin { + readonly CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME: 2; + readonly CAPICOM_CERT_INFO_ISSUER_EMAIL_NAME: 3; + readonly CAPICOM_CERT_INFO_SUBJECT_UPN: 4; + readonly CAPICOM_CERT_INFO_ISSUER_UPN: 5; + readonly CAPICOM_CERT_INFO_SUBJECT_DNS_NAME: 6; + readonly CAPICOM_CERT_INFO_ISSUER_DNS_NAME: 7; + } + + interface KeyUsagePlugin { + readonly CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE: 128; + } + + interface CAPICOM_KEY_USAGE extends KeyUsagePlugin { + readonly CAPICOM_NON_REPUDIATION_KEY_USAGE: 64; + readonly CAPICOM_KEY_ENCIPHERMENT_KEY_USAGE: 32; + readonly CAPICOM_DATA_ENCIPHERMENT_KEY_USAGE: 16; + readonly CAPICOM_KEY_AGREEMENT_KEY_USAGE: 8; + readonly CAPICOM_KEY_CERT_SIGN_KEY_USAGE: 4; + readonly CAPICOM_OFFLINE_CRL_SIGN_KEY_USAGE: 2; + readonly CAPICOM_CRL_SIGN_KEY_USAGE: 2; + readonly CAPICOM_ENCIPHER_ONLY_KEY_USAGE: 1; + readonly CAPICOM_DECIPHER_ONLY_KEY_USAGE: 32768; + } + + interface PropIDPlugin { + readonly CAPICOM_PROPID_ENHKEY_USAGE: 9; + } + + interface CAPICOM_PROPID extends PropIDPlugin { + readonly CAPICOM_PROPID_UNKNOWN: 0; + readonly CAPICOM_PROPID_KEY_PROV_HANDLE: 1; + readonly CAPICOM_PROPID_KEY_PROV_INFO: 2; + readonly CAPICOM_PROPID_SHA1_HASH: 3; + readonly CAPICOM_PROPID_HASH_PROP: 3; + readonly CAPICOM_PROPID_MD5_HASH: 4; + readonly CAPICOM_PROPID_KEY_CONTEXT: 5; + readonly CAPICOM_PROPID_KEY_SPEC: 6; + readonly CAPICOM_PROPID_IE30_RESERVED: 7; + readonly CAPICOM_PROPID_PUBKEY_HASH_RESERVED: 8; + readonly CAPICOM_PROPID_CTL_USAGE: 9; + readonly CAPICOM_PROPID_NEXT_UPDATE_LOCATION: 10; + readonly CAPICOM_PROPID_FRIENDLY_NAME: 11; + readonly CAPICOM_PROPID_PVK_FILE: 12; + readonly CAPICOM_PROPID_DESCRIPTION: 13; + readonly CAPICOM_PROPID_ACCESS_STATE: 14; + readonly CAPICOM_PROPID_SIGNATURE_HASH: 15; + readonly CAPICOM_PROPID_SMART_CARD_DATA: 16; + readonly CAPICOM_PROPID_EFS: 17; + readonly CAPICOM_PROPID_FORTEZZA_DATA: 18; + readonly CAPICOM_PROPID_ARCHIVED: 19; + readonly CAPICOM_PROPID_KEY_IDENTIFIER: 20; + readonly CAPICOM_PROPID_AUTO_ENROLL: 21; + readonly CAPICOM_PROPID_PUBKEY_ALG_PARA: 22; + readonly CAPICOM_PROPID_CROSS_CERT_DIST_POINTS: 23; + readonly CAPICOM_PROPID_ISSUER_PUBLIC_KEY_MD5_HASH: 24; + readonly CAPICOM_PROPID_SUBJECT_PUBLIC_KEY_MD5_HASH: 25; + readonly CAPICOM_PROPID_ENROLLMENT: 26; + readonly CAPICOM_PROPID_DATE_STAMP: 27; + readonly CAPICOM_PROPID_ISSUER_SERIAL_NUMBER_MD5_HASH: 28; + readonly CAPICOM_PROPID_SUBJECT_NAME_MD5_HASH: 29; + readonly CAPICOM_PROPID_EXTENDED_ERROR_INFO: 30; + readonly CAPICOM_PROPID_RENEWAL: 64; + readonly CAPICOM_PROPID_ARCHIVED_KEY_HASH: 65; + readonly CAPICOM_PROPID_FIRST_RESERVED: 66; + readonly CAPICOM_PROPID_LAST_RESERVED: 32767; + readonly CAPICOM_PROPID_FIRST_USER: 32768; + readonly CAPICOM_PROPID_LAST_USER: 65535; + } + + interface OIDPlugin { + readonly CAPICOM_OID_OTHER: 0; + readonly CAPICOM_OID_KEY_USAGE_EXTENSION: 10; + } + + interface CAPICOM_OID extends OIDPlugin { + readonly CAPICOM_OID_AUTHORITY_KEY_IDENTIFIER_EXTENSION: 1; + readonly CAPICOM_OID_KEY_ATTRIBUTES_EXTENSION: 2; + readonly CAPICOM_OID_CERT_POLICIES_95_EXTENSION: 3; + readonly CAPICOM_OID_KEY_USAGE_RESTRICTION_EXTENSION: 4; + readonly CAPICOM_OID_LEGACY_POLICY_MAPPINGS_EXTENSION: 5; + readonly CAPICOM_OID_SUBJECT_ALT_NAME_EXTENSION: 6; + readonly CAPICOM_OID_ISSUER_ALT_NAME_EXTENSION: 7; + readonly CAPICOM_OID_BASIC_CONSTRAINTS_EXTENSION: 8; + readonly CAPICOM_OID_SUBJECT_KEY_IDENTIFIER_EXTENSION: 9; + readonly CAPICOM_OID_PRIVATEKEY_USAGE_PERIOD_EXTENSION: 11; + readonly CAPICOM_OID_SUBJECT_ALT_NAME2_EXTENSION: 12; + readonly CAPICOM_OID_ISSUER_ALT_NAME2_EXTENSION: 13; + readonly CAPICOM_OID_BASIC_CONSTRAINTS2_EXTENSION: 14; + readonly CAPICOM_OID_NAME_CONSTRAINTS_EXTENSION: 15; + readonly CAPICOM_OID_CRL_DIST_POINTS_EXTENSION: 16; + readonly CAPICOM_OID_CERT_POLICIES_EXTENSION: 17; + readonly CAPICOM_OID_POLICY_MAPPINGS_EXTENSION: 18; + readonly CAPICOM_OID_AUTHORITY_KEY_IDENTIFIER2_EXTENSION: 19; + readonly CAPICOM_OID_POLICY_CONSTRAINTS_EXTENSION: 20; + readonly CAPICOM_OID_ENHANCED_KEY_USAGE_EXTENSION: 21; + readonly CAPICOM_OID_CERTIFICATE_TEMPLATE_EXTENSION: 22; + readonly CAPICOM_OID_APPLICATION_CERT_POLICIES_EXTENSION: 23; + readonly CAPICOM_OID_APPLICATION_POLICY_MAPPINGS_EXTENSION: 24; + readonly CAPICOM_OID_APPLICATION_POLICY_CONSTRAINTS_EXTENSION: 25; + readonly CAPICOM_OID_AUTHORITY_INFO_ACCESS_EXTENSION: 26; + readonly CAPICOM_OID_SERVER_AUTH_EKU: 100; + readonly CAPICOM_OID_CLIENT_AUTH_EKU: 101; + readonly CAPICOM_OID_CODE_SIGNING_EKU: 102; + readonly CAPICOM_OID_EMAIL_PROTECTION_EKU: 103; + readonly CAPICOM_OID_IPSEC_END_SYSTEM_EKU: 104; + readonly CAPICOM_OID_IPSEC_TUNNEL_EKU: 105; + readonly CAPICOM_OID_IPSEC_USER_EKU: 106; + readonly CAPICOM_OID_TIME_STAMPING_EKU: 107; + readonly CAPICOM_OID_CTL_USAGE_SIGNING_EKU: 108; + readonly CAPICOM_OID_TIME_STAMP_SIGNING_EKU: 109; + readonly CAPICOM_OID_SERVER_GATED_CRYPTO_EKU: 110; + readonly CAPICOM_OID_ENCRYPTING_FILE_SYSTEM_EKU: 111; + readonly CAPICOM_OID_EFS_RECOVERY_EKU: 112; + readonly CAPICOM_OID_WHQL_CRYPTO_EKU: 113; + readonly CAPICOM_OID_NT5_CRYPTO_EKU: 114; + readonly CAPICOM_OID_OEM_WHQL_CRYPTO_EKU: 115; + readonly CAPICOM_OID_EMBEDED_NT_CRYPTO_EKU: 116; + readonly CAPICOM_OID_ROOT_LIST_SIGNER_EKU: 117; + readonly CAPICOM_OID_QUALIFIED_SUBORDINATION_EKU: 118; + readonly CAPICOM_OID_KEY_RECOVERY_EKU: 119; + readonly CAPICOM_OID_DIGITAL_RIGHTS_EKU: 120; + readonly CAPICOM_OID_LICENSES_EKU: 121; + readonly CAPICOM_OID_LICENSE_SERVER_EKU: 122; + readonly CAPICOM_OID_SMART_CARD_LOGON_EKU: 123; + readonly CAPICOM_OID_PKIX_POLICY_QUALIFIER_CPS: 124; + readonly CAPICOM_OID_PKIX_POLICY_QUALIFIER_USERNOTICE: 125; + } + + interface EKUPlugin { + readonly CAPICOM_EKU_OTHER: 0; + readonly CAPICOM_EKU_CLIENT_AUTH: 2; + readonly CAPICOM_EKU_SMARTCARD_LOGON: 5; + } + + interface CAPICOM_EKU { + readonly CAPICOM_EKU_SERVER_AUTH: 1; + readonly CAPICOM_EKU_CODE_SIGNING: 3; + readonly CAPICOM_EKU_EMAIL_PROTECTION: 4; + readonly CAPICOM_EKU_ENCRYPTING_FILE_SYSTEM: 6; + } + + interface CAPICOM_ATTRIBUTE { + readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME: 0; + readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME: 1; + readonly CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION: 2; + } + + interface CAPICOM_HASH_ALGORITHM { + readonly CAPICOM_HASH_ALGORITHM_SHA1: 0; + readonly CAPICOM_HASH_ALGORITHM_MD2: 1; + readonly CAPICOM_HASH_ALGORITHM_MD4: 2; + readonly CAPICOM_HASH_ALGORITHM_MD5: 3; + readonly CAPICOM_HASH_ALGORITHM_SHA_256: 4; + readonly CAPICOM_HASH_ALGORITHM_SHA_384: 5; + readonly CAPICOM_HASH_ALGORITHM_SHA_512: 6; + } + + interface CAPICOM_ENCODING_TYPE { + readonly CAPICOM_ENCODE_ANY: -1; + readonly CAPICOM_ENCODE_BASE64: 0; + readonly CAPICOM_ENCODE_BINARY: 1; + } +} diff --git a/types/cadesplugin/ts3.1/common.d.ts b/types/cadesplugin/ts3.1/common.d.ts new file mode 100644 index 0000000000..315b0490a3 --- /dev/null +++ b/types/cadesplugin/ts3.1/common.d.ts @@ -0,0 +1,25 @@ +declare namespace CADES_Common { + type ValuesOf = T[keyof T]; + type VarDate = object; + + // Extracts the type if wrapped by a Promise + type Unpacked = T extends Promise ? 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; + + type PromisifiedFunction = // tslint:disable-line ban-types + T extends (...args: infer A) => infer U ? (...args: { [K in keyof A]: Unpacked }) => Promise> : + T; + + type Async = { + readonly [K in keyof T]: T[K] extends Function ? PromisifiedFunction : // tslint:disable-line ban-types + Promise>; + }; +} diff --git a/types/cadesplugin/ts3.1/index.d.ts b/types/cadesplugin/ts3.1/index.d.ts new file mode 100644 index 0000000000..13fdba4187 --- /dev/null +++ b/types/cadesplugin/ts3.1/index.d.ts @@ -0,0 +1,13 @@ +/// + +/// +/// +/// + +/// +/// +/// + +/// + +declare const cadesplugin: CADESPlugin; diff --git a/types/cadesplugin/ts3.1/tsconfig.json b/types/cadesplugin/ts3.1/tsconfig.json new file mode 100644 index 0000000000..dbc37d117b --- /dev/null +++ b/types/cadesplugin/ts3.1/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../tsconfig", + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cadesplugin-tests.ts" + ] +} diff --git a/types/cadesplugin/ts3.1/tslint.json b/types/cadesplugin/ts3.1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/cadesplugin/ts3.1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/cadesplugin/tsconfig.json b/types/cadesplugin/tsconfig.json new file mode 100644 index 0000000000..71e6b79545 --- /dev/null +++ b/types/cadesplugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/types/cadesplugin/tslint.json b/types/cadesplugin/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/cadesplugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}