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AG,KAAQ,MACzB,IAAgB,GAAkB,KACtC,GAAkB,GAIpB,IAAI,QAAgB,KACnB,CACC,IAAW,EAAO,OAAS,OAC3B,GAAY,IAAK,GAAS,GAC1B,EAAgB,QACV,KAAK,GAAQ,KAClB,KAAK,QAGH,EAAa,SAA0B,QAAQ,EAAW,CAAC,EAAM,EAAQ,IAC1E,QAAkB,KAAK,EAAa,CAAC,UAAW,EAAM,EAAkB,GAAS,KAAK,OAAO,KAAK,OAEtG,MAAO,CACN,UAAW,UACX,WAAY,GAAG,KAAa,IAC5B,cAAe,EACf,UAAW,EAEb,CACD","file":"/npm/aws-http-auth@0.0.2/dist/auth.esm.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/aws-http-auth@0.0.2/dist/auth.esm.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const txt = new TextEncoder;\nconst toUTF8 = txt.encode.bind(txt);\nconst ALGORITHM = 'AWS4-HMAC-SHA256';\n\n// https://github.com/aws/aws-sdk-js/blob/cc29728c1c4178969ebabe3bbe6b6f3159436394/lib/signers/v4.js#L190-L198\nconst NOSIGNING = ['authorization', 'content-type', 'content-length', 'user-agent', 'presigned-expires', 'expect', 'x-amzn-trace-id'];\n\nasync function hmac(bits, value) {\n\tlet key = await crypto.subtle.importKey('raw', bits, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);\n\treturn crypto.subtle.sign('HMAC', key, toUTF8(value));\n}\n\nfunction hash(msg) {\n\treturn crypto.subtle.digest('SHA-256', toUTF8(msg)).then(toHEX);\n}\n\nfunction toHEX(bits) {\n\tlet i=0, hex='', arr = new Uint8Array(bits);\n\tfor (; i < arr.length; i++) hex += arr[i].toString(16).padStart(2, '0');\n\treturn hex;\n}\n\nasync function signkey(secret, values=[]) {\n\tlet val, key = toUTF8(`AWS4${secret}`);\n\tlet arr = values.concat('aws4_request');\n\tfor (val of arr) key = await hmac(key, val);\n\treturn [key, arr.join('/')];\n}\n\nexport default function (clientKey, secretKey, config={}) {\n\treturn async function (req, opts={}) {\n\t\tlet { method, pathname, query, body, headers={} } = req;\n\n\t\tlet service = opts.service || config.service;\n\t\tlet region = opts.region || config.region;\n\n\t\tlet date = headers['X-Amz-Date'] = headers['Date'] = (\n\t\t\topts.date || (new Date).toUTCString()\n\t\t);\n\n\t\tlet hkey, hval, headers_signed='', headers_string='';\n\t\tfor ([hkey, hval] of new Headers(headers)) {\n\t\t\tif (!NOSIGNING.includes(hkey)) {\n\t\t\t\theaders_string += `${hkey}:${hval}\\n`;\n\t\t\t\tif (headers_signed) headers_signed += ';';\n\t\t\t\theaders_signed += hkey;\n\t\t\t}\n\t\t}\n\n\t\tlet reqinfo = await hash(\n\t\t\t[\n\t\t\t\tmethod || (body ? 'POST' : 'GET'),\n\t\t\t\tpathname || '/', query || '',\n\t\t\t\theaders_string, headers_signed,\n\t\t\t\tawait hash(body || '')\n\t\t\t].join('\\n')\n\t\t);\n\n\t\tlet [signing_key, credential_scope] = await signkey(secretKey, [date, region, service]);\n\t\tlet signature = await hmac(signing_key, [ALGORITHM, date, credential_scope, reqinfo].join('\\n')).then(toHEX);\n\n\t\treturn {\n\t\t\tAlgorithm: ALGORITHM,\n\t\t\tCredential: `${clientKey}/${credential_scope}`,\n\t\t\tSignedHeaders: headers_signed,\n\t\t\tSignature: signature,\n\t\t};\n\t};\n}\n"]}