Files
portfolio/node_modules/.cache/babel-loader/ec061248aa9c5f25f50415467f037122.json
2021-09-20 16:54:47 -04:00

1 line
39 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"ast":null,"code":"var aws4 = exports,\n url = require('url'),\n querystring = require('querystring'),\n crypto = require('crypto'),\n lru = require('./lru'),\n credentialsCache = lru(1000); // http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html\n\n\nfunction hmac(key, string, encoding) {\n return crypto.createHmac('sha256', key).update(string, 'utf8').digest(encoding);\n}\n\nfunction hash(string, encoding) {\n return crypto.createHash('sha256').update(string, 'utf8').digest(encoding);\n} // This function assumes the string has already been percent encoded\n\n\nfunction encodeRfc3986(urlEncodedString) {\n return urlEncodedString.replace(/[!'()*]/g, function (c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase();\n });\n}\n\nfunction encodeRfc3986Full(str) {\n return encodeRfc3986(encodeURIComponent(str));\n} // A bit of a combination of:\n// https://github.com/aws/aws-sdk-java-v2/blob/dc695de6ab49ad03934e1b02e7263abbd2354be0/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/AbstractAws4Signer.java#L59\n// https://github.com/aws/aws-sdk-js/blob/18cb7e5b463b46239f9fdd4a65e2ff8c81831e8f/lib/signers/v4.js#L191-L199\n// https://github.com/mhart/aws4fetch/blob/b3aed16b6f17384cf36ea33bcba3c1e9f3bdfefd/src/main.js#L25-L34\n\n\nvar HEADERS_TO_IGNORE = {\n 'authorization': true,\n 'connection': true,\n 'x-amzn-trace-id': true,\n 'user-agent': true,\n 'expect': true,\n 'presigned-expires': true,\n 'range': true\n}; // request: { path | body, [host], [method], [headers], [service], [region] }\n// credentials: { accessKeyId, secretAccessKey, [sessionToken] }\n\nfunction RequestSigner(request, credentials) {\n if (typeof request === 'string') request = url.parse(request);\n var headers = request.headers = request.headers || {},\n hostParts = (!this.service || !this.region) && this.matchHost(request.hostname || request.host || headers.Host || headers.host);\n this.request = request;\n this.credentials = credentials || this.defaultCredentials();\n this.service = request.service || hostParts[0] || '';\n this.region = request.region || hostParts[1] || 'us-east-1'; // SES uses a different domain from the service name\n\n if (this.service === 'email') this.service = 'ses';\n if (!request.method && request.body) request.method = 'POST';\n\n if (!headers.Host && !headers.host) {\n headers.Host = request.hostname || request.host || this.createHost(); // If a port is specified explicitly, use it as is\n\n if (request.port) headers.Host += ':' + request.port;\n }\n\n if (!request.hostname && !request.host) request.hostname = headers.Host || headers.host;\n this.isCodeCommitGit = this.service === 'codecommit' && request.method === 'GIT';\n}\n\nRequestSigner.prototype.matchHost = function (host) {\n var match = (host || '').match(/([^\\.]+)\\.(?:([^\\.]*)\\.)?amazonaws\\.com(\\.cn)?$/);\n var hostParts = (match || []).slice(1, 3); // ES's hostParts are sometimes the other way round, if the value that is expected\n // to be region equals es switch them back\n // e.g. search-cluster-name-aaaa00aaaa0aaa0aaaaaaa0aaa.us-east-1.es.amazonaws.com\n\n if (hostParts[1] === 'es') hostParts = hostParts.reverse();\n\n if (hostParts[1] == 's3') {\n hostParts[0] = 's3';\n hostParts[1] = 'us-east-1';\n } else {\n for (var i = 0; i < 2; i++) {\n if (/^s3-/.test(hostParts[i])) {\n hostParts[1] = hostParts[i].slice(3);\n hostParts[0] = 's3';\n break;\n }\n }\n }\n\n return hostParts;\n}; // http://docs.aws.amazon.com/general/latest/gr/rande.html\n\n\nRequestSigner.prototype.isSingleRegion = function () {\n // Special case for S3 and SimpleDB in us-east-1\n if (['s3', 'sdb'].indexOf(this.service) >= 0 && this.region === 'us-east-1') return true;\n return ['cloudfront', 'ls', 'route53', 'iam', 'importexport', 'sts'].indexOf(this.service) >= 0;\n};\n\nRequestSigner.prototype.createHost = function () {\n var region = this.isSingleRegion() ? '' : '.' + this.region,\n subdomain = this.service === 'ses' ? 'email' : this.service;\n return subdomain + region + '.amazonaws.com';\n};\n\nRequestSigner.prototype.prepareRequest = function () {\n this.parsePath();\n var request = this.request,\n headers = request.headers,\n query;\n\n if (request.signQuery) {\n this.parsedPath.query = query = this.parsedPath.query || {};\n if (this.credentials.sessionToken) query['X-Amz-Security-Token'] = this.credentials.sessionToken;\n if (this.service === 's3' && !query['X-Amz-Expires']) query['X-Amz-Expires'] = 86400;\n if (query['X-Amz-Date']) this.datetime = query['X-Amz-Date'];else query['X-Amz-Date'] = this.getDateTime();\n query['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256';\n query['X-Amz-Credential'] = this.credentials.accessKeyId + '/' + this.credentialString();\n query['X-Amz-SignedHeaders'] = this.signedHeaders();\n } else {\n if (!request.doNotModifyHeaders && !this.isCodeCommitGit) {\n if (request.body && !headers['Content-Type'] && !headers['content-type']) headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';\n if (request.body && !headers['Content-Length'] && !headers['content-length']) headers['Content-Length'] = Buffer.byteLength(request.body);\n if (this.credentials.sessionToken && !headers['X-Amz-Security-Token'] && !headers['x-amz-security-token']) headers['X-Amz-Security-Token'] = this.credentials.sessionToken;\n if (this.service === 's3' && !headers['X-Amz-Content-Sha256'] && !headers['x-amz-content-sha256']) headers['X-Amz-Content-Sha256'] = hash(this.request.body || '', 'hex');\n if (headers['X-Amz-Date'] || headers['x-amz-date']) this.datetime = headers['X-Amz-Date'] || headers['x-amz-date'];else headers['X-Amz-Date'] = this.getDateTime();\n }\n\n delete headers.Authorization;\n delete headers.authorization;\n }\n};\n\nRequestSigner.prototype.sign = function () {\n if (!this.parsedPath) this.prepareRequest();\n\n if (this.request.signQuery) {\n this.parsedPath.query['X-Amz-Signature'] = this.signature();\n } else {\n this.request.headers.Authorization = this.authHeader();\n }\n\n this.request.path = this.formatPath();\n return this.request;\n};\n\nRequestSigner.prototype.getDateTime = function () {\n if (!this.datetime) {\n var headers = this.request.headers,\n date = new Date(headers.Date || headers.date || new Date());\n this.datetime = date.toISOString().replace(/[:\\-]|\\.\\d{3}/g, ''); // Remove the trailing 'Z' on the timestamp string for CodeCommit git access\n\n if (this.isCodeCommitGit) this.datetime = this.datetime.slice(0, -1);\n }\n\n return this.datetime;\n};\n\nRequestSigner.prototype.getDate = function () {\n return this.getDateTime().substr(0, 8);\n};\n\nRequestSigner.prototype.authHeader = function () {\n return ['AWS4-HMAC-SHA256 Credential=' + this.credentials.accessKeyId + '/' + this.credentialString(), 'SignedHeaders=' + this.signedHeaders(), 'Signature=' + this.signature()].join(', ');\n};\n\nRequestSigner.prototype.signature = function () {\n var date = this.getDate(),\n cacheKey = [this.credentials.secretAccessKey, date, this.region, this.service].join(),\n kDate,\n kRegion,\n kService,\n kCredentials = credentialsCache.get(cacheKey);\n\n if (!kCredentials) {\n kDate = hmac('AWS4' + this.credentials.secretAccessKey, date);\n kRegion = hmac(kDate, this.region);\n kService = hmac(kRegion, this.service);\n kCredentials = hmac(kService, 'aws4_request');\n credentialsCache.set(cacheKey, kCredentials);\n }\n\n return hmac(kCredentials, this.stringToSign(), 'hex');\n};\n\nRequestSigner.prototype.stringToSign = function () {\n return ['AWS4-HMAC-SHA256', this.getDateTime(), this.credentialString(), hash(this.canonicalString(), 'hex')].join('\\n');\n};\n\nRequestSigner.prototype.canonicalString = function () {\n if (!this.parsedPath) this.prepareRequest();\n var pathStr = this.parsedPath.path,\n query = this.parsedPath.query,\n headers = this.request.headers,\n queryStr = '',\n normalizePath = this.service !== 's3',\n decodePath = this.service === 's3' || this.request.doNotEncodePath,\n decodeSlashesInPath = this.service === 's3',\n firstValOnly = this.service === 's3',\n bodyHash;\n\n if (this.service === 's3' && this.request.signQuery) {\n bodyHash = 'UNSIGNED-PAYLOAD';\n } else if (this.isCodeCommitGit) {\n bodyHash = '';\n } else {\n bodyHash = headers['X-Amz-Content-Sha256'] || headers['x-amz-content-sha256'] || hash(this.request.body || '', 'hex');\n }\n\n if (query) {\n var reducedQuery = Object.keys(query).reduce(function (obj, key) {\n if (!key) return obj;\n obj[encodeRfc3986Full(key)] = !Array.isArray(query[key]) ? query[key] : firstValOnly ? query[key][0] : query[key];\n return obj;\n }, {});\n var encodedQueryPieces = [];\n Object.keys(reducedQuery).sort().forEach(function (key) {\n if (!Array.isArray(reducedQuery[key])) {\n encodedQueryPieces.push(key + '=' + encodeRfc3986Full(reducedQuery[key]));\n } else {\n reducedQuery[key].map(encodeRfc3986Full).sort().forEach(function (val) {\n encodedQueryPieces.push(key + '=' + val);\n });\n }\n });\n queryStr = encodedQueryPieces.join('&');\n }\n\n if (pathStr !== '/') {\n if (normalizePath) pathStr = pathStr.replace(/\\/{2,}/g, '/');\n pathStr = pathStr.split('/').reduce(function (path, piece) {\n if (normalizePath && piece === '..') {\n path.pop();\n } else if (!normalizePath || piece !== '.') {\n if (decodePath) piece = decodeURIComponent(piece.replace(/\\+/g, ' '));\n path.push(encodeRfc3986Full(piece));\n }\n\n return path;\n }, []).join('/');\n if (pathStr[0] !== '/') pathStr = '/' + pathStr;\n if (decodeSlashesInPath) pathStr = pathStr.replace(/%2F/g, '/');\n }\n\n return [this.request.method || 'GET', pathStr, queryStr, this.canonicalHeaders() + '\\n', this.signedHeaders(), bodyHash].join('\\n');\n};\n\nRequestSigner.prototype.canonicalHeaders = function () {\n var headers = this.request.headers;\n\n function trimAll(header) {\n return header.toString().trim().replace(/\\s+/g, ' ');\n }\n\n return Object.keys(headers).filter(function (key) {\n return HEADERS_TO_IGNORE[key.toLowerCase()] == null;\n }).sort(function (a, b) {\n return a.toLowerCase() < b.toLowerCase() ? -1 : 1;\n }).map(function (key) {\n return key.toLowerCase() + ':' + trimAll(headers[key]);\n }).join('\\n');\n};\n\nRequestSigner.prototype.signedHeaders = function () {\n return Object.keys(this.request.headers).map(function (key) {\n return key.toLowerCase();\n }).filter(function (key) {\n return HEADERS_TO_IGNORE[key] == null;\n }).sort().join(';');\n};\n\nRequestSigner.prototype.credentialString = function () {\n return [this.getDate(), this.region, this.service, 'aws4_request'].join('/');\n};\n\nRequestSigner.prototype.defaultCredentials = function () {\n var env = process.env;\n return {\n accessKeyId: env.AWS_ACCESS_KEY_ID || env.AWS_ACCESS_KEY,\n secretAccessKey: env.AWS_SECRET_ACCESS_KEY || env.AWS_SECRET_KEY,\n sessionToken: env.AWS_SESSION_TOKEN\n };\n};\n\nRequestSigner.prototype.parsePath = function () {\n var path = this.request.path || '/'; // S3 doesn't always encode characters > 127 correctly and\n // all services don't encode characters > 255 correctly\n // So if there are non-reserved chars (and it's not already all % encoded), just encode them all\n\n if (/[^0-9A-Za-z;,/?:@&=+$\\-_.!~*'()#%]/.test(path)) {\n path = encodeURI(decodeURI(path));\n }\n\n var queryIx = path.indexOf('?'),\n query = null;\n\n if (queryIx >= 0) {\n query = querystring.parse(path.slice(queryIx + 1));\n path = path.slice(0, queryIx);\n }\n\n this.parsedPath = {\n path: path,\n query: query\n };\n};\n\nRequestSigner.prototype.formatPath = function () {\n var path = this.parsedPath.path,\n query = this.parsedPath.query;\n if (!query) return path; // Services don't support empty query string keys\n\n if (query[''] != null) delete query[''];\n return path + '?' + encodeRfc3986(querystring.stringify(query));\n};\n\naws4.RequestSigner = RequestSigner;\n\naws4.sign = function (request, credentials) {\n return new RequestSigner(request, credentials).sign();\n};","map":{"version":3,"sources":["/Users/tylerkoenig/Code/personal/react-scss2/node_modules/aws4/aws4.js"],"names":["aws4","exports","url","require","querystring","crypto","lru","credentialsCache","hmac","key","string","encoding","createHmac","update","digest","hash","createHash","encodeRfc3986","urlEncodedString","replace","c","charCodeAt","toString","toUpperCase","encodeRfc3986Full","str","encodeURIComponent","HEADERS_TO_IGNORE","RequestSigner","request","credentials","parse","headers","hostParts","service","region","matchHost","hostname","host","Host","defaultCredentials","method","body","createHost","port","isCodeCommitGit","prototype","match","slice","reverse","i","test","isSingleRegion","indexOf","subdomain","prepareRequest","parsePath","query","signQuery","parsedPath","sessionToken","datetime","getDateTime","accessKeyId","credentialString","signedHeaders","doNotModifyHeaders","Buffer","byteLength","Authorization","authorization","sign","signature","authHeader","path","formatPath","date","Date","toISOString","getDate","substr","join","cacheKey","secretAccessKey","kDate","kRegion","kService","kCredentials","get","set","stringToSign","canonicalString","pathStr","queryStr","normalizePath","decodePath","doNotEncodePath","decodeSlashesInPath","firstValOnly","bodyHash","reducedQuery","Object","keys","reduce","obj","Array","isArray","encodedQueryPieces","sort","forEach","push","map","val","split","piece","pop","decodeURIComponent","canonicalHeaders","trimAll","header","trim","filter","toLowerCase","a","b","env","process","AWS_ACCESS_KEY_ID","AWS_ACCESS_KEY","AWS_SECRET_ACCESS_KEY","AWS_SECRET_KEY","AWS_SESSION_TOKEN","encodeURI","decodeURI","queryIx","stringify"],"mappings":"AAAA,IAAIA,IAAI,GAAGC,OAAX;AAAA,IACIC,GAAG,GAAGC,OAAO,CAAC,KAAD,CADjB;AAAA,IAEIC,WAAW,GAAGD,OAAO,CAAC,aAAD,CAFzB;AAAA,IAGIE,MAAM,GAAGF,OAAO,CAAC,QAAD,CAHpB;AAAA,IAIIG,GAAG,GAAGH,OAAO,CAAC,OAAD,CAJjB;AAAA,IAKII,gBAAgB,GAAGD,GAAG,CAAC,IAAD,CAL1B,C,CAOA;;;AAEA,SAASE,IAAT,CAAcC,GAAd,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqC;AACnC,SAAON,MAAM,CAACO,UAAP,CAAkB,QAAlB,EAA4BH,GAA5B,EAAiCI,MAAjC,CAAwCH,MAAxC,EAAgD,MAAhD,EAAwDI,MAAxD,CAA+DH,QAA/D,CAAP;AACD;;AAED,SAASI,IAAT,CAAcL,MAAd,EAAsBC,QAAtB,EAAgC;AAC9B,SAAON,MAAM,CAACW,UAAP,CAAkB,QAAlB,EAA4BH,MAA5B,CAAmCH,MAAnC,EAA2C,MAA3C,EAAmDI,MAAnD,CAA0DH,QAA1D,CAAP;AACD,C,CAED;;;AACA,SAASM,aAAT,CAAuBC,gBAAvB,EAAyC;AACvC,SAAOA,gBAAgB,CAACC,OAAjB,CAAyB,UAAzB,EAAqC,UAASC,CAAT,EAAY;AACtD,WAAO,MAAMA,CAAC,CAACC,UAAF,CAAa,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AAK,GAAGrD,WAAW,CAAC2B,KAAZ,CAAkB2C,IAAI,CAAC1B,KAAL,CAAWsF,OAAO,GAAG,CAArB,CAAlB,CAAR;AACA5D,IAAAA,IAAI,GAAGA,IAAI,CAAC1B,KAAL,CAAW,CAAX,EAAcsF,OAAd,CAAP;AACD;;AAED,OAAK3E,UAAL,GAAkB;AAChBe,IAAAA,IAAI,EAAEA,IADU;AAEhBjB,IAAAA,KAAK,EAAEA;AAFS,GAAlB;AAID,CAtBD;;AAwBA7B,aAAa,CAACkB,SAAd,CAAwB6B,UAAxB,GAAqC,YAAW;AAC9C,MAAID,IAAI,GAAG,KAAKf,UAAL,CAAgBe,IAA3B;AAAA,MACIjB,KAAK,GAAG,KAAKE,UAAL,CAAgBF,KAD5B;AAGA,MAAI,CAACA,KAAL,EAAY,OAAOiB,IAAP,CAJkC,CAM9C;;AACA,MAAIjB,KAAK,CAAC,EAAD,CAAL,IAAa,IAAjB,EAAuB,OAAOA,KAAK,CAAC,EAAD,CAAZ;AAEvB,SAAOiB,IAAI,GAAG,GAAP,GAAazD,aAAa,CAACb,WAAW,CAACmI,SAAZ,CAAsB9E,KAAtB,CAAD,CAAjC;AACD,CAVD;;AAYAzD,IAAI,CAAC4B,aAAL,GAAqBA,aAArB;;AAEA5B,IAAI,CAACuE,IAAL,GAAY,UAAS1C,OAAT,EAAkBC,WAAlB,EAA+B;AACzC,SAAO,IAAIF,aAAJ,CAAkBC,OAAlB,EAA2BC,WAA3B,EAAwCyC,IAAxC,EAAP;AACD,CAFD","sourcesContent":["var aws4 = exports,\n url = require('url'),\n querystring = require('querystring'),\n crypto = require('crypto'),\n lru = require('./lru'),\n credentialsCache = lru(1000)\n\n// http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html\n\nfunction hmac(key, string, encoding) {\n return crypto.createHmac('sha256', key).update(string, 'utf8').digest(encoding)\n}\n\nfunction hash(string, encoding) {\n return crypto.createHash('sha256').update(string, 'utf8').digest(encoding)\n}\n\n// This function assumes the string has already been percent encoded\nfunction encodeRfc3986(urlEncodedString) {\n return urlEncodedString.replace(/[!'()*]/g, function(c) {\n return '%' + c.charCodeAt(0).toString(16).toUpperCase()\n })\n}\n\nfunction encodeRfc3986Full(str) {\n return encodeRfc3986(encodeURIComponent(str))\n}\n\n// A bit of a combination of:\n// https://github.com/aws/aws-sdk-java-v2/blob/dc695de6ab49ad03934e1b02e7263abbd2354be0/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/AbstractAws4Signer.java#L59\n// https://github.com/aws/aws-sdk-js/blob/18cb7e5b463b46239f9fdd4a65e2ff8c81831e8f/lib/signers/v4.js#L191-L199\n// https://github.com/mhart/aws4fetch/blob/b3aed16b6f17384cf36ea33bcba3c1e9f3bdfefd/src/main.js#L25-L34\nvar HEADERS_TO_IGNORE = {\n 'authorization': true,\n 'connection': true,\n 'x-amzn-trace-id': true,\n 'user-agent': true,\n 'expect': true,\n 'presigned-expires': true,\n 'range': true,\n}\n\n// request: { path | body, [host], [method], [headers], [service], [region] }\n// credentials: { accessKeyId, secretAccessKey, [sessionToken] }\nfunction RequestSigner(request, credentials) {\n\n if (typeof request === 'string') request = url.parse(request)\n\n var headers = request.headers = (request.headers || {}),\n hostParts = (!this.service || !this.region) && this.matchHost(request.hostname || request.host || headers.Host || headers.host)\n\n this.request = request\n this.credentials = credentials || this.defaultCredentials()\n\n this.service = request.service || hostParts[0] || ''\n this.region = request.region || hostParts[1] || 'us-east-1'\n\n // SES uses a different domain from the service name\n if (this.service === 'email') this.service = 'ses'\n\n if (!request.method && request.body)\n request.method = 'POST'\n\n if (!headers.Host && !headers.host) {\n headers.Host = request.hostname || request.host || this.createHost()\n\n // If a port is specified explicitly, use it as is\n if (request.port)\n headers.Host += ':' + request.port\n }\n if (!request.hostname && !request.host)\n request.hostname = headers.Host || headers.host\n\n this.isCodeCommitGit = this.service === 'codecommit' && request.method === 'GIT'\n}\n\nRequestSigner.prototype.matchHost = function(host) {\n var match = (host || '').match(/([^\\.]+)\\.(?:([^\\.]*)\\.)?amazonaws\\.com(\\.cn)?$/)\n var hostParts = (match || []).slice(1, 3)\n\n // ES's hostParts are sometimes the other way round, if the value that is expected\n // to be region equals es switch them back\n // e.g. search-cluster-name-aaaa00aaaa0aaa0aaaaaaa0aaa.us-east-1.es.amazonaws.com\n if (hostParts[1] === 'es')\n hostParts = hostParts.reverse()\n\n if (hostParts[1] == 's3') {\n hostParts[0] = 's3'\n hostParts[1] = 'us-east-1'\n } else {\n for (var i = 0; i < 2; i++) {\n if (/^s3-/.test(hostParts[i])) {\n hostParts[1] = hostParts[i].slice(3)\n hostParts[0] = 's3'\n break\n }\n }\n }\n\n return hostParts\n}\n\n// http://docs.aws.amazon.com/general/latest/gr/rande.html\nRequestSigner.prototype.isSingleRegion = function() {\n // Special case for S3 and SimpleDB in us-east-1\n if (['s3', 'sdb'].indexOf(this.service) >= 0 && this.region === 'us-east-1') return true\n\n return ['cloudfront', 'ls', 'route53', 'iam', 'importexport', 'sts']\n .indexOf(this.service) >= 0\n}\n\nRequestSigner.prototype.createHost = function() {\n var region = this.isSingleRegion() ? '' : '.' + this.region,\n subdomain = this.service === 'ses' ? 'email' : this.service\n return subdomain + region + '.amazonaws.com'\n}\n\nRequestSigner.prototype.prepareRequest = function() {\n this.parsePath()\n\n var request = this.request, headers = request.headers, query\n\n if (request.signQuery) {\n\n this.parsedPath.query = query = this.parsedPath.query || {}\n\n if (this.credentials.sessionToken)\n query['X-Amz-Security-Token'] = this.credentials.sessionToken\n\n if (this.service === 's3' && !query['X-Amz-Expires'])\n query['X-Amz-Expires'] = 86400\n\n if (query['X-Amz-Date'])\n this.datetime = query['X-Amz-Date']\n else\n query['X-Amz-Date'] = this.getDateTime()\n\n query['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256'\n query['X-Amz-Credential'] = this.credentials.accessKeyId + '/' + this.credentialString()\n query['X-Amz-SignedHeaders'] = this.signedHeaders()\n\n } else {\n\n if (!request.doNotModifyHeaders && !this.isCodeCommitGit) {\n if (request.body && !headers['Content-Type'] && !headers['content-type'])\n headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'\n\n if (request.body && !headers['Content-Length'] && !headers['content-length'])\n headers['Content-Length'] = Buffer.byteLength(request.body)\n\n if (this.credentials.sessionToken && !headers['X-Amz-Security-Token'] && !headers['x-amz-security-token'])\n headers['X-Amz-Security-Token'] = this.credentials.sessionToken\n\n if (this.service === 's3' && !headers['X-Amz-Content-Sha256'] && !headers['x-amz-content-sha256'])\n headers['X-Amz-Content-Sha256'] = hash(this.request.body || '', 'hex')\n\n if (headers['X-Amz-Date'] || headers['x-amz-date'])\n this.datetime = headers['X-Amz-Date'] || headers['x-amz-date']\n else\n headers['X-Amz-Date'] = this.getDateTime()\n }\n\n delete headers.Authorization\n delete headers.authorization\n }\n}\n\nRequestSigner.prototype.sign = function() {\n if (!this.parsedPath) this.prepareRequest()\n\n if (this.request.signQuery) {\n this.parsedPath.query['X-Amz-Signature'] = this.signature()\n } else {\n this.request.headers.Authorization = this.authHeader()\n }\n\n this.request.path = this.formatPath()\n\n return this.request\n}\n\nRequestSigner.prototype.getDateTime = function() {\n if (!this.datetime) {\n var headers = this.request.headers,\n date = new Date(headers.Date || headers.date || new Date)\n\n this.datetime = date.toISOString().replace(/[:\\-]|\\.\\d{3}/g, '')\n\n // Remove the trailing 'Z' on the timestamp string for CodeCommit git access\n if (this.isCodeCommitGit) this.datetime = this.datetime.slice(0, -1)\n }\n return this.datetime\n}\n\nRequestSigner.prototype.getDate = function() {\n return this.getDateTime().substr(0, 8)\n}\n\nRequestSigner.prototype.authHeader = function() {\n return [\n 'AWS4-HMAC-SHA256 Credential=' + this.credentials.accessKeyId + '/' + this.credentialString(),\n 'SignedHeaders=' + this.signedHeaders(),\n 'Signature=' + this.signature(),\n ].join(', ')\n}\n\nRequestSigner.prototype.signature = function() {\n var date = this.getDate(),\n cacheKey = [this.credentials.secretAccessKey, date, this.region, this.service].join(),\n kDate, kRegion, kService, kCredentials = credentialsCache.get(cacheKey)\n if (!kCredentials) {\n kDate = hmac('AWS4' + this.credentials.secretAccessKey, date)\n kRegion = hmac(kDate, this.region)\n kService = hmac(kRegion, this.service)\n kCredentials = hmac(kService, 'aws4_request')\n credentialsCache.set(cacheKey, kCredentials)\n }\n return hmac(kCredentials, this.stringToSign(), 'hex')\n}\n\nRequestSigner.prototype.stringToSign = function() {\n return [\n 'AWS4-HMAC-SHA256',\n this.getDateTime(),\n this.credentialString(),\n hash(this.canonicalString(), 'hex'),\n ].join('\\n')\n}\n\nRequestSigner.prototype.canonicalString = function() {\n if (!this.parsedPath) this.prepareRequest()\n\n var pathStr = this.parsedPath.path,\n query = this.parsedPath.query,\n headers = this.request.headers,\n queryStr = '',\n normalizePath = this.service !== 's3',\n decodePath = this.service === 's3' || this.request.doNotEncodePath,\n decodeSlashesInPath = this.service === 's3',\n firstValOnly = this.service === 's3',\n bodyHash\n\n if (this.service === 's3' && this.request.signQuery) {\n bodyHash = 'UNSIGNED-PAYLOAD'\n } else if (this.isCodeCommitGit) {\n bodyHash = ''\n } else {\n bodyHash = headers['X-Amz-Content-Sha256'] || headers['x-amz-content-sha256'] ||\n hash(this.request.body || '', 'hex')\n }\n\n if (query) {\n var reducedQuery = Object.keys(query).reduce(function(obj, key) {\n if (!key) return obj\n obj[encodeRfc3986Full(key)] = !Array.isArray(query[key]) ? query[key] :\n (firstValOnly ? query[key][0] : query[key])\n return obj\n }, {})\n var encodedQueryPieces = []\n Object.keys(reducedQuery).sort().forEach(function(key) {\n if (!Array.isArray(reducedQuery[key])) {\n encodedQueryPieces.push(key + '=' + encodeRfc3986Full(reducedQuery[key]))\n } else {\n reducedQuery[key].map(encodeRfc3986Full).sort()\n .forEach(function(val) { encodedQueryPieces.push(key + '=' + val) })\n }\n })\n queryStr = encodedQueryPieces.join('&')\n }\n if (pathStr !== '/') {\n if (normalizePath) pathStr = pathStr.replace(/\\/{2,}/g, '/')\n pathStr = pathStr.split('/').reduce(function(path, piece) {\n if (normalizePath && piece === '..') {\n path.pop()\n } else if (!normalizePath || piece !== '.') {\n if (decodePath) piece = decodeURIComponent(piece.replace(/\\+/g, ' '))\n path.push(encodeRfc3986Full(piece))\n }\n return path\n }, []).join('/')\n if (pathStr[0] !== '/') pathStr = '/' + pathStr\n if (decodeSlashesInPath) pathStr = pathStr.replace(/%2F/g, '/')\n }\n\n return [\n this.request.method || 'GET',\n pathStr,\n queryStr,\n this.canonicalHeaders() + '\\n',\n this.signedHeaders(),\n bodyHash,\n ].join('\\n')\n}\n\nRequestSigner.prototype.canonicalHeaders = function() {\n var headers = this.request.headers\n function trimAll(header) {\n return header.toString().trim().replace(/\\s+/g, ' ')\n }\n return Object.keys(headers)\n .filter(function(key) { return HEADERS_TO_IGNORE[key.toLowerCase()] == null })\n .sort(function(a, b) { return a.toLowerCase() < b.toLowerCase() ? -1 : 1 })\n .map(function(key) { return key.toLowerCase() + ':' + trimAll(headers[key]) })\n .join('\\n')\n}\n\nRequestSigner.prototype.signedHeaders = function() {\n return Object.keys(this.request.headers)\n .map(function(key) { return key.toLowerCase() })\n .filter(function(key) { return HEADERS_TO_IGNORE[key] == null })\n .sort()\n .join(';')\n}\n\nRequestSigner.prototype.credentialString = function() {\n return [\n this.getDate(),\n this.region,\n this.service,\n 'aws4_request',\n ].join('/')\n}\n\nRequestSigner.prototype.defaultCredentials = function() {\n var env = process.env\n return {\n accessKeyId: env.AWS_ACCESS_KEY_ID || env.AWS_ACCESS_KEY,\n secretAccessKey: env.AWS_SECRET_ACCESS_KEY || env.AWS_SECRET_KEY,\n sessionToken: env.AWS_SESSION_TOKEN,\n }\n}\n\nRequestSigner.prototype.parsePath = function() {\n var path = this.request.path || '/'\n\n // S3 doesn't always encode characters > 127 correctly and\n // all services don't encode characters > 255 correctly\n // So if there are non-reserved chars (and it's not already all % encoded), just encode them all\n if (/[^0-9A-Za-z;,/?:@&=+$\\-_.!~*'()#%]/.test(path)) {\n path = encodeURI(decodeURI(path))\n }\n\n var queryIx = path.indexOf('?'),\n query = null\n\n if (queryIx >= 0) {\n query = querystring.parse(path.slice(queryIx + 1))\n path = path.slice(0, queryIx)\n }\n\n this.parsedPath = {\n path: path,\n query: query,\n }\n}\n\nRequestSigner.prototype.formatPath = function() {\n var path = this.parsedPath.path,\n query = this.parsedPath.query\n\n if (!query) return path\n\n // Services don't support empty query string keys\n if (query[''] != null) delete query['']\n\n return path + '?' + encodeRfc3986(querystring.stringify(query))\n}\n\naws4.RequestSigner = RequestSigner\n\naws4.sign = function(request, credentials) {\n return new RequestSigner(request, credentials).sign()\n}\n"]},"metadata":{},"sourceType":"script"}