Class License

Hierarchy

  • License

Constructors

  • Parameters

    • _issuerId: string

      License issuer (e.g. "alex")

    • _machineId: string

      License Machine ID it's issued for (e.g. comp-1 or auto-id)

    • _validUntil: Date

      License valid until date

    • Optional _signature: string

      License secp256k1 signature to validate above parameters issued by certain issuer

    Returns License

Properties

_issuerId: string

License issuer (e.g. "alex")

_machineId: string

License Machine ID it's issued for (e.g. comp-1 or auto-id)

_signature?: string

License secp256k1 signature to validate above parameters issued by certain issuer

_validUntil: Date

License valid until date

Accessors

  • get rawLicense(): string
  • Get raw license string (without secp256k1 signature)

    Returns string

  • get rawLicenseHash(): string
  • Get raw license hash (mainly used internallly)

    Returns string

  • get signature(): undefined | string
  • Get license secp256k1 signature to validate against

    Returns undefined | string

  • get signedLicense(): string
  • Get secp256k1 signed license string

    Throws

    UnsignedLicenseError if the license is unsigned

    Returns string

Methods

  • Sign license using an issuer private key

    Parameters

    • issuerPrivateKey: PrivateKey

      Issuer private key (e.g. Secp256k1.utils.randomPrivateKey())

    Returns Promise<License>

    Returns same License instance

  • Validate secp256k1 signed license

    Throws

    MissingPublicKeyError if public key missing for a signed license

    Throws

    UnsignedLicenseError if the license is unsigned

    Parameters

    • Optional issuerPublicKey: PublicKey

      Issuer public key (e.g. Secp256k1.getPublicKey(PRIVATE_KEY))

    Returns boolean

    Returns true if license has both valid signature (if applicable) and date

  • Validate secp256k1 signed license against an issuer public key

    Throws

    UnsignedLicenseError if the license is unsigned

    Parameters

    • issuerPublicKey: PublicKey

      Issuer public key (e.g. Secp256k1.getPublicKey(PRIVATE_KEY))

    Returns boolean

    Returns true if license has a valid signature generated by the passed issuer

  • Creates a License instance with defaults if custom parameters skipped

    Parameters

    • issuerId: string

      License issuer (e.g. "alex")

    • Optional machineId: string

      License Machine ID it's issued for (e.g. comp-1 or auto-id)

    • Optional validUntil: Date

      License valid until date

    • Optional signature: string

      License secp256k1 signature to validate above parameters issued by certain issuer

    Returns Promise<License>

    a License instance initialized with either passed parameters or defaults

  • Restore a non signed (raw) license from license string

    Throws

    InvalidLicenseStringError if raw signature is invalid

    Parameters

    • license: string

      The raw license string

    Returns License

    a License instance with restored parameters

  • Restore a non secp256k1 signed license from license string

    Throws

    InvalidLicenseStringError if raw signature is invalid

    Parameters

    • license: string

      The signed license string

    Returns License

    a License instance with restored parameters

  • Generate a short ID for current machine (or container)

    Returns Promise<string>

    A small hashed machine ID

Generated using TypeDoc