Class OIDDataBase

Singleton class for OID(object identifier) name database

Example

import { OIDDataBase, OIDSET_CRYPTO, OIDSET_X509 } from "typepki-oiddb";
const oiddb = OIDDataBase.instance; // singleton object
oiddb.regist([OIDSET_CRYPTO, OIDSET_X509]);
oiddb.oidtoname("2.5.29.15") -> "keyUsage"
oiddb.nametooid("P-521") -> "1.3.132.0.35"
oiddb.shorttoname("CN") -> "commonName"
oiddb.nametoshort("commonName") -> "CN"
oiddb.shorttooid("C") -> "2.5.4.6"
oiddb.oidtoshort("2.5.4.6") -> "C"
oiddb.aliasto("P-256") -> "prime256v1"

Accessors

  • get uuid(): string
  • get UUID value of this object. This is debugging purpose.

    Returns string

Methods

  • convert alias name to original OID name defined in internal database

    Parameters

    • aliasfrom: string

      alias name (ex. "P-256").

    Returns string

    original OID name (ex. "prime256v1"). Return undefined if not defined.

    Example

    oiddb.aliasto("P-256") -> "prime256v1"
    oiddb.aliasto("FOO") -> undefined // FOO is not defined in aliases
  • convert OID name to OID value defined in internal database

    Parameters

    • name: string

      OID name. (ex. "countryName").

    Returns string

    OID value (ex. "1.2.3.4"). Return undefined if not defined.

    See

    oidtoname

    Example

    oiddb.nametooid("keyUsage") -> "2.5.29.15"
    oiddb.nametooid("foo-bar-") -> undefined // not registered
    oiddb.nametooid("P-521") -> "1.3.132.0.35"
  • convert OID name to short attribute type name defined in internal database

    Parameters

    • name: string

      OID name (ex. "commonName").

    • Optional useUndef: boolean

      flag to return undefined when it is undefined in the database

    Returns undefined | string

    short attribute type name for distinguished name. (ex. "CN"). Return OID name if not defined.

    See

    shorttoname

    Example

    oiddb.nametoshort("commonName") -> "CN"
    oiddb.nametoshort("serialNumber") -> "serialNumber" // for undefined short name
    oiddb.nametoshort("serialNumber", true) -> undefined // for undefined short name
  • convert OID value to OID name defined in internal database

    Parameters

    • oid: string

      OID value (ex. "1.2.3.4")

    • Optional useUndef: boolean

      flag to return undefined when it is undefined in the database

    Returns undefined | string

    OID name. (ex. "countryName"). Return undefined if not defined.

    See

    nametooid

    Example

    oiddb.oidtoname("2.5.29.15") -> "keyUsage"
    oiddb.oidtoname("1.2.3.4") -> "1.2.3.4"
    oiddb.oidtoname("1.2.3.4", true) -> undefined
  • convert OID value to short attribute type name defined in internal database

    Parameters

    • oid: string

      OID value (ex. "2.5.4.6").

    • Optional useUndef: boolean

      flag to return undefined when it is undefined in the database

    Returns undefined | string

    short attribute type name for distinguished name. (ex. "C"). Return OID name if not defined.

    See

    shorttooid

    Example

    oiddb.oidtoshort("2.5.4.6") -> "CN"
    oiddb.oidtoshort("2.5.4.97") -> "organizationIdentifier" // OID defined but short name not defined
    oiddb.oidtoshort("1.2.3.4") -> "1.2.3.4" // for undefined short name nor OID name
    oiddb.oidtoshort("1.2.3.4", true) -> undefined
  • Register OID data set to a singleton object

    Parameters

    Returns void

    Description

    This method will add OID definitions to object internal database by the list of OIDDataSet. When the OIDDataSet.setname already registered, its importing will be skipped. Also when the registering OID is already registered, its OID registration is skipped. This means existing OID definition will not be overwritten.

    Example

    import { OIDDataBase, OIDSET_CRYPTO, OIDSET_X509 } from "typepki-oiddb";
    const oiddb = OIDDatabase.instance;
    oiddb.regist([OIDSET_CRYPTO, OIDSET_X509]);
  • convert short attribute type name to OID value defined in internal database

    Parameters

    • short: string

      short attribute type name for distinguished name. (ex. "CN").

    • Optional useUndef: boolean

      flag to return undefined when it is undefined in the database

    Returns undefined | string

    OID name (ex. "commonName"). Return undefined if not defined.

    See

    nametoshort

    Example

    oiddb.shorttoname("CN") -> "commonName"
    oiddb.shorttoname("FOO") -> undefined // not registered
    oiddb.shorttoname("FOO", true) -> "FOO" // not registered
  • Parameters

    • short: string

    Returns string