import { Requester } from "./lib/requester"; import { type ParameterHandlerProps, type SecretHandlerProps } from "./lib/handlers"; import type { ErrorResponse, ParameterResponse, SecretResponse } from "./lib/responses"; /** * Options for retrieving a Parameter. */ export type ParameterOptions = Omit; /** * Options for retrieving a String Parameter. * Cannot set both `label` and `version`. */ export type StringParameterOptions = Pick; /** * Options for retrieving a String List Parameter. * Cannot set both `label` and `version`. */ export type StringListParameterOptions = StringParameterOptions; /** * Options for retrieving a Secure String Parameter. * Cannot set both `label` and `version`. */ export type SecureStringParameterOptions = Pick; /** * Options when retrieving Secrets using the Parameter Store endpoint. * Set one or neither, but not both: * * - `label` sets the `VersionStage` of the Secret (default `AWSCURRENT`) * - `version` sets the `VersionId` * * `withDecryption` is not an option. * Secrets returned from the Parameter Store are always returned encrypted */ export type SecretFromParamStoreOptions = Pick; export type SecretOptions = Omit; /** * Client Options */ export interface ClientOptions { /** * Requests to the extension require an AWS-supplied session token. * The Lambda service sets the opaque token value for running functions in the `AWS_SESSION_TOKEN` environment variable. * * The Client sends the token in the `X-Aws-Parameters-Secrets-Token` header. * Using this header indicates that the caller is within the Lambda environment. * * @default * process.env.AWS_SESSION_TOKEN */ token?: string; /** * Port is the Lambda Extension HTTP listener's assigned port on `localhost`. * * The Lambda service sets a default value of `"2773"` in `PARAMETERS_SECRETS_EXTENSION_HTTP_PORT`. * Lambda users can override the default by setting the Lambda Function's environment variable. * * `http://localhost:` * * @default * process.env.PARAMETERS_SECRETS_EXTENSION_HTTP_PORT ?? "2773" */ port?: string; /** * An object capable of making a HTTP GET Request * * @default * `FetchRequester` */ requester?: Requester; } /** * The Client makes requests to the `http:localhost` endpoint exposed by * the AWS Parameters and Secrets Lambda Extension. */ export declare class Client { /** * The Extension's base URL endpoint. * Protocol + host + port number. * * @default * `http://localhost:2773` */ readonly baseUrl: string; /** * An object capable of making a HTTP GET Request * * @default * `FetchRequester` */ private readonly requester; constructor(props?: ClientOptions); /** * Get the resource. */ private getResource; /** * Get a SSM String Parameter Value for from the Extension. * * If `parameterName` returns a comma-deliminated string for a `StringList` * and the decrypted value of a `SecureString`. * @param parameterName the `String` or `StringList` parameter name * @param options optional qualifiers * @returns a Promise of the parameter's string valu. `null` if error or undefined. */ stringParameter(parameterName: string, options?: StringParameterOptions): Promise; /** * Get a SSM String Parameter List Values as an array from the Extension. * * Use the `stringParameter` method to return the stringified value of a `StringList`. * @param parameterName the `StringList` parameter name * @param options optional qualifiers * @returns a Promise of the parameter's values as an array. `null` if error or undefined. */ stringListParameter(parameterName: string, options?: StringListParameterOptions): Promise; /** * Get a SSM String Parameter List Value from the Extension. * @param parameterName the `SecureString` parameter name * @param options optional qualifiers. The Client sets `withDecryption: true` by default. * @returns a Promise of the parameter's value. `null` if error or undefined. */ secureStringParameter(parameterName: string, options?: SecureStringParameterOptions): Promise; /** * Get a String Secret [from the SSM Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-ps-secretsmanager.html) using the Extension. * * Always returns the decrypted value. The WithDecryption flag must be True for retrieving a Secret Manager secret. * @param secretId the `StringSecret` secret name * @param options optional qualifiers. The Client sets `withDecryption: true` by default. * @returns a Promise of the parameter's value. `null` if error or undefined. */ stringSecretfromParameterStore(secretId: string, options?: SecretFromParamStoreOptions): Promise; /** * Get a Binary Secret [from the SSM Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-ps-secretsmanager.html) using the Extension. * * Always returns the decrypted value. The WithDecryption flag must be True for retrieving a Secret Manager secret. * @param secretId the `BinarySecret` secret name * @param options optional qualifiers. The Client sets `withDecryption: true` by default. * @returns a Promise of a Binary Secret as a `Buffer. `null` if error or undefined. */ binarySecretfromParameterStore(secretId: string, options?: SecretFromParamStoreOptions): Promise; /** * Get the full Response object from the Extension for a SSM Parameter * @param parameterName the parameter name * @param options optional qualifiers * @returns a Promise of the full response object returned by the Extension. */ parameterResponse(parameterName: string, options?: ParameterOptions): Promise; /** * Get the extension localhost URL path for a SSM Parameter * @param parameterName the parameter name * @param options optional qualifiers * @returns the localhost path of the request */ parameterPath(parameterName: string, options?: ParameterOptions): string; /** * * Get a Secrets Manager `StringSecret` Value from the Extension. * @param secretId the secret id * @param options optional qualifiers. * @returns a Promise of a String Secret or `null` if error or undefined */ stringSecret(secretId: string, options?: SecretOptions): Promise; /** * Get a Secrets Manager `BinarySecret` Value as a `Buffer` from the Extension. * * Converts the Extension's Base64 string response to a `Buffer`. * @param secretId the secret id * @param options optional qualifiers. * @returns a Promise of a Binary Secret as a `Buffer. `null` if error or undefined. */ binarySecret(secretId: string, options?: SecretOptions): Promise; /** * Get the full Response object from the Extension for a SecretManager Secret. * * For Binary Secrets _"The response parameter represents the binary data as a base64-encoded string."_ * (`GetSecretValueCommandOutput`) * @param secretId the secret id * @param options optional qualifiers. * @returns a Promise of the full response object returned by the Extension */ secretResponse(secretId: string, options?: SecretOptions): Promise; /** * Get the extension localhost URL path for a SecretManager Secret * @param secretId the secret id * @param options optional qualifiers * @returns the localhost path of the request */ secretPath(secretId: string, options?: SecretOptions): string; }