diff --git a/types/node-forge/README.md b/types/node-forge/README.md index c70966e474..98180a3856 100644 --- a/types/node-forge/README.md +++ b/types/node-forge/README.md @@ -1,7 +1,7 @@ # DefinitelyTyped for node-forge ## Current node-forge Version -`v0.7.6` +`v0.9.1` ## Usage ```bash diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index ac88b0862c..7652e79b5a 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-forge 0.8.1 +// Type definitions for node-forge 0.9.1 // Project: https://github.com/digitalbazaar/forge // Definitions by: Seth Westphal // Kay Schecker @@ -11,6 +11,7 @@ // supaiku0 // Anders Kaseorg // Sascha Zarhuber +// Rogier Schouten // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 @@ -247,6 +248,62 @@ declare module "node-forge" { */ verify(child: Certificate): boolean; + /** + * Gets an issuer or subject attribute from its name, type, or short name. + * + * @param options a short name string or an object with: + * shortName the short name for the attribute. + * name the name for the attribute. + * type the type for the attribute. + * + * @return the attribute. + */ + getAttribute(opts: string | GetAttributeOpts): Attribute | null; + } + + /** + * Attribute members to search on; any one hit will return the attribute + */ + interface GetAttributeOpts { + /** + * OID + */ + type?: string; + /** + * Long name + */ + name?: string; + /** + * Short name + */ + shortName?: string; + } + + interface Attribute { + /** + * e.g. challengePassword + */ + name: string; + /** + * Short name, if available (e.g. 'CN' for 'commonName') + */ + shortName?: string; + /** + * OID, e.g. '1.2.840.113549.1.9.7' + */ + type: string; + /** + * Attribute value + */ + value: any; + /** + * Attribute value data type + */ + valueTagClass: number; + /** + * Extensions + */ + extensions?: any[] } interface CAStore { diff --git a/types/node-forge/node-forge-tests.ts b/types/node-forge/node-forge-tests.ts index 064bd0f607..9b02586f7f 100644 --- a/types/node-forge/node-forge-tests.ts +++ b/types/node-forge/node-forge-tests.ts @@ -187,6 +187,9 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin } ]); + const attr: forge.pki.Attribute | undefined = cert.getAttribute({ name: "challengePassword" }); + + // self-sign certificate cert.sign(keypair.privateKey, forge.md.sha256.create()); } @@ -373,7 +376,7 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin message: toSign, privateKey }); - + const toSign2 = 'foo'; forge.pki.ed25519.sign({ message: toSign2,