@types/pem

  • Version 1.14.4
  • Published
  • 19.1 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 checkCertificate

checkCertificate: {
(certificate: string, passphrase: string, callback: Callback<boolean>): void;
(certificate: string, callback: Callback<boolean>): void;
};
  • Check a certificate

    Parameter certificate

    PEM encoded certificate

    Parameter passphrase

    password for the certificate

    Parameter callback

    Callback function with an error object and a boolean valid

function checkPkcs12

checkPkcs12: {
(
bufferOrPath: Buffer | string,
passphrase: string,
callback: Callback<boolean>
): void;
(bufferOrPath: any, callback: Callback<boolean>): void;
};
  • check a PKCS#12 file (.pfx or.p12)

    Parameter bufferOrPath

    PKCS#12 certificate

    Parameter passphrase

    optional passphrase which will be used to open the keystore

    Parameter callback

    Callback function with an error object and a boolean valid

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: string }>): void;
(callback: Callback<{ dhparam: string }>): 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 createEcparam

createEcparam: {
(
keyName: string,
paramEnc: string,
noOut: boolean,
callback: Callback<{ ecparam: string }>
): void;
(callback: Callback<{ ecparam: string }>): void;
};
  • Creates a ecparam key

    Parameter keyName

    Name of the key, defaults to secp256k1

    Parameter paramEnc

    Encoding of the elliptic curve parameters, defaults to explicit

    Parameter noOut

    This option inhibits the output of the encoded version of the parameters.

    Parameter callback

    Callback function with an error object and {ecparam}

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;

                                                                          Namespaces

                                                                          namespace promisified

                                                                          namespace promisified {}

                                                                            function checkCertificate

                                                                            checkCertificate: (certificate: string, passphrase?: string) => Promise<boolean>;
                                                                            • Check a certificate

                                                                              Parameter certificate

                                                                              PEM encoded certificate

                                                                              Parameter passphrase

                                                                              password for the certificate

                                                                              Returns

                                                                            function checkPkcs12

                                                                            checkPkcs12: (
                                                                            bufferOrPath: Buffer | string,
                                                                            passphrase?: string
                                                                            ) => Promise<boolean>;
                                                                            • check a PKCS#12 file (.pfx or.p12)

                                                                              Parameter bufferOrPath

                                                                              PKCS#12 certificate

                                                                              Parameter passphrase

                                                                              optional passphrase which will be used to open the keystore

                                                                              Parameter callback

                                                                              Callback function with an error object and a boolean valid

                                                                            function createCertificate

                                                                            createCertificate: (
                                                                            options?: CertificateCreationOptions
                                                                            ) => Promise<CertificateCreationResult>;
                                                                            • 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

                                                                              Returns

                                                                            function createCSR

                                                                            createCSR: (
                                                                            options?: CSRCreationOptions
                                                                            ) => Promise<{ csr: string; clientKey: string }>;
                                                                            • 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

                                                                              Returns

                                                                            function createDhparam

                                                                            createDhparam: (keyBitsize?: number) => Promise<{ dhparam: string }>;
                                                                            • Creates a dhparam key

                                                                              Parameter keyBitsize

                                                                              Size of the key, defaults to 512bit

                                                                              Returns

                                                                            function createEcparam

                                                                            createEcparam: (
                                                                            keyName?: string,
                                                                            paramEnc?: string,
                                                                            noOut?: boolean
                                                                            ) => Promise<{ ecparam: string }>;
                                                                            • Creates a ecparam key

                                                                              Parameter keyName

                                                                              Name of the key, defaults to secp256k1

                                                                              Parameter paramEnc

                                                                              Encoding of the elliptic curve parameters, defaults to explicit

                                                                              Parameter noOut

                                                                              This option inhibits the output of the encoded version of the parameters.

                                                                              Returns

                                                                            function createPkcs12

                                                                            createPkcs12: (
                                                                            key: string,
                                                                            certificate: string,
                                                                            password: string,
                                                                            options?: Pkcs12CreationOptions
                                                                            ) => Promise<{ pkcs12: any }>;
                                                                            • 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'}

                                                                              Returns

                                                                            function createPrivateKey

                                                                            createPrivateKey: {
                                                                            (keyBitsize: number, options: PrivateKeyCreationOptions): Promise<{
                                                                            key: string;
                                                                            }>;
                                                                            (optionsOrKeyBitsize?: number | PrivateKeyCreationOptions): Promise<{
                                                                            key: string;
                                                                            }>;
                                                                            };
                                                                            • 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)

                                                                              Returns

                                                                            function getDhparamInfo

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

                                                                              Parameter dh

                                                                              DH parameters PEM encoded

                                                                              Returns

                                                                            function getFingerprint

                                                                            getFingerprint: (
                                                                            certificate: string | Buffer | DataView | TypedArray,
                                                                            hash?: HashFunction
                                                                            ) => Promise<{ fingerprint: string }>;
                                                                            • 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)

                                                                              Returns

                                                                            function getModulus

                                                                            getModulus: (
                                                                            certificate: string,
                                                                            password?: string
                                                                            ) => Promise<{ modulus: any }>;
                                                                            • 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

                                                                              Returns

                                                                            function getPublicKey

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

                                                                              Parameter certificate

                                                                              PEM encoded private key, CSR or certificate

                                                                              Returns

                                                                            function readCertificateInfo

                                                                            readCertificateInfo: (
                                                                            certificate: string
                                                                            ) => Promise<CertificateSubjectReadResult>;
                                                                            • Reads subject data from a certificate or a CSR

                                                                              Parameter certificate

                                                                              PEM encoded CSR or certificate

                                                                              Returns

                                                                            function readPkcs12

                                                                            readPkcs12: (
                                                                            bufferOrPath: Buffer | string,
                                                                            options?: Pkcs12ReadOptions
                                                                            ) => Promise<Pkcs12ReadResult>;
                                                                            • Reads private key and certificate from a PKCS12 keystore

                                                                              Returns

                                                                            function verifySigningChain

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

                                                                              Parameter certificate

                                                                              PEM encoded certificate

                                                                              Parameter ca

                                                                              List of CA certificates

                                                                              Returns

                                                                            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>