@cumulus/common
Version:
Common utilities used across tasks
41 lines • 2.07 kB
TypeScript
/**
* Provides encryption and decryption methods with a consistent API but
* differing mechanisms for dealing with encryption keys.
*/
import { Readable } from 'stream';
import { S3 } from '@aws-sdk/client-s3';
export { KMS } from './kms';
export declare const buildS3Client: () => S3;
export declare const getObjectStreamContents: (objectReadStream: Readable) => Promise<string>;
export declare const retrieveKey: (keyId: string, bucket?: string | undefined, stack?: string | undefined) => Promise<string | undefined>;
/**
* Provides encryption and decryption methods using a keypair stored in S3
*/
export declare class S3KeyPairProvider {
/**
* Encrypt the given string using the given public key stored in the system_bucket.
*
* @param {string} str - The string to encrypt
* @param {string} [keyId] - The name of the public key to use for encryption
* @param {string} [bucket] - the optional bucket name. if not provided will
* use env variable "system_bucket"
* @param {stack} [stack] - the optional stack name. if not provided will
* use env variable "stackName"
* @returns {Promise.<string>} the encrypted string
*/
static encrypt(str: string, keyId?: string, bucket?: string, stack?: string): Promise<string>;
/**
* Decrypt the given string using a private key stored in S3
*
* @param {string} str - The string to decrypt
* @param {string} [keyId] - The name of the public key to use for decryption
* @param {string} [bucket] - the optional bucket name. Defaults to the value
* of the "system_bucket" environment variable
* @param {string} [stack] - the optional stack name. Defaults to the value of
* the "stackName" environment variable
* @returns {Promise.<string>} the decrypted string
*/
static decrypt(str: string, keyId?: string, bucket?: string, stack?: string): Promise<string>;
}
export { S3KeyPairProvider as DefaultProvider };
//# sourceMappingURL=key-pair-provider.d.ts.map