diff --git a/build/_signature.min.js b/build/_signature.min.js deleted file mode 100644 index e332dd6..0000000 --- a/build/_signature.min.js +++ /dev/null @@ -1,2 +0,0 @@ -(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{HashingAlgorithm:()=>T,InvalidSignatureError:()=>C,URIEncode:()=>q,URIEncodingConfig:()=>B,UnsignedPayload:()=>E,calculateSignature:()=>A,createCanonicalHeaders:()=>k,createCanonicalPayload:()=>L,createCanonicalQueryString:()=>H,createCanonicalRequest:()=>M,createCanonicalURI:()=>U,createCredentialScope:()=>x,createSignedHeaders:()=>D,createStringToSign:()=>I,deriveSigningKey:()=>R,parseQueryString:()=>W,signHeaders:()=>_,toDate:()=>K,toTime:()=>z});const r=require("k6/crypto");var n=e.n(r);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function u(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r="A"&&r<="Z"||r>="a"&&r<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var r})).join("")}var B=g((function e(t,r){j(this,e),d(this,"double",void 0),d(this,"path",void 0),this.double=t,this.path=r}));function z(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function K(e){return z(e).substring(0,8)}function W(e){return 0===e.length?[]:e.split("&").filter((function(e){return e})).map((function(e){var t=e.split("=",2),r=decodeURIComponent(t[0]),n=decodeURIComponent(t[1]);return"undefined"===n&&(n=""),[r,n]})).sort((function(e,t){return e[0].localeCompare(t[0])}))}var F=exports;for(var N in t)F[N]=t[N];t.__esModule&&Object.defineProperty(F,"__esModule",{value:!0})})(); -//# sourceMappingURL=_signature.min.js.map \ No newline at end of file diff --git a/build/_signature.min.js.map b/build/_signature.min.js.map deleted file mode 100644 index 88dd857..0000000 --- a/build/_signature.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"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,EACAK,EAAUO,OACVN,GAGEO,EAAmBC,EACrBb,EAC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,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 /**\n * Error code issued by the service (if any)\n */\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 b/build/aws.min.js index c86a026..036b0a4 100644 --- a/build/aws.min.js +++ b/build/aws.min.js @@ -1,2 +1,2 @@ -(()=>{var e={877:(e,t,r)=>{var n=r(570),o=r(171),i=o;i.v1=n,i.v4=o,e.exports=i},327:e=>{for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);e.exports=function(e,r){var n=r||0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var r=new Uint8Array(16);e.exports=function(){return t(r),r}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},570:(e,t,r)=>{var n,o,i=r(217),c=r(327),a=0,u=0;e.exports=function(e,t,r){var s=t&&r||0,f=t||[],l=(e=e||{}).node||n,p=void 0!==e.clockseq?e.clockseq:o;if(null==l||null==p){var y=i();null==l&&(l=n=[1|y[0],y[1],y[2],y[3],y[4],y[5]]),null==p&&(p=o=16383&(y[6]<<8|y[7]))}var h=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:u+1,b=h-a+(d-u)/1e4;if(b<0&&void 0===e.clockseq&&(p=p+1&16383),(b<0||h>a)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=h,u=d,o=p;var v=(1e4*(268435455&(h+=122192928e5))+d)%4294967296;f[s++]=v>>>24&255,f[s++]=v>>>16&255,f[s++]=v>>>8&255,f[s++]=255&v;var m=h/4294967296*1e4&268435455;f[s++]=m>>>8&255,f[s++]=255&m,f[s++]=m>>>24&15|16,f[s++]=m>>>16&255,f[s++]=p>>>8|128,f[s++]=255&p;for(var g=0;g<6;++g)f[s+g]=l[g];return t||c(f)}},171:(e,t,r)=>{var n=r(217),o=r(327);e.exports=function(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var c=(e=e||{}).random||(e.rng||n)();if(c[6]=15&c[6]|64,c[8]=63&c[8]|128,t)for(var a=0;a<16;++a)t[i+a]=c[a];return t||o(c)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{AWSConfig:()=>U,InvalidAWSConfigError:()=>W,InvalidSignatureError:()=>T,KMSClient:()=>et,KMSDataKey:()=>rt,KMSServiceError:()=>nt,S3Bucket:()=>he,S3Client:()=>ye,S3Object:()=>de,S3ServiceError:()=>be,Secret:()=>Me,SecretsManagerClient:()=>Ie,SecretsManagerServiceError:()=>Ne,SystemsManagerClient:()=>Ot,SystemsManagerParameter:()=>wt,SystemsManagerServiceError:()=>St,URIEncodingConfig:()=>x,signHeaders:()=>R});const e=require("k6/crypto");var t=r.n(e);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r="A"&&r<="Z"||r>="a"&&r<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var r})).join("")}var x=O((function e(t,r){w(this,e),b(this,"double",void 0),b(this,"path",void 0),this.double=t,this.path=r}));function I(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function M(e){return I(e).substring(0,8)}function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}function q(e,t){if(t&&("object"===N(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function K(e){var t="function"==typeof Map?new Map:void 0;return K=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return z(e,arguments,B(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)},K(e)}function z(e,t,r){return z=H()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&L(o,r.prototype),o},z.apply(null,arguments)}function H(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function L(e,t){return L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},L(e,t)}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},B(e)}function G(e,t){for(var r=0;r128)throw new W("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new W("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new W("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),W=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&L(e,t)}(o,e);var t,r,n=(t=o,r=H(),function(){var e,n=B(t);if(r){var o=B(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return q(this,e)});function o(e){return X(this,o),n.call(this,e)}return J(o)}(K(Error));const F=require("k6/http");var $=r.n(F);function Y(e,t){for(var r=0;r=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new T(o,n.__type);throw new Ne(o,n.__type,e)}if(1500===r)throw new Ne("An error occured on the server side","InternalServiceError",e)}}}]),r}(Q),Me=function(){function e(t,r,n,o,i,c){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[];we(this,e),De(this,"name",void 0),De(this,"arn",void 0),De(this,"secret",void 0),De(this,"createdDate",void 0),De(this,"lastAccessedDate",void 0),De(this,"lastChangedDate",void 0),De(this,"tags",void 0),this.name=t,this.arn=r,this.secret=n,this.createdDate=o,this.lastAccessedDate=i,this.lastChangedDate=c,this.tags=a}return je(e,null,[{key:"fromJSON",value:function(t){return new e(t.Name,t.ARN,t.SecretString,t.CreatedDate,t.LastAccessedDate,t.LastChangedDate,t.Tags)}}]),e}(),Ne=function(e){Re(r,e);var t=Ee(r);function r(e,n,o){var i;return we(this,r),De(Ae(i=t.call(this,e,n)),"operation",void 0),i.name="SecretsManagerServiceError",i.operation=o,i}return je(r)}(h);function qe(e){return qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qe(e)}function Ke(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ze(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:Qe.Size256,n=JSON.stringify({KeyId:e,NumberOfBytes:t}),o=Ge($e(r.prototype),"buildRequest",this).call(this,this.method,this.host,"/","",n,ze(ze({},this.commonHeaders),{},{"X-Amz-Target":"TrentService.GenerateDataKey"})),i=$().request(this.method,o.url,n,{headers:o.headers});return this._handle_error(Ze.GenerateDataKey,i),rt.fromJSON(i.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new T(o,n.__type);throw new nt(o,n.__type,e)}if(1500===r)throw new nt("An error occured on the server side","InternalServiceError",e)}}}]),r}(Q),tt=function(){function e(t,r){He(this,e),Ye(this,"keyArn",void 0),Ye(this,"keyId",void 0),this.keyArn=t,this.keyId=r}return Be(e,null,[{key:"fromJSON",value:function(t){return new e(t.KeyArn,t.KeyId)}}]),e}(),rt=function(){function e(t,r,n){He(this,e),Ye(this,"id",void 0),Ye(this,"ciphertextBlob",void 0),Ye(this,"plaintext",void 0),this.ciphertextBlob=t,this.id=r,this.plaintext=n}return Be(e,null,[{key:"fromJSON",value:function(t){return new e(t.CiphertextBlob,t.KeyId,t.Plaintext)}}]),e}(),nt=function(e){Xe(r,e);var t=Ue(r);function r(e,n,o){var i;return He(this,r),Ye(Fe(i=t.call(this,e,n)),"operation",void 0),i.name="KMSServiceError",i.operation=o,i}return Be(r)}(h);function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function it(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ct(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1],n=JSON.stringify({Name:e,WithDecryption:t}),o=ft(vt(r.prototype),"buildRequest",this).call(this,this.method,this.host,"/","",n,ct(ct({},this.commonHeaders),{},{"X-Amz-Target":"AmazonSSM.GetParameter"})),i=$().request(this.method,o.url,n,{headers:o.headers});return this._handle_error(gt.GetParameter,i),wt.fromJSON(i.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new T(o,n.__type);throw new St(o,n.__type,e)}if(1500===r)throw new St("An error occured on the server side","InternalServiceError",e)}}}]),r}(Q),wt=function(){function e(t,r,n,o,i,c,a,u,s){at(this,e),mt(this,"arn",void 0),mt(this,"dataType",void 0),mt(this,"lastModifiedDate",void 0),mt(this,"name",void 0),mt(this,"selector",void 0),mt(this,"sourceResult",void 0),mt(this,"type",void 0),mt(this,"value",void 0),mt(this,"version",void 0),this.arn=t,this.dataType=r,this.lastModifiedDate=n,this.name=o,this.selector=i,this.sourceResult=c,this.type=a,this.value=u,this.version=s}return st(e,null,[{key:"fromJSON",value:function(t){var r=t.Parameter;return new e(r.ARN,r.DataType,r.LastModifiedDate,r.Name,r.Selector,r.SourceResult,r.Type,r.Value,r.Version)}}]),e}(),St=function(e){pt(r,e);var t=ht(r);function r(e,n,o){var i;return at(this,r),mt(bt(i=t.call(this,e,n)),"operation",void 0),i.name="SystemsManagerServiceError",i.operation=o,i}return st(r)}(h);!function(e){e.GetParameter="GetParameter"}(gt||(gt={}))})();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); +(()=>{var e={877:(e,t,r)=>{var n=r(570),o=r(171),i=o;i.v1=n,i.v4=o,e.exports=i},327:e=>{for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);e.exports=function(e,r){var n=r||0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var r=new Uint8Array(16);e.exports=function(){return t(r),r}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},570:(e,t,r)=>{var n,o,i=r(217),a=r(327),c=0,s=0;e.exports=function(e,t,r){var u=t&&r||0,f=t||[],l=(e=e||{}).node||n,h=void 0!==e.clockseq?e.clockseq:o;if(null==l||null==h){var y=i();null==l&&(l=n=[1|y[0],y[1],y[2],y[3],y[4],y[5]]),null==h&&(h=o=16383&(y[6]<<8|y[7]))}var p=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:s+1,v=p-c+(d-s)/1e4;if(v<0&&void 0===e.clockseq&&(h=h+1&16383),(v<0||p>c)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=p,s=d,o=h;var b=(1e4*(268435455&(p+=122192928e5))+d)%4294967296;f[u++]=b>>>24&255,f[u++]=b>>>16&255,f[u++]=b>>>8&255,f[u++]=255&b;var m=p/4294967296*1e4&268435455;f[u++]=m>>>8&255,f[u++]=255&m,f[u++]=m>>>24&15|16,f[u++]=m>>>16&255,f[u++]=h>>>8|128,f[u++]=255&h;for(var g=0;g<6;++g)f[u+g]=l[g];return t||a(f)}},171:(e,t,r)=>{var n=r(217),o=r(327);e.exports=function(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||n)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var c=0;c<16;++c)t[i+c]=a[c];return t||o(a)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{AMZ_CONTENT_SHA256_HEADER:()=>c,AWSConfig:()=>ie,InvalidAWSConfigError:()=>ae,InvalidSignatureError:()=>V,KMSClient:()=>Ce,KMSDataKey:()=>Ee,KMSServiceError:()=>Ae,S3Bucket:()=>Ge,S3Client:()=>Be,S3Object:()=>Je,S3ServiceError:()=>Ve,Secret:()=>st,SecretsManagerClient:()=>ct,SecretsManagerServiceError:()=>ut,SignatureV4:()=>J,SystemsManagerClient:()=>Pt,SystemsManagerParameter:()=>_t,SystemsManagerServiceError:()=>kt,UNSIGNED_PAYLOAD:()=>g});const e=require("k6/crypto");var t=r.n(e),o="X-Amz-Date",i="X-Amz-Signature",a="X-Amz-Security-Token",c="x-amz-content-sha256",s=o.toLowerCase(),u=i.toLowerCase(),f="X-Amz-Target".toLowerCase(),l=a.toLowerCase(),h="authorization",y=[h,s,"date"],p={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},d="aws4_request",v="AWS4-HMAC-SHA256",b=604800,m="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",g="UNSIGNED-PAYLOAD";const w=require("k6/html");function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function S(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[C]}e.headers[s]=w,this.credentials.sessionToken&&(e.headers[l]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var D=m;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,c=t.unsignableHeaders,s=t.unhoistableHeaders,u=t.signableHeaders,f=t.signingRegion,l=t.signingService,h=X(n),y=h.longDate,p=h.shortDate,m=f||this.region,g=l||this.service;if(i>b)throw new V("Signature version 4 presigned URLs can't be valid for more than 7 days");var w="".concat(p,"/").concat(m,"/").concat(g,"/").concat(d),O=this.moveHeadersToQuery(e,{unhoistableHeaders:s});O.headers.host=e.hostname,this.credentials.sessionToken&&(O.query[a]=this.credentials.sessionToken),O.query["X-Amz-Algorithm"]=v,O.query["X-Amz-Credential"]="".concat(this.credentials.accessKeyId,"/").concat(w),O.query["X-Amz-Date"]=y,O.query["X-Amz-Expires"]=i.toString(10);var S=this.computeCanonicalHeaders(O,c,u);O.query["X-Amz-SignedHeaders"]=Object.keys(S).sort().join(";");var j=this.deriveSigningKey(this.credentials,g,m,p),P=this.computePayloadHash(e),_=this.createCanonicalRequest(O,S,P);O.query["X-Amz-Signature"]=this.calculateSignature(y,w,j,_);var k="".concat(O.protocol,"://").concat(O.hostname);return O.path&&(k+=O.path),O.query&&(k+="?".concat(this.serializeQueryParameters(O.query))),L({url:k},O)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,r,n){var o=t().sha256(n,"hex");return"".concat(v,"\n")+"".concat(e,"\n")+"".concat(r,"\n")+"".concat(o)}},{key:"calculateSignature",value:function(e,r,n,o){var i=this.createStringToSign(e,r,o);return t().hmac("sha256",n,i,"hex")}},{key:"deriveSigningKey",value:function(e,r,n,o){var i=e.secretAccessKey,a=t().hmac("sha256","AWS4"+i,o,"binary"),c=t().hmac("sha256",a,n,"binary"),s=t().hmac("sha256",c,r,"binary");return t().hmac("sha256",s,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=I(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var a=null!=t&&t.startsWith("/")?"/":"",c=n.join("/"),s=n.length>0&&null!=t&&t.endsWith("/")?"/":"",u="".concat(a).concat(c).concat(s);return encodeURIComponent(u).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},a=function(e){if(e.toLowerCase()===u)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(W(e),"=").concat(W(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(W(e),"=").concat(W(r))])}),[]).join("&"))},c=I(Object.keys(n).sort());try{for(c.s();!(t=c.n()).done;)a(t.value)}catch(e){c.e(e)}finally{c.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},a=I(Object.keys(o).sort());try{for(a.s();!(n=a.n()).done;){var c=n.value;if(null!=o[c]){var s=c.toLowerCase();(s in p||null!=t&&t.has(s))&&(!r||r&&!r.has(s))||(i[s]=o[c].trim().replace(/\s+/g," "))}}}catch(e){a.e(e)}finally{a.f()}return i}},{key:"computePayloadHash",value:function(e){for(var r,n=e.headers,o=e.body,i=0,a=Object.keys(n);i1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,a=0,c=Object.keys(n);a128)throw new ae("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new ae("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new ae("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),ae=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&$(e,t)}(o,e);var t,r,n=(t=o,r=Y(),function(){var e,n=ee(t);if(r){var o=ee(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return F(this,e)});function o(e){return ne(this,o),n.call(this,e)}return re(o)}(Q(Error));const ce=require("k6/http");var se=r.n(ce);function ue(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:ke.Size256,r=this.signature.sign({method:this.method,protocol:this.awsConfig.scheme,hostname:this.host,path:"/",headers:pe(pe({},this.commonHeaders),{},Pe({},f,"TrentService.GenerateDataKey")),body:JSON.stringify({KeyId:e,NumberOfBytes:t})},{}),n=se().request(this.method,r.url,r.body,{headers:r.headers});return this._handle_error(_e.GenerateDataKey,n),Ee.fromJSON(n.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new V(o,n.__type);throw new Ae(o,n.__type,e)}if(1500===r)throw new Ae("An error occured on the server side","InternalServiceError",e)}}}]),r}(le),De=function(){function e(t,r){de(this,e),Pe(this,"keyArn",void 0),Pe(this,"keyId",void 0),this.keyArn=t,this.keyId=r}return be(e,null,[{key:"fromJSON",value:function(t){return new e(t.KeyArn,t.KeyId)}}]),e}(),Ee=function(){function e(t,r,n){de(this,e),Pe(this,"id",void 0),Pe(this,"ciphertextBlob",void 0),Pe(this,"plaintext",void 0),this.ciphertextBlob=t,this.id=r,this.plaintext=n}return be(e,null,[{key:"fromJSON",value:function(t){return new e(t.CiphertextBlob,t.KeyId,t.Plaintext)}}]),e}(),Ae=function(e){me(r,e);var t=we(r);function r(e,n,o){var i;return de(this,r),Pe(Se(i=t.call(this,e,n)),"operation",void 0),i.name="KMSServiceError",i.operation=o,i}return be(r)}(A);function Te(e){return Te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Te(e)}function Re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function xe(e,t){for(var r=0;r=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new V(o,n.__type);throw new ut(o,n.__type,e)}if(1500===r)throw new ut("An error occured on the server side","InternalServiceError",e)}}}]),r}(le),st=function(){function e(t,r,n,o,i,a){var c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[];Qe(this,e),it(this,"name",void 0),it(this,"arn",void 0),it(this,"secret",void 0),it(this,"createdDate",void 0),it(this,"lastAccessedDate",void 0),it(this,"lastChangedDate",void 0),it(this,"tags",void 0),this.name=t,this.arn=r,this.secret=n,this.createdDate=o,this.lastAccessedDate=i,this.lastChangedDate=a,this.tags=c}return Ye(e,null,[{key:"fromJSON",value:function(t){return new e(t.Name,t.ARN,t.SecretString,t.CreatedDate,t.LastAccessedDate,t.LastChangedDate,t.Tags)}}]),e}(),ut=function(e){$e(r,e);var t=tt(r);function r(e,n,o){var i;return Qe(this,r),it(nt(i=t.call(this,e,n)),"operation",void 0),i.name="SecretsManagerServiceError",i.operation=o,i}return Ye(r)}(A);function ft(e){return ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ft(e)}function lt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ht(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1],r=this.signature.sign({method:this.method,protocol:this.awsConfig.scheme,hostname:this.host,path:"/",headers:ht(ht({},this.commonHeaders),{},St({},f,"AmazonSSM.GetParameter")),body:JSON.stringify({Name:e,WithDecryption:t})},{}),n=se().request(this.method,r.url,r.body,{headers:r.headers});return this._handle_error(jt.GetParameter,n),_t.fromJSON(n.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new V(o,n.__type);throw new kt(o,n.__type,e)}if(1500===r)throw new kt("An error occured on the server side","InternalServiceError",e)}}}]),r}(le),_t=function(){function e(t,r,n,o,i,a,c,s,u){yt(this,e),St(this,"arn",void 0),St(this,"dataType",void 0),St(this,"lastModifiedDate",void 0),St(this,"name",void 0),St(this,"selector",void 0),St(this,"sourceResult",void 0),St(this,"type",void 0),St(this,"value",void 0),St(this,"version",void 0),this.arn=t,this.dataType=r,this.lastModifiedDate=n,this.name=o,this.selector=i,this.sourceResult=a,this.type=c,this.value=s,this.version=u}return dt(e,null,[{key:"fromJSON",value:function(t){var r=t.Parameter;return new e(r.ARN,r.DataType,r.LastModifiedDate,r.Name,r.Selector,r.SourceResult,r.Type,r.Value,r.Version)}}]),e}(),kt=function(e){vt(r,e);var t=mt(r);function r(e,n,o){var i;return yt(this,r),St(wt(i=t.call(this,e,n)),"operation",void 0),i.name="SystemsManagerServiceError",i.operation=o,i}return dt(r)}(A);!function(e){e.GetParameter="GetParameter"}(jt||(jt={}))})();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); //# sourceMappingURL=aws.min.js.map \ No newline at end of file diff --git a/build/aws.min.js.map b/build/aws.min.js.map index f0ca319..1e0b3ae 100644 --- a/build/aws.min.js.map +++ b/build/aws.min.js.map @@ -1 +1 @@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esToUuid.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 /**\n * Error code issued by the service (if any)\n */\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 /**\n * The Amazon Resource Name (ARN) of the parameter.\n */\n arn: string\n\n /**\n * The data type of the parameter, such as text or aws:ec2:image.\n * The default is text.\n */\n dataType: string\n\n /**\n * Date the parameter was last changed or updated and the parameter version was created.\n */\n lastModifiedDate: number\n\n /**\n * The friendly name of the parameter.\n */\n name: string\n\n /**\n * 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 */\n selector: string\n\n /**\n * plies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n */\n sourceResult: string\n\n /**\n * The type of parameter. Valid values include the following: String, StringList, and SecureString.\n */\n type: string\n\n /**\n * The parameter value.\n */\n value: string\n\n /**\n * The parameter version.\n */\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter\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 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 const parameter = json.Parameter as JSONObject\n\n return new SystemsManagerParameter(\n parameter.ARN as string,\n parameter.DataType as string,\n parameter.LastModifiedDate as number,\n parameter.Name as string,\n parameter.Selector as string,\n parameter.SourceResult as string,\n parameter.Type as string,\n parameter.Value as string,\n parameter.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","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","dataType","lastModifiedDate","selector","sourceResult","type","version","parameter","Parameter","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,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,IAAIK,EAAQ,IAAIC,WAAW,IAE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Aa,MAAQA,GAAa,KAAM,CAGxC,IAAMG,EACDD,EAAME,SAAuBF,EAAMvJ,SAAuBuJ,EAAMG,OAGrE,GAAqB,8BAAjBH,EAAMG,OACN,MAAM,IAAIjG,EAAsB+F,EAAcD,EAAMG,QAIxD,MAAM,IAAI4E,GAA2B9E,EAAcD,EAAMG,OAAkBP,EAC9E,CAED,GAAkB,OAAdE,EACA,MAAM,IAAIiF,GACN,sCACA,uBACAnF,EAtBP,CAyBJ,KAnGL,GAA0C3B,IAyG7B6G,GAAb,WAgEI,WACId,EACAgB,EACAC,EACAtO,EACAuO,EACAC,EACAC,EACAxQ,EACAyQ,GACF,yPACE9N,KAAKyM,IAAMA,EACXzM,KAAKyN,SAAWA,EAChBzN,KAAK0N,iBAAmBA,EACxB1N,KAAKZ,KAAOA,EACZY,KAAK2N,SAAWA,EAChB3N,KAAK4N,aAAeA,EACpB5N,KAAK6N,KAAOA,EACZ7N,KAAK3C,MAAQA,EACb2C,KAAK8N,QAAUA,CAClB,CApFL,wCA8FI,SAAgBpG,GACZ,IAAMqG,EAAYrG,EAAKsG,UAEvB,OAAO,IAAIT,EACPQ,EAAUjB,IACViB,EAAUE,SACVF,EAAUG,iBACVH,EAAUlC,KACVkC,EAAUI,SACVJ,EAAUK,aACVL,EAAUM,KACVN,EAAUO,MACVP,EAAUQ,QAEjB,KA5GL,KA+Gaf,GAAb,gCAUI,WAAYtO,EAAiBC,EAAckJ,GAAoC,8BAC3E,cAAMnJ,EAASC,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAKiJ,UAAYA,EAH0D,CAI9E,CAdL,cAAgDpJ,I,SAoB3CiO,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/./src/internal/constants.ts","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/http.ts","webpack://k6-jslib-aws/./src/internal/utils.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/kms.ts","webpack://k6-jslib-aws/./src/internal/s3.ts","webpack://k6-jslib-aws/./src/internal/secrets-manager.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\");","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\n","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 /**\n * Error code issued by the service (if any)\n */\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 from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\n )\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 // FIXME: Should really be called \"host\" instead. When used\n // with localstack we pass a complete host (hostname:port) here.\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 { AWSConfig } from './config'\nimport { HTTPHeaders } from './http'\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\n private _host?: string\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) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\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 public get host() {\n if (this._host == undefined) {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n return this._host\n }\n\n public set host(host: string) {\n this._host = host\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 } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'kms')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\n })\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 '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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n // For some reason, the base target is not kms...\n [AMZ_TARGET_HEADER]: `TrentService.ListKeys`,\n },\n body: JSON.stringify({}),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n // For some reason, the base target is not kms...\n [AMZ_TARGET_HEADER]: `TrentService.GenerateDataKey`,\n },\n body: JSON.stringify({ KeyId: id, NumberOfBytes: size }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 { bytes } from 'k6'\nimport { parseHTML } from 'k6/html'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\nimport { SignedHTTPRequest } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n signature: SignatureV4\n\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 super(awsConfig, 's3')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: this.awsConfig.region,\n credentials: {\n accessKeyId: this.awsConfig.accessKeyID,\n secretAccessKey: this.awsConfig.secretAccessKey,\n sessionToken: this.awsConfig.sessionToken,\n },\n uriEscapePath: false,\n applyChecksum: true,\n })\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 const method = 'GET'\n\n const signedRequest: SignedHTTPRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: this.host,\n path: '/',\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest: SignedHTTPRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: host,\n path: '/',\n query: {\n 'list-type': '2',\n prefix: prefix || '',\n },\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: method,\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n body: data,\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: method,\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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 || 'unknown', 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 { v4 as uuidv4 } from 'uuid'\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'secretsmanager')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\n })\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 '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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.ListSecrets`,\n },\n body: JSON.stringify({}),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.GetSecretValue`,\n },\n body: JSON.stringify({ SecretId: id }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.body, {\n headers: signedRequest.headers,\n })\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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.CreateSecret`,\n },\n body: JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n }),\n },\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, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.PutSecretValue`,\n },\n body: JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.DeleteSecret`,\n },\n body: JSON.stringify(payload),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(\n operation: SecretsManagerOperation,\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 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 { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'ssm')\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `AmazonSSM.GetParameter`,\n },\n body: JSON.stringify({ Name: name, WithDecryption: withDecryption }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 /**\n * The Amazon Resource Name (ARN) of the parameter.\n */\n arn: string\n\n /**\n * The data type of the parameter, such as text or aws:ec2:image.\n * The default is text.\n */\n dataType: string\n\n /**\n * Date the parameter was last changed or updated and the parameter version was created.\n */\n lastModifiedDate: number\n\n /**\n * The friendly name of the parameter.\n */\n name: string\n\n /**\n * 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 */\n selector: string\n\n /**\n * plies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n */\n sourceResult: string\n\n /**\n * The type of parameter. Valid values include the following: String, StringList, and SecureString.\n */\n type: string\n\n /**\n * The parameter value.\n */\n value: string\n\n /**\n * The parameter version.\n */\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter\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 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 const parameter = json.Parameter as JSONObject\n\n return new SystemsManagerParameter(\n parameter.ARN as string,\n parameter.DataType as string,\n parameter.LastModifiedDate as number,\n parameter.Name as string,\n parameter.Selector as string,\n parameter.SourceResult as string,\n parameter.Type as string,\n parameter.Value as string,\n parameter.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","AMZ_DATE_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TARGET_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","SignatureV4","service","region","credentials","uriEscapePath","applyChecksum","this","request","signingDate","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","sessionToken","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","accessKeyId","sort","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","secretAccessKey","kDate","kRegion","kService","normalizedURISegments","split","URISegment","length","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","isArray","slice","reduce","encoded","concat","filter","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString","AWSConfig","InvalidAWSConfigError","scheme","endpoint","AWSClient","awsConfig","serviceName","_host","host","KMSOperation","KMSKeySize","KMSClient","accessKeyID","commonHeaders","signedRequest","sign","res","http","_handle_error","ListKeys","json","k","KMSKey","fromJSON","id","size","Size256","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","operation","response","errorCode","error_code","error","errorMessage","Message","__type","KMSServiceError","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext","S3Client","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","bucketName","prefix","objects","objectDefinition","lastModified","etag","parseInt","storageClass","objectKey","S3Object","data","S3ServiceError","awsError","parseXML","S3Bucket","SecretsManagerOperation","SecretsManagerClient","ListSecrets","s","Secret","SecretId","GetSecretValue","secret","description","versionID","tags","uuidv4","Name","Description","SecretString","ClientRequestToken","Tags","CreateSecret","PutSecretValue","recoveryWindow","noRecovery","payload","DeleteSecret","SecretsManagerServiceError","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate","SystemsManagerOperation","SystemsManagerClient","withDecryption","WithDecryption","GetParameter","SystemsManagerParameter","SystemsManagerServiceError","dataType","lastModifiedDate","selector","sourceResult","type","version","parameter","Parameter","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file diff --git a/build/kms.min.js b/build/kms.min.js index 1a8f220..e42d7fd 100644 --- a/build/kms.min.js +++ b/build/kms.min.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AWSConfig:()=>X,InvalidAWSConfigError:()=>F,InvalidSignatureError:()=>R,KMSClient:()=>de,KMSDataKey:()=>me,KMSServiceError:()=>ge,URIEncodingConfig:()=>I,signHeaders:()=>A});const r=require("k6/crypto");var n=e.n(r);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r="A"&&r<="Z"||r>="a"&&r<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var r})).join("")}var I=w((function e(t,r){O(this,e),d(this,"double",void 0),d(this,"path",void 0),this.double=t,this.path=r}));function x(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function D(e){return x(e).substring(0,8)}function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}function z(e,t){if(t&&("object"===M(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function H(e){var t="function"==typeof Map?new Map:void 0;return H=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return B(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,e)},H(e)}function B(e,t,r){return B=N()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&U(o,r.prototype),o},B.apply(null,arguments)}function N(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function U(e,t){return U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},U(e,t)}function q(e){return q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},q(e)}function L(e,t){for(var r=0;r128)throw new F("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new F("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new F("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),F=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&U(e,t)}(o,e);var t,r,n=(t=o,r=N(),function(){var e,n=q(t);if(r){var o=q(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return z(this,e)});function o(e){return G(this,o),n.call(this,e)}return W(o)}(H(Error));const $=require("k6/http");var Y=e.n($);function Z(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:be.Size256,n=JSON.stringify({KeyId:e,NumberOfBytes:t}),o=ie(pe(r.prototype),"buildRequest",this).call(this,this.method,this.host,"/","",n,te(te({},this.commonHeaders),{},{"X-Amz-Target":"TrentService.GenerateDataKey"})),i=Y().request(this.method,o.url,n,{headers:o.headers});return this._handle_error(he.GenerateDataKey,i),me.fromJSON(i.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new R(o,n.__type);throw new ge(o,n.__type,e)}if(1500===r)throw new ge("An error occured on the server side","InternalServiceError",e)}}}]),r}(function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Q(this,"awsConfig",void 0),Q(this,"serviceName",void 0),Q(this,"URIencodingConfig",void 0),this.awsConfig=t,this.serviceName=r,this.URIencodingConfig=n}var t,r,n;return t=e,(r=[{key:"buildRequest",value:function(e,t,r,n,o,i){var c=Date.now(),u=x(c);i.Host=t,i["X-Amz-Date"]=u,i=A(i,c,e,r,n,o,this.awsConfig,this.serviceName,this.URIencodingConfig),r=""!==r?r:"/";var a="".concat(this.awsConfig.scheme,"://").concat(t).concat(r);return""!==n&&(a+="?".concat(n)),{url:a,headers:i}}},{key:"host",get:function(){return"".concat(this.serviceName,".").concat(this.awsConfig.region,".").concat(this.awsConfig.endpoint)}}])&&Z(t.prototype,r),n&&Z(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()),ve=function(){function e(t,r){re(this,e),ye(this,"keyArn",void 0),ye(this,"keyId",void 0),this.keyArn=t,this.keyId=r}return oe(e,null,[{key:"fromJSON",value:function(t){return new e(t.KeyArn,t.KeyId)}}]),e}(),me=function(){function e(t,r,n){re(this,e),ye(this,"id",void 0),ye(this,"ciphertextBlob",void 0),ye(this,"plaintext",void 0),this.ciphertextBlob=t,this.id=r,this.plaintext=n}return oe(e,null,[{key:"fromJSON",value:function(t){return new e(t.CiphertextBlob,t.KeyId,t.Plaintext)}}]),e}(),ge=function(e){ue(r,e);var t=fe(r);function r(e,n,o){var i;return re(this,r),ye(le(i=t.call(this,e,n)),"operation",void 0),i.name="KMSServiceError",i.operation=o,i}return oe(r)}(h);!function(e){e.GenerateDataKey="GenerateDataKey",e.ListKeys="ListKeys"}(he||(he={})),function(e){e[e.Size256=32]="Size256",e[e.Size512=64]="Size512"}(be||(be={}));var we=exports;for(var Oe in t)we[Oe]=t[Oe];t.__esModule&&Object.defineProperty(we,"__esModule",{value:!0})})(); +(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},o(e)}function i(e,t,r){return i=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&a(o,r.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function s(e,t){for(var r=0;rp,InvalidAWSConfigError:()=>h,InvalidSignatureError:()=>se,KMSClient:()=>Ae,KMSDataKey:()=>Ke,KMSServiceError:()=>Ee});var p=f((function e(t){if(l(this,e),y(this,"region",void 0),y(this,"accessKeyId",void 0),y(this,"secretAccessKey",void 0),y(this,"sessionToken",void 0),y(this,"scheme","https"),y(this,"endpoint","amazonaws.com"),""===t.region)throw new h("invalid AWS region; reason: should be a non empty string");if(""===t.accessKeyId)throw new h("invalid AWS access key ID; reason: should be a non empty string");if(t.accessKeyId.length<16||t.accessKeyId.length>128)throw new h("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new h("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new h("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),h=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(i,e);var t,r,o=(t=i,r=c(),function(){var e,o=u(t);if(r){var i=u(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return n(this,e)});function i(e){return l(this,i),o.call(this,e)}return f(i)}(o(Error));const d=require("k6/http");var b=e.n(d);function v(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){a=!0,i=e},f:function(){try{c||null==r.return||r.return()}finally{if(a)throw i}}}}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[m]}e.headers[P]=l,this.credentials.sessionToken&&(e.headers[A]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var g=R;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,c=t.unsignableHeaders,a=t.unhoistableHeaders,u=t.signableHeaders,s=t.signingRegion,f=t.signingService,l=le(n),y=l.longDate,p=l.shortDate,h=s||this.region,d=f||this.service;if(i>T)throw new se("Signature version 4 presigned URLs can't be valid for more than 7 days");var b="".concat(p,"/").concat(h,"/").concat(d,"/").concat(x),v=this.moveHeadersToQuery(e,{unhoistableHeaders:a});v.headers.host=e.hostname,this.credentials.sessionToken&&(v.query[S]=this.credentials.sessionToken),v.query["X-Amz-Algorithm"]=D,v.query["X-Amz-Credential"]="".concat(this.credentials.accessKeyId,"/").concat(b),v.query["X-Amz-Date"]=y,v.query["X-Amz-Expires"]=i.toString(10);var m=this.computeCanonicalHeaders(v,c,u);v.query["X-Amz-SignedHeaders"]=Object.keys(m).sort().join(";");var g=this.deriveSigningKey(this.credentials,d,h,p),w=this.computePayloadHash(e),O=this.createCanonicalRequest(v,m,w);v.query["X-Amz-Signature"]=this.calculateSignature(y,b,g,O);var j="".concat(v.protocol,"://").concat(v.hostname);return v.path&&(j+=v.path),v.query&&(j+="?".concat(this.serializeQueryParameters(v.query))),ne({url:j},v)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=F().sha256(r,"hex");return"".concat(D,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return F().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,i=F().hmac("sha256","AWS4"+o,n,"binary"),c=F().hmac("sha256",i,r,"binary"),a=F().hmac("sha256",c,t,"binary");return F().hmac("sha256",a,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=ee(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var c=null!=t&&t.startsWith("/")?"/":"",a=n.join("/"),u=n.length>0&&null!=t&&t.endsWith("/")?"/":"",s="".concat(c).concat(a).concat(u);return encodeURIComponent(s).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},c=function(e){if(e.toLowerCase()===k)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(fe(e),"=").concat(fe(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(fe(e),"=").concat(fe(r))])}),[]).join("&"))},a=ee(Object.keys(n).sort());try{for(a.s();!(t=a.n()).done;)c(t.value)}catch(e){a.e(e)}finally{a.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},c=ee(Object.keys(o).sort());try{for(c.s();!(n=c.n()).done;){var a=n.value;if(null!=o[a]){var u=a.toLowerCase();(u in E||null!=t&&t.has(u))&&(!r||r&&!r.has(u))||(i[u]=o[a].trim().replace(/\s+/g," "))}}}catch(e){c.e(e)}finally{c.f()}return i}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,i=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,c=0,a=Object.keys(n);c1&&void 0!==arguments[1]?arguments[1]:_e.Size256,r=this.signature.sign({method:this.method,protocol:this.awsConfig.scheme,hostname:this.host,path:"/",headers:he(he({},this.commonHeaders),{},Pe({},_,"TrentService.GenerateDataKey")),body:JSON.stringify({KeyId:e,NumberOfBytes:t})},{}),n=b().request(this.method,r.url,r.body,{headers:r.headers});return this._handle_error(ke.GenerateDataKey,n),Ke.fromJSON(n.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new se(o,n.__type);throw new Ee(o,n.__type,e)}if(1500===r)throw new Ee("An error occured on the server side","InternalServiceError",e)}}}]),r}(g),Ce=function(){function e(t,r){de(this,e),Pe(this,"keyArn",void 0),Pe(this,"keyId",void 0),this.keyArn=t,this.keyId=r}return ve(e,null,[{key:"fromJSON",value:function(t){return new e(t.KeyArn,t.KeyId)}}]),e}(),Ke=function(){function e(t,r,n){de(this,e),Pe(this,"id",void 0),Pe(this,"ciphertextBlob",void 0),Pe(this,"plaintext",void 0),this.ciphertextBlob=t,this.id=r,this.plaintext=n}return ve(e,null,[{key:"fromJSON",value:function(t){return new e(t.CiphertextBlob,t.KeyId,t.Plaintext)}}]),e}(),Ee=function(e){me(r,e);var t=we(r);function r(e,n,o){var i;return de(this,r),Pe(Se(i=t.call(this,e,n)),"operation",void 0),i.name="KMSServiceError",i.operation=o,i}return ve(r)}(U);!function(e){e.GenerateDataKey="GenerateDataKey",e.ListKeys="ListKeys"}(ke||(ke={})),function(e){e[e.Size256=32]="Size256",e[e.Size512=64]="Size512"}(_e||(_e={}));var xe=exports;for(var De in t)xe[De]=t[De];t.__esModule&&Object.defineProperty(xe,"__esModule",{value:!0})})(); //# sourceMappingURL=kms.min.js.map \ No newline at end of file diff --git a/build/kms.min.js.map b/build/kms.min.js.map index f396382..85678ee 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,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,iMCL9D,MAAM,EAA+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L,gBA2EI,WACI,gBAAU0F,KAAK4C,YAAf,YAA8B5C,KAAKpF,UAAUO,OAA7C,YAAuD6E,KAAKpF,UAAU8F,SACzE,M,8EA7EL,MDwHac,GAAb,WAWI,WAAYsB,EAAgBf,GAAe,4DACvC/B,KAAK8C,OAASA,EACd9C,KAAK+C,MAAQhB,CAChB,CAdL,wCAgBI,SAAgBT,GACZ,OAAO,IAAIE,EAAOF,EAAK0B,OAAkB1B,EAAKS,MACjD,KAlBL,KAwBaG,GAAb,WAiBI,WAAYe,EAAwBlB,EAAemB,GAAmB,6FAClElD,KAAKmD,eAAiBF,EACtBjD,KAAK0B,GAAKK,EACV/B,KAAKoD,UAAYF,CACpB,CArBL,wCAuBI,SAAgB5B,GACZ,OAAO,IAAIY,EACPZ,EAAK2B,eACL3B,EAAKS,MACLT,EAAK4B,UAEZ,KA7BL,KAgCaP,GAAb,gCAUI,WAAY/I,EAAiBC,EAAcsI,GAAyB,8BAChE,cAAMvI,EAASC,IADiD,oBAEhE,EAAKC,KAAO,kBACZ,EAAKqI,UAAYA,EAH+C,CAInE,CAdL,cAAqCxI,I,SAoBhCgH,GAAAA,EAAAA,gBAAAA,kBAAAA,EAAAA,SAAAA,U,EAAAA,KAAAA,GAAAA,CAAAA,I,SAQAC,GAAAA,EAAAA,EAAAA,QAAAA,IAAAA,UAAAA,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 /**\n * Error code issued by the service (if any)\n */\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","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,IA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kBAAAA,EAAAA,SAAAA,U,EAAAA,KAAAA,GAAAA,CAAAA,I,SAQAC,GAAAA,EAAAA,EAAAA,QAAAA,IAAAA,UAAAA,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/./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/constants.ts","webpack://k6-jslib-aws/external commonjs \"k6/html\"","webpack://k6-jslib-aws/./src/internal/error.ts","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/./src/internal/signature.ts","webpack://k6-jslib-aws/./src/internal/http.ts","webpack://k6-jslib-aws/./src/internal/utils.ts","webpack://k6-jslib-aws/./src/internal/kms.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};","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 // FIXME: Should really be called \"host\" instead. When used\n // with localstack we pass a complete host (hostname:port) here.\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 { AWSConfig } from './config'\nimport { HTTPHeaders } from './http'\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\n private _host?: string\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) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\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 public get host() {\n if (this._host == undefined) {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n return this._host\n }\n\n public set host(host: string) {\n this._host = host\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","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\n","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 /**\n * Error code issued by the service (if any)\n */\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","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","import crypto from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\n )\n}\n","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'kms')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\n })\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 '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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n // For some reason, the base target is not kms...\n [AMZ_TARGET_HEADER]: `TrentService.ListKeys`,\n },\n body: JSON.stringify({}),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n // For some reason, the base target is not kms...\n [AMZ_TARGET_HEADER]: `TrentService.GenerateDataKey`,\n },\n body: JSON.stringify({ KeyId: id, NumberOfBytes: size }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","AWSConfig","options","region","InvalidAWSConfigError","accessKeyId","length","secretAccessKey","this","undefined","sessionToken","scheme","endpoint","message","Error","require","AWSClient","awsConfig","serviceName","_host","host","AMZ_DATE_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TARGET_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","AWSError","code","name","xmlDocument","doc","parseHTML","find","text","SignatureV4","service","credentials","uriEscapePath","applyChecksum","request","signingDate","Date","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","crypto","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","sort","join","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","toString","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","kDate","kRegion","kService","normalizedURISegments","split","URISegment","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","Array","isArray","slice","reduce","encoded","concat","filter","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString","KMSOperation","KMSKeySize","KMSClient","accessKeyID","commonHeaders","signedRequest","sign","res","http","_handle_error","ListKeys","json","k","KMSKey","fromJSON","id","size","Size256","KeyId","NumberOfBytes","GenerateDataKey","KMSDataKey","operation","response","errorCode","error_code","error","errorMessage","Message","__type","KMSServiceError","keyArn","keyId","KeyArn","CiphertextBlob","Plaintext","ciphertextBlob","plaintext"],"sourceRoot":""} \ No newline at end of file diff --git a/build/s3.min.js b/build/s3.min.js index 06f93de..aa7aa47 100644 --- a/build/s3.min.js +++ b/build/s3.min.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AWSConfig:()=>F,InvalidAWSConfigError:()=>$,InvalidSignatureError:()=>A,S3Bucket:()=>he,S3Client:()=>pe,S3Object:()=>ye,S3ServiceError:()=>de,URIEncodingConfig:()=>I});const n=require("k6/crypto");var r=e.n(n);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n="A"&&n<="Z"||n>="a"&&n<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var n})).join("")}var I=w((function e(t,n){O(this,e),b(this,"double",void 0),b(this,"path",void 0),this.double=t,this.path=n}));function D(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function M(e){return D(e).substring(0,8)}function z(e){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},z(e)}function q(e,t){if(t&&("object"===z(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function H(e){var t="function"==typeof Map?new Map:void 0;return H=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return K(e,arguments,B(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),U(r,e)},H(e)}function K(e,t,n){return K=L()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&U(o,n.prototype),o},K.apply(null,arguments)}function L(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function U(e,t){return U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},U(e,t)}function B(e){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},B(e)}function W(e,t){for(var n=0;n128)throw new $("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new $("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new $("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),$=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&U(e,t)}(o,e);var t,n,r=(t=o,n=L(),function(){var e,r=B(t);if(n){var o=B(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return q(this,e)});function o(e){return X(this,o),r.call(this,e)}return N(o)}(H(Error));const V=require("k6/http");var Y=e.n(V);function Z(e,t){for(var n=0;n{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},o(e)}function i(e,t,r){return i=a()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&c(o,r.prototype),o},i.apply(null,arguments)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){for(var r=0;ry,InvalidAWSConfigError:()=>p,InvalidSignatureError:()=>ne,S3Bucket:()=>je,S3Client:()=>Oe,S3Object:()=>Se,S3ServiceError:()=>ke});var y=f((function e(t){if(l(this,e),h(this,"region",void 0),h(this,"accessKeyId",void 0),h(this,"secretAccessKey",void 0),h(this,"sessionToken",void 0),h(this,"scheme","https"),h(this,"endpoint","amazonaws.com"),""===t.region)throw new p("invalid AWS region; reason: should be a non empty string");if(""===t.accessKeyId)throw new p("invalid AWS access key ID; reason: should be a non empty string");if(t.accessKeyId.length<16||t.accessKeyId.length>128)throw new p("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new p("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new p("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(i,e);var t,r,o=(t=i,r=a(),function(){var e,o=s(t);if(r){var i=s(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return n(this,e)});function i(e){return l(this,i),o.call(this,e)}return f(i)}(o(Error));const d=require("k6/crypto");var b=e.n(d),v="X-Amz-Date",g="X-Amz-Signature",m="X-Amz-Security-Token",w="x-amz-content-sha256",O=v.toLowerCase(),j=g.toLowerCase(),S=("X-Amz-Target".toLowerCase(),m.toLowerCase()),k="authorization",C=[k,O,"date"],P={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},_="aws4_request",A="AWS4-HMAC-SHA256",E=604800,T="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",x="UNSIGNED-PAYLOAD";const R=require("k6/html");function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function z(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[m]}e.headers[O]=l,this.credentials.sessionToken&&(e.headers[S]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var j=T;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,a=t.unsignableHeaders,c=t.unhoistableHeaders,s=t.signableHeaders,u=t.signingRegion,f=t.signingService,l=ie(n),h=l.longDate,y=l.shortDate,p=u||this.region,d=f||this.service;if(i>E)throw new ne("Signature version 4 presigned URLs can't be valid for more than 7 days");var b="".concat(y,"/").concat(p,"/").concat(d,"/").concat(_),v=this.moveHeadersToQuery(e,{unhoistableHeaders:c});v.headers.host=e.hostname,this.credentials.sessionToken&&(v.query[m]=this.credentials.sessionToken),v.query["X-Amz-Algorithm"]=A,v.query["X-Amz-Credential"]="".concat(this.credentials.accessKeyId,"/").concat(b),v.query["X-Amz-Date"]=h,v.query["X-Amz-Expires"]=i.toString(10);var g=this.computeCanonicalHeaders(v,a,s);v.query["X-Amz-SignedHeaders"]=Object.keys(g).sort().join(";");var w=this.deriveSigningKey(this.credentials,d,p,y),O=this.computePayloadHash(e),j=this.createCanonicalRequest(v,g,O);v.query["X-Amz-Signature"]=this.calculateSignature(h,b,w,j);var S="".concat(v.protocol,"://").concat(v.hostname);return v.path&&(S+=v.path),v.query&&(S+="?".concat(this.serializeQueryParameters(v.query))),Z({url:S},v)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=b().sha256(r,"hex");return"".concat(A,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return b().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,i=b().hmac("sha256","AWS4"+o,n,"binary"),a=b().hmac("sha256",i,r,"binary"),c=b().hmac("sha256",a,t,"binary");return b().hmac("sha256",c,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=F(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var a=null!=t&&t.startsWith("/")?"/":"",c=n.join("/"),s=n.length>0&&null!=t&&t.endsWith("/")?"/":"",u="".concat(a).concat(c).concat(s);return encodeURIComponent(u).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},a=function(e){if(e.toLowerCase()===j)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(oe(e),"=").concat(oe(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(oe(e),"=").concat(oe(r))])}),[]).join("&"))},c=F(Object.keys(n).sort());try{for(c.s();!(t=c.n()).done;)a(t.value)}catch(e){c.e(e)}finally{c.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},a=F(Object.keys(o).sort());try{for(a.s();!(n=a.n()).done;){var c=n.value;if(null!=o[c]){var s=c.toLowerCase();(s in P||null!=t&&t.has(s))&&(!r||r&&!r.has(s))||(i[s]=o[c].trim().replace(/\s+/g," "))}}}catch(e){a.e(e)}finally{a.f()}return i}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,i=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,a=0,c=Object.keys(n);a {\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 /**\n * Error code issued by the service (if any)\n */\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","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,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L,O,EAAA,G,EAAA,iBAoBI,WACI,OAAkBrJ,MAAdD,KAAK+L,MACL,UAAU/L,KAAKsJ,YAAf,YAA8BtJ,KAAKqJ,UAAU1J,OAA7C,YAAuDK,KAAKqJ,UAAUjJ,UAEnEJ,KAAK+L,KACf,EAzBL,IA2BI,SAAgBrC,GACZ1J,KAAK+L,MAAQrC,CAChB,M,gFA7BL,MD4RasC,GAAb,IAUI,WAAY7J,EAAcsI,GAAoB,iEAC1CzK,KAAKmC,KAAOA,EACZnC,KAAKyK,aAAeA,CACvB,IAIQW,GAAb,IAkBI,WACIzM,EACAmM,EACAC,EACAC,EACAE,EACAG,GACF,oKACErL,KAAKrB,IAAMA,EACXqB,KAAK8K,aAAeA,EACpB9K,KAAK+K,KAAOA,EACZ/K,KAAKgL,KAAOA,EACZhL,KAAKkL,aAAeA,EACpBlL,KAAKqL,KAAOA,CACf,IAWQO,GAAb,gCAUI,WAAYvL,EAAiB6B,EAAcoJ,GAAmB,8BAC1D,cAAMjL,EAAS6B,IAD2C,oBAE1D,EAAKC,KAAO,iBACZ,EAAKmJ,UAAYA,EAHyC,CAI7D,CAdL,cAAoCrJ,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/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/./src/internal/constants.ts","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/http.ts","webpack://k6-jslib-aws/./src/internal/utils.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};","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 // FIXME: Should really be called \"host\" instead. When used\n // with localstack we pass a complete host (hostname:port) here.\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/crypto\");","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\n","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 /**\n * Error code issued by the service (if any)\n */\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 from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\n )\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { bytes } from 'k6'\nimport { parseHTML } from 'k6/html'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AWSError } from './error'\nimport { SignedHTTPRequest } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\n\n/** Class allowing to interact with Amazon AWS's S3 service */\nexport class S3Client extends AWSClient {\n signature: SignatureV4\n\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 super(awsConfig, 's3')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: this.awsConfig.region,\n credentials: {\n accessKeyId: this.awsConfig.accessKeyID,\n secretAccessKey: this.awsConfig.secretAccessKey,\n sessionToken: this.awsConfig.sessionToken,\n },\n uriEscapePath: false,\n applyChecksum: true,\n })\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 const method = 'GET'\n\n const signedRequest: SignedHTTPRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: this.host,\n path: '/',\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest: SignedHTTPRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: host,\n path: '/',\n query: {\n 'list-type': '2',\n prefix: prefix || '',\n },\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: 'GET',\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: method,\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n body: data,\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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\n const signedRequest = this.signature.sign(\n {\n method: method,\n protocol: 'https',\n hostname: host,\n path: `/${objectKey}`,\n headers: {},\n },\n {}\n )\n\n const res = http.request(method, signedRequest.url, signedRequest.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 || 'unknown', 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 { AWSConfig } from './config'\nimport { HTTPHeaders } from './http'\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\n private _host?: string\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) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\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 public get host() {\n if (this._host == undefined) {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n return this._host\n }\n\n public set host(host: string) {\n this._host = host\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","AWSConfig","options","region","InvalidAWSConfigError","accessKeyId","length","secretAccessKey","this","undefined","sessionToken","scheme","endpoint","message","Error","require","AMZ_DATE_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","AWSError","code","name","xmlDocument","doc","parseHTML","find","text","SignatureV4","service","credentials","uriEscapePath","applyChecksum","request","signingDate","Date","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","crypto","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","sort","join","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","toString","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","kDate","kRegion","kService","normalizedURISegments","split","URISegment","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","Array","isArray","slice","reduce","encoded","concat","filter","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString","S3Client","awsConfig","serviceName","accessKeyID","signedRequest","sign","host","res","http","_handle_error","buckets","children","each","_","bucketDefinition","bucket","forEach","child","nodeName","assign","textContent","creationDate","bucketName","prefix","objects","objectDefinition","lastModified","etag","size","parseInt","storageClass","objectKey","S3Object","data","operation","response","errorCode","error_code","errorMessage","error","S3ServiceError","awsError","parseXML","_host","S3Bucket"],"sourceRoot":""} \ No newline at end of file diff --git a/build/secrets-manager.min.js b/build/secrets-manager.min.js index 219ad66..13ada8b 100644 --- a/build/secrets-manager.min.js +++ b/build/secrets-manager.min.js @@ -1,2 +1,2 @@ -(()=>{var e={877:(e,t,r)=>{var n=r(570),o=r(171),i=o;i.v1=n,i.v4=o,e.exports=i},327:e=>{for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);e.exports=function(e,r){var n=r||0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var r=new Uint8Array(16);e.exports=function(){return t(r),r}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},570:(e,t,r)=>{var n,o,i=r(217),c=r(327),u=0,a=0;e.exports=function(e,t,r){var s=t&&r||0,f=t||[],l=(e=e||{}).node||n,p=void 0!==e.clockseq?e.clockseq:o;if(null==l||null==p){var y=i();null==l&&(l=n=[1|y[0],y[1],y[2],y[3],y[4],y[5]]),null==p&&(p=o=16383&(y[6]<<8|y[7]))}var h=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:a+1,v=h-u+(d-a)/1e4;if(v<0&&void 0===e.clockseq&&(p=p+1&16383),(v<0||h>u)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");u=h,a=d,o=p;var b=(1e4*(268435455&(h+=122192928e5))+d)%4294967296;f[s++]=b>>>24&255,f[s++]=b>>>16&255,f[s++]=b>>>8&255,f[s++]=255&b;var m=h/4294967296*1e4&268435455;f[s++]=m>>>8&255,f[s++]=255&m,f[s++]=m>>>24&15|16,f[s++]=m>>>16&255,f[s++]=p>>>8|128,f[s++]=255&p;for(var g=0;g<6;++g)f[s+g]=l[g];return t||c(f)}},171:(e,t,r)=>{var n=r(217),o=r(327);e.exports=function(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var c=(e=e||{}).random||(e.rng||n)();if(c[6]=15&c[6]|64,c[8]=63&c[8]|128,t)for(var u=0;u<16;++u)t[i+u]=c[u];return t||o(c)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{AWSConfig:()=>X,InvalidAWSConfigError:()=>F,InvalidSignatureError:()=>A,Secret:()=>me,SecretsManagerClient:()=>be,SecretsManagerServiceError:()=>ge,URIEncodingConfig:()=>I,signHeaders:()=>R});const e=require("k6/crypto");var t=r.n(e);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r="A"&&r<="Z"||r>="a"&&r<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var r})).join("")}var I=w((function e(t,r){S(this,e),v(this,"double",void 0),v(this,"path",void 0),this.double=t,this.path=r}));function x(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function N(e){return x(e).substring(0,8)}function q(e){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q(e)}function M(e,t){if(t&&("object"===q(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function H(e){var t="function"==typeof Map?new Map:void 0;return H=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return K(e,arguments,U(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)},H(e)}function K(e,t,r){return K=z()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&L(o,r.prototype),o},K.apply(null,arguments)}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function L(e,t){return L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},L(e,t)}function U(e){return U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},U(e)}function V(e,t){for(var r=0;r128)throw new F("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new F("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new F("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),F=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&L(e,t)}(o,e);var t,r,n=(t=o,r=z(),function(){var e,n=U(t);if(r){var o=U(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return M(this,e)});function o(e){return J(this,o),n.call(this,e)}return W(o)}(H(Error));const G=require("k6/http");var $=r.n(G);function Y(e,t){for(var r=0;r=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new A(o,n.__type);throw new ge(o,n.__type,e)}if(1500===r)throw new ge("An error occured on the server side","InternalServiceError",e)}}}]),r}(Q),me=function(){function e(t,r,n,o,i,c){var u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[];oe(this,e),de(this,"name",void 0),de(this,"arn",void 0),de(this,"secret",void 0),de(this,"createdDate",void 0),de(this,"lastAccessedDate",void 0),de(this,"lastChangedDate",void 0),de(this,"tags",void 0),this.name=t,this.arn=r,this.secret=n,this.createdDate=o,this.lastAccessedDate=i,this.lastChangedDate=c,this.tags=u}return ce(e,null,[{key:"fromJSON",value:function(t){return new e(t.Name,t.ARN,t.SecretString,t.CreatedDate,t.LastAccessedDate,t.LastChangedDate,t.Tags)}}]),e}(),ge=function(e){se(r,e);var t=le(r);function r(e,n,o){var i;return oe(this,r),de(ye(i=t.call(this,e,n)),"operation",void 0),i.name="SecretsManagerServiceError",i.operation=o,i}return ce(r)}(h);!function(e){e.ListSecrets="ListSecrets",e.GetSecretValue="GetSecretValue",e.CreateSecret="CreateSecret",e.PutSecretValue="PutSecretValue",e.DeleteSecret="DeleteSecret"}(ve||(ve={}))})();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); +(()=>{var e={877:(e,t,r)=>{var n=r(570),o=r(171),i=o;i.v1=n,i.v4=o,e.exports=i},327:e=>{for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);e.exports=function(e,r){var n=r||0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var r=new Uint8Array(16);e.exports=function(){return t(r),r}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},570:(e,t,r)=>{var n,o,i=r(217),c=r(327),a=0,s=0;e.exports=function(e,t,r){var u=t&&r||0,f=t||[],l=(e=e||{}).node||n,h=void 0!==e.clockseq?e.clockseq:o;if(null==l||null==h){var y=i();null==l&&(l=n=[1|y[0],y[1],y[2],y[3],y[4],y[5]]),null==h&&(h=o=16383&(y[6]<<8|y[7]))}var p=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:s+1,v=p-a+(d-s)/1e4;if(v<0&&void 0===e.clockseq&&(h=h+1&16383),(v<0||p>a)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=p,s=d,o=h;var b=(1e4*(268435455&(p+=122192928e5))+d)%4294967296;f[u++]=b>>>24&255,f[u++]=b>>>16&255,f[u++]=b>>>8&255,f[u++]=255&b;var m=p/4294967296*1e4&268435455;f[u++]=m>>>8&255,f[u++]=255&m,f[u++]=m>>>24&15|16,f[u++]=m>>>16&255,f[u++]=h>>>8|128,f[u++]=255&h;for(var g=0;g<6;++g)f[u+g]=l[g];return t||c(f)}},171:(e,t,r)=>{var n=r(217),o=r(327);e.exports=function(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var c=(e=e||{}).random||(e.rng||n)();if(c[6]=15&c[6]|64,c[8]=63&c[8]|128,t)for(var a=0;a<16;++a)t[i+a]=c[a];return t||o(c)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},o(e)}function i(e,t,r){return i=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&a(o,r.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){for(var r=0;ry,InvalidAWSConfigError:()=>p,InvalidSignatureError:()=>oe,Secret:()=>ke,SecretsManagerClient:()=>_e,SecretsManagerServiceError:()=>Ae});var y=f((function e(t){if(l(this,e),h(this,"region",void 0),h(this,"accessKeyId",void 0),h(this,"secretAccessKey",void 0),h(this,"sessionToken",void 0),h(this,"scheme","https"),h(this,"endpoint","amazonaws.com"),""===t.region)throw new p("invalid AWS region; reason: should be a non empty string");if(""===t.accessKeyId)throw new p("invalid AWS access key ID; reason: should be a non empty string");if(t.accessKeyId.length<16||t.accessKeyId.length>128)throw new p("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new p("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new p("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(i,e);var r,n,o=(r=i,n=c(),function(){var e,o=s(r);if(n){var i=s(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return t(this,e)});function i(e){return l(this,i),o.call(this,e)}return f(i)}(o(Error));const d=require("k6/crypto");var v=r.n(d),b="X-Amz-Date",m="X-Amz-Signature",g="X-Amz-Security-Token",w="x-amz-content-sha256",S=b.toLowerCase(),O=m.toLowerCase(),j="X-Amz-Target".toLowerCase(),P=g.toLowerCase(),C="authorization",_=[C,S,"date"],k={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},A="aws4_request",D="AWS4-HMAC-SHA256",R=604800,x="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",E="UNSIGNED-PAYLOAD";const T=require("k6/html");function q(e){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q(e)}function I(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){a=!0,i=e},f:function(){try{c||null==r.return||r.return()}finally{if(a)throw i}}}}function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[g]}e.headers[S]=l,this.credentials.sessionToken&&(e.headers[P]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var O=x;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,c=t.unsignableHeaders,a=t.unhoistableHeaders,s=t.signableHeaders,u=t.signingRegion,f=t.signingService,l=ce(n),h=l.longDate,y=l.shortDate,p=u||this.region,d=f||this.service;if(i>R)throw new oe("Signature version 4 presigned URLs can't be valid for more than 7 days");var v="".concat(y,"/").concat(p,"/").concat(d,"/").concat(A),b=this.moveHeadersToQuery(e,{unhoistableHeaders:a});b.headers.host=e.hostname,this.credentials.sessionToken&&(b.query[g]=this.credentials.sessionToken),b.query["X-Amz-Algorithm"]=D,b.query["X-Amz-Credential"]="".concat(this.credentials.accessKeyId,"/").concat(v),b.query["X-Amz-Date"]=h,b.query["X-Amz-Expires"]=i.toString(10);var m=this.computeCanonicalHeaders(b,c,s);b.query["X-Amz-SignedHeaders"]=Object.keys(m).sort().join(";");var w=this.deriveSigningKey(this.credentials,d,p,y),S=this.computePayloadHash(e),O=this.createCanonicalRequest(b,m,S);b.query["X-Amz-Signature"]=this.calculateSignature(h,v,w,O);var j="".concat(b.protocol,"://").concat(b.hostname);return b.path&&(j+=b.path),b.query&&(j+="?".concat(this.serializeQueryParameters(b.query))),$({url:j},b)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=v().sha256(r,"hex");return"".concat(D,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return v().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,i=v().hmac("sha256","AWS4"+o,n,"binary"),c=v().hmac("sha256",i,r,"binary"),a=v().hmac("sha256",c,t,"binary");return v().hmac("sha256",a,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=F(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var c=null!=t&&t.startsWith("/")?"/":"",a=n.join("/"),s=n.length>0&&null!=t&&t.endsWith("/")?"/":"",u="".concat(c).concat(a).concat(s);return encodeURIComponent(u).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},c=function(e){if(e.toLowerCase()===O)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(ie(e),"=").concat(ie(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(ie(e),"=").concat(ie(r))])}),[]).join("&"))},a=F(Object.keys(n).sort());try{for(a.s();!(t=a.n()).done;)c(t.value)}catch(e){a.e(e)}finally{a.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},c=F(Object.keys(o).sort());try{for(c.s();!(n=c.n()).done;){var a=n.value;if(null!=o[a]){var s=a.toLowerCase();(s in k||null!=t&&t.has(s))&&(!r||r&&!r.has(s))||(i[s]=o[a].trim().replace(/\s+/g," "))}}}catch(e){c.e(e)}finally{c.f()}return i}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,i=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,c=0,a=Object.keys(n);c=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new oe(o,n.__type);throw new Ae(o,n.__type,e)}if(1500===r)throw new Ae("An error occured on the server side","InternalServiceError",e)}}}]),r}(function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),le(this,"awsConfig",void 0),le(this,"serviceName",void 0),le(this,"_host",void 0),this.awsConfig=t,this.serviceName=r}var t,r,n;return t=e,(r=[{key:"host",get:function(){return null==this._host?"".concat(this.serviceName,".").concat(this.awsConfig.region,".").concat(this.awsConfig.endpoint):this._host},set:function(e){this._host=e}}])&&fe(t.prototype,r),n&&fe(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()),ke=function(){function e(t,r,n,o,i,c){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:[];de(this,e),Pe(this,"name",void 0),Pe(this,"arn",void 0),Pe(this,"secret",void 0),Pe(this,"createdDate",void 0),Pe(this,"lastAccessedDate",void 0),Pe(this,"lastChangedDate",void 0),Pe(this,"tags",void 0),this.name=t,this.arn=r,this.secret=n,this.createdDate=o,this.lastAccessedDate=i,this.lastChangedDate=c,this.tags=a}return be(e,null,[{key:"fromJSON",value:function(t){return new e(t.Name,t.ARN,t.SecretString,t.CreatedDate,t.LastAccessedDate,t.LastChangedDate,t.Tags)}}]),e}(),Ae=function(e){me(r,e);var t=we(r);function r(e,n,o){var i;return de(this,r),Pe(Oe(i=t.call(this,e,n)),"operation",void 0),i.name="SecretsManagerServiceError",i.operation=o,i}return be(r)}(W);!function(e){e.ListSecrets="ListSecrets",e.GetSecretValue="GetSecretValue",e.CreateSecret="CreateSecret",e.PutSecretValue="PutSecretValue",e.DeleteSecret="DeleteSecret"}(Ce||(Ce={}))})();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); //# sourceMappingURL=secrets-manager.min.js.map \ No newline at end of file diff --git a/build/secrets-manager.min.js.map b/build/secrets-manager.min.js.map index 0fa59ed..6d2d5e0 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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KAAO,6BACZ,EAAKyI,UAAYA,EAH0D,CAI9E,CAdL,cAAgD5I,I,SAoB3C4G,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 /**\n * Error code issued by the service (if any)\n */\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","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,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,IA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,UAdL,O,EAAA,G,EAAA,iBAoBI,WACI,OAAkB3L,MAAd0C,KAAK2L,MACL,UAAU3L,KAAKiJ,YAAf,YAA8BjJ,KAAKgJ,UAAUrJ,OAA7C,YAAuDK,KAAKgJ,UAAU7I,UAEnEH,KAAK2L,KACf,EAzBL,IA2BI,SAAgBrC,GACZtJ,KAAK2L,MAAQrC,CAChB,M,gFA7BL,MD0SaO,GAAb,WAoBI,WACI3H,EACA0J,EACAC,EACAC,EACAC,EACAC,GAEF,IADE3B,EACF,uDAD2C,GAC3C,2MACErK,KAAKkC,KAAOA,EACZlC,KAAK4L,IAAMA,EACX5L,KAAKkK,OAAS2B,EACd7L,KAAK8L,YAAcA,EACnB9L,KAAK+L,iBAAmBA,EACxB/L,KAAKgM,gBAAkBA,EACvBhM,KAAKqK,KAAOA,CACf,CApCL,wCA8CI,SAAgBV,GACZ,OAAO,IAAIE,EACPF,EAAKY,KACLZ,EAAKsC,IACLtC,EAAKc,aACLd,EAAKuC,YACLvC,EAAKwC,iBACLxC,EAAKyC,gBACLzC,EAAKgB,KAEZ,KAxDL,KA2Dae,GAAb,gCAUI,WAAYtL,EAAiB6B,EAAciJ,GAAoC,8BAC3E,cAAM9K,EAAS6B,IAD4D,oBAE3E,EAAKC,KAAO,6BACZ,EAAKgJ,UAAYA,EAH0D,CAI9E,CAdL,cAAgDlJ,I,SAoB3C8G,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/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/./src/internal/constants.ts","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/http.ts","webpack://k6-jslib-aws/./src/internal/utils.ts","webpack://k6-jslib-aws/external commonjs \"k6/http\"","webpack://k6-jslib-aws/./src/internal/secrets-manager.ts","webpack://k6-jslib-aws/./src/internal/client.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};","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 // FIXME: Should really be called \"host\" instead. When used\n // with localstack we pass a complete host (hostname:port) here.\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/crypto\");","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\n","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 /**\n * Error code issued by the service (if any)\n */\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 from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\n )\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONArray, JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { v4 as uuidv4 } from 'uuid'\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'secretsmanager')\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\n })\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 '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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.ListSecrets`,\n },\n body: JSON.stringify({}),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.GetSecretValue`,\n },\n body: JSON.stringify({ SecretId: id }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.body, {\n headers: signedRequest.headers,\n })\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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.CreateSecret`,\n },\n body: JSON.stringify({\n Name: name,\n Description: description,\n SecretString: secret,\n ClientRequestToken: versionID,\n Tags: tags,\n }),\n },\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, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.PutSecretValue`,\n },\n body: JSON.stringify({\n SecretId: id,\n SecretString: secret,\n ClientRequestToken: versionID,\n }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `${this.serviceName}.DeleteSecret`,\n },\n body: JSON.stringify(payload),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.body, {\n headers: signedRequest.headers,\n })\n this._handle_error(SecretsManagerOperation.DeleteSecret, res)\n }\n\n _handle_error(\n operation: SecretsManagerOperation,\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 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 { AWSConfig } from './config'\nimport { HTTPHeaders } from './http'\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\n private _host?: string\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) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\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 public get host() {\n if (this._host == undefined) {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n return this._host\n }\n\n public set host(host: string) {\n this._host = host\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":["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","AWSConfig","region","InvalidAWSConfigError","accessKeyId","length","secretAccessKey","this","sessionToken","scheme","endpoint","message","require","AMZ_DATE_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TARGET_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","AWSError","code","name","xmlDocument","doc","parseHTML","find","text","SignatureV4","service","credentials","uriEscapePath","applyChecksum","request","signingDate","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","sort","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","kDate","kRegion","kService","normalizedURISegments","split","URISegment","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","isArray","slice","reduce","encoded","concat","filter","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString","SecretsManagerOperation","SecretsManagerClient","awsConfig","serviceName","accessKeyID","commonHeaders","signedRequest","sign","host","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","payload","DeleteSecret","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SecretsManagerServiceError","_host","arn","secretString","createdDate","lastAccessedDate","lastChangedDate","ARN","CreatedDate","LastAccessedDate","LastChangedDate"],"sourceRoot":""} \ No newline at end of file diff --git a/build/signature.min.js b/build/signature.min.js new file mode 100644 index 0000000..750bf37 --- /dev/null +++ b/build/signature.min.js @@ -0,0 +1,2 @@ +(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AMZ_ALGORITHM_QUERY_PARAM:()=>r,AMZ_CONTENT_SHA256_HEADER:()=>s,AMZ_CREDENTIAL_QUERY_PARAM:()=>n,AMZ_DATE_HEADER:()=>l,AMZ_DATE_QUERY_PARAM:()=>o,AMZ_EXPIRES_QUERY_PARAM:()=>a,AMZ_SIGNATURE_QUERY_PARAM:()=>i,AMZ_SIGNED_HEADERS_QUERY_PARAM:()=>c,AMZ_TOKEN_QUERY_PARAM:()=>u,AUTHORIZATION_HEADER:()=>p,HOST_HEADER:()=>d,SIGNING_ALGORITHM_IDENTIFIER:()=>g,SignatureV4:()=>K,UNSIGNED_PAYLOAD:()=>w});var r="X-Amz-Algorithm",n="X-Amz-Credential",o="X-Amz-Date",a="X-Amz-Expires",i="X-Amz-Signature",c="X-Amz-SignedHeaders",u="X-Amz-Security-Token",s="x-amz-content-sha256",l=o.toLowerCase(),f=i.toLowerCase(),y=("X-Amz-Target".toLowerCase(),u.toLowerCase()),p="authorization",h=[p,l,"date"],d="host",b={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},v="aws4_request",g="AWS4-HMAC-SHA256",m=604800,O="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",w="UNSIGNED-PAYLOAD";const A=require("k6/crypto");var S=e.n(A);const j=require("k6/html");function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function E(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[R]}e.headers[l]=b,this.credentials.sessionToken&&(e.headers[y]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var C=O;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},s=t.signingDate,l=void 0===s?new Date:s,f=t.expiresIn,y=void 0===f?3600:f,p=t.unsignableHeaders,h=t.unhoistableHeaders,b=t.signableHeaders,O=t.signingRegion,w=t.signingService,A=V(l),S=A.longDate,j=A.shortDate,_=O||this.region,E=w||this.service;if(y>m)throw new W("Signature version 4 presigned URLs can't be valid for more than 7 days");var P="".concat(j,"/").concat(_,"/").concat(E,"/").concat(v),R=this.moveHeadersToQuery(e,{unhoistableHeaders:h});R.headers[d]=e.hostname,this.credentials.sessionToken&&(R.query[u]=this.credentials.sessionToken),R.query[r]=g,R.query[n]="".concat(this.credentials.accessKeyId,"/").concat(P),R.query[o]=S,R.query[a]=y.toString(10);var C=this.computeCanonicalHeaders(R,p,b);R.query[c]=Object.keys(C).sort().join(";");var k=this.deriveSigningKey(this.credentials,E,_,j),D=this.computePayloadHash(e),T=this.createCanonicalRequest(R,C,D);R.query[i]=this.calculateSignature(S,P,k,T);var M="".concat(R.protocol,"://").concat(R.hostname);return R.path&&(M+=R.path),R.query&&(M+="?".concat(this.serializeQueryParameters(R.query))),Z({url:M},R)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),a=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(a,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=S().sha256(r,"hex");return"".concat(g,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return S().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,a=S().hmac("sha256","AWS4"+o,n,"binary"),i=S().hmac("sha256",a,r,"binary"),c=S().hmac("sha256",i,t,"binary");return S().hmac("sha256",c,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=U(t.split("/"));try{for(o.s();!(r=o.n()).done;){var a=r.value;0!=(null==a?void 0:a.length)&&("."!==a&&(".."===a?n.pop():n.push(a)))}}catch(e){o.e(e)}finally{o.f()}var i=null!=t&&t.startsWith("/")?"/":"",c=n.join("/"),u=n.length>0&&null!=t&&t.endsWith("/")?"/":"",s="".concat(i).concat(c).concat(u);return encodeURIComponent(s).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],a={},i=function(e){if(e.toLowerCase()===f)return"continue";o.push(e);var t=n[e];"string"==typeof t?a[e]="".concat(F(e),"=").concat(F(t)):Array.isArray(t)&&(a[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(F(e),"=").concat(F(r))])}),[]).join("&"))},c=U(Object.keys(n).sort());try{for(c.s();!(t=c.n()).done;)i(t.value)}catch(e){c.e(e)}finally{c.f()}return o.map((function(e){return a[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,a={},i=U(Object.keys(o).sort());try{for(i.s();!(n=i.n()).done;){var c=n.value;if(null!=o[c]){var u=c.toLowerCase();(u in b||null!=t&&t.has(u))&&(!r||r&&!r.has(u))||(a[u]=o[c].trim().replace(/\s+/g," "))}}}catch(e){i.e(e)}finally{i.f()}return a}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,a=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,a=void 0===o?{}:o,i=0,c=Object.keys(n);i {\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};","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\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 /**\n * Error code issued by the service (if any)\n */\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 from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\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","AMZ_ALGORITHM_QUERY_PARAM","AMZ_CREDENTIAL_QUERY_PARAM","AMZ_DATE_QUERY_PARAM","AMZ_EXPIRES_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_SIGNED_HEADERS_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","HOST_HEADER","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","require","AWSError","message","code","name","xmlDocument","doc","parseHTML","find","text","Error","SignatureV4","service","region","credentials","uriEscapePath","applyChecksum","this","request","signingDate","Date","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","sessionToken","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","crypto","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","accessKeyId","sort","join","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","options","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","toString","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","secretAccessKey","kDate","kRegion","kService","normalizedURISegments","split","URISegment","length","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","Array","isArray","slice","reduce","encoded","concat","filter","undefined","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString"],"sourceRoot":""} \ No newline at end of file diff --git a/build/ssm.min.js b/build/ssm.min.js index 3723759..e4aec9f 100644 --- a/build/ssm.min.js +++ b/build/ssm.min.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AWSConfig:()=>X,InvalidAWSConfigError:()=>J,InvalidSignatureError:()=>A,SystemsManagerClient:()=>be,SystemsManagerParameter:()=>de,SystemsManagerServiceError:()=>ve,URIEncodingConfig:()=>M,signHeaders:()=>R});const r=require("k6/crypto");var n=e.n(r);const o=require("k6/html");function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r="A"&&r<="Z"||r>="a"&&r<="z"||function(e){return e>="0"&&e<="9"}(e)||"-._~".includes(e)?e:" "==e?"%20":"/"==e&&t?"/":"%"+e.charCodeAt(0).toString(16).toUpperCase();var r})).join("")}var M=w((function e(t,r){O(this,e),d(this,"double",void 0),d(this,"path",void 0),this.double=t,this.path=r}));function x(e){return new Date(e).toISOString().replace(/[:\-]|\.\d{3}/g,"")}function D(e){return x(e).substring(0,8)}function K(e){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},K(e)}function H(e,t){if(t&&("object"===K(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function N(e){var t="function"==typeof Map?new Map:void 0;return N=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return U(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),z(n,e)},N(e)}function U(e,t,r){return U=W()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&z(o,r.prototype),o},U.apply(null,arguments)}function W(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function z(e,t){return z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},z(e,t)}function q(e){return q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},q(e)}function B(e,t){for(var r=0;r128)throw new J("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new J("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new J("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),J=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&z(e,t)}(o,e);var t,r,n=(t=o,r=W(),function(){var e,n=q(t);if(r){var o=q(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return H(this,e)});function o(e){return G(this,o),n.call(this,e)}return L(o)}(N(Error));const V=require("k6/http");var $=e.n(V);function Y(e,t){for(var r=0;r1&&void 0!==arguments[1]&&arguments[1],n=JSON.stringify({Name:e,WithDecryption:t}),o=ie(pe(r.prototype),"buildRequest",this).call(this,this.method,this.host,"/","",n,te(te({},this.commonHeaders),{},{"X-Amz-Target":"AmazonSSM.GetParameter"})),i=$().request(this.method,o.url,n,{headers:o.headers});return this._handle_error(he.GetParameter,i),de.fromJSON(i.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new A(o,n.__type);throw new ve(o,n.__type,e)}if(1500===r)throw new ve("An error occured on the server side","InternalServiceError",e)}}}]),r}(function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Z(this,"awsConfig",void 0),Z(this,"serviceName",void 0),Z(this,"URIencodingConfig",void 0),this.awsConfig=t,this.serviceName=r,this.URIencodingConfig=n}var t,r,n;return t=e,(r=[{key:"buildRequest",value:function(e,t,r,n,o,i){var c=Date.now(),u=x(c);i.Host=t,i["X-Amz-Date"]=u,i=R(i,c,e,r,n,o,this.awsConfig,this.serviceName,this.URIencodingConfig),r=""!==r?r:"/";var a="".concat(this.awsConfig.scheme,"://").concat(t).concat(r);return""!==n&&(a+="?".concat(n)),{url:a,headers:i}}},{key:"host",get:function(){return"".concat(this.serviceName,".").concat(this.awsConfig.region,".").concat(this.awsConfig.endpoint)}}])&&Y(t.prototype,r),n&&Y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()),de=function(){function e(t,r,n,o,i,c,u,a,s){re(this,e),ye(this,"arn",void 0),ye(this,"dataType",void 0),ye(this,"lastModifiedDate",void 0),ye(this,"name",void 0),ye(this,"selector",void 0),ye(this,"sourceResult",void 0),ye(this,"type",void 0),ye(this,"value",void 0),ye(this,"version",void 0),this.arn=t,this.dataType=r,this.lastModifiedDate=n,this.name=o,this.selector=i,this.sourceResult=c,this.type=u,this.value=a,this.version=s}return oe(e,null,[{key:"fromJSON",value:function(t){var r=t.Parameter;return new e(r.ARN,r.DataType,r.LastModifiedDate,r.Name,r.Selector,r.SourceResult,r.Type,r.Value,r.Version)}}]),e}(),ve=function(e){ue(r,e);var t=se(r);function r(e,n,o){var i;return re(this,r),ye(le(i=t.call(this,e,n)),"operation",void 0),i.name="SystemsManagerServiceError",i.operation=o,i}return oe(r)}(h);!function(e){e.GetParameter="GetParameter"}(he||(he={}));var me=exports;for(var ge in t)me[ge]=t[ge];t.__esModule&&Object.defineProperty(me,"__esModule",{value:!0})})(); +(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if(t&&("object"===r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function o(e){var t="function"==typeof Map?new Map:void 0;return o=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},o(e)}function i(e,t,r){return i=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&a(o,r.prototype),o},i.apply(null,arguments)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function s(e,t){for(var r=0;rp,InvalidAWSConfigError:()=>h,InvalidSignatureError:()=>oe,SystemsManagerClient:()=>_e,SystemsManagerParameter:()=>ke,SystemsManagerServiceError:()=>Ae});var p=f((function e(t){if(l(this,e),y(this,"region",void 0),y(this,"accessKeyId",void 0),y(this,"secretAccessKey",void 0),y(this,"sessionToken",void 0),y(this,"scheme","https"),y(this,"endpoint","amazonaws.com"),""===t.region)throw new h("invalid AWS region; reason: should be a non empty string");if(""===t.accessKeyId)throw new h("invalid AWS access key ID; reason: should be a non empty string");if(t.accessKeyId.length<16||t.accessKeyId.length>128)throw new h("invalid AWS access key ID; reason: size should be between 16 and 128 characters, got ".concat(t.accessKeyId.length));if(""===t.secretAccessKey)throw new h("invalid AWS secret access key; reason: should be a non empty string");if(t.secretAccessKey.length<16||t.secretAccessKey.length>128)throw new h("invalid AWS secret access key; reason: size should be between 16 and 128 characters, got ".concat(t.secretAccessKey.length));this.region=t.region,this.accessKeyId=t.accessKeyId,this.secretAccessKey=t.secretAccessKey,void 0!==t.sessionToken&&(this.sessionToken=t.sessionToken),void 0!==t.scheme&&(this.scheme=t.scheme),void 0!==t.endpoint&&(this.endpoint=t.endpoint)})),h=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(i,e);var t,r,o=(t=i,r=c(),function(){var e,o=u(t);if(r){var i=u(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return n(this,e)});function i(e){return l(this,i),o.call(this,e)}return f(i)}(o(Error));const d=require("k6/crypto");var b=e.n(d),v="X-Amz-Date",m="X-Amz-Signature",g="X-Amz-Security-Token",w="x-amz-content-sha256",O=v.toLowerCase(),j=m.toLowerCase(),S="X-Amz-Target".toLowerCase(),P=g.toLowerCase(),_="authorization",k=[_,O,"date"],A={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},C="aws4_request",E="AWS4-HMAC-SHA256",R=604800,T="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",D="UNSIGNED-PAYLOAD";const x=require("k6/html");function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function z(e,t){for(var r=0;r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){a=!0,i=e},f:function(){try{c||null==r.return||r.return()}finally{if(a)throw i}}}}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r-1&&delete e.headers[g]}e.headers[O]=l,this.credentials.sessionToken&&(e.headers[P]=this.credentials.sessionToken),ArrayBuffer.isView(e.body)&&(e.body=e.body.buffer),e.body||(e.body="");var j=T;this.applyChecksum&&(!function(e,t){e=e.toLowerCase();for(var r=0,n=Object.keys(t);r1&&void 0!==arguments[1]?arguments[1]:{},r=t.signingDate,n=void 0===r?new Date:r,o=t.expiresIn,i=void 0===o?3600:o,c=t.unsignableHeaders,a=t.unhoistableHeaders,u=t.signableHeaders,s=t.signingRegion,f=t.signingService,l=ce(n),y=l.longDate,p=l.shortDate,h=s||this.region,d=f||this.service;if(i>R)throw new oe("Signature version 4 presigned URLs can't be valid for more than 7 days");var b="".concat(p,"/").concat(h,"/").concat(d,"/").concat(C),v=this.moveHeadersToQuery(e,{unhoistableHeaders:a});v.headers.host=e.hostname,this.credentials.sessionToken&&(v.query[g]=this.credentials.sessionToken),v.query["X-Amz-Algorithm"]=E,v.query["X-Amz-Credential"]="".concat(this.credentials.accessKeyId,"/").concat(b),v.query["X-Amz-Date"]=y,v.query["X-Amz-Expires"]=i.toString(10);var m=this.computeCanonicalHeaders(v,c,u);v.query["X-Amz-SignedHeaders"]=Object.keys(m).sort().join(";");var w=this.deriveSigningKey(this.credentials,d,h,p),O=this.computePayloadHash(e),j=this.createCanonicalRequest(v,m,O);v.query["X-Amz-Signature"]=this.calculateSignature(y,b,w,j);var S="".concat(v.protocol,"://").concat(v.hostname);return v.path&&(S+=v.path),v.query&&(S+="?".concat(this.serializeQueryParameters(v.query))),$({url:S},v)}},{key:"createCanonicalRequest",value:function(e,t,r){var n=Object.keys(t).sort(),o=n.map((function(e){return"".concat(e,":").concat(t[e])})).join("\n"),i=n.join(";");return"".concat(e.method,"\n")+"".concat(this.computeCanonicalURI(e),"\n")+"".concat(this.computeCanonicalQuerystring(e),"\n")+"".concat(o,"\n\n")+"".concat(i,"\n")+"".concat(r)}},{key:"createStringToSign",value:function(e,t,r){var n=b().sha256(r,"hex");return"".concat(E,"\n")+"".concat(e,"\n")+"".concat(t,"\n")+"".concat(n)}},{key:"calculateSignature",value:function(e,t,r,n){var o=this.createStringToSign(e,t,n);return b().hmac("sha256",r,o,"hex")}},{key:"deriveSigningKey",value:function(e,t,r,n){var o=e.secretAccessKey,i=b().hmac("sha256","AWS4"+o,n,"binary"),c=b().hmac("sha256",i,r,"binary"),a=b().hmac("sha256",c,t,"binary");return b().hmac("sha256",a,"aws4_request","binary")}},{key:"computeCanonicalURI",value:function(e){var t=e.path;if(!this.uriEscapePath)return t;var r,n=[],o=J(t.split("/"));try{for(o.s();!(r=o.n()).done;){var i=r.value;0!=(null==i?void 0:i.length)&&("."!==i&&(".."===i?n.pop():n.push(i)))}}catch(e){o.e(e)}finally{o.f()}var c=null!=t&&t.startsWith("/")?"/":"",a=n.join("/"),u=n.length>0&&null!=t&&t.endsWith("/")?"/":"",s="".concat(c).concat(a).concat(u);return encodeURIComponent(s).replace(/%2F/g,"/")}},{key:"computeCanonicalQuerystring",value:function(e){var t,r=e.query,n=void 0===r?{}:r,o=[],i={},c=function(e){if(e.toLowerCase()===j)return"continue";o.push(e);var t=n[e];"string"==typeof t?i[e]="".concat(ie(e),"=").concat(ie(t)):Array.isArray(t)&&(i[e]=t.slice(0).sort().reduce((function(t,r){return t.concat(["".concat(ie(e),"=").concat(ie(r))])}),[]).join("&"))},a=J(Object.keys(n).sort());try{for(a.s();!(t=a.n()).done;)c(t.value)}catch(e){a.e(e)}finally{a.f()}return o.map((function(e){return i[e]})).filter((function(e){return e})).join("&")}},{key:"computeCanonicalHeaders",value:function(e,t,r){var n,o=e.headers,i={},c=J(Object.keys(o).sort());try{for(c.s();!(n=c.n()).done;){var a=n.value;if(null!=o[a]){var u=a.toLowerCase();(u in A||null!=t&&t.has(u))&&(!r||r&&!r.has(u))||(i[u]=o[a].trim().replace(/\s+/g," "))}}}catch(e){c.e(e)}finally{c.f()}return i}},{key:"computePayloadHash",value:function(e){for(var t,r=e.headers,n=e.body,o=0,i=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=r.headers,o=r.query,i=void 0===o?{}:o,c=0,a=Object.keys(n);c1&&void 0!==arguments[1]&&arguments[1],r=this.signature.sign({method:this.method,protocol:this.awsConfig.scheme,hostname:this.host,path:"/",headers:pe(pe({},this.commonHeaders),{},Se({},S,"AmazonSSM.GetParameter")),body:JSON.stringify({Name:e,WithDecryption:t})},{}),n=ue().request(this.method,r.url,r.body,{headers:r.headers});return this._handle_error(Pe.GetParameter,n),ke.fromJSON(n.json())}},{key:"_handle_error",value:function(e,t){var r=t.error_code;if(0!==r){var n=t.json();if(r>=1400&&r<=1499){var o=n.Message||n.message||n.__type;if("InvalidSignatureException"===n.__type)throw new oe(o,n.__type);throw new Ae(o,n.__type,e)}if(1500===r)throw new Ae("An error occured on the server side","InternalServiceError",e)}}}]),r}(function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),fe(this,"awsConfig",void 0),fe(this,"serviceName",void 0),fe(this,"_host",void 0),this.awsConfig=t,this.serviceName=r}var t,r,n;return t=e,(r=[{key:"host",get:function(){return null==this._host?"".concat(this.serviceName,".").concat(this.awsConfig.region,".").concat(this.awsConfig.endpoint):this._host},set:function(e){this._host=e}}])&&se(t.prototype,r),n&&se(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()),ke=function(){function e(t,r,n,o,i,c,a,u,s){he(this,e),Se(this,"arn",void 0),Se(this,"dataType",void 0),Se(this,"lastModifiedDate",void 0),Se(this,"name",void 0),Se(this,"selector",void 0),Se(this,"sourceResult",void 0),Se(this,"type",void 0),Se(this,"value",void 0),Se(this,"version",void 0),this.arn=t,this.dataType=r,this.lastModifiedDate=n,this.name=o,this.selector=i,this.sourceResult=c,this.type=a,this.value=u,this.version=s}return be(e,null,[{key:"fromJSON",value:function(t){var r=t.Parameter;return new e(r.ARN,r.DataType,r.LastModifiedDate,r.Name,r.Selector,r.SourceResult,r.Type,r.Value,r.Version)}}]),e}(),Ae=function(e){ve(r,e);var t=ge(r);function r(e,n,o){var i;return he(this,r),Se(Oe(i=t.call(this,e,n)),"operation",void 0),i.name="SystemsManagerServiceError",i.operation=o,i}return be(r)}(W);!function(e){e.GetParameter="GetParameter"}(Pe||(Pe={}));var Ce=exports;for(var Ee in t)Ce[Ee]=t[Ee];t.__esModule&&Object.defineProperty(Ce,"__esModule",{value:!0})})(); //# sourceMappingURL=ssm.min.js.map \ No newline at end of file diff --git a/build/ssm.min.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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 /**\n * Error code issued by the service (if any)\n */\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 /**\n * The Amazon Resource Name (ARN) of the parameter.\n */\n arn: string\n\n /**\n * The data type of the parameter, such as text or aws:ec2:image.\n * The default is text.\n */\n dataType: string\n\n /**\n * Date the parameter was last changed or updated and the parameter version was created.\n */\n lastModifiedDate: number\n\n /**\n * The friendly name of the parameter.\n */\n name: string\n\n /**\n * 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 */\n selector: string\n\n /**\n * plies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n */\n sourceResult: string\n\n /**\n * The type of parameter. Valid values include the following: String, StringList, and SecureString.\n */\n type: string\n\n /**\n * The parameter value.\n */\n value: string\n\n /**\n * The parameter version.\n */\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter\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 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 const parameter = json.Parameter as JSONObject\n\n return new SystemsManagerParameter(\n parameter.ARN as string,\n parameter.DataType as string,\n parameter.LastModifiedDate as number,\n parameter.Name as string,\n parameter.Selector as string,\n parameter.SourceResult as string,\n parameter.Type as string,\n parameter.Value as string,\n parameter.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","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","arn","dataType","lastModifiedDate","selector","sourceResult","type","version","parameter","Parameter","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,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,+zECFvD,IAAMC,EAAb,GAmDI,WAAYC,GACR,GADmC,8IAjBlB,SAiBkB,kBARpB,iBASQ,KAAnBA,EAAQC,OACR,MAAM,IAAIC,EACN,4DAIR,GAA4B,KAAxBF,EAAQG,YACR,MAAM,IAAID,EACN,mEAIR,GAAIF,EAAQG,YAAYC,OAAS,IAA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3E,EAAKC,KAAO,6BACZ,EAAKoI,UAAYA,EAH0D,CAI9E,CAdL,cAAgDtI,I,SAoB3CmH,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/./src/internal/config.ts","webpack://k6-jslib-aws/external commonjs \"k6/crypto\"","webpack://k6-jslib-aws/./src/internal/constants.ts","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/http.ts","webpack://k6-jslib-aws/./src/internal/utils.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};","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 // FIXME: Should really be called \"host\" instead. When used\n // with localstack we pass a complete host (hostname:port) here.\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/crypto\");","/**\n * Standard Amazon AWS query parameter names\n */\nexport const AMZ_ALGORITHM_QUERY_PARAM = 'X-Amz-Algorithm'\nexport const AMZ_CREDENTIAL_QUERY_PARAM = 'X-Amz-Credential'\nexport const AMZ_DATE_QUERY_PARAM = 'X-Amz-Date'\nexport const AMZ_EXPIRES_QUERY_PARAM = 'X-Amz-Expires'\nexport const AMZ_SIGNATURE_QUERY_PARAM = 'X-Amz-Signature'\nexport const AMZ_SIGNED_HEADERS_QUERY_PARAM = 'X-Amz-SignedHeaders'\nexport const AMZ_TARGET_QUERY_PARAM = 'X-Amz-Target'\nexport const AMZ_TOKEN_QUERY_PARAM = 'X-Amz-Security-Token'\n\n/**\n * Standard Amazon AWS header names\n */\nexport const AMZ_CONTENT_SHA256_HEADER = 'x-amz-content-sha256'\nexport const AMZ_DATE_HEADER = AMZ_DATE_QUERY_PARAM.toLowerCase()\nexport const AMZ_SIGNATURE_HEADER = AMZ_SIGNATURE_QUERY_PARAM.toLowerCase()\nexport const AMZ_TARGET_HEADER = AMZ_TARGET_QUERY_PARAM.toLowerCase()\nexport const AMZ_TOKEN_HEADER = AMZ_TOKEN_QUERY_PARAM.toLowerCase()\n\n/**\n * Common HTTP headers we rely on in the signing process\n */\nexport const AUTHORIZATION_HEADER = 'authorization'\nexport const DATE_HEADER = 'date'\n\n/**\n * Lists the headers that are generated as part of the signature process.\n */\nexport const GENERATED_HEADERS = [AUTHORIZATION_HEADER, AMZ_DATE_HEADER, DATE_HEADER]\nexport const HOST_HEADER = 'host'\n\n/**\n * Lists the headers that should never be included in the\n * request signature signature process.\n */\nexport const ALWAYS_UNSIGNABLE_HEADERS = {\n authorization: true,\n 'cache-control': true,\n connection: true,\n expect: true,\n from: true,\n 'keep-alive': true,\n 'max-forwards': true,\n pragma: true,\n referer: true,\n te: true,\n trailer: true,\n 'transfer-encoding': true,\n upgrade: true,\n 'user-agent': true,\n 'x-amzn-trace-id': true,\n}\n\n/**\n * Signature specific constants included in the signing process\n */\nexport const KEY_TYPE_IDENTIFIER = 'aws4_request'\nexport const SIGNING_ALGORITHM_IDENTIFIER = 'AWS4-HMAC-SHA256'\n\n/**\n * Maximum time to live of a signed request in seconds: 7 days.\n */\nexport const MAX_PRESIGNED_TTL = 60 * 60 * 24 * 7\n\n/**\n * SHA256 hash of an empty string (so we don't waste cycles recomputing it)\n */\nexport const EMPTY_SHA256 = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\n/**\n * SHA256 hash of the unsigned payload constant (so we don't waste cycles recomputing it)\n */\nexport const UNSIGNED_PAYLOAD_SHA256 =\n '5a41b0751e4537c6ff868564ab44a4d4ecceec2ec5b1c5f74d97422968e04237'\n\nexport const UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'\n","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 /**\n * Error code issued by the service (if any)\n */\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 from 'k6/crypto'\n\nimport * as constants from './constants'\nimport { AWSError } from './error'\nimport { hasHeader, HTTPHeaderBag, HTTPRequest, QueryParameterBag, SignedHTTPRequest } from './http'\nimport { isArrayBuffer } from './utils'\n\n/**\n * SignatureV4 can be used to sign HTTP requests and presign URLs using the AWS Signature\n * Version 4 signing process.\n *\n * It offers two signing methods:\n * - sign: signs the request headers and payload\n * - presign: returns a presigned (authorization information contained in the query string) URL\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html\n */\nexport class SignatureV4 {\n /**\n * The name of the service to sign for.\n */\n private readonly service: string\n\n /**\n * The name of the region to sign for.\n */\n private readonly region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n private readonly credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n private readonly uriEscapePath: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n private readonly applyChecksum: boolean\n\n // TODO: uriEscapePath and applyChecksum should not be present in the constructor\n constructor({\n service,\n region,\n credentials,\n uriEscapePath,\n applyChecksum,\n }: SignatureV4Options) {\n this.service = service\n this.region = region\n this.credentials = credentials\n this.uriEscapePath = typeof uriEscapePath === 'boolean' ? uriEscapePath : true\n this.applyChecksum = typeof applyChecksum === 'boolean' ? applyChecksum : true\n }\n\n /**\n * Includes AWS v4 signing information to the provided HTTP request.\n *\n * This method adds an Authorization header to the request, containing\n * the signature and other signing information. It also returns a preformatted\n * URL that can be used to make the k6 http request.\n *\n * This method mutates the request object.\n *\n * @param request {HTTPRequest} The request to sign.\n * @param param1 {SignOptions} Options for signing the request.\n * @returns {SignedHTTPRequest} The signed request.\n */\n sign(\n request: HTTPRequest,\n {\n signingDate = new Date(),\n signingService,\n signingRegion,\n unsignableHeaders = new Set(),\n signableHeaders = new Set(),\n }: RequestSigningOptions\n ): SignedHTTPRequest {\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const service = signingService || this.service\n const region = signingRegion || this.region\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n\n // FIXME: test wants us to leave host alone, but I'm unsure at this point\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n // request.headers[constants.HOST_HEADER] = request.hostname\n\n // Filter out headers that will be generated and managed by the signing process.\n // If the user provide any of those as part of the HTTPRequest's headers, they\n // will be ignored.\n for (const headerName of Object.keys(request.headers)) {\n if (constants.GENERATED_HEADERS.indexOf(headerName.toLowerCase()) > -1) {\n delete request.headers[headerName]\n }\n }\n\n request.headers[constants.AMZ_DATE_HEADER] = longDate\n if (this.credentials.sessionToken) {\n request.headers[constants.AMZ_TOKEN_HEADER] = this.credentials.sessionToken\n }\n\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n if (ArrayBuffer.isView(request.body)) {\n request.body = request.body.buffer\n }\n\n // Ensure we avoid passing undefined to the crypto hash function.\n if (!request.body) {\n request.body = ''\n }\n\n let payloadHash = constants.EMPTY_SHA256\n if (this.applyChecksum) {\n if (!hasHeader(constants.AMZ_CONTENT_SHA256_HEADER, request.headers)) {\n payloadHash = crypto.sha256(request.body, 'hex').toLowerCase()\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] = payloadHash\n } else if (\n request.headers[constants.AMZ_CONTENT_SHA256_HEADER] === constants.UNSIGNED_PAYLOAD\n ) {\n payloadHash = constants.UNSIGNED_PAYLOAD\n }\n }\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n const signature = this.calculateSignature(longDate, scope, signingKey, canonicalRequest)\n\n /**\n * Step 4 of the signing process: add the signature to the HTTP request's headers.\n *\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n */\n request.headers[constants.AUTHORIZATION_HEADER] =\n `${constants.SIGNING_ALGORITHM_IDENTIFIER} ` +\n `Credential=${this.credentials.accessKeyId}/${scope}, ` +\n `SignedHeaders=${Object.keys(canonicalHeaders).sort().join(';')}, ` +\n `Signature=${signature}`\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n // We exclude the signature from the query string\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return {\n url: url,\n ...request,\n }\n }\n\n /**\n * Produces a presigned URL with AWS v4 signature information for the provided HTTP request.\n *\n * A presigned URL is a URL that contains the authorization information\n * (signature and other signing information) in the query string. This method\n * returns a preformatted URL that can be used to make the k6 http request.\n *\n * @param originalRequest - The original request to presign.\n * @param options - Options controlling the signing of the request.\n * @returns A signed request, including the presigned URL.\n */\n presign(originalRequest: HTTPRequest, options: PresignOptions = {}): SignedHTTPRequest {\n const {\n signingDate = new Date(),\n expiresIn = 3600,\n unsignableHeaders,\n unhoistableHeaders,\n signableHeaders,\n signingRegion,\n signingService,\n } = options\n const { longDate, shortDate }: DateInfo = formatDate(signingDate)\n const region = signingRegion || this.region\n const service = signingService || this.service\n\n if (expiresIn > constants.MAX_PRESIGNED_TTL) {\n throw new InvalidSignatureError(\n \"Signature version 4 presigned URLs can't be valid for more than 7 days\"\n )\n }\n\n const scope = `${shortDate}/${region}/${service}/${constants.KEY_TYPE_IDENTIFIER}`\n const request = this.moveHeadersToQuery(originalRequest, { unhoistableHeaders })\n\n // Required by the specification:\n // \"For HTTP/1.1 requests, you must include the host header at a minimum.\n // Standard headers like content-type are optional.\n // For HTTP/2 requests, you must include the :authority header instead of\n // the host header. Different services might require other headers.\"\n request.headers[constants.HOST_HEADER] = originalRequest.hostname\n\n // If the user provided a session token, include it in the signed url query string.\n if (this.credentials.sessionToken) {\n request.query[constants.AMZ_TOKEN_QUERY_PARAM] = this.credentials.sessionToken\n }\n\n // Add base signing query parameters to the request, as described in the documentation\n // @see https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n request.query[constants.AMZ_ALGORITHM_QUERY_PARAM] = constants.SIGNING_ALGORITHM_IDENTIFIER\n request.query[\n constants.AMZ_CREDENTIAL_QUERY_PARAM\n ] = `${this.credentials.accessKeyId}/${scope}`\n request.query[constants.AMZ_DATE_QUERY_PARAM] = longDate\n request.query[constants.AMZ_EXPIRES_QUERY_PARAM] = expiresIn.toString(10)\n\n const canonicalHeaders = this.computeCanonicalHeaders(\n request,\n unsignableHeaders,\n signableHeaders\n )\n request.query[constants.AMZ_SIGNED_HEADERS_QUERY_PARAM] = Object.keys(canonicalHeaders)\n .sort()\n .join(';')\n\n const signingKey = this.deriveSigningKey(this.credentials, service, region, shortDate)\n\n // Computing the payload from the original request. This is required\n // in the event the user attempts to produce a presigned URL for s3,\n // which requires the payload hash to be 'UNSIGNED-PAYLOAD'.\n //\n // To that effect, users need to set the 'x-amz-content-sha256' header,\n // and mark it as unhoistable and unsignable. When setup this way,\n // the computePayloadHash method will then return the string 'UNSIGNED-PAYLOAD'.\n const payloadHash = this.computePayloadHash(originalRequest)\n const canonicalRequest = this.createCanonicalRequest(request, canonicalHeaders, payloadHash)\n\n request.query[constants.AMZ_SIGNATURE_QUERY_PARAM] = this.calculateSignature(\n longDate,\n scope,\n signingKey,\n canonicalRequest\n )\n\n // If a request path was provided, add it to the URL\n let url = `${request.protocol}://${request.hostname}`\n if (request.path) {\n url += request.path\n }\n\n // If a request query string was provided, add it to the URL\n if (request.query) {\n url += `?${this.serializeQueryParameters(request.query)}`\n }\n\n return { url: url, ...request }\n }\n\n /**\n * Create a string including information from your request\n * in a AWS signature v4 standardized (canonical) format.\n *\n * Step 1 of the signing process: create the canonical request string.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html\n *\n * @param request {HTTPRequest} The request to sign.\n * @param canonicalHeaders {HTTPHeaderBag} The request's canonical headers.\n * @param payloadHash {string} The hexadecimally encoded request's payload hash .\n * @returns {string} The canonical request string.\n */\n private createCanonicalRequest(\n request: HTTPRequest,\n canonicalHeaders: HTTPHeaderBag,\n payloadHash: string\n ): string {\n const sortedHeaders = Object.keys(canonicalHeaders).sort()\n const sortedCanonicalHeaders = sortedHeaders\n .map((name) => `${name}:${canonicalHeaders[name]}`)\n .join('\\n')\n const signedHeaders = sortedHeaders.join(';')\n\n return (\n `${request.method}\\n` +\n `${this.computeCanonicalURI(request)}\\n` +\n `${this.computeCanonicalQuerystring(request)}\\n` +\n `${sortedCanonicalHeaders}\\n\\n` +\n `${signedHeaders}\\n` +\n `${payloadHash}`\n )\n }\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 * Step 2 of the signing process: create the string to sign.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The \"string to sign\".\n */\n private createStringToSign(\n longDate: string,\n credentialScope: string,\n canonicalRequest: string\n ): string {\n const hashedCanonicalRequest = crypto.sha256(canonicalRequest, 'hex')\n\n return (\n `${constants.SIGNING_ALGORITHM_IDENTIFIER}\\n` +\n `${longDate}\\n` +\n `${credentialScope}\\n` +\n `${hashedCanonicalRequest}`\n )\n }\n\n /**\n * Calculte the signature for AWS signature version 4.\n *\n * Step 3 of the signing process: create the signature.\n * @see https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html\n *\n * @param longDate {string} The request's date in iso 8601 format.\n * @param credentialScope {string} The request's credential scope.\n * @param signingKey {string} the signing key as computed by the deriveSigningKey method.\n * @param canonicalRequest {string} The request's canonical request.\n * @returns {string} The signature.\n */\n private calculateSignature(\n longDate: string,\n credentialScope: string,\n signingKey: Uint8Array,\n canonicalRequest: string\n ): string {\n const stringToSign = this.createStringToSign(longDate, credentialScope, canonicalRequest)\n return crypto.hmac('sha256', signingKey, stringToSign, 'hex')\n }\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 credentials {AWSCredentials} The credentials to use for signing.\n * @param service {string} The service the request is targeted at.\n * @param region {string} The region the request is targeted at.\n * @param shortDate {string} The request's date in YYYYMMDD format.\n * @returns {Uint8Array} The derived signing key.\n */\n private deriveSigningKey(\n credentials: Credentials,\n service: string,\n region: string,\n shortDate: string\n ): Uint8Array {\n const kSecret = credentials.secretAccessKey\n const kDate: any = crypto.hmac('sha256', 'AWS4' + kSecret, shortDate, 'binary')\n const kRegion: any = crypto.hmac('sha256', kDate, region, 'binary')\n const kService: any = crypto.hmac('sha256', kRegion, service, 'binary')\n const kSigning: any = crypto.hmac('sha256', kService, 'aws4_request', 'binary')\n\n return kSigning\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 param0 {HTTPRequest} The request to sign.\n * @returns {string} The canonical URI.\n */\n private computeCanonicalURI({ path }: HTTPRequest): string {\n if (!this.uriEscapePath) {\n // If the path is not uri-escaped, as in S3, then there's no need to\n // double encode it nor normalize it.\n return path\n }\n\n const normalizedURISegments = []\n\n for (const URISegment of path.split('/')) {\n if (URISegment?.length == 0) {\n continue\n }\n\n if (URISegment === '.') {\n continue\n }\n\n if (URISegment === '..') {\n normalizedURISegments.pop()\n } else {\n normalizedURISegments.push(URISegment)\n }\n }\n\n // Normalize and double encode the URI\n const leading = path?.startsWith('/') ? '/' : ''\n const URI = normalizedURISegments.join('/')\n const trailing = normalizedURISegments.length > 0 && path?.endsWith('/') ? '/' : ''\n const normalizedURI = `${leading}${URI}${trailing}`\n\n const doubleEncoded = encodeURIComponent(normalizedURI)\n\n return doubleEncoded.replace(/%2F/g, '/')\n }\n\n /**\n * Serializes the request's query parameters into their canonical\n * string version. If the request does not include a query parameters,\n * returns an empty string.\n *\n * @param param0 {HTTPRequest} The request containing the query parameters.\n * @returns {string} The canonical query string.\n */\n private computeCanonicalQuerystring({ query = {} }: HTTPRequest): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (key.toLowerCase() === constants.AMZ_SIGNATURE_HEADER) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\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 * @param param0 {HTTPRequest} The request to compute the canonical headers of.\n * @param unsignableHeaders {Set} The headers that should not be signed.\n * @param signableHeaders {Set} The headers that should be signed.\n * @returns {string} The canonical headers.\n */\n private computeCanonicalHeaders(\n { headers }: HTTPRequest,\n unsignableHeaders?: Set,\n signableHeaders?: Set\n ): HTTPHeaderBag {\n const canonicalHeaders: HTTPHeaderBag = {}\n\n for (const headerName of Object.keys(headers).sort()) {\n if (headers[headerName] == undefined) {\n continue\n }\n\n const canonicalHeaderName = headerName.toLowerCase()\n if (\n canonicalHeaderName in constants.ALWAYS_UNSIGNABLE_HEADERS ||\n unsignableHeaders?.has(canonicalHeaderName)\n ) {\n if (\n !signableHeaders ||\n (signableHeaders && !signableHeaders.has(canonicalHeaderName))\n ) {\n continue\n }\n }\n\n canonicalHeaders[canonicalHeaderName] = headers[headerName].trim().replace(/\\s+/g, ' ')\n }\n\n return canonicalHeaders\n }\n\n /**\n * Computes the SHA256 cryptographic hash of the request's body.\n *\n * If the headers contain the 'X-Amz-Content-Sha256' header, then\n * the value of that header is returned instead. This proves useful\n * when, for example, presiging a URL for S3, as the payload hash\n * must always be equal to 'UNSIGNED-PAYLOAD'.\n *\n * @param param0 {HTTPRequest} The request to compute the payload hash of.\n * @returns {string} The hex encoded SHA256 payload hash, or the value of the 'X-Amz-Content-Sha256' header.\n */\n private computePayloadHash({ headers, body }: HTTPRequest): string {\n for (const headerName of Object.keys(headers)) {\n // If the header is present, return its value.\n // So that we let the 'UNSIGNED-PAYLOAD' value pass through.\n if (headerName.toLowerCase() === constants.AMZ_CONTENT_SHA256_HEADER) {\n return headers[headerName]\n }\n }\n\n if (body == undefined) {\n return constants.EMPTY_SHA256\n }\n\n if (typeof body === 'string' || isArrayBuffer(body)) {\n return crypto.sha256(body, 'hex').toLowerCase()\n }\n\n if (ArrayBuffer.isView(body)) {\n // If the request body is a typed array, we need to convert it to a buffer\n // so that we can calculate the checksum.\n return crypto.sha256((body as DataView).buffer, 'hex').toLowerCase()\n }\n\n return constants.UNSIGNED_PAYLOAD\n }\n\n /**\n * Moves a request's headers to its query parameters.\n *\n * The operation will ignore any amazon standard headers, prefixed\n * with 'X-Amz-'. It will also ignore any headers specified as unhoistable\n * by the options.\n *\n * The operation will delete the headers from the request.\n *\n * @param request {HTTPRequest} The request to move the headers from.\n * @param options\n * @returns {HTTPRequest} The request with the headers moved to the query parameters.\n */\n private moveHeadersToQuery(\n request: HTTPRequest,\n options: { unhoistableHeaders?: Set } = {}\n ): HTTPRequest & { query: QueryParameterBag } {\n const requestCopy = JSON.parse(JSON.stringify(request))\n const { headers, query = {} as QueryParameterBag } = requestCopy\n\n for (const name of Object.keys(headers)) {\n const lowerCaseName = name.toLowerCase()\n if (\n lowerCaseName.slice(0, 6) === 'x-amz-' &&\n !options.unhoistableHeaders?.has(lowerCaseName)\n ) {\n query[name] = headers[name]\n delete headers[name]\n }\n }\n\n return {\n ...requestCopy,\n headers,\n query,\n }\n }\n\n /**\n * Serializes a HTTPRequest's query parameter bag into a string.\n *\n * @param query {QueryParameterBag} The query parameters to serialize.\n * @param ignoreKeys {Set} The keys to ignore.\n * @returns {string} The serialized, and ready to use in a URL, query parameters.\n */\n private serializeQueryParameters(query: QueryParameterBag, ignoreKeys?: string[]): string {\n const keys: Array = []\n const serialized: Record = {}\n\n for (const key of Object.keys(query).sort()) {\n if (ignoreKeys?.includes(key.toLowerCase())) {\n continue\n }\n\n keys.push(key)\n const value = query[key]\n\n if (typeof value === 'string') {\n serialized[key] = `${escapeURI(key)}=${escapeURI(value)}`\n } else if (Array.isArray(value)) {\n serialized[key] = value\n .slice(0)\n .sort()\n .reduce(\n (encoded: Array, value: string) =>\n encoded.concat([`${escapeURI(key)}=${escapeURI(value)}`]),\n []\n )\n .join('&')\n }\n }\n\n return keys\n .map((key) => serialized[key])\n .filter((serialized) => serialized)\n .join('&')\n }\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\nexport interface SignatureV4Options {\n /**\n * The name of the service to sign for.\n */\n service: string\n\n /**\n * The name of the region to sign for.\n */\n region: string\n\n /**\n * The credentials with which the request should be signed.\n */\n credentials: Credentials\n\n /**\n * Whether to uri-escape the request URI path as part of computing the\n * canonical request string. This is required for every AWS service, except\n * Amazon S3, as of late 2017.\n *\n * @default [true]\n */\n uriEscapePath?: boolean\n\n /**\n * Whether to calculate a checksum of the request body and include it as\n * either a request header (when signing) or as a query string parameter\n * (when presigning). This is required for AWS Glacier and Amazon S3 and optional for\n * every other AWS service as of late 2017.\n *\n * @default [true]\n */\n applyChecksum?: boolean\n}\n\nexport interface SignOptions {\n /**\n * The date and time to be used as signature metadata. This value should be\n * a Date object, a unix (epoch) timestamp, or a string that can be\n * understood by the JavaScript `Date` constructor.If not supplied, the\n * value returned by `new Date()` will be used.\n */\n signingDate?: Date\n\n /**\n * The service signing name. It will override the service name of the signer\n * in current invocation\n */\n signingService?: string\n\n /**\n * The region name to sign the request. It will override the signing region of the\n * signer in current invocation\n */\n signingRegion?: string\n}\n\nexport interface RequestSigningOptions extends SignOptions {\n /**\n * A set of strings whose members represents headers that cannot be signed.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unsignableHeaders set.\n */\n unsignableHeaders?: Set\n\n /**\n * A set of strings whose members represents headers that should be signed.\n * Any values passed here will override those provided via unsignableHeaders,\n * allowing them to be signed.\n *\n * All headers in the provided request will have their names converted to\n * lower case before signing.\n */\n signableHeaders?: Set\n}\n\nexport interface PresignOptions extends RequestSigningOptions {\n /**\n * The number of seconds before the presigned URL expires\n */\n expiresIn?: number\n\n /**\n * A set of strings whose representing headers that should not be hoisted\n * to presigned request's query string. If not supplied, the presigner\n * moves all the AWS-specific headers (starting with `x-amz-`) to the request\n * query string. If supplied, these headers remain in the presigned request's\n * header.\n * All headers in the provided request will have their names converted to\n * lower case and then checked for existence in the unhoistableHeaders set.\n */\n unhoistableHeaders?: Set\n}\n\nexport interface Credentials {\n /**\n * AWS access key ID\n */\n readonly accessKeyId: string\n\n /**\n * AWS secret access key\n */\n readonly secretAccessKey: string\n\n /**\n * A security or session token to use with these credentials. Usually\n * present for temporary credentials.\n */\n readonly sessionToken?: string\n}\n\nexport interface DateInfo {\n /**\n * ISO8601 formatted date string\n */\n longDate: string\n\n /**\n * String in the format YYYYMMDD\n */\n shortDate: string\n}\n\n/**\n * Escapes a URI following the AWS signature v4 escaping rules.\n *\n * @param URI {string} The URI to escape.\n * @returns {string} The escaped URI.\n */\nfunction escapeURI(URI: string): string {\n const hexEncode = (c: string): string => {\n return `%${c.charCodeAt(0).toString(16).toUpperCase()}`\n }\n\n return encodeURIComponent(URI).replace(/[!'()*]/g, hexEncode)\n}\n\n/**\n * formatDate formats a Date object into a ISO8601 formatted date string\n * and a string in the format YYYYMMDD.\n *\n * @param date {Date} The date to format.\n * @returns {DateInfo} The formatted date.\n */\nfunction formatDate(date: Date): DateInfo {\n const longDate = iso8601(date).replace(/[\\-:]/g, '')\n return {\n longDate,\n shortDate: longDate.slice(0, 8),\n }\n}\n\n/**\n * Formats a time into an ISO 8601 string.\n *\n * @see https://en.wikipedia.org/wiki/ISO_8601\n *\n * @param time {number | string | Date} The time to format.\n * @returns {string} The ISO 8601 formatted time.\n */\nfunction iso8601(time: number | string | Date): string {\n return toDate(time)\n .toISOString()\n .replace(/\\.\\d{3}Z$/, 'Z')\n}\n\n/**\n * Converts a time value into a Date object.\n *\n * @param time {number | string | Date} The time to convert.\n * @returns {Date} The resulting Date object.\n */\nfunction toDate(time: number | string | Date): Date {\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n\n if (typeof time === 'string') {\n if (Number(time)) {\n return new Date(Number(time) * 1000)\n }\n\n return new Date(time)\n }\n\n return time\n}\n","/**\n * Type representing HTTP schemes\n */\nexport type HTTPScheme = 'http' | 'https'\n\n/**\n * Type representing HTTP Methods\n *\n */\nexport type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * Type alias representing HTTP Headers\n */\nexport type HTTPHeaders = { [key: string]: string }\n\n/**\n * HTTPHeaderBag is a type alias representing HTTP Headers\n */\nexport type HTTPHeaderBag = Record\n\nexport function hasHeader(soughtHeader: string, headers: HTTPHeaderBag): boolean {\n soughtHeader = soughtHeader.toLowerCase()\n\n for (const headerName of Object.keys(headers)) {\n if (soughtHeader === headerName.toLowerCase()) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * QueryParameterBag is a type alias representing HTTP Query Parameters\n */\nexport type QueryParameterBag = Record>\n\n/**\n * HTTPRequest represents an HTTP request\n */\nexport interface HTTPRequest {\n /**\n * The HTTP method to use\n */\n method: HTTPMethod\n\n /**\n * The protocol to use (http or https)\n */\n protocol: HTTPScheme\n\n /**\n * The hostname (domain name or IP address) the request targets\n */\n hostname: string\n\n /**\n * The port to the request targets\n */\n port?: number\n\n /**\n * The path to the resource\n */\n path: string\n\n /**\n * The query parameters to include in the request\n */\n query?: QueryParameterBag\n\n /**\n * The headers to include in the request\n */\n headers: HTTPHeaderBag\n\n /**\n * The body of the request\n */\n body?: string | ArrayBuffer | null\n}\n\n/**\n * SignedHTTPRequest represents an HTTP request that has been signed\n * with an AWS signature. It is a superset of HTTPRequest adding\n * the following fields:\n * - url: the fully qualified URL of the request that can be used in a k6 http.request.\n */\nexport interface SignedHTTPRequest extends HTTPRequest {\n url: string\n}\n","/**\n *\n * @param value\n * @returns\n */\nexport function isArrayBuffer(value: any): value is ArrayBuffer {\n return (\n typeof ArrayBuffer === 'function' &&\n (value instanceof ArrayBuffer ||\n Object.prototype.toString.call(value) === '[object ArrayBuffer]')\n )\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/http\");","import { JSONObject } from 'k6'\nimport http, { RefinedResponse, ResponseType } from 'k6/http'\n\nimport { AWSClient } from './client'\nimport { AWSConfig } from './config'\nimport { AMZ_TARGET_HEADER } from './constants'\nimport { AWSError } from './error'\nimport { HTTPHeaders, HTTPMethod } from './http'\nimport { InvalidSignatureError, SignatureV4 } from './signature'\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 signature: SignatureV4\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 super(awsConfig, 'ssm')\n\n // All interactions with the Systems Manager service\n // are made via the POST method.\n this.method = 'POST'\n this.commonHeaders = {\n 'Content-Type': 'application/x-amz-json-1.1',\n }\n\n this.signature = new SignatureV4({\n service: this.serviceName,\n region: awsConfig.region,\n credentials: {\n accessKeyId: awsConfig.accessKeyID,\n secretAccessKey: awsConfig.secretAccessKey,\n },\n uriEscapePath: false,\n applyChecksum: false,\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 signedRequest = this.signature.sign(\n {\n method: this.method,\n protocol: this.awsConfig.scheme,\n hostname: this.host,\n path: '/',\n headers: {\n ...this.commonHeaders,\n [AMZ_TARGET_HEADER]: `AmazonSSM.GetParameter`,\n },\n body: JSON.stringify({ Name: name, WithDecryption: withDecryption }),\n },\n {}\n )\n\n const res = http.request(this.method, signedRequest.url, signedRequest.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 /**\n * The Amazon Resource Name (ARN) of the parameter.\n */\n arn: string\n\n /**\n * The data type of the parameter, such as text or aws:ec2:image.\n * The default is text.\n */\n dataType: string\n\n /**\n * Date the parameter was last changed or updated and the parameter version was created.\n */\n lastModifiedDate: number\n\n /**\n * The friendly name of the parameter.\n */\n name: string\n\n /**\n * 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 */\n selector: string\n\n /**\n * plies to parameters that reference information in other AWS services. SourceResult is the raw result or response from the source.\n */\n sourceResult: string\n\n /**\n * The type of parameter. Valid values include the following: String, StringList, and SecureString.\n */\n type: string\n\n /**\n * The parameter value.\n */\n value: string\n\n /**\n * The parameter version.\n */\n version: number\n\n /**\n * Constructs a Systems Manager's Parameter\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 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 const parameter = json.Parameter as JSONObject\n\n return new SystemsManagerParameter(\n parameter.ARN as string,\n parameter.DataType as string,\n parameter.LastModifiedDate as number,\n parameter.Name as string,\n parameter.Selector as string,\n parameter.SourceResult as string,\n parameter.Type as string,\n parameter.Value as string,\n parameter.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 { AWSConfig } from './config'\nimport { HTTPHeaders } from './http'\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\n private _host?: string\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) {\n this.awsConfig = awsConfig\n this.serviceName = serviceName\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 public get host() {\n if (this._host == undefined) {\n return `${this.serviceName}.${this.awsConfig.region}.${this.awsConfig.endpoint}`\n }\n return this._host\n }\n\n public set host(host: string) {\n this._host = host\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","AWSConfig","options","region","InvalidAWSConfigError","accessKeyId","length","secretAccessKey","this","undefined","sessionToken","scheme","endpoint","message","Error","require","AMZ_DATE_QUERY_PARAM","AMZ_SIGNATURE_QUERY_PARAM","AMZ_TOKEN_QUERY_PARAM","AMZ_CONTENT_SHA256_HEADER","AMZ_DATE_HEADER","toLowerCase","AMZ_SIGNATURE_HEADER","AMZ_TARGET_HEADER","AMZ_TOKEN_HEADER","AUTHORIZATION_HEADER","GENERATED_HEADERS","ALWAYS_UNSIGNABLE_HEADERS","authorization","connection","expect","from","pragma","referer","te","trailer","upgrade","KEY_TYPE_IDENTIFIER","SIGNING_ALGORITHM_IDENTIFIER","MAX_PRESIGNED_TTL","EMPTY_SHA256","UNSIGNED_PAYLOAD","AWSError","code","name","xmlDocument","doc","parseHTML","find","text","SignatureV4","service","credentials","uriEscapePath","applyChecksum","request","signingDate","Date","signingService","signingRegion","unsignableHeaders","Set","signableHeaders","formatDate","longDate","shortDate","scope","constants","keys","headers","headerName","ArrayBuffer","isView","body","buffer","payloadHash","soughtHeader","hasHeader","crypto","canonicalHeaders","computeCanonicalHeaders","canonicalRequest","createCanonicalRequest","signingKey","deriveSigningKey","signature","calculateSignature","sort","join","url","protocol","hostname","path","query","serializeQueryParameters","originalRequest","expiresIn","unhoistableHeaders","InvalidSignatureError","moveHeadersToQuery","toString","computePayloadHash","sortedHeaders","sortedCanonicalHeaders","map","signedHeaders","method","computeCanonicalURI","computeCanonicalQuerystring","credentialScope","hashedCanonicalRequest","stringToSign","createStringToSign","kSecret","kDate","kRegion","kService","normalizedURISegments","split","URISegment","pop","push","leading","startsWith","URI","trailing","endsWith","normalizedURI","encodeURIComponent","replace","serialized","escapeURI","Array","isArray","slice","reduce","encoded","concat","filter","canonicalHeaderName","has","trim","requestCopy","JSON","parse","stringify","lowerCaseName","ignoreKeys","includes","c","charCodeAt","toUpperCase","date","time","Number","toDate","toISOString","SystemsManagerOperation","SystemsManagerClient","awsConfig","commonHeaders","serviceName","accessKeyID","withDecryption","signedRequest","sign","host","Name","WithDecryption","res","http","_handle_error","GetParameter","SystemsManagerParameter","fromJSON","json","operation","response","errorCode","error_code","error","errorMessage","Message","__type","SystemsManagerServiceError","_host","arn","dataType","lastModifiedDate","selector","sourceResult","type","version","parameter","Parameter","ARN","DataType","LastModifiedDate","Selector","SourceResult","Type","Value","Version"],"sourceRoot":""} \ No newline at end of file