From 56e1395fd6b3e7402cd9476c9a1a0c6a1ecafa24 Mon Sep 17 00:00:00 2001 From: oleiade Date: Tue, 4 Oct 2022 10:55:45 +0200 Subject: [PATCH] Produce v0.6.0 build artifacts --- build/_signature.min.js.map | 2 +- build/aws.min.js.map | 2 +- build/kms.min.js.map | 2 +- build/s3.min.js.map | 2 +- build/secrets-manager.min.js.map | 2 +- build/ssm.min.js.map | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/_signature.min.js.map b/build/_signature.min.js.map index 4a61523..c7f8207 100644 --- a/build/_signature.min.js.map +++ b/build/_signature.min.js.map @@ -1 +1 @@ -{"version":3,"file":"_signature.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,ydCL9D,MAAM,EAA+BC,QAAQ,a,aCA7C,MAAM,EAA+BA,QAAQ,W,k5IC2BtC,SAASC,EACZC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAIIF,EAAUG,eACVT,EAAQ,wBAA0BM,EAAUG,cAGhD,IAAMC,EAAoBC,EACtBL,EAAUM,gBACVX,E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ASjC,EAAOgD,GACnB,OAAOzC,EAAOyC,GAAWG,UAAU,EAAG,EACzC,CASM,SAAS9B,EAAiBD,GAC7B,OAAkB,IAAdA,EAAGF,OACI,GAGJE,EACFkB,MAAM,KACNc,QAAO,SAACC,GAAD,OAAOA,CAAP,IACP/B,KAAI,SAACU,GACF,IAAMsB,EAAQtB,EAAEM,MAAM,IAAK,GACrBjG,EAAMkH,mBAAmBD,EAAM,IACjCpG,EAAQqG,mBAAmBD,EAAM,IAIrC,MAHc,cAAVpG,IACAA,EAAQ,IAEL,CAACb,EAAKa,EAChB,IACAgF,MAAK,SAAChG,EAAqBsH,GACxB,OAAOtH,EAAE,GAAGuH,cAAcD,EAAE,GAC/B,GACR,C","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/error.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","deriveSigningKey","secretAccessKey","region","canonicalRequest","createCanonicalRequest","stringToSign","createStringToSign","sha256","credentialScope","createCredentialScope","signedHeaders","createSignedHeaders","signature","calculateSignature","authorizationHeader","HashingAlgorithm","accessKeyID","InvalidSignatureError","message","code","name","xmlDocument","doc","parseHTML","AWSError","find","text","Error","hmac","time","kSecret","date","toDate","kDate","kRegion","kService","UnsignedPayload","hashedCanonicalRequest","requestDateTime","toTime","join","uri","query","payload","toUpperCase","createCanonicalURI","createCanonicalQueryString","createCanonicalHeaders","createCanonicalPayload","canonicalURI","length","URIEncode","qs","parseQueryString","map","uriComponent","encodeURIComponent","constructor","entries","values","toLowerCase","trim","Array","isArray","v","replace","sort","TypeError","keys","crypto","split","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","filter","e","parts","decodeURIComponent","b","localeCompare"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"_signature.min.js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ACjCK,OACA1B,KAAK,KAkBP,SAASQ,EAAuBL,GACnC,OAAIA,IAAYP,EACLO,EAMJ0B,IAAAA,OAAc1B,GAAW,GAAI,OAAOiB,cA2BxC,SAAST,EAAUV,EAAajD,GACnC,MAAW,IAAPiD,EACOA,EAGJA,EACF6B,MAAM,IACNhB,KAAI,SAACiB,GACF,OAwFKC,EAxFOD,IAyFP,KAAOC,GAAK,KAASA,GAAK,KAAOA,GAAK,KAGvD,SAAmBA,GACf,OAAOA,GAAK,KAAOA,GAAK,IA7FOC,CAAUF,IAAW,OAAOG,SAASH,GACjDA,EAIG,KAAVA,EACO,MAKG,KAAVA,GAAiB/E,EACV,IAGJ,IAAM+E,EAAOI,WAAW,GAAGC,SAAS,IAAIhC,cAyE3D,IAAiB4B,KAvERhC,KAAK,IAMP,IAAMqC,EAAb,GAUI,WAAYC,EAAiBtF,GAAe,wDACxCuF,KAAA,OAAcD,EACdC,KAAKvF,KAAOA,KAWb,SAAS+C,EAAOyC,GACnB,OAAO,IAAIC,KAAKD,GAAWE,cAAcjB,QAAQ,iBAAkB,IAQhE,SAASjC,EAAOgD,GACnB,OAAOzC,EAAOyC,GAAWG,UAAU,EAAG,GAUnC,SAAS9B,EAAiBD,GAC7B,OAAkB,IAAdA,EAAGF,OACI,GAGJE,EACFkB,MAAM,KACNc,QAAO,SAACC,GAAD,OAAOA,KACd/B,KAAI,SAACU,GACF,IAAMsB,EAAQtB,EAAEM,MAAM,IAAK,GACrBjG,EAAMkH,mBAAmBD,EAAM,IACjCpG,EAAQqG,mBAAmBD,EAAM,IAIrC,MAHc,cAAVpG,IACAA,EAAQ,IAEL,CAACb,EAAKa,MAEhBgF,MAAK,SAAChG,EAAqBsH,GACxB,OAAOtH,EAAE,GAAGuH,cAAcD,EAAE,O","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/error.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","deriveSigningKey","secretAccessKey","region","canonicalRequest","createCanonicalRequest","stringToSign","createStringToSign","sha256","credentialScope","createCredentialScope","signedHeaders","createSignedHeaders","signature","calculateSignature","authorizationHeader","HashingAlgorithm","accessKeyID","InvalidSignatureError","message","code","name","xmlDocument","doc","parseHTML","AWSError","find","text","Error","hmac","time","kSecret","date","toDate","kDate","kRegion","kService","UnsignedPayload","hashedCanonicalRequest","requestDateTime","toTime","join","uri","query","payload","toUpperCase","createCanonicalURI","createCanonicalQueryString","createCanonicalHeaders","createCanonicalPayload","canonicalURI","length","URIEncode","qs","parseQueryString","map","uriComponent","encodeURIComponent","constructor","entries","values","toLowerCase","trim","Array","isArray","v","replace","sort","TypeError","keys","crypto","split","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","filter","e","parts","decodeURIComponent","b","localeCompare"],"sourceRoot":""} \ No newline at end of file diff --git a/build/aws.min.js.map b/build/aws.min.js.map index 056e94a..1d8d138 100644 --- a/build/aws.min.js.map +++ b/build/aws.min.js.map @@ -1 +1 @@ -{"version":3,"file":"aws.min.js","mappings":"2BAAA,IAAIA,EAAK,EAAQ,KACbC,EAAK,EAAQ,KAEbC,EAAOD,EACXC,EAAKF,GAAKA,EACVE,EAAKD,GAAKA,EAEVE,EAAOC,QAAUF,C,UCFjB,IADA,IAAIG,EAAY,GACPC,EAAI,EAAGA,EAAI,MAAOA,EACzBD,EAAUC,IAAMA,EAAI,KAAOC,SAAS,IAAIC,OAAO,GAmBjDL,EAAOC,QAhBP,SAAqBK,EAAKC,GACxB,IAAIJ,EAAII,GAAU,EACdC,EAAMN,EAEV,MAAO,CACLM,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MACvBK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAAO,IAC9BK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAA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gB5D,GACZ,OAAO,IAAI0D,EAAwB1D,EAAK8D,UAC3C,KAtBL,KA4BMD,GAAAA,WA0BF,WACIpC,EACAsC,EACAC,EACA5N,EACA6N,EACAC,EACAC,EACApO,EACAqO,GACF,yPACEpI,KAAKyF,IAAMA,EACXzF,KAAK+H,SAAWA,EAChB/H,KAAKgI,iBAAmBA,EACxBhI,KAAK5F,KAAOA,EACZ4F,KAAKiI,SAAWA,EAChBjI,KAAKkI,aAAeA,EACpBlI,KAAKmI,KAAOA,EACZnI,KAAKjG,MAAQA,EACbiG,KAAKoI,QAAUA,CAClB,C,wCAUD,SAAgBpE,GACZ,OAAO,IAAI6D,EACP7D,EAAK8B,IACL9B,EAAKqE,SACLrE,EAAKsE,iBACLtE,EAAKY,KACLZ,EAAKuE,SACLvE,EAAKwE,aACLxE,EAAKyE,KACLzE,EAAK0E,MACL1E,EAAK2E,QAEZ,K,EApECd,GAuEOF,GAAb,gCAUI,WAAYzN,EAAiBC,EAAc4I,GAAoC,8BAC3E,cAAM7I,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAK2I,UAAYA,EAH0D,CAI9E,CAdL,cAAgD9I,I,SAoB3CoN,GAAAA,EAAAA,aAAAA,c,EAAAA,KAAAA,GAAAA,CAAAA,G","sources":["webpack://k6-jslib-aws/./node_modules/uuid/index.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/bytesToUuid.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/rng-browser.js","webpack://k6-jslib-aws/./node_modules/uuid/v1.js","webpack://k6-jslib-aws/./node_modules/uuid/v4.js","webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/client.ts","webpack://k6-jslib-aws/./src/internal/s3.ts","webpack://k6-jslib-aws/./src/internal/secrets-manager.ts","webpack://k6-jslib-aws/./src/internal/kms.ts","webpack://k6-jslib-aws/./src/internal/ssm.ts"],"sourcesContent":["var v1 = require('./v1');\nvar v4 = require('./v4');\n\nvar uuid = v4;\nuuid.v1 = v1;\nuuid.v4 = v4;\n\nmodule.exports = uuid;\n","/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nvar byteToHex = [];\nfor (var i = 0; i < 256; ++i) {\n byteToHex[i] = (i + 0x100).toString(16).substr(1);\n}\n\nfunction bytesToUuid(buf, offset) {\n var i = offset || 0;\n var bth = byteToHex;\n // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4\n return ([\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]]\n ]).join('');\n}\n\nmodule.exports = bytesToUuid;\n","// Unique ID creation requires a high quality random # generator. In the\n// browser this is a little complicated due to unknown quality of Math.random()\n// and inconsistent support for the `crypto` API. We do the best we can via\n// feature-detection\n\n// getRandomValues needs to be invoked in a context where \"this\" is a Crypto\n// implementation. Also, find the complete implementation of crypto on IE11.\nvar getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||\n (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));\n\nif (getRandomValues) {\n // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto\n var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef\n\n module.exports = function whatwgRNG() {\n getRandomValues(rnds8);\n return rnds8;\n };\n} else {\n // Math.random()-based (RNG)\n //\n // If all else fails, use Math.random(). It's fast, but is of unspecified\n // quality.\n var rnds = new Array(16);\n\n module.exports = function mathRNG() {\n for (var i = 0, r; i < 16; i++) {\n if ((i & 0x03) === 0) r = Math.random() * 0x100000000;\n rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return rnds;\n };\n}\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\n// **`v1()` - Generate time-based UUID**\n//\n// Inspired by https://github.com/LiosK/UUID.js\n// and http://docs.python.org/library/uuid.html\n\nvar _nodeId;\nvar _clockseq;\n\n// Previous uuid creation time\nvar _lastMSecs = 0;\nvar _lastNSecs = 0;\n\n// See https://github.com/uuidjs/uuid for API details\nfunction v1(options, buf, offset) {\n var i = buf && offset || 0;\n var b = buf || [];\n\n options = options || {};\n var node = options.node || _nodeId;\n var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;\n\n // node and clockseq need to be initialized to random values if they're not\n // specified. We do this lazily to minimize issues related to insufficient\n // system entropy. See #189\n if (node == null || clockseq == null) {\n var seedBytes = rng();\n if (node == null) {\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n node = _nodeId = [\n seedBytes[0] | 0x01,\n seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]\n ];\n }\n if (clockseq == null) {\n // Per 4.2.2, randomize (14 bit) clockseq\n clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;\n }\n }\n\n // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();\n\n // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;\n\n // Time since last uuid creation (in msecs)\n var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;\n\n // Per 4.2.1.2, Bump clockseq on clock regression\n if (dt < 0 && options.clockseq === undefined) {\n clockseq = clockseq + 1 & 0x3fff;\n }\n\n // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {\n nsecs = 0;\n }\n\n // Per 4.2.1.2 Throw error if too many uuids are requested\n if (nsecs >= 10000) {\n throw new Error('uuid.v1(): Can\\'t create more than 10M uuids/sec');\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq;\n\n // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n msecs += 12219292800000;\n\n // `time_low`\n var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff;\n\n // `time_mid`\n var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff;\n\n // `time_high_and_version`\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n b[i++] = tmh >>> 16 & 0xff;\n\n // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n b[i++] = clockseq >>> 8 | 0x80;\n\n // `clock_seq_low`\n b[i++] = clockseq & 0xff;\n\n // `node`\n for (var n = 0; n < 6; ++n) {\n b[i + n] = node[n];\n }\n\n return buf ? buf : bytesToUuid(b);\n}\n\nmodule.exports = v1;\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\nfunction v4(options, buf, offset) {\n var i = buf && offset || 0;\n\n if (typeof(options) == 'string') {\n buf = options === 'binary' ? new Array(16) : null;\n options = null;\n }\n options = options || {};\n\n var rnds = options.random || (options.rng || rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n for (var ii = 0; ii < 16; ++ii) {\n buf[i + ii] = rnds[ii];\n }\n }\n\n return buf || bytesToUuid(rnds);\n}\n\nmodule.exports = v4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n","import { bytes } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\nimport { parseHTML } from 'k6/html'\nimport { sha256 } from 'k6/crypto'\n\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n /**\n * Create a S3Client\n *\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(false, true)\n super(awsConfig, 's3', URIencodingConfig)\n }\n\n /**\n * Returns a list of all buckets owned by the authenticated sender of the request.\n * To use this operation, you must have the s3:ListAllMyBuckets permission.\n *\n * @return {Array.} buckets - An array of objects describing S3 buckets\n * with the following fields: name, and creationDate.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listBuckets(): Array {\n // Prepare request\n const method = 'GET'\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, this.host, '/', '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListBuckets', res)\n\n let buckets: Array = []\n\n const doc = parseHTML(res.body as string)\n\n doc.find('Buckets')\n .children()\n .each((_, bucketDefinition) => {\n let bucket = {}\n\n bucketDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'name':\n Object.assign(bucket, { name: child.textContent() })\n break\n case 'creationdate':\n Object.assign(bucket, {\n creationDate: Date.parse(child.textContent()),\n })\n }\n })\n\n buckets.push(bucket as S3Bucket)\n })\n\n return buckets\n }\n\n /**\n * Returns some or all (up to 1,000) of the objects in a bucket.\n *\n * @param {string} bucketName - Bucket name to list.\n * @param {string?} prefix='' - Limits the response to keys that begin with the specified prefix.\n * @return {Array.} - returns an array of objects describing S3 objects\n * with the following fields: key, lastModified, etag, size and storageClass.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listObjects(bucketName: string, prefix?: string): Array {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const body = ''\n const querystring = `list-type=2&prefix=${prefix || ''}`\n const signedRequest: AWSRequest = super.buildRequest(method, host, '/', querystring, body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n Prefix: prefix ?? '',\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListObjectsV2', res)\n\n let objects: Array = []\n\n // Extract the objects definition from\n // the XML response\n parseHTML(res.body as string)\n .find('Contents')\n .each((_, objectDefinition) => {\n let obj = {}\n\n objectDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'key':\n Object.assign(obj, { key: child.textContent() })\n break\n case 'lastmodified':\n Object.assign(obj, { lastModified: Date.parse(child.textContent()) })\n break\n case 'etag':\n Object.assign(obj, { etag: child.textContent() })\n break\n case 'size':\n Object.assign(obj, { size: parseInt(child.textContent()) })\n break\n case 'storageclass':\n Object.assign(obj, { storageClass: child.textContent() })\n }\n })\n\n objects.push(obj as S3Object)\n })\n\n return objects\n }\n /**\n * Retrieves an Object from Amazon S3.\n *\n * To use getObject, you must have `READ` access to the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to get.\n * @return {S3Object} - returns the content of the fetched S3 Object.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n getObject(bucketName: string, objectKey: string): S3Object {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, host, path, '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('GetObject', res)\n\n return new S3Object(\n objectKey,\n Date.parse(res.headers['Last-Modified']),\n res.headers['ETag'],\n parseInt(res.headers['Content-Length']),\n\n // The X-Amz-Storage-Class header is only set if the storage class is\n // not the default 'STANDARD' one.\n (res.headers['X-Amz-Storage-Class'] ?? 'STANDARD') as StorageClass,\n\n res.body\n )\n }\n /**\n * Adds an object to a bucket.\n *\n * You must have WRITE permissions on a bucket to add an object to it.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to put.\n * @param {string | ArrayBuffer} data - the content of the S3 Object to upload.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n putObject(bucketName: string, objectKey: string, data: string | ArrayBuffer) {\n // Prepare request\n const method = 'PUT'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = data\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('PutObject', res)\n }\n\n /**\n * Removes the null version (if there is one) of an object and inserts a delete marker,\n * which becomes the latest version of the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to delete.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteObject(bucketName: string, objectKey: string): void {\n // Prepare request\n const method = 'DELETE'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('DeleteObject', res)\n }\n\n _handle_error(operation: S3Operation, response: RefinedResponse) {\n const errorCode: number = response.error_code\n const errorMessage: string = response.error\n\n if (errorMessage == '' && errorCode === 0) {\n return\n }\n\n // FIXME: should be errorCode === 1301 instead\n // See: https://github.com/grafana/k6/issues/2474\n // See: https://github.com/golang/go/issues/49281\n if (errorMessage && errorMessage.startsWith('301')) {\n throw new S3ServiceError('Resource not found', 'ResourceNotFound', operation)\n }\n\n const awsError = AWSError.parseXML(response.body as string)\n switch (awsError.code) {\n case 'AuthorizationHeaderMalformed':\n throw new InvalidSignatureError(awsError.message, awsError.code)\n default:\n throw new S3ServiceError(awsError.message, awsError.code, operation)\n }\n }\n}\n\n/** Class representing a S3 Bucket */\nexport class S3Bucket {\n name: string\n creationDate: Date\n\n /**\n * Create an S3 Bucket\n *\n * @param {string} name - S3 bucket's name\n * @param {Date} creationDate - S3 bucket's creation date\n */\n constructor(name: string, creationDate: Date) {\n this.name = name\n this.creationDate = creationDate\n }\n}\n\n/** Class representing an S3 Object */\nexport class S3Object {\n key: string\n lastModified: number\n etag: string\n size: number\n storageClass: StorageClass\n data?: string | bytes | null\n\n /**\n * Create an S3 Object\n *\n * @param {string} key - S3 object's key\n * @param {Date} lastModified - S3 object last modification date\n * @param {string} etag - S3 object's etag\n * @param {number} size - S3 object's size\n * @param {StorageClass} storageClass - S3 object's storage class\n * @param {string | bytes | null} data=null - S3 Object's data\n */\n constructor(\n key: string,\n lastModified: number,\n etag: string,\n size: number,\n storageClass: StorageClass,\n data?: string | bytes | null\n ) {\n this.key = key\n this.lastModified = lastModified\n this.etag = etag\n this.size = size\n this.storageClass = storageClass\n this.data = data\n }\n}\n\n/**\n * Error indicating a S3 operation failed\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class S3ServiceError extends AWSError {\n operation: string\n\n /**\n * Constructs a S3ServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: string) {\n super(message, code)\n this.name = 'S3ServiceError'\n this.operation = operation\n }\n}\n\n/**\n * S3Operation describes possible values for S3 API operations,\n * as defined by AWS APIs.\n */\ntype S3Operation = 'ListBuckets' | 'ListObjectsV2' | 'GetObject' | 'PutObject' | 'DeleteObject'\n\n/**\n * Describes the class of storage used to store a S3 object.\n */\ntype StorageClass =\n | 'STANDARD'\n | 'REDUCED_REDUNDANCY'\n | 'GLACIER'\n | 'STANDARD_IA'\n | 'INTELLIGENT_TIERING'\n | 'DEEP_ARCHIVE'\n | 'OUTPOSTS'\n | 'GLACIER_IR'\n | undefined\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { v4 as uuidv4 } from 'uuid'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's SecretsManager service\n */\nexport class SecretsManagerClient extends AWSClient {\n /**\n * HTTP Method to use when interacting with the Secrets Manager service.\n */\n method: HTTPMethod\n\n /**\n * HTTP headers to use accross all requests to the Secrets Manager service.\n */\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SecretsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'secretsmanager', URIencodingConfig)\n\n // All interactions with the Secrets Manager service\n // are made via the GET or POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Returns a list of all secrets owned by the authenticated sender of the request.\n * To use this operation, you must have the secretsmanager:ListSecrets permission.\n *\n * @return {Array.} secrets - An array of objects describing Secret Manager's secrets\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n listSecrets(): Array {\n const body = JSON.stringify({})\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.ListSecrets`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.ListSecrets, res)\n const json: JSONArray = res.json('SecretList') as JSONArray\n\n return json.map((s) => Secret.fromJSON(s as JSONObject))\n }\n\n /**\n * Retrieves a secret from Amazon Sercets Manager\n *\n * @param {string} id - The ARN or name of the secret to retrieve.\n * @returns {Secret} - returns the content of the fetched Secret object.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getSecret(id: string): Secret | undefined {\n const body = JSON.stringify({ SecretId: id })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.GetSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.GetSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Creates a new secret\n *\n * Note that this method only supports string-based values at the moment.\n *\n * @param {string} name - The name of the new secret.\n * The secret name can contain ASCII letters, numbers, and the following characters: /_+=.@\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {string} description - The description of the secret.\n * @param {string} versionID=null - Version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * algorithm.\n * @param {Array.} tags=[] - A list of tags to attach to the secret. Each tag is a key and\n * value pair of strings in a JSON text string. Note that tag key names are case sensitive.\n * @returns {Secret} - returns the created secret\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n createSecret(\n name: string,\n secret: string,\n description: string,\n versionID?: string,\n tags?: Array\n ): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n })\n\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.CreateSecret`,\n }\n )\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n // headers['X-Amz-Target'] = `${this.serviceName}.CreateSecret`\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.CreateSecret, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n /**\n * Update a secret's value.\n *\n * Note that this method only support string-based values at the moment.\n *\n * @param {string} id - The ARN or name of the secret to update.\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {} versionID=null - A unique identifier for the new version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n putSecretValue(id: string, secret: string, versionID?: string): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.PutSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.PutSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Deletes a secret and all of its versions.\n *\n * You can specify a recovery window during which you can restore the secret.\n * The minimum recovery window is 7 days. The default recovery window is 30 days.\n *\n * @param {string} secretID - The ARN or name of the secret to delete.\n * @param {number} recoveryWindow - The number of days from 7 to 30 that Secrets Manager\n * waits before permanently deleting the secret.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteSecret(\n id: string,\n { recoveryWindow = 30, noRecovery = false }: { recoveryWindow: number; noRecovery: boolean }\n ) {\n const payload: { [key: string]: string | boolean | number } = {\n SecretId: id,\n }\n\n // noRecovery and recoveryWindow are exclusive parameters\n if (noRecovery === true) {\n payload['ForceDeleteWithoutRecovery'] = true\n } else {\n payload['RecoveryWindowInDays'] = recoveryWindow\n }\n\n const body = JSON.stringify(payload)\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.DeleteSecret`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(operation: SecretsManagerOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SecretsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SecretsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n// TODO: create a Tags type\n\n/**\n * Class representing a Secret Manager's secret\n */\nexport class Secret {\n name: string\n arn: string\n secret: string\n createdDate: number\n lastAccessedDate: number\n lastChangedDate: number\n tags: Array<{ [key: string]: string }>\n\n /**\n * Constructs a Secret Manager's Secret\n *\n * @param {string} name - The friendly name of the secret.\n * @param {string} arn - The ARN of the secret.\n * @param {number} createdDate - The date and time that this version of the secret was created.\n * @param {number} lastAccessedDate - The last date that this secret was accessed. This value is\n * truncated to midnight of the date and therefore shows only the date, not the time.\n * @param {number} lastChangedDate - The last date and time that this secret was modified in any way.\n * @param {Array.} tags - The list of user-defined tags associated with the secret.\n */\n constructor(\n name: string,\n arn: string,\n secretString: string,\n createdDate: number,\n lastAccessedDate: number,\n lastChangedDate: number,\n tags: Array<{ [key: string]: string }> = []\n ) {\n this.name = name\n this.arn = arn\n this.secret = secretString\n this.createdDate = createdDate\n this.lastAccessedDate = lastAccessedDate\n this.lastChangedDate = lastChangedDate\n this.tags = tags\n }\n\n /**\n * Parses and constructs a Secret Manager's Secret from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {Secret}\n */\n static fromJSON(json: JSONObject) {\n return new Secret(\n json.Name as string,\n json.ARN as string,\n json.SecretString as string,\n json.CreatedDate as number,\n json.LastAccessedDate as number,\n json.LastChangedDate as number,\n json.Tags as Array<{ [key: string]: string }>\n )\n }\n}\n\nexport class SecretsManagerServiceError extends AWSError {\n operation: SecretsManagerOperation\n\n /**\n * Constructs a SecretsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SecretsManagerOperation) {\n super(message, code)\n this.name = 'SecretsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SecretsManagerOperation defines all currently implemented Secrets Manager Service operations.\n */\nenum SecretsManagerOperation {\n ListSecrets = 'ListSecrets',\n GetSecretValue = 'GetSecretValue',\n CreateSecret = 'CreateSecret',\n PutSecretValue = 'PutSecretValue',\n DeleteSecret = 'DeleteSecret'\n}\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's KMS service\n */\nexport class KMSClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a KMSClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'kms', URIencodingConfig)\n\n // this.serviceName = 'kms'\n\n // All interactions with the KMS service\n // are made via the GET or POST method.\n this.method = 'POST'\n\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Gets a list of all the KMS keys in the caller's AWS\n * account and region.\n *\n * @returns an array of all the available keys\n */\n listKeys(): Array {\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(this.method, this.host, '/', '', '', {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.ListKeys`,\n })\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.ListKeys, res)\n\n const json: JSONArray = res.json('Keys') as JSONArray\n return json.map((k) => KMSKey.fromJSON(k as JSONObject))\n }\n\n /**\n * GenerateDataKey returns a unique symmetric data key for use outside of AWS KMS.\n *\n * This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify.\n * The bytes in the plaintext key are random; they are not related to the caller or the KMS key.\n * You can use the plaintext key to encrypt your data outside of AWS KMS and store the encrypted data key with the encrypted data.\n *\n * To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key.\n * You cannot use an asymmetric KMS key to encrypt data keys.\n *\n * Used to generate data key with the KMS key defined\n * @param {string} id - Specifies the symmetric encryption KMS key that encrypts the data key. Use its key ID, key ARN, alias name, or alias ARN.\n * @param {KMKeySize} size - Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). Default is 32, and generates a 256-bit data key.\n * @throws {KMSServiceError}\n * @throws {InvalidSignatureError}\n * @returns {KMSDataKey} - The generated data key.\n */\n generateDataKey(id: string, size: KMSKeySize = KMSKeySize.Size256): KMSDataKey | undefined {\n const body = JSON.stringify({ KeyId: id, NumberOfBytes: size })\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.GenerateDataKey`,\n }\n )\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.GenerateDataKey, res)\n\n return KMSDataKey.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(operation: KMSOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new KMSServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new KMSServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a KMS key\n */\nexport class KMSKey {\n /**\n * ARN of the key\n */\n keyArn: string\n\n /**\n * Unique identifier of the key\n */\n keyId: string\n\n constructor(keyArn: string, KeyId: string) {\n this.keyArn = keyArn\n this.keyId = KeyId\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSKey(json.KeyArn as string, json.KeyId as string)\n }\n}\n\n/**\n * Class representing a data key\n */\nexport class KMSDataKey {\n /**\n * The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key.\n */\n id: string\n\n /**\n * The (base64-encoded) encrypted copy of the data key.\n */\n ciphertextBlob: string\n\n /**\n * The plaintext data key.\n * Use this data key to encrypt your data outside of KMS. Then, remove it from memory as soon as possible.\n */\n plaintext: string\n\n constructor(CiphertextBlob: string, KeyId: string, Plaintext: string) {\n this.ciphertextBlob = CiphertextBlob\n this.id = KeyId\n this.plaintext = Plaintext\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSDataKey(\n json.CiphertextBlob as string,\n json.KeyId as string,\n json.Plaintext as string\n )\n }\n}\n\nexport class KMSServiceError extends AWSError {\n operation: KMSOperation\n\n /**\n * Constructs a KMSServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: KMSOperation) {\n super(message, code)\n this.name = 'KMSServiceError'\n this.operation = operation\n }\n}\n\n/**\n * KMSOperation defines all currently implemented KMS Service operations.\n */\nenum KMSOperation {\n GenerateDataKey = 'GenerateDataKey',\n ListKeys = 'ListKeys'\n}\n\n/**\n * KMSKeyLength describes possible key lenght values for KMS API data key operations.\n */\nenum KMSKeySize {\n Size256 = 32,\n Size512 = 64,\n}\n","import { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's Systems Manager service\n */\nexport class SystemsManagerClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SystemsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'ssm', URIencodingConfig)\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Retrieves a parameter from Amazon Systems Manager\n *\n * @param {string} name - The ARN or name of the parameter to retrieve.\n * @param {boolean} withDecryption - whether returned secure string parameters should be decrypted.\n * @returns {SystemsManagerParameter} - returns the fetched Parameter object.\n * @throws {SystemsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getParameter(\n name: string,\n withDecryption: boolean = false\n ): SystemsManagerParameter | undefined {\n const body = JSON.stringify({ Name: name, WithDecryption: withDecryption })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `AmazonSSM.GetParameter`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SystemsManagerOperation.GetParameter, res);\n\n return SystemsManagerParameter.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(\n operation: SystemsManagerOperation,\n response: RefinedResponse\n ) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SystemsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SystemsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter\n */\nexport class SystemsManagerParameter {\n parameter: SystemsManagerParameterItem\n\n /**\n * Constructs a Systems Manager's Parameter\n *\n * @param {JSONObject} parameter - The response object content for the AWS System Manager.\n */\n constructor(parameter: JSONObject) {\n this.parameter = SystemsManagerParameterItem.fromJSON(parameter)\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameter}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameter {\n return new SystemsManagerParameter(json.Parameter as JSONObject)\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter Object content\n */\nclass SystemsManagerParameterItem {\n arn: string\n dataType: string\n lastModifiedDate: number\n name: string\n selector: string\n sourceResult: string\n type: string\n value: string\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter object contents\n *\n * @param {string} arn - The Amazon Resource Name (ARN) of the parameter.\n * @param {string} dataType - The data type of the parameter, such as text or aws:ec2:image. The default is text.\n * @param {number} lastModifiedDate - Date the parameter was last changed or updated and the parameter version was created.\n * @param {string} name - The friendly name of the parameter.\n * @param {string} selector - Either the version number or the label used to retrieve the parameter value. Specify selectors by using one of the following formats:\n * parameter_name:version\n * parameter_name:label\n * @param {string} sourceResult - Applies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n * @param {string} type - The type of parameter. Valid values include the following: String, StringList, and SecureString.\n * @param {string} value - The parameter value.\n * @param {number} version - The parameter version.\n */\n constructor(\n arn: string,\n dataType: string,\n lastModifiedDate: number,\n name: string,\n selector: string,\n sourceResult: string,\n type: string,\n value: string,\n version: number\n ) {\n this.arn = arn\n this.dataType = dataType\n this.lastModifiedDate = lastModifiedDate\n this.name = name\n this.selector = selector\n this.sourceResult = sourceResult\n this.type = type\n this.value = value\n this.version = version\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter object from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameterItem}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameterItem {\n return new SystemsManagerParameterItem(\n json.ARN as string,\n json.DataType as string,\n json.LastModifiedDate as number,\n json.Name as string,\n json.Selector as string,\n json.SourceResult as string,\n json.Type as string,\n json.Value as string,\n json.Version as number\n )\n }\n}\n\nexport class SystemsManagerServiceError extends AWSError {\n operation: SystemsManagerOperation\n\n /**\n * Constructs a SystemsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {SystemsManagerOperation} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SystemsManagerOperation) {\n super(message, code)\n this.name = 'SystemsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SystemsManagerOperation defines all currently implemented Systems Manager operations.\n */\nenum SystemsManagerOperation {\n GetParameter = 'GetParameter',\n}\n"],"names":["v1","v4","uuid","module","exports","byteToHex","i","toString","substr","buf","offset","bth","join","getRandomValues","crypto","bind","window","msCrypto","rnds8","Uint8Array","rnds","Array","r","Math","random","_nodeId","_clockseq","rng","bytesToUuid","_lastMSecs","_lastNSecs","options","b","node","clockseq","undefined","seedBytes","msecs","Date","getTime","nsecs","dt","Error","tl","tmh","n","ii","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","localeCompare","parseQueryString","uriComponent","encodeURIComponent","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","URIEncodingConfig","double","this","timestamp","toISOString","substring","AWSConfig","InvalidAWSConfigError","accessKeyId","scheme","endpoint","AWSClient","serviceName","host","now","url","S3Client","signedRequest","res","http","_handle_error","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","parse","push","bucketName","prefix","querystring","Prefix","objects","objectDefinition","lastModified","etag","size","parseInt","storageClass","objectKey","S3Object","data","operation","response","errorCode","error_code","errorMessage","error","startsWith","S3ServiceError","awsError","parseXML","S3Bucket","SecretsManagerOperation","SecretsManagerClient","commonHeaders","JSON","stringify","ListSecrets","json","s","Secret","fromJSON","id","SecretId","GetSecretValue","secret","description","versionID","tags","uuidv4","Name","Description","SecretString","ClientRequestToken","Tags","CreateSecret","PutSecretValue","recoveryWindow","noRecovery","DeleteSecret","Message","__type","SecretsManagerServiceError","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate","KMSOperation","KMSKeySize","KMSClient","ListKeys","k","KMSKey","Size256","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","KMSServiceError","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext","SystemsManagerOperation","SystemsManagerClient","withDecryption","WithDecryption","GetParameter","SystemsManagerParameter","SystemsManagerServiceError","parameter","SystemsManagerParameterItem","Parameter","dataType","lastModifiedDate","selector","sourceResult","type","version","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"aws.min.js","mappings":"2BAAA,IAAIA,EAAK,EAAQ,KACbC,EAAK,EAAQ,KAEbC,EAAOD,EACXC,EAAKF,GAAKA,E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AChB/H,KAAKgI,iBAAmBA,EACxBhI,KAAK5F,KAAOA,EACZ4F,KAAKiI,SAAWA,EAChBjI,KAAKkI,aAAeA,EACpBlI,KAAKmI,KAAOA,EACZnI,KAAKjG,MAAQA,EACbiG,KAAKoI,QAAUA,E,wCAWnB,SAAgBpE,GACZ,OAAO,IAAI6D,EACP7D,EAAK8B,IACL9B,EAAKqE,SACLrE,EAAKsE,iBACLtE,EAAKY,KACLZ,EAAKuE,SACLvE,EAAKwE,aACLxE,EAAKyE,KACLzE,EAAK0E,MACL1E,EAAK2E,a,EAlEXd,GAuEOF,GAAb,gCAUI,WAAYzN,EAAiBC,EAAc4I,GAAoC,8BAC3E,cAAM7I,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAK2I,UAAYA,EAH0D,EAVnF,cAAgD9I,I,SAoB3CoN,GAAAA,EAAAA,aAAAA,e,CAAAA,KAAAA,GAAAA,M","sources":["webpack://k6-jslib-aws/./node_modules/uuid/index.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/bytesToUuid.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/rng-browser.js","webpack://k6-jslib-aws/./node_modules/uuid/v1.js","webpack://k6-jslib-aws/./node_modules/uuid/v4.js","webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/client.ts","webpack://k6-jslib-aws/./src/internal/s3.ts","webpack://k6-jslib-aws/./src/internal/secrets-manager.ts","webpack://k6-jslib-aws/./src/internal/kms.ts","webpack://k6-jslib-aws/./src/internal/ssm.ts"],"sourcesContent":["var v1 = require('./v1');\nvar v4 = require('./v4');\n\nvar uuid = v4;\nuuid.v1 = v1;\nuuid.v4 = v4;\n\nmodule.exports = uuid;\n","/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nvar byteToHex = [];\nfor (var i = 0; i < 256; ++i) {\n byteToHex[i] = (i + 0x100).toString(16).substr(1);\n}\n\nfunction bytesToUuid(buf, offset) {\n var i = offset || 0;\n var bth = byteToHex;\n // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4\n return ([\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]]\n ]).join('');\n}\n\nmodule.exports = bytesToUuid;\n","// Unique ID creation requires a high quality random # generator. In the\n// browser this is a little complicated due to unknown quality of Math.random()\n// and inconsistent support for the `crypto` API. We do the best we can via\n// feature-detection\n\n// getRandomValues needs to be invoked in a context where \"this\" is a Crypto\n// implementation. Also, find the complete implementation of crypto on IE11.\nvar getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||\n (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));\n\nif (getRandomValues) {\n // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto\n var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef\n\n module.exports = function whatwgRNG() {\n getRandomValues(rnds8);\n return rnds8;\n };\n} else {\n // Math.random()-based (RNG)\n //\n // If all else fails, use Math.random(). It's fast, but is of unspecified\n // quality.\n var rnds = new Array(16);\n\n module.exports = function mathRNG() {\n for (var i = 0, r; i < 16; i++) {\n if ((i & 0x03) === 0) r = Math.random() * 0x100000000;\n rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return rnds;\n };\n}\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\n// **`v1()` - Generate time-based UUID**\n//\n// Inspired by https://github.com/LiosK/UUID.js\n// and http://docs.python.org/library/uuid.html\n\nvar _nodeId;\nvar _clockseq;\n\n// Previous uuid creation time\nvar _lastMSecs = 0;\nvar _lastNSecs = 0;\n\n// See https://github.com/uuidjs/uuid for API details\nfunction v1(options, buf, offset) {\n var i = buf && offset || 0;\n var b = buf || [];\n\n options = options || {};\n var node = options.node || _nodeId;\n var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;\n\n // node and clockseq need to be initialized to random values if they're not\n // specified. We do this lazily to minimize issues related to insufficient\n // system entropy. See #189\n if (node == null || clockseq == null) {\n var seedBytes = rng();\n if (node == null) {\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n node = _nodeId = [\n seedBytes[0] | 0x01,\n seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]\n ];\n }\n if (clockseq == null) {\n // Per 4.2.2, randomize (14 bit) clockseq\n clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;\n }\n }\n\n // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();\n\n // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;\n\n // Time since last uuid creation (in msecs)\n var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;\n\n // Per 4.2.1.2, Bump clockseq on clock regression\n if (dt < 0 && options.clockseq === undefined) {\n clockseq = clockseq + 1 & 0x3fff;\n }\n\n // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {\n nsecs = 0;\n }\n\n // Per 4.2.1.2 Throw error if too many uuids are requested\n if (nsecs >= 10000) {\n throw new Error('uuid.v1(): Can\\'t create more than 10M uuids/sec');\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq;\n\n // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n msecs += 12219292800000;\n\n // `time_low`\n var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff;\n\n // `time_mid`\n var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff;\n\n // `time_high_and_version`\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n b[i++] = tmh >>> 16 & 0xff;\n\n // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n b[i++] = clockseq >>> 8 | 0x80;\n\n // `clock_seq_low`\n b[i++] = clockseq & 0xff;\n\n // `node`\n for (var n = 0; n < 6; ++n) {\n b[i + n] = node[n];\n }\n\n return buf ? buf : bytesToUuid(b);\n}\n\nmodule.exports = v1;\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\nfunction v4(options, buf, offset) {\n var i = buf && offset || 0;\n\n if (typeof(options) == 'string') {\n buf = options === 'binary' ? new Array(16) : null;\n options = null;\n }\n options = options || {};\n\n var rnds = options.random || (options.rng || rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n for (var ii = 0; ii < 16; ++ii) {\n buf[i + ii] = rnds[ii];\n }\n }\n\n return buf || bytesToUuid(rnds);\n}\n\nmodule.exports = v4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n","import { bytes } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\nimport { parseHTML } from 'k6/html'\nimport { sha256 } from 'k6/crypto'\n\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n /**\n * Create a S3Client\n *\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(false, true)\n super(awsConfig, 's3', URIencodingConfig)\n }\n\n /**\n * Returns a list of all buckets owned by the authenticated sender of the request.\n * To use this operation, you must have the s3:ListAllMyBuckets permission.\n *\n * @return {Array.} buckets - An array of objects describing S3 buckets\n * with the following fields: name, and creationDate.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listBuckets(): Array {\n // Prepare request\n const method = 'GET'\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, this.host, '/', '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListBuckets', res)\n\n let buckets: Array = []\n\n const doc = parseHTML(res.body as string)\n\n doc.find('Buckets')\n .children()\n .each((_, bucketDefinition) => {\n let bucket = {}\n\n bucketDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'name':\n Object.assign(bucket, { name: child.textContent() })\n break\n case 'creationdate':\n Object.assign(bucket, {\n creationDate: Date.parse(child.textContent()),\n })\n }\n })\n\n buckets.push(bucket as S3Bucket)\n })\n\n return buckets\n }\n\n /**\n * Returns some or all (up to 1,000) of the objects in a bucket.\n *\n * @param {string} bucketName - Bucket name to list.\n * @param {string?} prefix='' - Limits the response to keys that begin with the specified prefix.\n * @return {Array.} - returns an array of objects describing S3 objects\n * with the following fields: key, lastModified, etag, size and storageClass.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listObjects(bucketName: string, prefix?: string): Array {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const body = ''\n const querystring = `list-type=2&prefix=${prefix || ''}`\n const signedRequest: AWSRequest = super.buildRequest(method, host, '/', querystring, body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n Prefix: prefix ?? '',\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListObjectsV2', res)\n\n let objects: Array = []\n\n // Extract the objects definition from\n // the XML response\n parseHTML(res.body as string)\n .find('Contents')\n .each((_, objectDefinition) => {\n let obj = {}\n\n objectDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'key':\n Object.assign(obj, { key: child.textContent() })\n break\n case 'lastmodified':\n Object.assign(obj, { lastModified: Date.parse(child.textContent()) })\n break\n case 'etag':\n Object.assign(obj, { etag: child.textContent() })\n break\n case 'size':\n Object.assign(obj, { size: parseInt(child.textContent()) })\n break\n case 'storageclass':\n Object.assign(obj, { storageClass: child.textContent() })\n }\n })\n\n objects.push(obj as S3Object)\n })\n\n return objects\n }\n /**\n * Retrieves an Object from Amazon S3.\n *\n * To use getObject, you must have `READ` access to the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to get.\n * @return {S3Object} - returns the content of the fetched S3 Object.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n getObject(bucketName: string, objectKey: string): S3Object {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, host, path, '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('GetObject', res)\n\n return new S3Object(\n objectKey,\n Date.parse(res.headers['Last-Modified']),\n res.headers['ETag'],\n parseInt(res.headers['Content-Length']),\n\n // The X-Amz-Storage-Class header is only set if the storage class is\n // not the default 'STANDARD' one.\n (res.headers['X-Amz-Storage-Class'] ?? 'STANDARD') as StorageClass,\n\n res.body\n )\n }\n /**\n * Adds an object to a bucket.\n *\n * You must have WRITE permissions on a bucket to add an object to it.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to put.\n * @param {string | ArrayBuffer} data - the content of the S3 Object to upload.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n putObject(bucketName: string, objectKey: string, data: string | ArrayBuffer) {\n // Prepare request\n const method = 'PUT'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = data\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('PutObject', res)\n }\n\n /**\n * Removes the null version (if there is one) of an object and inserts a delete marker,\n * which becomes the latest version of the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to delete.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteObject(bucketName: string, objectKey: string): void {\n // Prepare request\n const method = 'DELETE'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('DeleteObject', res)\n }\n\n _handle_error(operation: S3Operation, response: RefinedResponse) {\n const errorCode: number = response.error_code\n const errorMessage: string = response.error\n\n if (errorMessage == '' && errorCode === 0) {\n return\n }\n\n // FIXME: should be errorCode === 1301 instead\n // See: https://github.com/grafana/k6/issues/2474\n // See: https://github.com/golang/go/issues/49281\n if (errorMessage && errorMessage.startsWith('301')) {\n throw new S3ServiceError('Resource not found', 'ResourceNotFound', operation)\n }\n\n const awsError = AWSError.parseXML(response.body as string)\n switch (awsError.code) {\n case 'AuthorizationHeaderMalformed':\n throw new InvalidSignatureError(awsError.message, awsError.code)\n default:\n throw new S3ServiceError(awsError.message, awsError.code, operation)\n }\n }\n}\n\n/** Class representing a S3 Bucket */\nexport class S3Bucket {\n name: string\n creationDate: Date\n\n /**\n * Create an S3 Bucket\n *\n * @param {string} name - S3 bucket's name\n * @param {Date} creationDate - S3 bucket's creation date\n */\n constructor(name: string, creationDate: Date) {\n this.name = name\n this.creationDate = creationDate\n }\n}\n\n/** Class representing an S3 Object */\nexport class S3Object {\n key: string\n lastModified: number\n etag: string\n size: number\n storageClass: StorageClass\n data?: string | bytes | null\n\n /**\n * Create an S3 Object\n *\n * @param {string} key - S3 object's key\n * @param {Date} lastModified - S3 object last modification date\n * @param {string} etag - S3 object's etag\n * @param {number} size - S3 object's size\n * @param {StorageClass} storageClass - S3 object's storage class\n * @param {string | bytes | null} data=null - S3 Object's data\n */\n constructor(\n key: string,\n lastModified: number,\n etag: string,\n size: number,\n storageClass: StorageClass,\n data?: string | bytes | null\n ) {\n this.key = key\n this.lastModified = lastModified\n this.etag = etag\n this.size = size\n this.storageClass = storageClass\n this.data = data\n }\n}\n\n/**\n * Error indicating a S3 operation failed\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class S3ServiceError extends AWSError {\n operation: string\n\n /**\n * Constructs a S3ServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: string) {\n super(message, code)\n this.name = 'S3ServiceError'\n this.operation = operation\n }\n}\n\n/**\n * S3Operation describes possible values for S3 API operations,\n * as defined by AWS APIs.\n */\ntype S3Operation = 'ListBuckets' | 'ListObjectsV2' | 'GetObject' | 'PutObject' | 'DeleteObject'\n\n/**\n * Describes the class of storage used to store a S3 object.\n */\ntype StorageClass =\n | 'STANDARD'\n | 'REDUCED_REDUNDANCY'\n | 'GLACIER'\n | 'STANDARD_IA'\n | 'INTELLIGENT_TIERING'\n | 'DEEP_ARCHIVE'\n | 'OUTPOSTS'\n | 'GLACIER_IR'\n | undefined\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { v4 as uuidv4 } from 'uuid'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's SecretsManager service\n */\nexport class SecretsManagerClient extends AWSClient {\n /**\n * HTTP Method to use when interacting with the Secrets Manager service.\n */\n method: HTTPMethod\n\n /**\n * HTTP headers to use accross all requests to the Secrets Manager service.\n */\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SecretsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'secretsmanager', URIencodingConfig)\n\n // All interactions with the Secrets Manager service\n // are made via the GET or POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Returns a list of all secrets owned by the authenticated sender of the request.\n * To use this operation, you must have the secretsmanager:ListSecrets permission.\n *\n * @return {Array.} secrets - An array of objects describing Secret Manager's secrets\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n listSecrets(): Array {\n const body = JSON.stringify({})\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.ListSecrets`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.ListSecrets, res)\n const json: JSONArray = res.json('SecretList') as JSONArray\n\n return json.map((s) => Secret.fromJSON(s as JSONObject))\n }\n\n /**\n * Retrieves a secret from Amazon Sercets Manager\n *\n * @param {string} id - The ARN or name of the secret to retrieve.\n * @returns {Secret} - returns the content of the fetched Secret object.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getSecret(id: string): Secret | undefined {\n const body = JSON.stringify({ SecretId: id })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.GetSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.GetSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Creates a new secret\n *\n * Note that this method only supports string-based values at the moment.\n *\n * @param {string} name - The name of the new secret.\n * The secret name can contain ASCII letters, numbers, and the following characters: /_+=.@\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {string} description - The description of the secret.\n * @param {string} versionID=null - Version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * algorithm.\n * @param {Array.} tags=[] - A list of tags to attach to the secret. Each tag is a key and\n * value pair of strings in a JSON text string. Note that tag key names are case sensitive.\n * @returns {Secret} - returns the created secret\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n createSecret(\n name: string,\n secret: string,\n description: string,\n versionID?: string,\n tags?: Array\n ): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n })\n\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.CreateSecret`,\n }\n )\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n // headers['X-Amz-Target'] = `${this.serviceName}.CreateSecret`\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.CreateSecret, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n /**\n * Update a secret's value.\n *\n * Note that this method only support string-based values at the moment.\n *\n * @param {string} id - The ARN or name of the secret to update.\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {} versionID=null - A unique identifier for the new version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n putSecretValue(id: string, secret: string, versionID?: string): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.PutSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.PutSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Deletes a secret and all of its versions.\n *\n * You can specify a recovery window during which you can restore the secret.\n * The minimum recovery window is 7 days. The default recovery window is 30 days.\n *\n * @param {string} secretID - The ARN or name of the secret to delete.\n * @param {number} recoveryWindow - The number of days from 7 to 30 that Secrets Manager\n * waits before permanently deleting the secret.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteSecret(\n id: string,\n { recoveryWindow = 30, noRecovery = false }: { recoveryWindow: number; noRecovery: boolean }\n ) {\n const payload: { [key: string]: string | boolean | number } = {\n SecretId: id,\n }\n\n // noRecovery and recoveryWindow are exclusive parameters\n if (noRecovery === true) {\n payload['ForceDeleteWithoutRecovery'] = true\n } else {\n payload['RecoveryWindowInDays'] = recoveryWindow\n }\n\n const body = JSON.stringify(payload)\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.DeleteSecret`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(operation: SecretsManagerOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SecretsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SecretsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n// TODO: create a Tags type\n\n/**\n * Class representing a Secret Manager's secret\n */\nexport class Secret {\n name: string\n arn: string\n secret: string\n createdDate: number\n lastAccessedDate: number\n lastChangedDate: number\n tags: Array<{ [key: string]: string }>\n\n /**\n * Constructs a Secret Manager's Secret\n *\n * @param {string} name - The friendly name of the secret.\n * @param {string} arn - The ARN of the secret.\n * @param {number} createdDate - The date and time that this version of the secret was created.\n * @param {number} lastAccessedDate - The last date that this secret was accessed. This value is\n * truncated to midnight of the date and therefore shows only the date, not the time.\n * @param {number} lastChangedDate - The last date and time that this secret was modified in any way.\n * @param {Array.} tags - The list of user-defined tags associated with the secret.\n */\n constructor(\n name: string,\n arn: string,\n secretString: string,\n createdDate: number,\n lastAccessedDate: number,\n lastChangedDate: number,\n tags: Array<{ [key: string]: string }> = []\n ) {\n this.name = name\n this.arn = arn\n this.secret = secretString\n this.createdDate = createdDate\n this.lastAccessedDate = lastAccessedDate\n this.lastChangedDate = lastChangedDate\n this.tags = tags\n }\n\n /**\n * Parses and constructs a Secret Manager's Secret from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {Secret}\n */\n static fromJSON(json: JSONObject) {\n return new Secret(\n json.Name as string,\n json.ARN as string,\n json.SecretString as string,\n json.CreatedDate as number,\n json.LastAccessedDate as number,\n json.LastChangedDate as number,\n json.Tags as Array<{ [key: string]: string }>\n )\n }\n}\n\nexport class SecretsManagerServiceError extends AWSError {\n operation: SecretsManagerOperation\n\n /**\n * Constructs a SecretsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SecretsManagerOperation) {\n super(message, code)\n this.name = 'SecretsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SecretsManagerOperation defines all currently implemented Secrets Manager Service operations.\n */\nenum SecretsManagerOperation {\n ListSecrets = 'ListSecrets',\n GetSecretValue = 'GetSecretValue',\n CreateSecret = 'CreateSecret',\n PutSecretValue = 'PutSecretValue',\n DeleteSecret = 'DeleteSecret'\n}\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's KMS service\n */\nexport class KMSClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a KMSClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'kms', URIencodingConfig)\n\n // this.serviceName = 'kms'\n\n // All interactions with the KMS service\n // are made via the GET or POST method.\n this.method = 'POST'\n\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Gets a list of all the KMS keys in the caller's AWS\n * account and region.\n *\n * @returns an array of all the available keys\n */\n listKeys(): Array {\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(this.method, this.host, '/', '', '', {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.ListKeys`,\n })\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.ListKeys, res)\n\n const json: JSONArray = res.json('Keys') as JSONArray\n return json.map((k) => KMSKey.fromJSON(k as JSONObject))\n }\n\n /**\n * GenerateDataKey returns a unique symmetric data key for use outside of AWS KMS.\n *\n * This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify.\n * The bytes in the plaintext key are random; they are not related to the caller or the KMS key.\n * You can use the plaintext key to encrypt your data outside of AWS KMS and store the encrypted data key with the encrypted data.\n *\n * To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key.\n * You cannot use an asymmetric KMS key to encrypt data keys.\n *\n * Used to generate data key with the KMS key defined\n * @param {string} id - Specifies the symmetric encryption KMS key that encrypts the data key. Use its key ID, key ARN, alias name, or alias ARN.\n * @param {KMKeySize} size - Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). Default is 32, and generates a 256-bit data key.\n * @throws {KMSServiceError}\n * @throws {InvalidSignatureError}\n * @returns {KMSDataKey} - The generated data key.\n */\n generateDataKey(id: string, size: KMSKeySize = KMSKeySize.Size256): KMSDataKey | undefined {\n const body = JSON.stringify({ KeyId: id, NumberOfBytes: size })\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.GenerateDataKey`,\n }\n )\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.GenerateDataKey, res)\n\n return KMSDataKey.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(operation: KMSOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new KMSServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new KMSServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a KMS key\n */\nexport class KMSKey {\n /**\n * ARN of the key\n */\n keyArn: string\n\n /**\n * Unique identifier of the key\n */\n keyId: string\n\n constructor(keyArn: string, KeyId: string) {\n this.keyArn = keyArn\n this.keyId = KeyId\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSKey(json.KeyArn as string, json.KeyId as string)\n }\n}\n\n/**\n * Class representing a data key\n */\nexport class KMSDataKey {\n /**\n * The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key.\n */\n id: string\n\n /**\n * The (base64-encoded) encrypted copy of the data key.\n */\n ciphertextBlob: string\n\n /**\n * The plaintext data key.\n * Use this data key to encrypt your data outside of KMS. Then, remove it from memory as soon as possible.\n */\n plaintext: string\n\n constructor(CiphertextBlob: string, KeyId: string, Plaintext: string) {\n this.ciphertextBlob = CiphertextBlob\n this.id = KeyId\n this.plaintext = Plaintext\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSDataKey(\n json.CiphertextBlob as string,\n json.KeyId as string,\n json.Plaintext as string\n )\n }\n}\n\nexport class KMSServiceError extends AWSError {\n operation: KMSOperation\n\n /**\n * Constructs a KMSServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: KMSOperation) {\n super(message, code)\n this.name = 'KMSServiceError'\n this.operation = operation\n }\n}\n\n/**\n * KMSOperation defines all currently implemented KMS Service operations.\n */\nenum KMSOperation {\n GenerateDataKey = 'GenerateDataKey',\n ListKeys = 'ListKeys'\n}\n\n/**\n * KMSKeyLength describes possible key lenght values for KMS API data key operations.\n */\nenum KMSKeySize {\n Size256 = 32,\n Size512 = 64,\n}\n","import { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's Systems Manager service\n */\nexport class SystemsManagerClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SystemsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'ssm', URIencodingConfig)\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Retrieves a parameter from Amazon Systems Manager\n *\n * @param {string} name - The ARN or name of the parameter to retrieve.\n * @param {boolean} withDecryption - whether returned secure string parameters should be decrypted.\n * @returns {SystemsManagerParameter} - returns the fetched Parameter object.\n * @throws {SystemsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getParameter(\n name: string,\n withDecryption: boolean = false\n ): SystemsManagerParameter | undefined {\n const body = JSON.stringify({ Name: name, WithDecryption: withDecryption })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `AmazonSSM.GetParameter`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SystemsManagerOperation.GetParameter, res);\n\n return SystemsManagerParameter.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(\n operation: SystemsManagerOperation,\n response: RefinedResponse\n ) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SystemsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SystemsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter\n */\nexport class SystemsManagerParameter {\n parameter: SystemsManagerParameterItem\n\n /**\n * Constructs a Systems Manager's Parameter\n *\n * @param {JSONObject} parameter - The response object content for the AWS System Manager.\n */\n constructor(parameter: JSONObject) {\n this.parameter = SystemsManagerParameterItem.fromJSON(parameter)\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameter}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameter {\n return new SystemsManagerParameter(json.Parameter as JSONObject)\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter Object content\n */\nclass SystemsManagerParameterItem {\n arn: string\n dataType: string\n lastModifiedDate: number\n name: string\n selector: string\n sourceResult: string\n type: string\n value: string\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter object contents\n *\n * @param {string} arn - The Amazon Resource Name (ARN) of the parameter.\n * @param {string} dataType - The data type of the parameter, such as text or aws:ec2:image. The default is text.\n * @param {number} lastModifiedDate - Date the parameter was last changed or updated and the parameter version was created.\n * @param {string} name - The friendly name of the parameter.\n * @param {string} selector - Either the version number or the label used to retrieve the parameter value. Specify selectors by using one of the following formats:\n * parameter_name:version\n * parameter_name:label\n * @param {string} sourceResult - Applies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n * @param {string} type - The type of parameter. Valid values include the following: String, StringList, and SecureString.\n * @param {string} value - The parameter value.\n * @param {number} version - The parameter version.\n */\n constructor(\n arn: string,\n dataType: string,\n lastModifiedDate: number,\n name: string,\n selector: string,\n sourceResult: string,\n type: string,\n value: string,\n version: number\n ) {\n this.arn = arn\n this.dataType = dataType\n this.lastModifiedDate = lastModifiedDate\n this.name = name\n this.selector = selector\n this.sourceResult = sourceResult\n this.type = type\n this.value = value\n this.version = version\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter object from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameterItem}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameterItem {\n return new SystemsManagerParameterItem(\n json.ARN as string,\n json.DataType as string,\n json.LastModifiedDate as number,\n json.Name as string,\n json.Selector as string,\n json.SourceResult as string,\n json.Type as string,\n json.Value as string,\n json.Version as number\n )\n }\n}\n\nexport class SystemsManagerServiceError extends AWSError {\n operation: SystemsManagerOperation\n\n /**\n * Constructs a SystemsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {SystemsManagerOperation} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SystemsManagerOperation) {\n super(message, code)\n this.name = 'SystemsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SystemsManagerOperation defines all currently implemented Systems Manager operations.\n */\nenum SystemsManagerOperation {\n GetParameter = 'GetParameter',\n}\n"],"names":["v1","v4","uuid","module","exports","byteToHex","i","toString","substr","buf","offset","bth","join","getRandomValues","crypto","bind","window","msCrypto","rnds8","Uint8Array","rnds","Array","r","Math","random","_nodeId","_clockseq","rng","bytesToUuid","_lastMSecs","_lastNSecs","options","b","node","clockseq","undefined","seedBytes","msecs","Date","getTime","nsecs","dt","Error","tl","tmh","n","ii","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","localeCompare","parseQueryString","uriComponent","encodeURIComponent","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","URIEncodingConfig","double","this","timestamp","toISOString","substring","AWSConfig","InvalidAWSConfigError","accessKeyId","scheme","endpoint","AWSClient","serviceName","host","now","url","S3Client","signedRequest","res","http","_handle_error","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","parse","push","bucketName","prefix","querystring","Prefix","objects","objectDefinition","lastModified","etag","size","parseInt","storageClass","objectKey","S3Object","data","operation","response","errorCode","error_code","errorMessage","error","startsWith","S3ServiceError","awsError","parseXML","S3Bucket","SecretsManagerOperation","SecretsManagerClient","commonHeaders","JSON","stringify","ListSecrets","json","s","Secret","fromJSON","id","SecretId","GetSecretValue","secret","description","versionID","tags","uuidv4","Name","Description","SecretString","ClientRequestToken","Tags","CreateSecret","PutSecretValue","recoveryWindow","noRecovery","DeleteSecret","Message","__type","SecretsManagerServiceError","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate","KMSOperation","KMSKeySize","KMSClient","ListKeys","k","KMSKey","Size256","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","KMSServiceError","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext","SystemsManagerOperation","SystemsManagerClient","withDecryption","WithDecryption","GetParameter","SystemsManagerParameter","SystemsManagerServiceError","parameter","SystemsManagerParameterItem","Parameter","dataType","lastModifiedDate","selector","sourceResult","type","version","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file diff --git a/build/kms.min.js.map b/build/kms.min.js.map index ede168c..1f5c657 100644 --- a/build/kms.min.js.map +++ b/build/kms.min.js.map @@ -1 +1 @@ -{"version":3,"file":"kms.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC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AA,EAAAA,EAAAA,QAAAA,IAAAA,S,EAAAA,KAAAA,GAAAA,CAAAA,I","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/kms.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's KMS service\n */\nexport class KMSClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a KMSClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'kms', URIencodingConfig)\n\n // this.serviceName = 'kms'\n\n // All interactions with the KMS service\n // are made via the GET or POST method.\n this.method = 'POST'\n\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Gets a list of all the KMS keys in the caller's AWS\n * account and region.\n *\n * @returns an array of all the available keys\n */\n listKeys(): Array {\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(this.method, this.host, '/', '', '', {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.ListKeys`,\n })\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.ListKeys, res)\n\n const json: JSONArray = res.json('Keys') as JSONArray\n return json.map((k) => KMSKey.fromJSON(k as JSONObject))\n }\n\n /**\n * GenerateDataKey returns a unique symmetric data key for use outside of AWS KMS.\n *\n * This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify.\n * The bytes in the plaintext key are random; they are not related to the caller or the KMS key.\n * You can use the plaintext key to encrypt your data outside of AWS KMS and store the encrypted data key with the encrypted data.\n *\n * To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key.\n * You cannot use an asymmetric KMS key to encrypt data keys.\n *\n * Used to generate data key with the KMS key defined\n * @param {string} id - Specifies the symmetric encryption KMS key that encrypts the data key. Use its key ID, key ARN, alias name, or alias ARN.\n * @param {KMKeySize} size - Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). Default is 32, and generates a 256-bit data key.\n * @throws {KMSServiceError}\n * @throws {InvalidSignatureError}\n * @returns {KMSDataKey} - The generated data key.\n */\n generateDataKey(id: string, size: KMSKeySize = KMSKeySize.Size256): KMSDataKey | undefined {\n const body = JSON.stringify({ KeyId: id, NumberOfBytes: size })\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.GenerateDataKey`,\n }\n )\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.GenerateDataKey, res)\n\n return KMSDataKey.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(operation: KMSOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new KMSServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new KMSServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a KMS key\n */\nexport class KMSKey {\n /**\n * ARN of the key\n */\n keyArn: string\n\n /**\n * Unique identifier of the key\n */\n keyId: string\n\n constructor(keyArn: string, KeyId: string) {\n this.keyArn = keyArn\n this.keyId = KeyId\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSKey(json.KeyArn as string, json.KeyId as string)\n }\n}\n\n/**\n * Class representing a data key\n */\nexport class KMSDataKey {\n /**\n * The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key.\n */\n id: string\n\n /**\n * The (base64-encoded) encrypted copy of the data key.\n */\n ciphertextBlob: string\n\n /**\n * The plaintext data key.\n * Use this data key to encrypt your data outside of KMS. Then, remove it from memory as soon as possible.\n */\n plaintext: string\n\n constructor(CiphertextBlob: string, KeyId: string, Plaintext: string) {\n this.ciphertextBlob = CiphertextBlob\n this.id = KeyId\n this.plaintext = Plaintext\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSDataKey(\n json.CiphertextBlob as string,\n json.KeyId as string,\n json.Plaintext as string\n )\n }\n}\n\nexport class KMSServiceError extends AWSError {\n operation: KMSOperation\n\n /**\n * Constructs a KMSServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: KMSOperation) {\n super(message, code)\n this.name = 'KMSServiceError'\n this.operation = operation\n }\n}\n\n/**\n * KMSOperation defines all currently implemented KMS Service operations.\n */\nenum KMSOperation {\n GenerateDataKey = 'GenerateDataKey',\n ListKeys = 'ListKeys'\n}\n\n/**\n * KMSKeyLength describes possible key lenght values for KMS API data key operations.\n */\nenum KMSKeySize {\n Size256 = 32,\n Size512 = 64,\n}\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","KMSOperation","KMSKeySize","KMSClient","commonHeaders","signedRequest","host","res","http","url","_handle_error","ListKeys","json","k","KMSKey","fromJSON","id","size","Size256","JSON","stringify","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","operation","response","errorCode","error_code","error","errorMessage","Message","__type","KMSServiceError","serviceName","now","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"kms.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,iMCLvD,MAAM,EAA+BC,QAAQ,a,aCA7C,MAAM,EAA+BA,QAAQ,W,q0DCUtC,IAAMC,EAAb,a,qRAAA,U,UAAA,G,EAAA,E,mJASI,WAAYC,EAAiBC,GAAc,M,MAAA,O,4FAAA,SACvC,cAAMD,G,EADiC,K,OAAA,G,EAAA,U,wFAEvC,EAAKE,KAAO,WACZ,EAAKD,KAAOA,EAH2B,EAT/C,O,EAAA,E,EAAA,uBAoBI,SAAgBE,GACZ,IAAMC,GAAMC,EAAAA,EAAAA,W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WAAYhJ,EAAiBC,EAAcuI,GAAyB,8BAChE,cAAMxI,EAASC,IADiD,oBAEhE,EAAKC,KAAO,kBACZ,EAAKsI,UAAYA,EAH+C,EAVxE,cAAqCzI,I,SAoBhCiH,GAAAA,EAAAA,gBAAAA,kBAAAA,EAAAA,SAAAA,W,CAAAA,KAAAA,GAAAA,K,SAQAC,GAAAA,EAAAA,EAAAA,QAAAA,IAAAA,UAAAA,EAAAA,EAAAA,QAAAA,IAAAA,U,CAAAA,KAAAA,GAAAA,K","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/kms.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's KMS service\n */\nexport class KMSClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a KMSClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'kms', URIencodingConfig)\n\n // this.serviceName = 'kms'\n\n // All interactions with the KMS service\n // are made via the GET or POST method.\n this.method = 'POST'\n\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Gets a list of all the KMS keys in the caller's AWS\n * account and region.\n *\n * @returns an array of all the available keys\n */\n listKeys(): Array {\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(this.method, this.host, '/', '', '', {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.ListKeys`,\n })\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.ListKeys, res)\n\n const json: JSONArray = res.json('Keys') as JSONArray\n return json.map((k) => KMSKey.fromJSON(k as JSONObject))\n }\n\n /**\n * GenerateDataKey returns a unique symmetric data key for use outside of AWS KMS.\n *\n * This operation returns a plaintext copy of the data key and a copy that is encrypted under a symmetric encryption KMS key that you specify.\n * The bytes in the plaintext key are random; they are not related to the caller or the KMS key.\n * You can use the plaintext key to encrypt your data outside of AWS KMS and store the encrypted data key with the encrypted data.\n *\n * To generate a data key, specify the symmetric encryption KMS key that will be used to encrypt the data key.\n * You cannot use an asymmetric KMS key to encrypt data keys.\n *\n * Used to generate data key with the KMS key defined\n * @param {string} id - Specifies the symmetric encryption KMS key that encrypts the data key. Use its key ID, key ARN, alias name, or alias ARN.\n * @param {KMKeySize} size - Specifies the length of the data key in bytes. For example, use the value 64 to generate a 512-bit data key (64 bytes is 512 bits). Default is 32, and generates a 256-bit data key.\n * @throws {KMSServiceError}\n * @throws {InvalidSignatureError}\n * @returns {KMSDataKey} - The generated data key.\n */\n generateDataKey(id: string, size: KMSKeySize = KMSKeySize.Size256): KMSDataKey | undefined {\n const body = JSON.stringify({ KeyId: id, NumberOfBytes: size })\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `TrentService.GenerateDataKey`,\n }\n )\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(KMSOperation.GenerateDataKey, res)\n\n return KMSDataKey.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(operation: KMSOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new KMSServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new KMSServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a KMS key\n */\nexport class KMSKey {\n /**\n * ARN of the key\n */\n keyArn: string\n\n /**\n * Unique identifier of the key\n */\n keyId: string\n\n constructor(keyArn: string, KeyId: string) {\n this.keyArn = keyArn\n this.keyId = KeyId\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSKey(json.KeyArn as string, json.KeyId as string)\n }\n}\n\n/**\n * Class representing a data key\n */\nexport class KMSDataKey {\n /**\n * The Amazon Resource Name (key ARN) of the KMS key that encrypted the data key.\n */\n id: string\n\n /**\n * The (base64-encoded) encrypted copy of the data key.\n */\n ciphertextBlob: string\n\n /**\n * The plaintext data key.\n * Use this data key to encrypt your data outside of KMS. Then, remove it from memory as soon as possible.\n */\n plaintext: string\n\n constructor(CiphertextBlob: string, KeyId: string, Plaintext: string) {\n this.ciphertextBlob = CiphertextBlob\n this.id = KeyId\n this.plaintext = Plaintext\n }\n\n static fromJSON(json: JSONObject) {\n return new KMSDataKey(\n json.CiphertextBlob as string,\n json.KeyId as string,\n json.Plaintext as string\n )\n }\n}\n\nexport class KMSServiceError extends AWSError {\n operation: KMSOperation\n\n /**\n * Constructs a KMSServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: KMSOperation) {\n super(message, code)\n this.name = 'KMSServiceError'\n this.operation = operation\n }\n}\n\n/**\n * KMSOperation defines all currently implemented KMS Service operations.\n */\nenum KMSOperation {\n GenerateDataKey = 'GenerateDataKey',\n ListKeys = 'ListKeys'\n}\n\n/**\n * KMSKeyLength describes possible key lenght values for KMS API data key operations.\n */\nenum KMSKeySize {\n Size256 = 32,\n Size512 = 64,\n}\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","KMSOperation","KMSKeySize","KMSClient","commonHeaders","signedRequest","host","res","http","url","_handle_error","ListKeys","json","k","KMSKey","fromJSON","id","size","Size256","JSON","stringify","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","operation","response","errorCode","error_code","error","errorMessage","Message","__type","KMSServiceError","serviceName","now","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext"],"sourceRoot":""} \ No newline at end of file diff --git a/build/s3.min.js.map b/build/s3.min.js.map index b14fca3..dec135e 100644 --- a/build/s3.min.js.map +++ b/build/s3.min.js.map @@ -1 +1 @@ -{"version":3,"file":"s3.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAA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KwC,KAAOA,EACZxC,KAAKyC,KAAOA,EACZzC,KAAK2C,aAAeA,EACpB3C,KAAK8C,KAAOA,CACf,IAWQQ,GAAb,gCAUI,WAAY1J,EAAiBC,EAAckJ,GAAmB,8BAC1D,cAAMnJ,EAASC,IAD2C,oBAE1D,EAAKC,KAAO,iBACZ,EAAKiJ,UAAYA,EAHyC,CAI7D,CAdL,cAAoCpJ,G","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/s3.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { bytes } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\nimport { parseHTML } from 'k6/html'\nimport { sha256 } from 'k6/crypto'\n\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n /**\n * Create a S3Client\n *\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(false, true)\n super(awsConfig, 's3', URIencodingConfig)\n }\n\n /**\n * Returns a list of all buckets owned by the authenticated sender of the request.\n * To use this operation, you must have the s3:ListAllMyBuckets permission.\n *\n * @return {Array.} buckets - An array of objects describing S3 buckets\n * with the following fields: name, and creationDate.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listBuckets(): Array {\n // Prepare request\n const method = 'GET'\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, this.host, '/', '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListBuckets', res)\n\n let buckets: Array = []\n\n const doc = parseHTML(res.body as string)\n\n doc.find('Buckets')\n .children()\n .each((_, bucketDefinition) => {\n let bucket = {}\n\n bucketDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'name':\n Object.assign(bucket, { name: child.textContent() })\n break\n case 'creationdate':\n Object.assign(bucket, {\n creationDate: Date.parse(child.textContent()),\n })\n }\n })\n\n buckets.push(bucket as S3Bucket)\n })\n\n return buckets\n }\n\n /**\n * Returns some or all (up to 1,000) of the objects in a bucket.\n *\n * @param {string} bucketName - Bucket name to list.\n * @param {string?} prefix='' - Limits the response to keys that begin with the specified prefix.\n * @return {Array.} - returns an array of objects describing S3 objects\n * with the following fields: key, lastModified, etag, size and storageClass.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listObjects(bucketName: string, prefix?: string): Array {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const body = ''\n const querystring = `list-type=2&prefix=${prefix || ''}`\n const signedRequest: AWSRequest = super.buildRequest(method, host, '/', querystring, body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n Prefix: prefix ?? '',\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListObjectsV2', res)\n\n let objects: Array = []\n\n // Extract the objects definition from\n // the XML response\n parseHTML(res.body as string)\n .find('Contents')\n .each((_, objectDefinition) => {\n let obj = {}\n\n objectDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'key':\n Object.assign(obj, { key: child.textContent() })\n break\n case 'lastmodified':\n Object.assign(obj, { lastModified: Date.parse(child.textContent()) })\n break\n case 'etag':\n Object.assign(obj, { etag: child.textContent() })\n break\n case 'size':\n Object.assign(obj, { size: parseInt(child.textContent()) })\n break\n case 'storageclass':\n Object.assign(obj, { storageClass: child.textContent() })\n }\n })\n\n objects.push(obj as S3Object)\n })\n\n return objects\n }\n /**\n * Retrieves an Object from Amazon S3.\n *\n * To use getObject, you must have `READ` access to the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to get.\n * @return {S3Object} - returns the content of the fetched S3 Object.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n getObject(bucketName: string, objectKey: string): S3Object {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, host, path, '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('GetObject', res)\n\n return new S3Object(\n objectKey,\n Date.parse(res.headers['Last-Modified']),\n res.headers['ETag'],\n parseInt(res.headers['Content-Length']),\n\n // The X-Amz-Storage-Class header is only set if the storage class is\n // not the default 'STANDARD' one.\n (res.headers['X-Amz-Storage-Class'] ?? 'STANDARD') as StorageClass,\n\n res.body\n )\n }\n /**\n * Adds an object to a bucket.\n *\n * You must have WRITE permissions on a bucket to add an object to it.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to put.\n * @param {string | ArrayBuffer} data - the content of the S3 Object to upload.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n putObject(bucketName: string, objectKey: string, data: string | ArrayBuffer) {\n // Prepare request\n const method = 'PUT'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = data\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('PutObject', res)\n }\n\n /**\n * Removes the null version (if there is one) of an object and inserts a delete marker,\n * which becomes the latest version of the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to delete.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteObject(bucketName: string, objectKey: string): void {\n // Prepare request\n const method = 'DELETE'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('DeleteObject', res)\n }\n\n _handle_error(operation: S3Operation, response: RefinedResponse) {\n const errorCode: number = response.error_code\n const errorMessage: string = response.error\n\n if (errorMessage == '' && errorCode === 0) {\n return\n }\n\n // FIXME: should be errorCode === 1301 instead\n // See: https://github.com/grafana/k6/issues/2474\n // See: https://github.com/golang/go/issues/49281\n if (errorMessage && errorMessage.startsWith('301')) {\n throw new S3ServiceError('Resource not found', 'ResourceNotFound', operation)\n }\n\n const awsError = AWSError.parseXML(response.body as string)\n switch (awsError.code) {\n case 'AuthorizationHeaderMalformed':\n throw new InvalidSignatureError(awsError.message, awsError.code)\n default:\n throw new S3ServiceError(awsError.message, awsError.code, operation)\n }\n }\n}\n\n/** Class representing a S3 Bucket */\nexport class S3Bucket {\n name: string\n creationDate: Date\n\n /**\n * Create an S3 Bucket\n *\n * @param {string} name - S3 bucket's name\n * @param {Date} creationDate - S3 bucket's creation date\n */\n constructor(name: string, creationDate: Date) {\n this.name = name\n this.creationDate = creationDate\n }\n}\n\n/** Class representing an S3 Object */\nexport class S3Object {\n key: string\n lastModified: number\n etag: string\n size: number\n storageClass: StorageClass\n data?: string | bytes | null\n\n /**\n * Create an S3 Object\n *\n * @param {string} key - S3 object's key\n * @param {Date} lastModified - S3 object last modification date\n * @param {string} etag - S3 object's etag\n * @param {number} size - S3 object's size\n * @param {StorageClass} storageClass - S3 object's storage class\n * @param {string | bytes | null} data=null - S3 Object's data\n */\n constructor(\n key: string,\n lastModified: number,\n etag: string,\n size: number,\n storageClass: StorageClass,\n data?: string | bytes | null\n ) {\n this.key = key\n this.lastModified = lastModified\n this.etag = etag\n this.size = size\n this.storageClass = storageClass\n this.data = data\n }\n}\n\n/**\n * Error indicating a S3 operation failed\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class S3ServiceError extends AWSError {\n operation: string\n\n /**\n * Constructs a S3ServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: string) {\n super(message, code)\n this.name = 'S3ServiceError'\n this.operation = operation\n }\n}\n\n/**\n * S3Operation describes possible values for S3 API operations,\n * as defined by AWS APIs.\n */\ntype S3Operation = 'ListBuckets' | 'ListObjectsV2' | 'GetObject' | 'PutObject' | 'DeleteObject'\n\n/**\n * Describes the class of storage used to store a S3 object.\n */\ntype StorageClass =\n | 'STANDARD'\n | 'REDUCED_REDUNDANCY'\n | 'GLACIER'\n | 'STANDARD_IA'\n | 'INTELLIGENT_TIERING'\n | 'DEEP_ARCHIVE'\n | 'OUTPOSTS'\n | 'GLACIER_IR'\n | undefined\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","S3Client","signedRequest","host","res","http","url","_handle_error","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","parse","push","bucketName","prefix","querystring","Prefix","objects","objectDefinition","lastModified","etag","size","parseInt","storageClass","objectKey","S3Object","data","operation","response","errorCode","error_code","errorMessage","error","startsWith","S3ServiceError","awsError","parseXML","serviceName","now","S3Bucket"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"s3.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,E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F,e,8EA5E9E,MD4PagD,GAAb,IAUI,WAAY7J,EAAcgI,GAAoB,iEAC1C9B,KAAKlG,KAAOA,EACZkG,KAAK8B,aAAeA,KAKfe,GAAb,IAkBI,WACIjK,EACA2J,EACAC,EACAC,EACAE,EACAG,GACF,oKACE9C,KAAKpH,IAAMA,EACXoH,KAAKuC,aAAeA,EACpBvC,KAAKwC,KAAOA,EACZxC,KAAKyC,KAAOA,EACZzC,KAAK2C,aAAeA,EACpB3C,KAAK8C,KAAOA,KAYPQ,GAAb,gCAUI,WAAY1J,EAAiBC,EAAckJ,GAAmB,8BAC1D,cAAMnJ,EAASC,IAD2C,oBAE1D,EAAKC,KAAO,iBACZ,EAAKiJ,UAAYA,EAHyC,EAVlE,cAAoCpJ,G","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/s3.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { bytes } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\nimport { parseHTML } from 'k6/html'\nimport { sha256 } from 'k6/crypto'\n\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n /**\n * Create a S3Client\n *\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(false, true)\n super(awsConfig, 's3', URIencodingConfig)\n }\n\n /**\n * Returns a list of all buckets owned by the authenticated sender of the request.\n * To use this operation, you must have the s3:ListAllMyBuckets permission.\n *\n * @return {Array.} buckets - An array of objects describing S3 buckets\n * with the following fields: name, and creationDate.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listBuckets(): Array {\n // Prepare request\n const method = 'GET'\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, this.host, '/', '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListBuckets', res)\n\n let buckets: Array = []\n\n const doc = parseHTML(res.body as string)\n\n doc.find('Buckets')\n .children()\n .each((_, bucketDefinition) => {\n let bucket = {}\n\n bucketDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'name':\n Object.assign(bucket, { name: child.textContent() })\n break\n case 'creationdate':\n Object.assign(bucket, {\n creationDate: Date.parse(child.textContent()),\n })\n }\n })\n\n buckets.push(bucket as S3Bucket)\n })\n\n return buckets\n }\n\n /**\n * Returns some or all (up to 1,000) of the objects in a bucket.\n *\n * @param {string} bucketName - Bucket name to list.\n * @param {string?} prefix='' - Limits the response to keys that begin with the specified prefix.\n * @return {Array.} - returns an array of objects describing S3 objects\n * with the following fields: key, lastModified, etag, size and storageClass.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n listObjects(bucketName: string, prefix?: string): Array {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const body = ''\n const querystring = `list-type=2&prefix=${prefix || ''}`\n const signedRequest: AWSRequest = super.buildRequest(method, host, '/', querystring, body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n Prefix: prefix ?? '',\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('ListObjectsV2', res)\n\n let objects: Array = []\n\n // Extract the objects definition from\n // the XML response\n parseHTML(res.body as string)\n .find('Contents')\n .each((_, objectDefinition) => {\n let obj = {}\n\n objectDefinition.children().forEach((child) => {\n switch (child.nodeName()) {\n case 'key':\n Object.assign(obj, { key: child.textContent() })\n break\n case 'lastmodified':\n Object.assign(obj, { lastModified: Date.parse(child.textContent()) })\n break\n case 'etag':\n Object.assign(obj, { etag: child.textContent() })\n break\n case 'size':\n Object.assign(obj, { size: parseInt(child.textContent()) })\n break\n case 'storageclass':\n Object.assign(obj, { storageClass: child.textContent() })\n }\n })\n\n objects.push(obj as S3Object)\n })\n\n return objects\n }\n /**\n * Retrieves an Object from Amazon S3.\n *\n * To use getObject, you must have `READ` access to the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to get.\n * @return {S3Object} - returns the content of the fetched S3 Object.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n getObject(bucketName: string, objectKey: string): S3Object {\n // Prepare request\n const method = 'GET'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(method, host, path, '', body, {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n })\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('GetObject', res)\n\n return new S3Object(\n objectKey,\n Date.parse(res.headers['Last-Modified']),\n res.headers['ETag'],\n parseInt(res.headers['Content-Length']),\n\n // The X-Amz-Storage-Class header is only set if the storage class is\n // not the default 'STANDARD' one.\n (res.headers['X-Amz-Storage-Class'] ?? 'STANDARD') as StorageClass,\n\n res.body\n )\n }\n /**\n * Adds an object to a bucket.\n *\n * You must have WRITE permissions on a bucket to add an object to it.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to put.\n * @param {string | ArrayBuffer} data - the content of the S3 Object to upload.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n putObject(bucketName: string, objectKey: string, data: string | ArrayBuffer) {\n // Prepare request\n const method = 'PUT'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = data\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('PutObject', res)\n }\n\n /**\n * Removes the null version (if there is one) of an object and inserts a delete marker,\n * which becomes the latest version of the object.\n *\n * @param {string} bucketName - The bucket name containing the object.\n * @param {string} objectKey - Key of the object to delete.\n * @throws {S3ServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteObject(bucketName: string, objectKey: string): void {\n // Prepare request\n const method = 'DELETE'\n const host = `${bucketName}.${this.host}`\n const path = `/${objectKey}`\n const queryString = ''\n const body = ''\n const signedRequest: AWSRequest = super.buildRequest(\n method,\n host,\n path,\n queryString,\n body,\n {\n 'X-Amz-Content-SHA256': sha256(body, 'hex'),\n }\n )\n\n const res = http.request(method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error('DeleteObject', res)\n }\n\n _handle_error(operation: S3Operation, response: RefinedResponse) {\n const errorCode: number = response.error_code\n const errorMessage: string = response.error\n\n if (errorMessage == '' && errorCode === 0) {\n return\n }\n\n // FIXME: should be errorCode === 1301 instead\n // See: https://github.com/grafana/k6/issues/2474\n // See: https://github.com/golang/go/issues/49281\n if (errorMessage && errorMessage.startsWith('301')) {\n throw new S3ServiceError('Resource not found', 'ResourceNotFound', operation)\n }\n\n const awsError = AWSError.parseXML(response.body as string)\n switch (awsError.code) {\n case 'AuthorizationHeaderMalformed':\n throw new InvalidSignatureError(awsError.message, awsError.code)\n default:\n throw new S3ServiceError(awsError.message, awsError.code, operation)\n }\n }\n}\n\n/** Class representing a S3 Bucket */\nexport class S3Bucket {\n name: string\n creationDate: Date\n\n /**\n * Create an S3 Bucket\n *\n * @param {string} name - S3 bucket's name\n * @param {Date} creationDate - S3 bucket's creation date\n */\n constructor(name: string, creationDate: Date) {\n this.name = name\n this.creationDate = creationDate\n }\n}\n\n/** Class representing an S3 Object */\nexport class S3Object {\n key: string\n lastModified: number\n etag: string\n size: number\n storageClass: StorageClass\n data?: string | bytes | null\n\n /**\n * Create an S3 Object\n *\n * @param {string} key - S3 object's key\n * @param {Date} lastModified - S3 object last modification date\n * @param {string} etag - S3 object's etag\n * @param {number} size - S3 object's size\n * @param {StorageClass} storageClass - S3 object's storage class\n * @param {string | bytes | null} data=null - S3 Object's data\n */\n constructor(\n key: string,\n lastModified: number,\n etag: string,\n size: number,\n storageClass: StorageClass,\n data?: string | bytes | null\n ) {\n this.key = key\n this.lastModified = lastModified\n this.etag = etag\n this.size = size\n this.storageClass = storageClass\n this.data = data\n }\n}\n\n/**\n * Error indicating a S3 operation failed\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class S3ServiceError extends AWSError {\n operation: string\n\n /**\n * Constructs a S3ServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: string) {\n super(message, code)\n this.name = 'S3ServiceError'\n this.operation = operation\n }\n}\n\n/**\n * S3Operation describes possible values for S3 API operations,\n * as defined by AWS APIs.\n */\ntype S3Operation = 'ListBuckets' | 'ListObjectsV2' | 'GetObject' | 'PutObject' | 'DeleteObject'\n\n/**\n * Describes the class of storage used to store a S3 object.\n */\ntype StorageClass =\n | 'STANDARD'\n | 'REDUCED_REDUNDANCY'\n | 'GLACIER'\n | 'STANDARD_IA'\n | 'INTELLIGENT_TIERING'\n | 'DEEP_ARCHIVE'\n | 'OUTPOSTS'\n | 'GLACIER_IR'\n | undefined\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","S3Client","signedRequest","host","res","http","url","_handle_error","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","parse","push","bucketName","prefix","querystring","Prefix","objects","objectDefinition","lastModified","etag","size","parseInt","storageClass","objectKey","S3Object","data","operation","response","errorCode","error_code","errorMessage","error","startsWith","S3ServiceError","awsError","parseXML","serviceName","now","S3Bucket"],"sourceRoot":""} \ No newline at end of file diff --git a/build/secrets-manager.min.js.map b/build/secrets-manager.min.js.map index e31c89b..4d67af9 100644 --- a/build/secrets-manager.min.js.map +++ b/build/secrets-manager.min.js.map @@ -1 +1 @@ -{"version":3,"file":"secrets-manager.min.js","mappings":"2BAAA,IAAIA,EAAK,EAAQ,KACbC,EAAK,EAAQ,KAEbC,EAAOD,EACXC,EAAKF,GAAKA,EACVE,EAAKD,GAAKA,EAEVE,EAAOC,QAAUF,C,UCFjB,IADA,IAAIG,EAAY,GACPC,EAAI,EAAGA,EAAI,MAAOA,EACzBD,EAAUC,IAAMA,EAAI,KAAOC,SAAS,IAAIC,OAAO,GAmBjDL,EAAOC,QAhBP,SAAqBK,EAAKC,GACxB,IAAIJ,EAAII,GAAU,EACdC,EAAMN,EAEV,MAAO,CACLM,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MACvBK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAAO,IAC9BK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAAO,IAC9BK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAAO,IAC9BK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MAAO,IAC9BK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MACvBK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MACvBK,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,OACtBM,KAAK,GACV,C,UChBA,IAAIC,EAAqC,oBAAZ,QAA2BC,OAAOD,iBAAmBC,OAAOD,gBAAgBE,KAAKD,SACnE,oBAAd,UAAuE,mBAAnCE,OAAOC,SAASJ,iBAAiCI,SAASJ,gBAAgBE,KAAKE,UAEhJ,GAAIJ,EAAiB,CAEnB,IAA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RL,GAA0CrC,GA0R7BiB,GAAb,WAoBI,WACItH,EACAmJ,EACAC,EACAC,EACAC,EACAC,GAEF,IADEzB,EACF,uDAD2C,GAC3C,2MACElC,KAAK5F,KAAOA,EACZ4F,KAAKuD,IAAMA,EACXvD,KAAK+B,OAASyB,EACdxD,KAAKyD,YAAcA,EACnBzD,KAAK0D,iBAAmBA,EACxB1D,KAAK2D,gBAAkBA,EACvB3D,KAAKkC,KAAOA,CACf,CApCL,wCA8CI,SAAgBV,GACZ,OAAO,IAAIE,EACPF,EAAKY,KACLZ,EAAKoC,IACLpC,EAAKc,aACLd,EAAKqC,YACLrC,EAAKsC,iBACLtC,EAAKuC,gBACLvC,EAAKgB,KAEZ,KAxDL,KA2Dac,GAAb,gCAUI,WAAYpJ,EAAiBC,EAAc2I,GAAoC,8BAC3E,cAAM5I,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAK0I,UAAYA,EAH0D,CAI9E,CAdL,cAAgD7I,I,SAoB3C6G,GAAAA,EAAAA,YAAAA,cAAAA,EAAAA,eAAAA,iBAAAA,EAAAA,aAAAA,eAAAA,EAAAA,eAAAA,iBAAAA,EAAAA,aAAAA,c,EAAAA,KAAAA,GAAAA,CAAAA,G","sources":["webpack://k6-jslib-aws/./node_modules/uuid/index.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/bytesToUuid.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/rng-browser.js","webpack://k6-jslib-aws/./node_modules/uuid/v1.js","webpack://k6-jslib-aws/./node_modules/uuid/v4.js","webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/client.ts","webpack://k6-jslib-aws/./src/internal/secrets-manager.ts"],"sourcesContent":["var v1 = require('./v1');\nvar v4 = require('./v4');\n\nvar uuid = v4;\nuuid.v1 = v1;\nuuid.v4 = v4;\n\nmodule.exports = uuid;\n","/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nvar byteToHex = [];\nfor (var i = 0; i < 256; ++i) {\n byteToHex[i] = (i + 0x100).toString(16).substr(1);\n}\n\nfunction bytesToUuid(buf, offset) {\n var i = offset || 0;\n var bth = byteToHex;\n // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4\n return ([\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]]\n ]).join('');\n}\n\nmodule.exports = bytesToUuid;\n","// Unique ID creation requires a high quality random # generator. In the\n// browser this is a little complicated due to unknown quality of Math.random()\n// and inconsistent support for the `crypto` API. We do the best we can via\n// feature-detection\n\n// getRandomValues needs to be invoked in a context where \"this\" is a Crypto\n// implementation. Also, find the complete implementation of crypto on IE11.\nvar getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||\n (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));\n\nif (getRandomValues) {\n // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto\n var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef\n\n module.exports = function whatwgRNG() {\n getRandomValues(rnds8);\n return rnds8;\n };\n} else {\n // Math.random()-based (RNG)\n //\n // If all else fails, use Math.random(). It's fast, but is of unspecified\n // quality.\n var rnds = new Array(16);\n\n module.exports = function mathRNG() {\n for (var i = 0, r; i < 16; i++) {\n if ((i & 0x03) === 0) r = Math.random() * 0x100000000;\n rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return rnds;\n };\n}\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\n// **`v1()` - Generate time-based UUID**\n//\n// Inspired by https://github.com/LiosK/UUID.js\n// and http://docs.python.org/library/uuid.html\n\nvar _nodeId;\nvar _clockseq;\n\n// Previous uuid creation time\nvar _lastMSecs = 0;\nvar _lastNSecs = 0;\n\n// See https://github.com/uuidjs/uuid for API details\nfunction v1(options, buf, offset) {\n var i = buf && offset || 0;\n var b = buf || [];\n\n options = options || {};\n var node = options.node || _nodeId;\n var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;\n\n // node and clockseq need to be initialized to random values if they're not\n // specified. We do this lazily to minimize issues related to insufficient\n // system entropy. See #189\n if (node == null || clockseq == null) {\n var seedBytes = rng();\n if (node == null) {\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n node = _nodeId = [\n seedBytes[0] | 0x01,\n seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]\n ];\n }\n if (clockseq == null) {\n // Per 4.2.2, randomize (14 bit) clockseq\n clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;\n }\n }\n\n // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();\n\n // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;\n\n // Time since last uuid creation (in msecs)\n var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;\n\n // Per 4.2.1.2, Bump clockseq on clock regression\n if (dt < 0 && options.clockseq === undefined) {\n clockseq = clockseq + 1 & 0x3fff;\n }\n\n // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {\n nsecs = 0;\n }\n\n // Per 4.2.1.2 Throw error if too many uuids are requested\n if (nsecs >= 10000) {\n throw new Error('uuid.v1(): Can\\'t create more than 10M uuids/sec');\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq;\n\n // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n msecs += 12219292800000;\n\n // `time_low`\n var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff;\n\n // `time_mid`\n var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff;\n\n // `time_high_and_version`\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n b[i++] = tmh >>> 16 & 0xff;\n\n // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n b[i++] = clockseq >>> 8 | 0x80;\n\n // `clock_seq_low`\n b[i++] = clockseq & 0xff;\n\n // `node`\n for (var n = 0; n < 6; ++n) {\n b[i + n] = node[n];\n }\n\n return buf ? buf : bytesToUuid(b);\n}\n\nmodule.exports = v1;\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\nfunction v4(options, buf, offset) {\n var i = buf && offset || 0;\n\n if (typeof(options) == 'string') {\n buf = options === 'binary' ? new Array(16) : null;\n options = null;\n }\n options = options || {};\n\n var rnds = options.random || (options.rng || rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n for (var ii = 0; ii < 16; ++ii) {\n buf[i + ii] = rnds[ii];\n }\n }\n\n return buf || bytesToUuid(rnds);\n}\n\nmodule.exports = v4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { v4 as uuidv4 } from 'uuid'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's SecretsManager service\n */\nexport class SecretsManagerClient extends AWSClient {\n /**\n * HTTP Method to use when interacting with the Secrets Manager service.\n */\n method: HTTPMethod\n\n /**\n * HTTP headers to use accross all requests to the Secrets Manager service.\n */\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SecretsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'secretsmanager', URIencodingConfig)\n\n // All interactions with the Secrets Manager service\n // are made via the GET or POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Returns a list of all secrets owned by the authenticated sender of the request.\n * To use this operation, you must have the secretsmanager:ListSecrets permission.\n *\n * @return {Array.} secrets - An array of objects describing Secret Manager's secrets\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n listSecrets(): Array {\n const body = JSON.stringify({})\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.ListSecrets`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.ListSecrets, res)\n const json: JSONArray = res.json('SecretList') as JSONArray\n\n return json.map((s) => Secret.fromJSON(s as JSONObject))\n }\n\n /**\n * Retrieves a secret from Amazon Sercets Manager\n *\n * @param {string} id - The ARN or name of the secret to retrieve.\n * @returns {Secret} - returns the content of the fetched Secret object.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getSecret(id: string): Secret | undefined {\n const body = JSON.stringify({ SecretId: id })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.GetSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.GetSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Creates a new secret\n *\n * Note that this method only supports string-based values at the moment.\n *\n * @param {string} name - The name of the new secret.\n * The secret name can contain ASCII letters, numbers, and the following characters: /_+=.@\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {string} description - The description of the secret.\n * @param {string} versionID=null - Version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * algorithm.\n * @param {Array.} tags=[] - A list of tags to attach to the secret. Each tag is a key and\n * value pair of strings in a JSON text string. Note that tag key names are case sensitive.\n * @returns {Secret} - returns the created secret\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n createSecret(\n name: string,\n secret: string,\n description: string,\n versionID?: string,\n tags?: Array\n ): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n })\n\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.CreateSecret`,\n }\n )\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n // headers['X-Amz-Target'] = `${this.serviceName}.CreateSecret`\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.CreateSecret, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n /**\n * Update a secret's value.\n *\n * Note that this method only support string-based values at the moment.\n *\n * @param {string} id - The ARN or name of the secret to update.\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {} versionID=null - A unique identifier for the new version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n putSecretValue(id: string, secret: string, versionID?: string): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.PutSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.PutSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Deletes a secret and all of its versions.\n *\n * You can specify a recovery window during which you can restore the secret.\n * The minimum recovery window is 7 days. The default recovery window is 30 days.\n *\n * @param {string} secretID - The ARN or name of the secret to delete.\n * @param {number} recoveryWindow - The number of days from 7 to 30 that Secrets Manager\n * waits before permanently deleting the secret.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteSecret(\n id: string,\n { recoveryWindow = 30, noRecovery = false }: { recoveryWindow: number; noRecovery: boolean }\n ) {\n const payload: { [key: string]: string | boolean | number } = {\n SecretId: id,\n }\n\n // noRecovery and recoveryWindow are exclusive parameters\n if (noRecovery === true) {\n payload['ForceDeleteWithoutRecovery'] = true\n } else {\n payload['RecoveryWindowInDays'] = recoveryWindow\n }\n\n const body = JSON.stringify(payload)\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.DeleteSecret`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(operation: SecretsManagerOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SecretsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SecretsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n// TODO: create a Tags type\n\n/**\n * Class representing a Secret Manager's secret\n */\nexport class Secret {\n name: string\n arn: string\n secret: string\n createdDate: number\n lastAccessedDate: number\n lastChangedDate: number\n tags: Array<{ [key: string]: string }>\n\n /**\n * Constructs a Secret Manager's Secret\n *\n * @param {string} name - The friendly name of the secret.\n * @param {string} arn - The ARN of the secret.\n * @param {number} createdDate - The date and time that this version of the secret was created.\n * @param {number} lastAccessedDate - The last date that this secret was accessed. This value is\n * truncated to midnight of the date and therefore shows only the date, not the time.\n * @param {number} lastChangedDate - The last date and time that this secret was modified in any way.\n * @param {Array.} tags - The list of user-defined tags associated with the secret.\n */\n constructor(\n name: string,\n arn: string,\n secretString: string,\n createdDate: number,\n lastAccessedDate: number,\n lastChangedDate: number,\n tags: Array<{ [key: string]: string }> = []\n ) {\n this.name = name\n this.arn = arn\n this.secret = secretString\n this.createdDate = createdDate\n this.lastAccessedDate = lastAccessedDate\n this.lastChangedDate = lastChangedDate\n this.tags = tags\n }\n\n /**\n * Parses and constructs a Secret Manager's Secret from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {Secret}\n */\n static fromJSON(json: JSONObject) {\n return new Secret(\n json.Name as string,\n json.ARN as string,\n json.SecretString as string,\n json.CreatedDate as number,\n json.LastAccessedDate as number,\n json.LastChangedDate as number,\n json.Tags as Array<{ [key: string]: string }>\n )\n }\n}\n\nexport class SecretsManagerServiceError extends AWSError {\n operation: SecretsManagerOperation\n\n /**\n * Constructs a SecretsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SecretsManagerOperation) {\n super(message, code)\n this.name = 'SecretsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SecretsManagerOperation defines all currently implemented Secrets Manager Service operations.\n */\nenum SecretsManagerOperation {\n ListSecrets = 'ListSecrets',\n GetSecretValue = 'GetSecretValue',\n CreateSecret = 'CreateSecret',\n PutSecretValue = 'PutSecretValue',\n DeleteSecret = 'DeleteSecret'\n}\n"],"names":["v1","v4","uuid","module","exports","byteToHex","i","toString","substr","buf","offset","bth","join","getRandomValues","crypto","bind","window","msCrypto","rnds8","Uint8Array","rnds","Array","r","Math","random","_nodeId","_clockseq","rng","bytesToUuid","_lastMSecs","_lastNSecs","options","b","node","clockseq","undefined","seedBytes","msecs","Date","getTime","nsecs","dt","Error","tl","tmh","n","ii","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","localeCompare","parseQueryString","uriComponent","encodeURIComponent","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","URIEncodingConfig","double","this","timestamp","toISOString","substring","AWSConfig","InvalidAWSConfigError","accessKeyId","scheme","endpoint","AWSClient","serviceName","host","now","url","SecretsManagerOperation","SecretsManagerClient","commonHeaders","JSON","stringify","signedRequest","res","http","_handle_error","ListSecrets","json","s","Secret","fromJSON","id","SecretId","GetSecretValue","secret","description","versionID","tags","uuidv4","Name","Description","SecretString","ClientRequestToken","Tags","CreateSecret","PutSecretValue","recoveryWindow","noRecovery","DeleteSecret","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SecretsManagerServiceError","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"secrets-manager.min.js","mappings":"2BAAA,IAAIA,EAAK,EAAQ,KACbC,EAAK,EAAQ,KAEbC,EAAOD,EACXC,EAAKF,GAAKA,EACVE,EAAKD,GAAKA,EAEVE,EAAOC,QAAUF,G,QCFjB,IADA,IAAIG,EAAY,GACPC,EAAI,EAAGA,EAAI,MAAOA,EACzBD,EAAUC,IAAMA,EAAI,KAAOC,SAAS,IAAIC,OAAO,GAmBjDL,EAAOC,QAhBP,SAAqBK,EAAKC,GACxB,IAAIJ,EAAII,GAAU,EACdC,EAAMN,EAEV,MAAO,CACLM,EAAIF,EAAIH,MAAOK,EAAIF,EAAIH,MACvBK,EAAIF,E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AGrE,GAAqB,8BAAjBH,EAAMG,OACN,MAAM,IAAI/D,EAAsB6D,EAAcD,EAAMG,QAIxD,MAAM,IAAIC,GAA2BH,EAAcD,EAAMG,OAAkBP,GAG/E,GAAkB,OAAdE,EACA,MAAM,IAAIM,GACN,sCACA,uBACAR,QA/QhB,GAA0CrC,GA0R7BiB,GAAb,WAoBI,WACItH,EACAmJ,EACAC,EACAC,EACAC,EACAC,GAEF,IADEzB,EACF,uDAD2C,GAC3C,2MACElC,KAAK5F,KAAOA,EACZ4F,KAAKuD,IAAMA,EACXvD,KAAK+B,OAASyB,EACdxD,KAAKyD,YAAcA,EACnBzD,KAAK0D,iBAAmBA,EACxB1D,KAAK2D,gBAAkBA,EACvB3D,KAAKkC,KAAOA,EAnCpB,wCA8CI,SAAgBV,GACZ,OAAO,IAAIE,EACPF,EAAKY,KACLZ,EAAKoC,IACLpC,EAAKc,aACLd,EAAKqC,YACLrC,EAAKsC,iBACLtC,EAAKuC,gBACLvC,EAAKgB,UAtDjB,KA2Dac,GAAb,gCAUI,WAAYpJ,EAAiBC,EAAc2I,GAAoC,8BAC3E,cAAM5I,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAK0I,UAAYA,EAH0D,EAVnF,cAAgD7I,I,SAoB3C6G,GAAAA,EAAAA,YAAAA,cAAAA,EAAAA,eAAAA,iBAAAA,EAAAA,aAAAA,eAAAA,EAAAA,eAAAA,iBAAAA,EAAAA,aAAAA,e,CAAAA,KAAAA,GAAAA,M","sources":["webpack://k6-jslib-aws/./node_modules/uuid/index.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/bytesToUuid.js","webpack://k6-jslib-aws/./node_modules/uuid/lib/rng-browser.js","webpack://k6-jslib-aws/./node_modules/uuid/v1.js","webpack://k6-jslib-aws/./node_modules/uuid/v4.js","webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/client.ts","webpack://k6-jslib-aws/./src/internal/secrets-manager.ts"],"sourcesContent":["var v1 = require('./v1');\nvar v4 = require('./v4');\n\nvar uuid = v4;\nuuid.v1 = v1;\nuuid.v4 = v4;\n\nmodule.exports = uuid;\n","/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nvar byteToHex = [];\nfor (var i = 0; i < 256; ++i) {\n byteToHex[i] = (i + 0x100).toString(16).substr(1);\n}\n\nfunction bytesToUuid(buf, offset) {\n var i = offset || 0;\n var bth = byteToHex;\n // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4\n return ([\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]], '-',\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]],\n bth[buf[i++]], bth[buf[i++]]\n ]).join('');\n}\n\nmodule.exports = bytesToUuid;\n","// Unique ID creation requires a high quality random # generator. In the\n// browser this is a little complicated due to unknown quality of Math.random()\n// and inconsistent support for the `crypto` API. We do the best we can via\n// feature-detection\n\n// getRandomValues needs to be invoked in a context where \"this\" is a Crypto\n// implementation. Also, find the complete implementation of crypto on IE11.\nvar getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||\n (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));\n\nif (getRandomValues) {\n // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto\n var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef\n\n module.exports = function whatwgRNG() {\n getRandomValues(rnds8);\n return rnds8;\n };\n} else {\n // Math.random()-based (RNG)\n //\n // If all else fails, use Math.random(). It's fast, but is of unspecified\n // quality.\n var rnds = new Array(16);\n\n module.exports = function mathRNG() {\n for (var i = 0, r; i < 16; i++) {\n if ((i & 0x03) === 0) r = Math.random() * 0x100000000;\n rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return rnds;\n };\n}\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\n// **`v1()` - Generate time-based UUID**\n//\n// Inspired by https://github.com/LiosK/UUID.js\n// and http://docs.python.org/library/uuid.html\n\nvar _nodeId;\nvar _clockseq;\n\n// Previous uuid creation time\nvar _lastMSecs = 0;\nvar _lastNSecs = 0;\n\n// See https://github.com/uuidjs/uuid for API details\nfunction v1(options, buf, offset) {\n var i = buf && offset || 0;\n var b = buf || [];\n\n options = options || {};\n var node = options.node || _nodeId;\n var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;\n\n // node and clockseq need to be initialized to random values if they're not\n // specified. We do this lazily to minimize issues related to insufficient\n // system entropy. See #189\n if (node == null || clockseq == null) {\n var seedBytes = rng();\n if (node == null) {\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n node = _nodeId = [\n seedBytes[0] | 0x01,\n seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]\n ];\n }\n if (clockseq == null) {\n // Per 4.2.2, randomize (14 bit) clockseq\n clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;\n }\n }\n\n // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();\n\n // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;\n\n // Time since last uuid creation (in msecs)\n var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;\n\n // Per 4.2.1.2, Bump clockseq on clock regression\n if (dt < 0 && options.clockseq === undefined) {\n clockseq = clockseq + 1 & 0x3fff;\n }\n\n // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {\n nsecs = 0;\n }\n\n // Per 4.2.1.2 Throw error if too many uuids are requested\n if (nsecs >= 10000) {\n throw new Error('uuid.v1(): Can\\'t create more than 10M uuids/sec');\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq;\n\n // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n msecs += 12219292800000;\n\n // `time_low`\n var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff;\n\n // `time_mid`\n var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff;\n\n // `time_high_and_version`\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n b[i++] = tmh >>> 16 & 0xff;\n\n // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n b[i++] = clockseq >>> 8 | 0x80;\n\n // `clock_seq_low`\n b[i++] = clockseq & 0xff;\n\n // `node`\n for (var n = 0; n < 6; ++n) {\n b[i + n] = node[n];\n }\n\n return buf ? buf : bytesToUuid(b);\n}\n\nmodule.exports = v1;\n","var rng = require('./lib/rng');\nvar bytesToUuid = require('./lib/bytesToUuid');\n\nfunction v4(options, buf, offset) {\n var i = buf && offset || 0;\n\n if (typeof(options) == 'string') {\n buf = options === 'binary' ? new Array(16) : null;\n options = null;\n }\n options = options || {};\n\n var rnds = options.random || (options.rng || rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n for (var ii = 0; ii < 16; ++ii) {\n buf[i + ii] = rnds[ii];\n }\n }\n\n return buf || bytesToUuid(rnds);\n}\n\nmodule.exports = v4;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { v4 as uuidv4 } from 'uuid'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's SecretsManager service\n */\nexport class SecretsManagerClient extends AWSClient {\n /**\n * HTTP Method to use when interacting with the Secrets Manager service.\n */\n method: HTTPMethod\n\n /**\n * HTTP headers to use accross all requests to the Secrets Manager service.\n */\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SecretsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'secretsmanager', URIencodingConfig)\n\n // All interactions with the Secrets Manager service\n // are made via the GET or POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Returns a list of all secrets owned by the authenticated sender of the request.\n * To use this operation, you must have the secretsmanager:ListSecrets permission.\n *\n * @return {Array.} secrets - An array of objects describing Secret Manager's secrets\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n listSecrets(): Array {\n const body = JSON.stringify({})\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.ListSecrets`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.ListSecrets, res)\n const json: JSONArray = res.json('SecretList') as JSONArray\n\n return json.map((s) => Secret.fromJSON(s as JSONObject))\n }\n\n /**\n * Retrieves a secret from Amazon Sercets Manager\n *\n * @param {string} id - The ARN or name of the secret to retrieve.\n * @returns {Secret} - returns the content of the fetched Secret object.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getSecret(id: string): Secret | undefined {\n const body = JSON.stringify({ SecretId: id })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.GetSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.GetSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Creates a new secret\n *\n * Note that this method only supports string-based values at the moment.\n *\n * @param {string} name - The name of the new secret.\n * The secret name can contain ASCII letters, numbers, and the following characters: /_+=.@\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {string} description - The description of the secret.\n * @param {string} versionID=null - Version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * algorithm.\n * @param {Array.} tags=[] - A list of tags to attach to the secret. Each tag is a key and\n * value pair of strings in a JSON text string. Note that tag key names are case sensitive.\n * @returns {Secret} - returns the created secret\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n createSecret(\n name: string,\n secret: string,\n description: string,\n versionID?: string,\n tags?: Array\n ): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n })\n\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.CreateSecret`,\n }\n )\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n // headers['X-Amz-Target'] = `${this.serviceName}.CreateSecret`\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.CreateSecret, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n /**\n * Update a secret's value.\n *\n * Note that this method only support string-based values at the moment.\n *\n * @param {string} id - The ARN or name of the secret to update.\n * @param {string} secret - The text data to encrypt and store in this new version of the secret.\n * @param {} versionID=null - A unique identifier for the new version of the secret. This value helps ensure idempotency.\n * As a default, if no versionID is provided, one will be created for you using the UUID v4\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n putSecretValue(id: string, secret: string, versionID?: string): Secret {\n versionID = versionID || uuidv4()\n\n const body = JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.PutSecretValue`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.PutSecretValue, res)\n\n return Secret.fromJSON(res.json() as JSONObject)\n }\n\n /**\n * Deletes a secret and all of its versions.\n *\n * You can specify a recovery window during which you can restore the secret.\n * The minimum recovery window is 7 days. The default recovery window is 30 days.\n *\n * @param {string} secretID - The ARN or name of the secret to delete.\n * @param {number} recoveryWindow - The number of days from 7 to 30 that Secrets Manager\n * waits before permanently deleting the secret.\n * @throws {SecretsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n deleteSecret(\n id: string,\n { recoveryWindow = 30, noRecovery = false }: { recoveryWindow: number; noRecovery: boolean }\n ) {\n const payload: { [key: string]: string | boolean | number } = {\n SecretId: id,\n }\n\n // noRecovery and recoveryWindow are exclusive parameters\n if (noRecovery === true) {\n payload['ForceDeleteWithoutRecovery'] = true\n } else {\n payload['RecoveryWindowInDays'] = recoveryWindow\n }\n\n const body = JSON.stringify(payload)\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `${this.serviceName}.DeleteSecret`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(operation: SecretsManagerOperation, response: RefinedResponse) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SecretsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SecretsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n// TODO: create a Tags type\n\n/**\n * Class representing a Secret Manager's secret\n */\nexport class Secret {\n name: string\n arn: string\n secret: string\n createdDate: number\n lastAccessedDate: number\n lastChangedDate: number\n tags: Array<{ [key: string]: string }>\n\n /**\n * Constructs a Secret Manager's Secret\n *\n * @param {string} name - The friendly name of the secret.\n * @param {string} arn - The ARN of the secret.\n * @param {number} createdDate - The date and time that this version of the secret was created.\n * @param {number} lastAccessedDate - The last date that this secret was accessed. This value is\n * truncated to midnight of the date and therefore shows only the date, not the time.\n * @param {number} lastChangedDate - The last date and time that this secret was modified in any way.\n * @param {Array.} tags - The list of user-defined tags associated with the secret.\n */\n constructor(\n name: string,\n arn: string,\n secretString: string,\n createdDate: number,\n lastAccessedDate: number,\n lastChangedDate: number,\n tags: Array<{ [key: string]: string }> = []\n ) {\n this.name = name\n this.arn = arn\n this.secret = secretString\n this.createdDate = createdDate\n this.lastAccessedDate = lastAccessedDate\n this.lastChangedDate = lastChangedDate\n this.tags = tags\n }\n\n /**\n * Parses and constructs a Secret Manager's Secret from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {Secret}\n */\n static fromJSON(json: JSONObject) {\n return new Secret(\n json.Name as string,\n json.ARN as string,\n json.SecretString as string,\n json.CreatedDate as number,\n json.LastAccessedDate as number,\n json.LastChangedDate as number,\n json.Tags as Array<{ [key: string]: string }>\n )\n }\n}\n\nexport class SecretsManagerServiceError extends AWSError {\n operation: SecretsManagerOperation\n\n /**\n * Constructs a SecretsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {string} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SecretsManagerOperation) {\n super(message, code)\n this.name = 'SecretsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SecretsManagerOperation defines all currently implemented Secrets Manager Service operations.\n */\nenum SecretsManagerOperation {\n ListSecrets = 'ListSecrets',\n GetSecretValue = 'GetSecretValue',\n CreateSecret = 'CreateSecret',\n PutSecretValue = 'PutSecretValue',\n DeleteSecret = 'DeleteSecret'\n}\n"],"names":["v1","v4","uuid","module","exports","byteToHex","i","toString","substr","buf","offset","bth","join","getRandomValues","crypto","bind","window","msCrypto","rnds8","Uint8Array","rnds","Array","r","Math","random","_nodeId","_clockseq","rng","bytesToUuid","_lastMSecs","_lastNSecs","options","b","node","clockseq","undefined","seedBytes","msecs","Date","getTime","nsecs","dt","Error","tl","tmh","n","ii","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","localeCompare","parseQueryString","uriComponent","encodeURIComponent","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","URIEncodingConfig","double","this","timestamp","toISOString","substring","AWSConfig","InvalidAWSConfigError","accessKeyId","scheme","endpoint","AWSClient","serviceName","host","now","url","SecretsManagerOperation","SecretsManagerClient","commonHeaders","JSON","stringify","signedRequest","res","http","_handle_error","ListSecrets","json","s","Secret","fromJSON","id","SecretId","GetSecretValue","secret","description","versionID","tags","uuidv4","Name","Description","SecretString","ClientRequestToken","Tags","CreateSecret","PutSecretValue","recoveryWindow","noRecovery","DeleteSecret","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SecretsManagerServiceError","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate"],"sourceRoot":""} \ No newline at end of file diff --git a/build/ssm.min.js.map b/build/ssm.min.js.map index 7dfd687..4b39abb 100644 --- a/build/ssm.min.js.map +++ b/build/ssm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ssm.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,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AAwC5G,GAK/C,MAJoB,KAAhBC,IACA8G,GAAO,IAAJ,OAAQ9G,IAGR,CAAE8G,IAAKA,EAAKlH,QAASA,EAC/B,GArEL,gBA2EI,WACI,gBAAU0F,KAAKuC,YAAf,YAA8BvC,KAAKpF,UAAUO,OAA7C,YAAuD6E,KAAKpF,UAAU+F,SACzE,M,8EA7EL,MDiGagB,GAAb,WAQI,WAAYc,GAAuB,uCAC/BzC,KAAKyC,UAAYC,GAA4Bd,SAASa,EACzD,CAVL,wCAoBI,SAAgBZ,GACZ,OAAO,IAAIF,EAAwBE,EAAKc,UAC3C,KAtBL,KA4BMD,GAAAA,WA0BF,WACIE,EACAC,EACAC,EACAhJ,EACAiJ,EACAC,EACAC,EACAxJ,EACAyJ,GACF,yPACElD,KAAK4C,IAAMA,EACX5C,KAAK6C,SAAWA,EAChB7C,KAAK8C,iBAAmBA,EACxB9C,KAAKlG,KAAOA,EACZkG,KAAK+C,SAAWA,EAChB/C,KAAKgD,aAAeA,EACpBhD,KAAKiD,KAAOA,EACZjD,KAAKvG,MAAQA,EACbuG,KAAKkD,QAAUA,CAClB,C,wCAUD,SAAgBrB,GACZ,OAAO,IAAIa,EACPb,EAAKsB,IACLtB,EAAKuB,SACLvB,EAAKwB,iBACLxB,EAAKX,KACLW,EAAKyB,SACLzB,EAAK0B,aACL1B,EAAK2B,KACL3B,EAAK4B,MACL5B,EAAK6B,QAEZ,K,EApEChB,GAuEOJ,GAAb,gCAUI,WAAY1I,EAAiBC,EAAciI,GAAoC,8BAC3E,cAAMlI,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAKgI,UAAYA,EAH0D,CAI9E,CAdL,cAAgDnI,I,SAoB3CiH,GAAAA,EAAAA,aAAAA,c,EAAAA,KAAAA,GAAAA,CAAAA,I","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/ssm.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's Systems Manager service\n */\nexport class SystemsManagerClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SystemsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'ssm', URIencodingConfig)\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Retrieves a parameter from Amazon Systems Manager\n *\n * @param {string} name - The ARN or name of the parameter to retrieve.\n * @param {boolean} withDecryption - whether returned secure string parameters should be decrypted.\n * @returns {SystemsManagerParameter} - returns the fetched Parameter object.\n * @throws {SystemsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getParameter(\n name: string,\n withDecryption: boolean = false\n ): SystemsManagerParameter | undefined {\n const body = JSON.stringify({ Name: name, WithDecryption: withDecryption })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `AmazonSSM.GetParameter`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SystemsManagerOperation.GetParameter, res);\n\n return SystemsManagerParameter.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(\n operation: SystemsManagerOperation,\n response: RefinedResponse\n ) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SystemsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SystemsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter\n */\nexport class SystemsManagerParameter {\n parameter: SystemsManagerParameterItem\n\n /**\n * Constructs a Systems Manager's Parameter\n *\n * @param {JSONObject} parameter - The response object content for the AWS System Manager.\n */\n constructor(parameter: JSONObject) {\n this.parameter = SystemsManagerParameterItem.fromJSON(parameter)\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameter}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameter {\n return new SystemsManagerParameter(json.Parameter as JSONObject)\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter Object content\n */\nclass SystemsManagerParameterItem {\n arn: string\n dataType: string\n lastModifiedDate: number\n name: string\n selector: string\n sourceResult: string\n type: string\n value: string\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter object contents\n *\n * @param {string} arn - The Amazon Resource Name (ARN) of the parameter.\n * @param {string} dataType - The data type of the parameter, such as text or aws:ec2:image. The default is text.\n * @param {number} lastModifiedDate - Date the parameter was last changed or updated and the parameter version was created.\n * @param {string} name - The friendly name of the parameter.\n * @param {string} selector - Either the version number or the label used to retrieve the parameter value. Specify selectors by using one of the following formats:\n * parameter_name:version\n * parameter_name:label\n * @param {string} sourceResult - Applies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n * @param {string} type - The type of parameter. Valid values include the following: String, StringList, and SecureString.\n * @param {string} value - The parameter value.\n * @param {number} version - The parameter version.\n */\n constructor(\n arn: string,\n dataType: string,\n lastModifiedDate: number,\n name: string,\n selector: string,\n sourceResult: string,\n type: string,\n value: string,\n version: number\n ) {\n this.arn = arn\n this.dataType = dataType\n this.lastModifiedDate = lastModifiedDate\n this.name = name\n this.selector = selector\n this.sourceResult = sourceResult\n this.type = type\n this.value = value\n this.version = version\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter object from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameterItem}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameterItem {\n return new SystemsManagerParameterItem(\n json.ARN as string,\n json.DataType as string,\n json.LastModifiedDate as number,\n json.Name as string,\n json.Selector as string,\n json.SourceResult as string,\n json.Type as string,\n json.Value as string,\n json.Version as number\n )\n }\n}\n\nexport class SystemsManagerServiceError extends AWSError {\n operation: SystemsManagerOperation\n\n /**\n * Constructs a SystemsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {SystemsManagerOperation} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SystemsManagerOperation) {\n super(message, code)\n this.name = 'SystemsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SystemsManagerOperation defines all currently implemented Systems Manager operations.\n */\nenum SystemsManagerOperation {\n GetParameter = 'GetParameter',\n}\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","SystemsManagerOperation","SystemsManagerClient","commonHeaders","withDecryption","JSON","stringify","Name","WithDecryption","signedRequest","host","res","http","url","_handle_error","GetParameter","SystemsManagerParameter","fromJSON","json","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SystemsManagerServiceError","serviceName","now","parameter","SystemsManagerParameterItem","Parameter","arn","dataType","lastModifiedDate","selector","sourceResult","type","version","ARN","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"ssm.min.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,oOCLvD,MAAM,EAA+BC,QAAQ,a,aCA7C,MAAM,EAA+BA,QAAQ,W,q0DCUtC,IAAMC,EAAb,a,qRAAA,U,UAAA,G,EAAA,E,mJASI,WAAYC,EAAiBC,GAAc,M,MAAA,O,4FAAA,SACvC,cAAMD,G,EADiC,K,OAAA,G,EAAA,U,wFAEvC,EAAKE,KAAO,WACZ,EAAKD,KAAOA,EAH2B,EAT/C,O,EAAA,E,EAAA,uBAoBI,SAAgBE,GACZ,IAAMC,GAAMC,EAAAA,EAAAA,WAAUF,GAC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AoB3CiH,GAAAA,EAAAA,aAAAA,e,CAAAA,KAAAA,GAAAA,K","sources":["webpack://k6-jslib-aws/webpack/bootstrap","webpack://k6-jslib-aws/webpack/runtime/compat get default export","webpack://k6-jslib-aws/webpack/runtime/define property getters","webpack://k6-jslib-aws/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-aws/webpack/runtime/make namespace object","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/ssm.ts","webpack://k6-jslib-aws/./src/internal/client.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/html\");","import { parseHTML } from 'k6/html'\n\n/**\n * Base class to derive errors from\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class AWSError extends Error {\n code: string\n\n /**\n * Create an AWSError\n *\n * @param {string} message - A longer human readable error message.\n * @param {string} code - A unique short code representing the error that was emitted\n */\n constructor(message: string, code: string) {\n super(message)\n this.name = 'AWSError'\n this.code = code\n }\n\n /**\n * Parse an AWSError from an XML document\n *\n * @param {string} xmlDocument - Serialized XML document to parse the error from\n */\n static parseXML(xmlDocument: string): AWSError {\n const doc = parseHTML(xmlDocument)\n return new AWSError(doc.find('Message').text(), doc.find('Code').text())\n }\n}\n","import crypto, { hmac, sha256 } from 'k6/crypto'\nimport { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\n\n/**\n * Includes AWS v4 signing information to the provided HTTP headers object.\n *\n * This function will compute the `Authorization` header signature for the\n * provided request components, and add it to `header`. It will do so by following\n * the procedure detailled AWS' API docs: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n *\n * The resulting `Authorization` header value is computed for the provided\n * headers object. Thus, any modification of the headers past a call to `signHeaders`\n * would effectively invalidate their signature, and the function should be\n * called again to recompute it.\n *\n * @param {object} headers - HTTP headers request to sign.\n * @param {number} requestTimestamp - Timestamp of the request\n * @param {string} method - HTTP method used\n * @param {string} path - HTTP request URL's path\n * @param {string} queryString - HTTP request URL's querystring\n * @param {string | ArrayBuffer} body - HTTP request's payload\n * @param {AWSConfig} - AWS configuration\n * @param {string} service - AWS service name\n * @param {URIEncodingConfig} - URI encoding configuration\n */\nexport function signHeaders(\n headers: HTTPHeaders,\n requestTimestamp: number,\n method: HTTPMethod,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n awsConfig: AWSConfig,\n service: string,\n URIencodingConfig: URIEncodingConfig\n): HTTPHeaders {\n // If the config contains a session token, we should add it to the headers\n // as a `X-Amz-Security-Token` header, cf: https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n if (awsConfig.sessionToken) {\n headers['X-Amz-Security-Token'] = awsConfig.sessionToken\n }\n\n const derivedSigningKey = deriveSigningKey(\n awsConfig.secretAccessKey,\n requestTimestamp,\n awsConfig.region,\n service\n )\n\n const canonicalRequest = createCanonicalRequest(\n method,\n path,\n queryString,\n headers,\n body,\n URIencodingConfig\n )\n\n const stringToSign = createStringToSign(\n requestTimestamp,\n awsConfig.region,\n service,\n sha256(canonicalRequest, 'hex')\n )\n\n const credentialScope = createCredentialScope(requestTimestamp, awsConfig.region, service)\n const signedHeaders = createSignedHeaders(headers)\n const signature = calculateSignature(derivedSigningKey, stringToSign)\n const authorizationHeader = `${HashingAlgorithm} Credential=${awsConfig.accessKeyID}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`\n\n headers['Authorization'] = authorizationHeader\n\n return headers\n}\n\n/**\n * Error indicating an Invalid signature has been sent to AWS services\n *\n * Inspired from AWS official error types, as\n * described in:\n * * https://aws.amazon.com/blogs/developer/service-error-handling-modular-aws-sdk-js/\n * * https://github.com/aws/aws-sdk-js/blob/master/lib/error.d.ts\n */\nexport class InvalidSignatureError extends AWSError {\n /**\n * Constructs an InvalidSignatureError\n *\n * @param {string} message - human readable error message\n */\n constructor(message: string, code: string) {\n super(message, code)\n this.name = 'InvalidSignatureError'\n }\n}\n\n/**\n * Calculte the signature for AWS signature version 4\n *\n * @param {string} derivedSigningKey - dervied signing key as computed by `deriveSigningKey`\n * @param {string} stringToSign - String to sign as computed by `createStringToSign`\n * @return {string}\n */\nexport function calculateSignature(derivedSigningKey: ArrayBuffer, stringToSign: string): string {\n return hmac('sha256', derivedSigningKey, stringToSign, 'hex')\n}\n/**\n * Derives the signing key for authenticating requests signed with\n * the Signature version 4 authentication protocol.\n *\n * deriveSigningKey produces a signing key by creating a series of\n * hash-based message authentication codes (HMACs) represented in\n * a binary format.\n *\n * The derived signing key is specific to the date it's made at, as well as\n * the service and region it targets.\n *\n * @param {string} secretAccessKey - the AWS secret access key to derive the signing key for\n * @param {number} time - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function deriveSigningKey(\n secretAccessKey: string,\n time: number,\n region: string,\n service: string\n): ArrayBuffer {\n const kSecret = secretAccessKey\n const date = toDate(time)\n\n // FIXME: hmac takes ArrayBuffer as input, but returns bytes (number[]).\n // How does one convert from one to the other?\n const kDate: any = hmac('sha256', 'AWS4' + kSecret, date, 'binary')\n const kRegion: any = hmac('sha256', kDate, region, 'binary')\n const kService: any = hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\n}\n\n// Hashing Algorithm to use in the signature process\nexport const HashingAlgorithm = 'AWS4-HMAC-SHA256'\n\n/**\n * Certain services, such as S3, allow for unsigned payloads. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n */\nexport const UnsignedPayload = 'UNSIGNED-PAYLOAD'\n\n/**\n * Create the \"string to sign\" part of the signature Version 4 protocol.\n *\n * The \"string to sign\" includes meta information about your request and\n * about the canonical request that you created with `createCanonicalRequest`.\n * It is used hand in hand with the signing key to create the request signature.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @param {string} hashedCanonicalRequest - canonical request as produced by calling the createCanonicalRequest function,\n * hashed using the SHA256 algorithm (encoded in hexadecimal format).\n * @return {string}\n */\nexport function createStringToSign(\n requestTimestamp: number,\n region: string,\n service: string,\n hashedCanonicalRequest: string\n): string {\n // the request date specified in ISO8601 format: YYYYMMDD'T'HHMMSS'Z'\n const requestDateTime = toTime(requestTimestamp)\n\n // The credential scope value, consisting of the date in YYYYMMDD format,\n // the targeted region, the targeted service, and a termination string.\n // Note that the region and service MUST be UTF-8 encoded.\n const credentialScope = createCredentialScope(requestTimestamp, region, service)\n\n const stringToSign = [\n // Algorithm\n HashingAlgorithm,\n\n // RequestDateTime\n requestDateTime,\n\n // CredentialScope\n credentialScope,\n\n // HashedCanonicalRequest\n hashedCanonicalRequest,\n ].join('\\n')\n\n return stringToSign\n}\n\n/**\n *\n * Helper function creating a credential scope string to use in the signature\n * version 4 process. A credential scope consists of the date of the request\n * in YYYYMMDD format, the targeted region, the targeted service, and a\n * termination string.\n *\n * Note that the region and service MUST be UTF-8 encoded.\n *\n * @param {number} requestTimestamp - timestamp of the request\n * @param {string} region - targeted AWS region. MUST be UTF-8 encoded.\n * @param {string} service - targeted AWS service name. MUST be UTF-8 encoded.\n * @return {string}\n */\nexport function createCredentialScope(\n requestTimestamp: number,\n region: string,\n service: string\n): string {\n return [toDate(requestTimestamp), region, service, 'aws4_request'].join('/')\n}\n\n/**\n * Create a string that includes information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * @param {string} method - the HTTP request method\n * @param {string} uri - URI-encoded version of the absolute path component of the URI\n * @param {string} query - request's query string\n * @param {Object} headers - all the HTTP headers that you wish to include with the signed request\n * @param {string | ArrayBuffer} payload - payload to include as the body of the request\n * @param {URIEncodingConfig} URIencodingConfig- URI encoding configuration\n * @return {string}\n */\nexport function createCanonicalRequest(\n method: HTTPMethod,\n uri: string,\n query: string,\n headers: HTTPHeaders,\n payload: string | ArrayBuffer,\n URIencodingConfig: URIEncodingConfig\n): string {\n const httpRequestMethod = method.toUpperCase()\n const canonicalURI = createCanonicalURI(uri, URIencodingConfig)\n const canonicalQueryString = createCanonicalQueryString(query)\n const canonicalHeaders = createCanonicalHeaders(headers)\n const signedHeaders = createSignedHeaders(headers)\n const requestPayload = createCanonicalPayload(payload)\n\n const canonicalRequest = [\n httpRequestMethod,\n canonicalURI,\n canonicalQueryString,\n canonicalHeaders,\n signedHeaders,\n requestPayload,\n ].join('\\n')\n\n return canonicalRequest\n}\n\n/**\n * Creates the (canonical) URI-encoded version of the\n * absolute path component of the URI: everything in the URI\n * from the HTTP host to the question mark character (\"?\")\n * that begins the query string parameters (if any).\n *\n * @param {string} uri - URI to canonize\n * @param {URIEncodingConfig} - URI encoding configuration\n * @return {string} - canonical URL\n */\nexport function createCanonicalURI(uri: string, URIencodingConfig: URIEncodingConfig): string {\n if (uri == '/') {\n return uri\n }\n\n let canonicalURI = uri\n if (uri[uri.length - 1] == '/' && canonicalURI[canonicalURI.length - 1] != '/') {\n canonicalURI += '/'\n }\n\n canonicalURI = URIEncode(canonicalURI, URIencodingConfig.path)\n\n return URIencodingConfig.double ? URIEncode(canonicalURI, URIencodingConfig.path) : canonicalURI\n}\n\n/**\n * Creates the canonical form of the request's query\n * string. If the request does not include a query string,\n * provide an empty string.\n *\n * @param {String | Object} qs - query string to canonize\n * @return {string}\n */\nexport function createCanonicalQueryString(qs: string): string {\n if (qs === '') {\n return ''\n }\n\n // const intermediary: { [key: string]: string } = parseQueryString(qs)\n\n // return Object.keys(intermediary)\n // .sort()\n // .map((key: string) => {\n // // const values: string[] = Array.isArray(intermediary[key])\n // // ? intermediary[key]\n // // : [intermediary[key]]\n // const values = intermediary[key]\n\n // return values\n // .sort()\n // .map((val: string) => encodeURIComponent(key) + '=' + encodeURIComponent(val))\n // .join('&')\n // })\n // .join('&')\n\n return parseQueryString(qs)\n .map(([key, value]: [string, string]): string => {\n let uriComponent = encodeURIComponent(key) + '='\n if (value !== 'undefined') {\n uriComponent += encodeURIComponent(value)\n }\n\n return uriComponent\n })\n .join('&')\n}\n\n/**\n * Create the canonical form of the request's headers.\n * Canonical headers consist of all the HTTP headers you\n * are including with the signed request.\n *\n * Note that:\n * * for HTTP/1.1 requests, the headers should at least\n * contain the `host` header.\n * * for HTTP/2, the `:authority` header must be used instead\n * of `host`.\n *\n * @param {Object} headers\n * @return {string}\n */\nexport function createCanonicalHeaders(headers: HTTPHeaders) {\n if (headers.constructor !== Object || Object.entries(headers).length === 0) {\n return ''\n }\n\n const canonicalHeaders = Object.entries(headers)\n .map(([name, values]) => {\n const canonicalName = name.toLowerCase().trim()\n const normalizedValues = Array.isArray(values) ? values : [values]\n\n // Note that we do not need to sort values\n const canonicalValues = normalizedValues\n .map((v) => {\n // convert sequential spaces to a single space\n return v.replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n })\n .join(',') // standard for multiple values in a HTTP header\n\n return canonicalName + ':' + canonicalValues + '\\n'\n })\n .sort()\n .join('')\n\n return canonicalHeaders\n}\n\n/**\n * Create the canonical request's signed headers.\n *\n * The signed headers part of the request contains the\n * list of headers included in the request's signing process.\n *\n * Note that:\n * * for HTTP/1.1 requests, the `host` header must be included.\n * * for HTTP/2 requests, the `:authority` header must be included instead\n * of host.\n * * if used, the `x-amz-date` header must be included.\n *\n * @param {Object} headers\n * @return {string}\n * @throws {TypeError} - on headers not being an Object, or being empty.\n */\nexport function createSignedHeaders(headers: { [key: string]: string }) {\n if (headers.constructor !== Object) {\n throw new TypeError('headers should be an object')\n }\n\n if (Object.entries(headers).length === 0) {\n throw 'headers should at least contain either the Host (HTTP 1.1) or :authority (HTTP 2) parameter'\n }\n\n // To create the signed headers list, convert\n // all header names to lowercase, sort them by\n // character code, and use a semicolon to separate\n // the header names.\n const result = Object.keys(headers)\n .map((name) => name.toLowerCase().trim())\n .sort()\n .join(';')\n\n return result\n}\n\n/**\n * Create the canonical form of the request's payload.\n *\n * The canonical payload consists in a lowercased, hex encoded,\n * SHA256 hash of the requests body/payload.\n *\n * Certain services, such as S3, allow for unsigned payload. If\n * producing a signed canonical request for such service, pass\n * the `UnsignedPayload` constant value as the payload parameter.\n *\n * @param {String | ArrayBuffer} payload\n * @return {string}\n */\nexport function createCanonicalPayload(payload: string | ArrayBuffer) {\n if (payload === UnsignedPayload) {\n return payload\n }\n\n // Note that if the paylaod is null, we convert it\n // to an empty string.\n // TODO: Should switching to empty string if null impact headers?\n return crypto.sha256(payload || '', 'hex').toLowerCase()\n}\n\n/**\n * URIEncodes encodes every bytes of a URI to be URL-safe.\n *\n * This implementation is specific to AWS; who intended to make it as\n * close as possible to the underlying RFC 3946. It:\n * * URI encode every byte except the unreserved characters: 'A'-'Z', 'a'-'z', '0'-'9',\n * '-', '.', '_', and '~'.\n * * considers the space character as a reserved character and must URI encodes\n * encodes it as \"%20\" (and not as \"+\").\n * * URI encodes every byte by prefixing with '%' the two-digit hexadecimal value of the byte.\n * * If the `path` argument is set, forward slashes are not encoded, to fit with\n * S3 requirements.\n *\n * N.B: this implementation differs with ES6' mainly in that it does\n * encode the \"'\" character.\n *\n * Based on AWS implementation: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/util/SdkHttpUtils.java#L66\n * Encoding specs: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n *\n * @param {string} uri - uri to encode\n * @param {boolean} path - slash characters should be encoded everywhere,\n * but in paths, set to false when encoding a path\n * @return {string} the URI encoded result\n */\nexport function URIEncode(uri: string, path: boolean): string {\n if (uri == '') {\n return uri\n }\n\n return uri\n .split('') // to be able to map over a string, because... javascript...\n .map((letter: string) => {\n if (isAlpha(letter) || isNumeric(letter) || '-._~'.includes(letter)) {\n return letter\n }\n\n // Space should be explicitly encoded to as %20.\n if (letter == ' ') {\n return '%20'\n }\n\n // If the URI is a path, the forward slash shouldn't\n // be encoded.\n if (letter == '/' && path) {\n return '/'\n }\n\n return '%' + letter.charCodeAt(0).toString(16).toUpperCase()\n })\n .join('')\n}\n\n/**\n * Class holding URI encoding configuration\n */\nexport class URIEncodingConfig {\n double: boolean\n path: boolean\n\n /**\n *\n * @param {boolean} double - should the URI be double encoded?\n * @param {boolean} path - is the URI a path? If so, its forward\n * slashes won't be URIencoded.\n */\n constructor(double: boolean, path: boolean) {\n this.double = double\n this.path = path\n }\n}\n\n/**\n * Compute the request time value as specified by the ISO8601\n * format: YYYYMMDD'T'HHMMSS'Z'\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toTime(timestamp: number): string {\n return new Date(timestamp).toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n}\n/**\n * Computethe request date value in the format: YYYMMDD\n *\n * @param {number} timestamp\n * @return {string}\n */\nexport function toDate(timestamp: number): string {\n return toTime(timestamp).substring(0, 8)\n}\n\n/**\n * Parse a HTTP request URL's querystring into an object\n * containing its `key=value` pairs.\n *\n * @param {string} qs\n * @return {object}\n */\nexport function parseQueryString(qs: string): Array<[string, string]> {\n if (qs.length === 0) {\n return []\n }\n\n return qs\n .split('&')\n .filter((e) => e)\n .map((v: string): [string, string] => {\n const parts = v.split('=', 2) as [string, string]\n const key = decodeURIComponent(parts[0])\n let value = decodeURIComponent(parts[1])\n if (value === 'undefined') {\n value = ''\n }\n return [key, value]\n })\n .sort((a: [string, string], b: [string, string]) => {\n return a[0].localeCompare(b[0])\n })\n}\n\nfunction isAlpha(c: string): boolean {\n return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')\n}\n\nfunction isNumeric(c: string): boolean {\n return c >= '0' && c <= '9'\n}\n\n// FIXME: finish implementation when needed\n// See the following for more details:\n// * https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n// * https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html\n// export function signQueryString(\n// queryString,\n// requestTimestamp,\n// accessKeyID,\n// secretAccessKey,\n// region,\n// service,\n// ttl, // in seconds\n// headers,\n// doubleURIEncoding = true\n// ) {\n// const credential = [accessKeyID, toDate(requestTimestamp), region, service].join('/')\n//\n// const canonicalRequest = createCanonicalRequest(\n// method,\n// path,\n// queryString,\n// headers,\n// body,\n// doubleURIEncoding\n// )\n//\n// const derivedSigningKey = deriveSigningKey(secretAccessKey, requestTimestamp, region, service)\n//\n// const stringToSign = createStringToSign(\n// requestTimestamp,\n// region,\n// service,\n// sha256(canonicalRequest, 'hex')\n// )\n//\n// const signedHeaders = createSignedHeaders(headers)\n// const signature = calculateSignature(derivedSigningKey, stringToSign)\n//\n// return [\n// `X-Amz-Algorithm=${HashingAlgorithm}`,\n// `X-Amz-Credential=${crediental}`,\n// `X-Amz-Date=${toTime(requestTimestamp)}`,\n// `X-Amz-Expires=${ttl}`,\n// `X-Amz-SignedHeaders=${signedHeaders}`,\n// `X-Amz-Signature=${signature}`,\n//`X-Amz-Security-Token=`, // TODO: optional\n// ].join('&')\n// }\n","import { HTTPScheme } from './http'\n\n/** Class holding an AWS connection information */\nexport class AWSConfig {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyID: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme} ['https']\n */\n scheme: HTTPScheme = 'https'\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string} ['amazonaws.com']\n */\n endpoint: string = 'amazonaws.com'\n\n /**\n * Create an AWSConfig.\n *\n * @param {AWSConfigOptions} options - configuration attributes to use when interacting with AWS' APIs\n * @throws {InvalidArgumentException}\n */\n constructor(options: AWSConfigOptions) {\n if (options.region === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS region; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS access key ID; reason: should be a non empty string'\n )\n }\n\n if (options.accessKeyId.length < 16 || options.accessKeyId.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ${options.accessKeyId.length}`\n )\n }\n\n if (options.secretAccessKey === '') {\n throw new InvalidAWSConfigError(\n 'invalid AWS secret access key; reason: should be a non empty string'\n )\n }\n\n if (options.secretAccessKey.length < 16 || options.secretAccessKey.length > 128) {\n throw new InvalidAWSConfigError(\n `invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ${options.secretAccessKey.length}`\n )\n }\n\n this.region = options.region\n this.accessKeyID = options.accessKeyId\n this.secretAccessKey = options.secretAccessKey\n\n if (options.sessionToken !== undefined) {\n this.sessionToken = options.sessionToken\n }\n\n if (options.scheme !== undefined) {\n this.scheme = options.scheme\n }\n\n if (options.endpoint !== undefined) {\n this.endpoint = options.endpoint\n }\n }\n}\n\n/**\n * Interface representing AWSConfig options\n */\nexport interface AWSConfigOptions {\n /**\n * The AWS region to connect to, as listed: https://docs.aws.amazon.com/general/latest/gr/rande.html\n *\n * @type {string}\n */\n region: string\n\n /**\n * Your user's AWS access key id credential.\n *\n * @type {string}\n */\n accessKeyId: string\n\n /**\n * Your user's AWS secret access key credential.\n *\n * @type {string}\n */\n secretAccessKey: string\n\n /**\n * Your user's AWS session token credential.\n *\n * @type {string}\n */\n sessionToken?: string\n\n /**\n * The HTTP scheme to use when connecting to AWS.\n *\n * @type {HTTPScheme}\n */\n scheme?: HTTPScheme\n\n /**\n * The AWS hostname to connect to.\n *\n * @type {string}\n */\n endpoint?: string\n}\n\n/** Class representing an invalid AWS configuration */\nexport class InvalidAWSConfigError extends Error {\n constructor(message: string) {\n super(message)\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient, AWSRequest } from './client'\nimport { AWSError } from './error'\nimport { AWSConfig } from './config'\nimport { InvalidSignatureError, URIEncodingConfig } from './signature'\nimport { HTTPMethod, HTTPHeaders } from './http'\n\n/**\n * Class allowing to interact with Amazon AWS's Systems Manager service\n */\nexport class SystemsManagerClient extends AWSClient {\n method: HTTPMethod\n commonHeaders: HTTPHeaders\n\n /**\n * Create a SystemsManagerClient\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n */\n constructor(awsConfig: AWSConfig) {\n const URIencodingConfig = new URIEncodingConfig(true, false)\n super(awsConfig, 'ssm', URIencodingConfig)\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Accept-Encoding': 'identity',\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n }\n\n /**\n * Retrieves a parameter from Amazon Systems Manager\n *\n * @param {string} name - The ARN or name of the parameter to retrieve.\n * @param {boolean} withDecryption - whether returned secure string parameters should be decrypted.\n * @returns {SystemsManagerParameter} - returns the fetched Parameter object.\n * @throws {SystemsManagerServiceError}\n * @throws {InvalidSignatureError}\n */\n getParameter(\n name: string,\n withDecryption: boolean = false\n ): SystemsManagerParameter | undefined {\n const body = JSON.stringify({ Name: name, WithDecryption: withDecryption })\n\n // Ensure to include the desired 'Action' in the X-Amz-Target\n // header field, as documented by the AWS API docs.\n const signedRequest: AWSRequest = super.buildRequest(\n this.method,\n this.host,\n '/',\n '',\n body,\n {\n ...this.commonHeaders,\n 'X-Amz-Target': `AmazonSSM.GetParameter`,\n }\n )\n\n const res = http.request(this.method, signedRequest.url, body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SystemsManagerOperation.GetParameter, res);\n\n return SystemsManagerParameter.fromJSON(res.json() as JSONObject)\n }\n\n _handle_error(\n operation: SystemsManagerOperation,\n response: RefinedResponse\n ) {\n const errorCode = response.error_code\n if (errorCode === 0) {\n return\n }\n\n const error = response.json() as JSONObject\n if (errorCode >= 1400 && errorCode <= 1499) {\n // In the event of certain errors, the message is not set.\n // Also, note the inconsistency in casing...\n const errorMessage: string =\n (error.Message as string) || (error.message as string) || (error.__type as string)\n\n // Handle specifically the case of an invalid signature\n if (error.__type === 'InvalidSignatureException') {\n throw new InvalidSignatureError(errorMessage, error.__type)\n }\n\n // Otherwise throw a standard service error\n throw new SystemsManagerServiceError(errorMessage, error.__type as string, operation)\n }\n\n if (errorCode === 1500) {\n throw new SystemsManagerServiceError(\n 'An error occured on the server side',\n 'InternalServiceError',\n operation\n )\n }\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter\n */\nexport class SystemsManagerParameter {\n parameter: SystemsManagerParameterItem\n\n /**\n * Constructs a Systems Manager's Parameter\n *\n * @param {JSONObject} parameter - The response object content for the AWS System Manager.\n */\n constructor(parameter: JSONObject) {\n this.parameter = SystemsManagerParameterItem.fromJSON(parameter)\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameter}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameter {\n return new SystemsManagerParameter(json.Parameter as JSONObject)\n }\n}\n\n/**\n * Class representing a Systems Manager's Parameter Object content\n */\nclass SystemsManagerParameterItem {\n arn: string\n dataType: string\n lastModifiedDate: number\n name: string\n selector: string\n sourceResult: string\n type: string\n value: string\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter object contents\n *\n * @param {string} arn - The Amazon Resource Name (ARN) of the parameter.\n * @param {string} dataType - The data type of the parameter, such as text or aws:ec2:image. The default is text.\n * @param {number} lastModifiedDate - Date the parameter was last changed or updated and the parameter version was created.\n * @param {string} name - The friendly name of the parameter.\n * @param {string} selector - Either the version number or the label used to retrieve the parameter value. Specify selectors by using one of the following formats:\n * parameter_name:version\n * parameter_name:label\n * @param {string} sourceResult - Applies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n * @param {string} type - The type of parameter. Valid values include the following: String, StringList, and SecureString.\n * @param {string} value - The parameter value.\n * @param {number} version - The parameter version.\n */\n constructor(\n arn: string,\n dataType: string,\n lastModifiedDate: number,\n name: string,\n selector: string,\n sourceResult: string,\n type: string,\n value: string,\n version: number\n ) {\n this.arn = arn\n this.dataType = dataType\n this.lastModifiedDate = lastModifiedDate\n this.name = name\n this.selector = selector\n this.sourceResult = sourceResult\n this.type = type\n this.value = value\n this.version = version\n }\n\n /**\n * Parses and constructs a Systems Manager's Parameter object from the content\n * of a JSON response returned by the AWS service\n *\n * @param {Object} json - JSON object as returned and parsed from\n * the AWS service's API call.\n * @returns {SystemsManagerParameterItem}\n */\n static fromJSON(json: JSONObject): SystemsManagerParameterItem {\n return new SystemsManagerParameterItem(\n json.ARN as string,\n json.DataType as string,\n json.LastModifiedDate as number,\n json.Name as string,\n json.Selector as string,\n json.SourceResult as string,\n json.Type as string,\n json.Value as string,\n json.Version as number\n )\n }\n}\n\nexport class SystemsManagerServiceError extends AWSError {\n operation: SystemsManagerOperation\n\n /**\n * Constructs a SystemsManagerServiceError\n *\n * @param {string} message - human readable error message\n * @param {string} code - A unique short code representing the error that was emitted\n * @param {SystemsManagerOperation} operation - Name of the failed Operation\n */\n constructor(message: string, code: string, operation: SystemsManagerOperation) {\n super(message, code)\n this.name = 'SystemsManagerServiceError'\n this.operation = operation\n }\n}\n\n/**\n * SystemsManagerOperation defines all currently implemented Systems Manager operations.\n */\nenum SystemsManagerOperation {\n GetParameter = 'GetParameter',\n}\n","import { HTTPMethod, HTTPHeaders } from './http'\nimport { AWSConfig } from './config'\nimport { signHeaders, URIEncodingConfig, toTime } from './signature'\n\n/**\n * Class allowing to build requests targeting AWS APIs\n *\n * This class is meant to be used as a base class for specific\n * services clients. See S3Client or SecretsManagerClient for\n * usage examples.\n */\nexport class AWSClient {\n awsConfig: AWSConfig\n serviceName: string\n URIencodingConfig: URIEncodingConfig\n\n /**\n * @param {AWSConfig} awsConfig - configuration attributes to use when interacting with AWS' APIs\n * @param {string} serviceName - name of the service to target.\n * @param {URIEncodingConfig} URIencodingConfig - configures how requests URIs should be encoded.\n */\n constructor(awsConfig: AWSConfig, serviceName: string, URIencodingConfig: URIEncodingConfig) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\n this.URIencodingConfig = URIencodingConfig\n }\n\n buildRequest(\n method: HTTPMethod,\n host: string,\n path: string,\n queryString: string,\n body: string | ArrayBuffer,\n headers: HTTPHeaders\n ): AWSRequest {\n const requestTimestamp: number = Date.now()\n const date: string = toTime(requestTimestamp)\n\n headers['Host'] = host\n headers['X-Amz-Date'] = date\n\n headers = signHeaders(\n // headers\n headers,\n\n // requestTimestamp\n requestTimestamp,\n\n // method\n method,\n\n // path\n path,\n\n // querystring\n queryString,\n\n // body\n body,\n\n // AWS configuration\n this.awsConfig,\n\n // AwS target service name\n this.serviceName,\n\n // doubleEncoding: S3 does single-encoding of the uri component\n // pathURIEncoding: S3 manipulates object keys, and forward slashes\n // shouldn't be URI encoded\n this.URIencodingConfig\n )\n\n // '?' should not be part of the querystring when we sign the headers\n path = path !== '' ? path : '/'\n let url = `${this.awsConfig.scheme}://${host}${path}`\n if (queryString !== '') {\n url += `?${queryString}`\n }\n\n return { url: url, headers: headers }\n }\n\n /**\n * Property computing the URL to send the requests to when interacting with\n * the specific AWS service the child class implements the functionalities of.\n */\n get host() {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n}\n\n/**\n * Type alias representing the result of an AWSClient.buildRequest call\n */\nexport interface AWSRequest {\n url: string\n headers: HTTPHeaders\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","signHeaders","headers","requestTimestamp","method","path","queryString","body","awsConfig","service","URIencodingConfig","sessionToken","derivedSigningKey","secretAccessKey","time","region","kSecret","date","toDate","kDate","hmac","kRegion","kService","deriveSigningKey","canonicalRequest","uri","query","payload","httpRequestMethod","toUpperCase","canonicalURI","length","URIEncode","createCanonicalURI","canonicalQueryString","qs","split","filter","e","map","v","parts","decodeURIComponent","sort","b","localeCompare","parseQueryString","uriComponent","encodeURIComponent","join","createCanonicalQueryString","canonicalHeaders","constructor","entries","values","toLowerCase","trim","Array","isArray","replace","createCanonicalHeaders","signedHeaders","createSignedHeaders","requestPayload","UnsignedPayload","crypto","createCanonicalPayload","createCanonicalRequest","stringToSign","hashedCanonicalRequest","requestDateTime","toTime","credentialScope","createCredentialScope","HashingAlgorithm","createStringToSign","sha256","signature","calculateSignature","authorizationHeader","accessKeyID","InvalidSignatureError","TypeError","keys","letter","c","isNumeric","includes","charCodeAt","toString","URIEncodingConfig","double","this","timestamp","Date","toISOString","substring","AWSConfig","options","InvalidAWSConfigError","accessKeyId","undefined","scheme","endpoint","SystemsManagerOperation","SystemsManagerClient","commonHeaders","withDecryption","JSON","stringify","Name","WithDecryption","signedRequest","host","res","http","url","_handle_error","GetParameter","SystemsManagerParameter","fromJSON","json","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SystemsManagerServiceError","serviceName","now","parameter","SystemsManagerParameterItem","Parameter","arn","dataType","lastModifiedDate","selector","sourceResult","type","version","ARN","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file