@types/pem

  • Version 1.9.6
  • Published
  • 12.2 kB
  • 1 dependency
  • MIT license

Install

npm i @types/pem
yarn add @types/pem
pnpm add @types/pem

Overview

TypeScript definitions for PEM

Index

Functions

function config

config: (options: ModuleConfiguration) => void;
  • config the pem module

function createCertificate

createCertificate: {
(
options: CertificateCreationOptions,
callback: Callback<CertificateCreationResult>
): void;
(callback: Callback<CertificateCreationResult>): void;
};
  • Creates a certificate based on a CSR. If CSR is not defined, a new one will be generated automatically. For CSR generation all the options values can be used as with createCSR.

    Parameter CertificateCreationOptions

    Optional options object

    Parameter callback

    Callback function with an error object and {certificate, csr, clientKey, serviceKey}

function createCSR

createCSR: {
(
options: CSRCreationOptions,
callback: Callback<{ csr: string; clientKey: string }>
): void;
(callback: Callback<{ csr: string; clientKey: string }>): void;
};
  • Creates a Certificate Signing Request

    If options.clientKey is undefined, a new key is created automatically. The used key is included in the callback return as clientKey

    Parameter options

    Optional options object

    Parameter callback

    Callback function with an error object and {csr, clientKey}

function createDhparam

createDhparam: {
(keyBitsize: number, callback: Callback<{ dhparam: any }>): void;
(callback: Callback<{ dhparam: any }>): void;
};
  • Creates a dhparam key

    Parameter keyBitsize

    Size of the key, defaults to 512bit

    Parameter callback

    Callback function with an error object and {dhparam}

function createPkcs12

createPkcs12: {
(
key: string,
certificate: string,
password: string,
options: Pkcs12CreationOptions,
callback: Callback<{ pkcs12: any }>
): void;
(
key: string,
certificate: string,
password: string,
callback: Callback<{ pkcs12: any }>
): void;
};
  • Exports private key and certificate to a PKCS12 keystore

    Parameter key

    PEM encoded private key

    Parameter certificate

    PEM encoded certificate

    Parameter password

    Password of the result PKCS12 file

    Parameter options

    object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'}

    Parameter callback

    Callback function with an error object and {pkcs12}

function createPrivateKey

createPrivateKey: {
(
keyBitsize: number,
options: PrivateKeyCreationOptions,
callback: Callback<{ key: string }>
): void;
(
optionsOrKeyBitsize: number | PrivateKeyCreationOptions,
callback: Callback<{ key: string }>
): void;
(callback: Callback<{ key: string }>): void;
};
  • Creates a private key

    Parameter keyBitsize

    Size of the key, defaults to 2048bit (can also be a function)

    Parameter options

    private key encryption settings, defaults to empty object (no enryption)

    Parameter callback

    Callback function with an error object and {key}

function getDhparamInfo

getDhparamInfo: (
dh: string,
callback: Callback<{ size: any; prime: any }>
) => void;
  • Gets the size and prime of DH parameters

    Parameter dh

    DH parameters PEM encoded

    Parameter callback

    Callback function with an error object and {size, prime}

function getFingerprint

getFingerprint: {
(
certificate: string,
hash: HashFunction,
callback: Callback<{ fingerprint: string }>
): void;
(certificate: string, callback: Callback<{ fingerprint: string }>): void;
(callback: Callback<{ fingerprint: string }>): void;
};
  • Gets the fingerprint for a certificate

    Parameter certificate

    PEM encoded certificate

    Parameter hash

    Hash function to use (either md5 sha1 or sha256, defaults to sha256)

    Parameter callback

    Callback function with an error object and {fingerprint}

function getModulus

getModulus: {
(
certificate: string,
password: string,
callback: Callback<{ modulus: any }>
): void;
(certificate: string, callback: Callback<{ modulus: any }>): void;
};
  • Gets the modulus from a certificate, a CSR or a private key

    Parameter certificate

    PEM encoded, CSR PEM encoded, or private key

    Parameter password

    password for the certificate

    Parameter callback

    Callback function with an error object and {modulus}

function getPublicKey

getPublicKey: {
(certificate: string, callback: Callback<{ publicKey: string }>): void;
(callback: Callback<{ publicKey: string }>): void;
};
  • Exports a public key from a private key, CSR or certificate

    Parameter certificate

    PEM encoded private key, CSR or certificate

    Parameter callback

    Callback function with an error object and {publicKey}

function readCertificateInfo

readCertificateInfo: {
(certificate: string, callback: Callback<CertificateSubjectReadResult>): void;
(callback: Callback<CertificateSubjectReadResult>): void;
};
  • Reads subject data from a certificate or a CSR

    Parameter certificate

    PEM encoded CSR or certificate

    Parameter callback

    Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress}

function readPkcs12

readPkcs12: {
(
bufferOrPath: Buffer | string,
options: Pkcs12ReadOptions,
callback: Callback<Pkcs12ReadResult>
): any;
(bufferOrPath: any, callback: Callback<Pkcs12ReadResult>): any;
};
  • Reads private key and certificate from a PKCS12 keystore

    Parameter callback

    Callback function with an error object and {pkcs12}

    Returns

    the result of the callback

function verifySigningChain

verifySigningChain: (
certificate: string,
ca: string[],
callback: Callback<boolean>
) => void;
  • Verifies the signing chain of the passed certificate

    Parameter certificate

    PEM encoded certificate

    Parameter ca

    List of CA certificates

    Parameter callback

    Callback function with an error object and a boolean valid

Interfaces

interface CertificateCreationOptions

interface CertificateCreationOptions extends CSRCreationOptions {}

    property clientKeyPassword

    clientKeyPassword?: string | undefined;
    • Password of the client key

    property config

    config?: string | undefined;
    • extension config file - with '-extensions v3_req'

    property csr

    csr?: string | undefined;
    • CSR for the certificate, if not defined a new one is generated from the provided parameters

    property days

    days?: number | undefined;
    • Certificate expire time in days, defaults to 365

    property extFile

    extFile?: string | undefined;
    • extension config file - without '-extensions v3_req'

    property selfSigned

    selfSigned?: boolean | undefined;
    • If set to true and serviceKey is not defined, use clientKey for signing

    property serial

    serial?: any;

      property serviceCertificate

      serviceCertificate?: any;

        property serviceKey

        serviceKey?: string | undefined;
        • Private key for signing the certificate, if not defined a new one is generated

        property serviceKeyPassword

        serviceKeyPassword?: string | undefined;
        • Password of the service key

        interface CertificateCreationResult

        interface CertificateCreationResult {}

          property certificate

          certificate: any;

            property clientKey

            clientKey: string;

              property csr

              csr: string;

                property serviceKey

                serviceKey: string;

                  interface CertificateSubjectReadResult

                  interface CertificateSubjectReadResult {}

                    property commonName

                    commonName: string;

                      property country

                      country: string;

                        property emailAddress

                        emailAddress: string;

                          property locality

                          locality: string;

                            property organization

                            organization: string;

                              property organizationUnit

                              organizationUnit: string;

                                property state

                                state: string;

                                  interface CSRCreationOptions

                                  interface CSRCreationOptions {}

                                    property altNames

                                    altNames?: string[] | undefined;
                                    • A list of subjectAltNames in the subjectAltName field

                                    property clientKey

                                    clientKey?: string | undefined;
                                    • Optional client key to use

                                    property clientKeyPassword

                                    clientKeyPassword?: string | undefined;

                                      property commonName

                                      commonName?: string | undefined;
                                      • CSR common name field, defaults to 'localhost'

                                      property country

                                      country?: string | undefined;
                                      • CSR country field

                                      property csrConfigFile

                                      csrConfigFile?: string | undefined;
                                      • CSR config file

                                      property emailAddress

                                      emailAddress?: string | undefined;
                                      • CSR email address field

                                      property hash

                                      hash?: HashFunction | undefined;
                                      • Hash function to use, defaults to sha256

                                      property keyBitsize

                                      keyBitsize?: number | undefined;
                                      • If clientKey is undefined, bit size to use for generating a new key (defaults to 2048)

                                      property locality

                                      locality?: string | undefined;
                                      • CSR locality field

                                      property organization

                                      organization?: string | undefined;
                                      • CSR organization field

                                      property organizationUnit

                                      organizationUnit?: string | undefined;
                                      • CSR organizational unit field

                                      property state

                                      state?: string | undefined;
                                      • CSR state field

                                      interface ModuleConfiguration

                                      interface ModuleConfiguration {}

                                        property pathOpenSSL

                                        pathOpenSSL: string;
                                        • Path to OpenSSL binaries

                                        interface Pkcs12CreationOptions

                                        interface Pkcs12CreationOptions {}

                                          property certFiles

                                          certFiles?: string[] | undefined;

                                            property cipher

                                            cipher?: PrivateKeyCipher | undefined;

                                              property clientKeyPassword

                                              clientKeyPassword?: string | undefined;

                                                interface Pkcs12ReadOptions

                                                interface Pkcs12ReadOptions {}

                                                  property clientKeyPassword

                                                  clientKeyPassword?: string | undefined;

                                                    property p12Password

                                                    p12Password?: string | undefined;

                                                      interface Pkcs12ReadResult

                                                      interface Pkcs12ReadResult {}

                                                        property ca

                                                        ca: string[];

                                                          property cert

                                                          cert: string;

                                                            property key

                                                            key: string;

                                                              interface PrivateKeyCreationOptions

                                                              interface PrivateKeyCreationOptions {}

                                                                property cipher

                                                                cipher: PrivateKeyCipher;

                                                                  property password

                                                                  password: string;

                                                                    Type Aliases

                                                                    type Callback

                                                                    type Callback<T> = (error: any, result: T) => any;

                                                                      type HashFunction

                                                                      type HashFunction = 'md5' | 'sha1' | 'sha256' | string;

                                                                        type PrivateKeyCipher

                                                                        type PrivateKeyCipher =
                                                                        | 'aes128'
                                                                        | 'aes192'
                                                                        | 'aes256'
                                                                        | 'camellia128'
                                                                        | 'camellia192'
                                                                        | 'camellia256'
                                                                        | 'des'
                                                                        | 'des3'
                                                                        | 'idea'
                                                                        | string;

                                                                          Package Files (1)

                                                                          Dependencies (1)

                                                                          Dev Dependencies (0)

                                                                          No dev dependencies.

                                                                          Peer Dependencies (0)

                                                                          No peer dependencies.

                                                                          Badge

                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/pem.

                                                                          • Markdown
                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/pem)
                                                                          • HTML
                                                                            <a href="https://www.jsdocs.io/package/@types/pem"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>