{"_id":"@aimoda/aws4fetch","_rev":"6-9e7cde52e788b4ab35e950b497bfc258","name":"@aimoda/aws4fetch","dist-tags":{"latest":"1.0.20"},"versions":{"1.0.18":{"name":"@aimoda/aws4fetch","version":"1.0.18","author":{"url":"https://github.com/mhart","name":"Michael Hart","email":"michael.hart.au@gmail.com"},"license":"MIT","_id":"@aimoda/aws4fetch@1.0.18","maintainers":[{"name":"aimoda","email":"npm@ai.moda"}],"dist":{"shasum":"1ea62e2cb5c6829522ce4fdf7d7772e3df60a49e","tarball":"https://registry.npmjs.org/@aimoda/aws4fetch/-/aws4fetch-1.0.18.tgz","fileCount":10,"integrity":"sha512-6Tdq/iVxg+nQ0+guAp2odXr1fXHAHZdsX2aS3Dt4wy6jREzAdbcuG+uE8uZU1VDKMeYxtIT+6FYovqE6uYq2Ag==","signatures":[{"sig":"MEUCIERVgRN/0GtQxY4s8CxP0pWhcCzOIWQK7BnFVYBHoSP4AiEAydRj7wI3uGiIdYJUMCETDIfMC0dg7kkcY3TOH/c6dG8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":61467,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5CzzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrd+w/+OoYWV7w6mEcCSV8N+0jkUAUN9pqEU6z9o834jpP7QXOZ66nT\r\n9bTHYGCiX8NETnSnWjcCKVCwS+gWtMl0sr2TOGJjU4UsmSTqfwJZmTPPXM8B\r\nDH6tNRo6ib0f4pzKVY82GSkTDOoYqK2DI6qmCQJoxTE7h8QYCN3Hxv5DAZnG\r\nOyDOaht/wpLaweGtTVUU4QtLir2gAlKRvVEDYJjs2wwXpIQH7676jXlnwRm+\r\naLfHM11CsReC8/ynqyG2gSlnj45zV73TMhFD5+ozSP1nMrTrXB5wPiCsUrxz\r\nN2q3cDG3pe7z17aXHx19NzM3XfZKVbrLMos+jfrRYfMmSCB9CvqFPCj+yvIf\r\nlsFUwD4OS6Dlr3cdmcLhYF2u8qrGcB39jveo5LxzzRkNKURYWo4P/dPLvFe0\r\nL32bAHgX2BwsnSG/qWBDrZ8A6qeE/6K8bwreK9ovH/RlQ70vKtNWA/Grvyfk\r\noFvaGyJep+D5ZA3bFR0sdgoG8H6Rtv2gBMSt+9fsVWNPALJEsq+NAHb8oUTC\r\nAfvzpNxEYd4fOLdJ57JvR9U8hg2B7cnwqQy93sjIdY5dkNc6hUksIX7dzHdO\r\nR6jnTsbrb45Lj5V5yki58IpiAVe3U6vHLSAI9UUUV0iHj7bzC1Rp5O2YX0nS\r\nHtlmsziyiO+rmqtrmPhupyddQRIf/hnNnpA=\r\n=Eqxv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/aws4fetch.cjs.js","types":"dist/main.d.ts","module":"dist/aws4fetch.esm.js","browser":"dist/aws4fetch.umd.js","exports":{".":{"import":"./dist/aws4fetch.esm.mjs","worker":"./dist/aws4fetch.esm.js","browser":"./dist/aws4fetch.umd.js","default":"./dist/aws4fetch.umd.js","require":"./dist/aws4fetch.cjs.js"}},"scripts":{"lint":"eslint --ext .js,.cjs,.mjs .","test":"node test/test.js","build":"npm run declaration && rollup -c","format":"eslint --ext .js,.cjs,.mjs --fix .","prepare":"npm run build","test-node":"node test/node-es.mjs && node test/node-commonjs.js","declaration":"tsc -p declaration.tsconfig.json","integration":"node test/integration.js"},"_npmUser":{"name":"aimoda","email":"npm@ai.moda"},"repository":{"url":"https://github.com/mhart/aws4fetch.git","type":"git"},"description":"A compact AWS client for modern JS environments","directories":{},"licenseText":"Copyright 2018 Michael Hart (michael.hart.au@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.24.0","rollup":"^2.79.1","puppeteer":"^18.0.5","typescript":"^4.8.4","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","eslint-plugin-promise":"^6.0.1","rollup-plugin-cleanup":"^3.2.1","eslint-config-standard":"^17.0.0","eslint-plugin-standard":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aws4fetch_1.0.18_1675898099172_0.5912171773400121","host":"s3://npm-registry-packages"}},"1.0.19":{"name":"@aimoda/aws4fetch","version":"1.0.19","author":{"url":"https://github.com/mhart","name":"Michael Hart","email":"michael.hart.au@gmail.com"},"license":"MIT","_id":"@aimoda/aws4fetch@1.0.19","maintainers":[{"name":"aimoda","email":"npm@ai.moda"}],"dist":{"shasum":"2f17ea1cf225d3c02a20a1751da2bea347828e75","tarball":"https://registry.npmjs.org/@aimoda/aws4fetch/-/aws4fetch-1.0.19.tgz","fileCount":10,"integrity":"sha512-4RcibdDupXYZdJw7qWGdzhouEgo+8V5PtqyJvqDn5MFDZkCjmfR0sJevhpt1LdLB1AOpngHBQo3Csu7kq2J6Yg==","signatures":[{"sig":"MEYCIQDc25Og/XYZdp4830bgSMzYGB8QQ6zD/qAJ4iByEzIsewIhAN0XAaAZNPZ1vuO5+admNj+55pfR4XgKe+VLtmoO/+0I","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":61763,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5DPGACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmphpg/+LkKQxmfrRJrLhyI6jzhmsmmUYnxZVlQbSK8AY3Dt6l/30Gmc\r\nzEjXHq00OpQTrtfjXrMBrZWpTJBFoipNbgPsGSJfZthMEjhw2obkn5jdQura\r\nZKFl1ez8RYrrC+z9bm8iI1BDmDQ9feZx3ORqGSLovWC+7+eRXG8Q20IgfWWj\r\nR1Y0s5GaymS73ueBj36MdNRS7TOoi3XbBrjTf5EZ1S+6YnwtpLHc411BXIJb\r\ntaS0358rf/opmDpypoaMQuNXSVLo+Tz+TzeLNbzMH6slYeCLqs8gF4esavp5\r\nwG7oGpKu+wvqOuCqdMYW9vnRuy0Wl0RWfxtbtnHosiDhnWSrhHTE235/aSnV\r\n0t3crwc3Hv0XPxAzpSAnjxlZU2630cIYEG46OJPxN8yxAE2vQOAPIzTgMJkN\r\nSv+VDAouLE/G06v2ndV/7Oxt8XSGuHvRnsQFM8U//toTqyeBS9Qa+r/X5MIO\r\np8fgpgCQGYRu1MN+5TzlBcA/1n0nbAhLx/5q8sdciZcVgIqgDgnTZq8kFDrS\r\nqAXVANJfMMYEVEBbjQ3g8CcyL02K7Nqam146bnH+NnEibBPzuDJI5iMY/NbN\r\nSbjKQmN0mjo+PGcv50acRqSKSyaVrxqQDs1Riv90vYFl3k7myJ46fKhLCsAS\r\nrCdsA75mGjAa4ZI92HXQ4d/wZcUDr5PHTFE=\r\n=wqML\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/aws4fetch.cjs.js","types":"dist/main.d.ts","module":"dist/aws4fetch.esm.js","browser":"dist/aws4fetch.umd.js","exports":{".":{"import":"./dist/aws4fetch.esm.mjs","worker":"./dist/aws4fetch.esm.js","browser":"./dist/aws4fetch.umd.js","default":"./dist/aws4fetch.umd.js","require":"./dist/aws4fetch.cjs.js"}},"scripts":{"lint":"eslint --ext .js,.cjs,.mjs .","test":"node test/test.js","build":"npm run declaration && rollup -c","format":"eslint --ext .js,.cjs,.mjs --fix .","prepare":"npm run build","test-node":"node test/node-es.mjs && node test/node-commonjs.js","declaration":"tsc -p declaration.tsconfig.json","integration":"node test/integration.js"},"_npmUser":{"name":"aimoda","email":"npm@ai.moda"},"repository":{"url":"https://github.com/mhart/aws4fetch.git","type":"git"},"description":"A compact AWS client for modern JS environments","directories":{},"licenseText":"Copyright 2018 Michael Hart (michael.hart.au@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.24.0","rollup":"^2.79.1","puppeteer":"^18.0.5","typescript":"^4.8.4","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","eslint-plugin-promise":"^6.0.1","rollup-plugin-cleanup":"^3.2.1","eslint-config-standard":"^17.0.0","eslint-plugin-standard":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aws4fetch_1.0.19_1675899846181_0.37724523436396207","host":"s3://npm-registry-packages"}},"1.0.20":{"name":"@aimoda/aws4fetch","version":"1.0.20","author":{"url":"https://github.com/mhart","name":"Michael Hart","email":"michael.hart.au@gmail.com"},"license":"MIT","_id":"@aimoda/aws4fetch@1.0.20","maintainers":[{"name":"aimoda","email":"npm@ai.moda"}],"dist":{"shasum":"4659481dd6b276db759e59efa01286175ab7bf55","tarball":"https://registry.npmjs.org/@aimoda/aws4fetch/-/aws4fetch-1.0.20.tgz","fileCount":10,"integrity":"sha512-098dxLCs1Yk8u3ujnuD7edvBNM2kfPKjT9PWTaPDGsjjgxGHV2m9grTQsG+7vnvY8kQNXG0DE9bL3zQZIvco8g==","signatures":[{"sig":"MEUCIGbIRNLPl0GOww9zw5o5aRTDmSw8ohI4OU1PAdEB2EAyAiEAkvYDZR7zqMTHL+tVh740IWEdJH8w4QPWzEUw7m84cck=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":61691,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5DZpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpRYA/+OTFoswSg+8RsZ7LwsieMtOrSfP5EZSR6Xgd+e1g6yVRMjTlA\r\nef5KM+cH2i2uKveGyAQ0aQQjxdroYAD2ivhuAFYtaAIojZcg9VRZd/9F/3A1\r\n18BIjHzhARkhRbh0LFrBBLTvJvMfXzvQA1r8/7BbQrxfdJ5qiUpSuFy4gbmI\r\nuSEJ2N2gn+7yH1VEFPBt8TDyCa8mckscYCAjk0j4LZ5H4uRRIjo2BebRXSlY\r\nxzD9F5b+xIRqwG2g2d3qB6tv4r78FoRikLew+0Y4uFYPQJjlU9ieaWBRKQXr\r\nSJjMtTtbSZMQKdK16S7vMXJoX1B4f8jHv5k/LdVJoKKoklfi8cj0KIZsRPvA\r\ncWZdiGME5YW9baBAuchUcBczWM3TN2LHBfUE9zgIn6j8v3BvxxSR9W+y909L\r\nKZzlk20EiOWMXy2wB33oHTrtCcXCJUIs+PU5lgfy3OTVMqtAAvdIFe4HlNpA\r\np2vGfC0XA9oQ5wG7UsCBUI1sv2WKMUCKHMgNZ1PhTcgLhjGJ/qNI1masn17b\r\nGcyq0gdpnoxTAxn07mKFP+IfcmgpQTf2ZB/hyyz6F3y2sg6bJrcUJJiaU0b2\r\n5qlBPbcR7lNV+yMnul818UmYfahZUuXK2vpXBQwfra9Sz4hEswODd06SPl7V\r\nszLuyVyb6HKxzLEKKZd6Hhbe+W5mGPuLbUc=\r\n=jWNC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/aws4fetch.cjs.js","types":"dist/main.d.ts","module":"dist/aws4fetch.esm.js","browser":"dist/aws4fetch.umd.js","exports":{".":{"import":"./dist/aws4fetch.esm.mjs","worker":"./dist/aws4fetch.esm.js","browser":"./dist/aws4fetch.umd.js","default":"./dist/aws4fetch.umd.js","require":"./dist/aws4fetch.cjs.js"}},"scripts":{"lint":"eslint --ext .js,.cjs,.mjs .","test":"node test/test.js","build":"npm run declaration && rollup -c","format":"eslint --ext .js,.cjs,.mjs --fix .","prepare":"npm run build","test-node":"node test/node-es.mjs && node test/node-commonjs.js","declaration":"tsc -p declaration.tsconfig.json","integration":"node test/integration.js"},"_npmUser":{"name":"aimoda","email":"npm@ai.moda"},"repository":{"url":"https://github.com/mhart/aws4fetch.git","type":"git"},"description":"A compact AWS client for modern JS environments","directories":{},"licenseText":"Copyright 2018 Michael Hart (michael.hart.au@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_hasShrinkwrap":false,"devDependencies":{"eslint":"^8.24.0","rollup":"^2.79.1","puppeteer":"^18.0.5","typescript":"^4.8.4","eslint-plugin-node":"^11.1.0","eslint-plugin-import":"^2.26.0","eslint-plugin-promise":"^6.0.1","rollup-plugin-cleanup":"^3.2.1","eslint-config-standard":"^17.0.0","eslint-plugin-standard":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aws4fetch_1.0.20_1675900520991_0.4746453702737885","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-02-08T23:14:59.117Z","modified":"2025-11-02T02:49:20.931Z","1.0.18":"2023-02-08T23:14:59.338Z","1.0.19":"2023-02-08T23:44:06.397Z","1.0.20":"2023-02-08T23:55:21.154Z"},"author":{"url":"https://github.com/mhart","name":"Michael Hart","email":"michael.hart.au@gmail.com"},"license":"MIT","repository":{"url":"https://github.com/mhart/aws4fetch.git","type":"git"},"description":"A compact AWS client for modern JS environments","maintainers":[{"email":"david.manouchehri@ai.moda","name":"manouchehri"}],"readme":"# aws4fetch\n\n<!-- [![Build Status](https://secure.travis-ci.org/mhart/aws4fetch.png?branch=master)](http://travis-ci.org/mhart/aws4fetch) -->\n\nA compact (6.4kb minified, 2.5kb gzipped) [AWS](https://aws.amazon.com/) client for environments that support\n[`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and\n[`SubtleCrypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) – that is, modern web browsers and\nJS platforms like [Cloudflare Workers](https://www.cloudflare.com/products/cloudflare-workers/). Also retries\nrequests with an [exponential backoff with full jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)\nstrategy by default.\n\n# Example\n\n```js\nimport { AwsClient } from 'aws4fetch'\n\n// https://developers.cloudflare.com/workers/reference/apis/environment-variables/#secrets\nconst aws = new AwsClient({ accessKeyId: MY_ACCESS_KEY, secretAccessKey: MY_SECRET_KEY })\n\n// https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html\nconst LAMBDA_FN_API = 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions'\n\nasync function invokeMyLambda(event) {\n  const res = await aws.fetch(`${LAMBDA_FN_API}/my-lambda/invocations`, { body: JSON.stringify(event) })\n\n  // `res` is a standard Response object: https://developer.mozilla.org/en-US/docs/Web/API/Response\n  return res.json()\n}\n\ninvokeMyLambda({my: 'event'}).then(json => console.log(json))\n```\n\nYou can see a more detailed example, a Cloudflare Worker script you can use as\na replacement for [API Gateway](https://aws.amazon.com/api-gateway/), in the [`example`](./example) directory.\n\n# API\n\n`aws4fetch` exports two classes: `AwsClient` and `AwsV4Signer`\n\n## `new AwsClient(options)`\n\nYou can use the same instance of `AwsClient` for all your service calls as the service and region will be determined\nat fetch time – or you can create separate instances if you have different needs, eg no retrying for some service.\n\n```js\nimport { AwsClient } from 'aws4fetch'\n\nconst aws = new AwsClient({\n  accessKeyId,     // required, akin to AWS_ACCESS_KEY_ID\n  secretAccessKey, // required, akin to AWS_SECRET_ACCESS_KEY\n  sessionToken,    // akin to AWS_SESSION_TOKEN if using temp credentials\n  service,         // AWS service, by default parsed at fetch time\n  region,          // AWS region, by default parsed at fetch time\n  cache,           // credential cache, defaults to `new Map()`\n  retries,         // number of retries before giving up, defaults to 10, set to 0 for no retrying\n  initRetryMs,     // defaults to 50 – timeout doubles each retry\n})\n```\n\n### `Promise<Response> aws.fetch(input[, init])`\n\nHas the same signature as the [global fetch function](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax)\n\n```js\nimport { AwsClient } from 'aws4fetch'\n\nconst aws = new AwsClient(opts)\n\nasync function doFetch() {\n\n  const response = await aws.fetch(url, {\n\n    method,  // if not supplied, will default to 'POST' if there's a body, otherwise 'GET'\n    headers, // standard JS object literal, or Headers instance\n    body,    // optional, String or ArrayBuffer/ArrayBufferView – ie, remember to stringify your JSON\n\n    // and any other standard fetch options, eg keepalive, etc\n\n    // optional, largely if you want to override options in the AwsClient instance\n    aws: {\n      signQuery,          // set to true to sign the query string instead of the Authorization header\n      accessKeyId,        // same as in AwsClient constructor above\n      secretAccessKey,    // same as in AwsClient constructor above\n      sessionToken,       // same as in AwsClient constructor above\n      service,            // same as in AwsClient constructor above\n      region,             // same as in AwsClient constructor above\n      cache,              // same as in AwsClient constructor above\n      datetime,           // defaults to now, to override use the form '20150830T123600Z'\n      appendSessionToken, // set to true to add X-Amz-Security-Token after signing, defaults to true for iot\n      allHeaders,         // set to true to force all headers to be signed instead of the defaults\n      singleEncode,       // set to true to only encode %2F once (usually only needed for testing)\n    },\n  })\n\n  console.log(await response.json())\n}\n```\n\nNB: Due to the way bodies are handled in [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)\ninstances, it's faster to invoke the function as above – using a URL as the `input`\nargument and passing the `body` in the `init` argument – instead of the form of\ninvocation that uses a `Request` object directly as `input`.\n\nIf you don't know which URL to call for the AWS service you want, the full list\nof AWS endpoints can be found here:\nhttps://docs.aws.amazon.com/general/latest/gr/rande.html\n\nAnd the APIs are documented here: https://docs.aws.amazon.com/ (the REST APIs\nare usually documented under \"API Reference\" for each service)\n\n### `Promise<Request> aws.sign(input[, init])`\n\nReturns a Promise that resolves to an\n[AWS4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)\nsigned [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) –\nhas the same signature as `fetch`. Use this to create a `Request` you can send\nusing `fetch()` yourself.\n\n```js\nimport { AwsClient } from 'aws4fetch'\n\nconst aws = new AwsClient(opts)\n\nasync function doFetch() {\n\n  const request = await aws.sign(url, {\n\n    method,  // if not supplied, will default to 'POST' if there's a body, otherwise 'GET'\n    headers, // standard JS object literal, or Headers instance\n    body,    // optional, String or ArrayBuffer/ArrayBufferView – ie, remember to stringify your JSON\n\n    // and any other standard fetch options, eg keepalive, etc\n\n    // optional, largely if you want to override options in the AwsClient instance\n    aws: {\n      signQuery,          // set to true to sign the query string instead of the Authorization header\n      accessKeyId,        // same as in AwsClient constructor above\n      secretAccessKey,    // same as in AwsClient constructor above\n      sessionToken,       // same as in AwsClient constructor above\n      service,            // same as in AwsClient constructor above\n      region,             // same as in AwsClient constructor above\n      cache,              // same as in AwsClient constructor above\n      datetime,           // defaults to now, to override use the form '20150830T123600Z'\n      appendSessionToken, // set to true to add X-Amz-Security-Token after signing, defaults to true for iot\n      allHeaders,         // set to true to force all headers to be signed instead of the defaults\n      singleEncode,       // set to true to only encode %2F once (usually only needed for testing)\n    },\n  })\n\n  const response = await fetch(request)\n\n  console.log(await response.json())\n}\n```\n\n## `new AwsV4Signer(options)`\n\nThe underlying signing class for a request – use this if you just want to deal\nwith the raw AWS4 signed method/url/headers/body.\n\n```js\nimport { AwsV4Signer } from 'aws4fetch'\n\nconst signer = new AwsV4Signer({\n  url,                // required, the AWS endpoint to sign\n  accessKeyId,        // required, akin to AWS_ACCESS_KEY_ID\n  secretAccessKey,    // required, akin to AWS_SECRET_ACCESS_KEY\n  sessionToken,       // akin to AWS_SESSION_TOKEN if using temp credentials\n  method,             // if not supplied, will default to 'POST' if there's a body, otherwise 'GET'\n  headers,            // standard JS object literal, or Headers instance\n  body,               // optional, String or ArrayBuffer/ArrayBufferView – ie, remember to stringify your JSON\n  signQuery,          // set to true to sign the query string instead of the Authorization header\n  service,            // AWS service, by default parsed at fetch time\n  region,             // AWS region, by default parsed at fetch time\n  cache,              // credential cache, defaults to `new Map()`\n  datetime,           // defaults to now, to override use the form '20150830T123600Z'\n  appendSessionToken, // set to true to add X-Amz-Security-Token after signing, defaults to true for iot\n  allHeaders,         // set to true to force all headers to be signed instead of the defaults\n  singleEncode,       // set to true to only encode %2F once (usually only needed for testing)\n})\n```\n\n### `Promise<{ method, url, headers, body }> signer.sign()`\n\nActually perform the signing of the request and return a Promise that resolves\nto an object containing the signed method, url, headers and body.\n\n`method` will be a `String`, `url` will be an instance of [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL),\n`headers` will be an instance of [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) and\n`body` will unchanged from the argument you supply to the constructor.\n\n```js\nimport { AwsV4Signer } from 'aws4fetch'\n\nconst signer = new AwsV4Signer(opts)\n\nasync function sign() {\n  const { method, url, headers, body } = await signer.sign()\n\n  console.log(method, url, [...headers], body)\n}\n```\n\n### `Promise<String> signer.authHeader()`\n\nReturns a Promise that resolves to the signed string to use in the\n[`Authorization` header](https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html#sigv4-add-signature-auth-header)\n\nUsed by the `sign()` method – you shouldn't need to access this directly unless you're constructing your own requests.\n\n### `Promise<String> signer.signature()`\n\nReturns a Promise that resolves to the\n[hex signature](https://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html#sigv4-calculate-signature)\n\nUsed by the `sign()` method – you shouldn't need to access this directly unless you're constructing your own requests.\n\n# Installation\n\nWith [npm](http://npmjs.org/) do:\n\n```\nnpm install aws4fetch\n```\n\nOr you can also reference different formats straight from unpkg.com:\n\n[ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import):\n\nhttps://unpkg.com/aws4fetch@1.0.17/dist/aws4fetch.esm.js\n\nOR\n\nhttps://unpkg.com/aws4fetch@1.0.17/dist/aws4fetch.esm.mjs\n\n[UMD](https://github.com/umdjs/umd):\n\nhttps://unpkg.com/aws4fetch@1.0.17/dist/aws4fetch.umd.js\n\n[CommonJS](https://requirejs.org/docs/commonjs.html):\n\nhttps://unpkg.com/aws4fetch@1.0.17/dist/aws4fetch.cjs.js\n","readmeFilename":"README.md"}