Class AWSKMSService

class: AWSKMSService

  • shared Key Management Service to encrypt/decrypt message.

Hierarchy

  • AWSKMSService

Implements

Constructors

Properties

_instance: KMS
_keyId: string
_options: AWSKMSSignOption
DEF_KMS_TARGET: string = ...
ENV_KMS_KEY_ID: string = 'KMS_KEY_ID'

environ name of KMS KEY

Methods

  • Decrypt message

    Parameters

    • encryptedSecret: string

    Returns Promise<string>

  • Encrypt message

    Parameters

    • message: string

    Returns Promise<string>

  • retrieve public-key for asymetric verification.

    • used to verify signature with JWT library w/o making request to AWS KMS.
    • in general, cache this public-key to verify locally.

    Parameters

    • encoding: BufferEncoding = 'base64'

      (optional) encoding type

    Returns Promise<string>

  • it should be 'hello lemon'

    Example

    # encrypt text
    $ aws kms encrypt --profile <profile> --key-id <kms-key-id> --plaintext "hello lemon" --query CiphertextBlob --output text

    Returns Promise<{ KMS_KEY_ID: string; decrypted: string; encrypted: string; keyId: string; message: string }>

  • make signature by message

    Parameters

    • message: string

      any string

    • forJwtSignature: boolean = true

      (option) flag to get JWT signature format.

    Returns Promise<string>

  • verify signature in asymetric way

    • it tooks around 30ms

    Parameters

    • message: string

      any string

    • signature: string | Buffer

      signature of Buffer or string(in base64)

    Returns Promise<boolean>

Generated using TypeDoc