aws4-axios
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -7,3 +7,18 @@ import { AxiosRequestConfig } from "axios"; | ||
} | ||
/** | ||
* Create an interceptor to add to the Axios request chain. This interceptor | ||
* will sign requests with the AWSv4 signature. | ||
* | ||
* @example | ||
* axios.interceptors.request.use( | ||
* aws4Interceptor({ region: "eu-west-2", service: "execute-api" }) | ||
* ); | ||
* | ||
* @param options The options to be used when signing a request | ||
*/ | ||
export declare const aws4Interceptor: (options?: InterceptorOptions | undefined) => (config: AxiosRequestConfig) => AxiosRequestConfig; | ||
/** | ||
* @deprecated Please use the alternative export of `aws4Interceptor` | ||
*/ | ||
export declare const interceptor: (options?: InterceptorOptions | undefined) => (config: AxiosRequestConfig) => AxiosRequestConfig; | ||
export {}; |
@@ -5,3 +5,14 @@ "use strict"; | ||
var url_1 = require("url"); | ||
exports.interceptor = function (options) { return function (config) { | ||
/** | ||
* Create an interceptor to add to the Axios request chain. This interceptor | ||
* will sign requests with the AWSv4 signature. | ||
* | ||
* @example | ||
* axios.interceptors.request.use( | ||
* aws4Interceptor({ region: "eu-west-2", service: "execute-api" }) | ||
* ); | ||
* | ||
* @param options The options to be used when signing a request | ||
*/ | ||
exports.aws4Interceptor = function (options) { return function (config) { | ||
if (!config.url) { | ||
@@ -29,1 +40,5 @@ throw new Error("No URL present in request config, unable to sign request"); | ||
}; }; | ||
/** | ||
* @deprecated Please use the alternative export of `aws4Interceptor` | ||
*/ | ||
exports.interceptor = exports.aws4Interceptor; |
{ | ||
"name": "aws4-axios", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Axios request interceptor for signing requests with AWSv4", | ||
@@ -25,6 +25,11 @@ "author": "James Bourne", | ||
"scripts": { | ||
"prepare": "tsc" | ||
"prepare": "tsc", | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.13", | ||
"@types/node": "^12.0.4", | ||
"eslint": "^5.16.0", | ||
"jest": "^24.8.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.5.1" | ||
@@ -31,0 +36,0 @@ }, |
@@ -9,1 +9,49 @@ # aws4-axios | ||
This may be useful for accessing AWS services protected with IAM auth such as an API Gateway. | ||
# Installation | ||
| yarn | npm | | ||
| --------------------- | ------------------------------- | | ||
| `yarn add aws4-axios` | `npm install --save aws4-axios` | | ||
# Usage | ||
To add an interceptor to the default Axios client: | ||
```typescript | ||
import axios from "axios"; | ||
import { aws4Interceptor } from "aws4-axios"; | ||
const interceptor = aws4Interceptor({ | ||
region: "eu-west-2", | ||
service: "execute-api" | ||
}); | ||
axios.interceptors.request.use(interceptor); | ||
// Requests made using Axios will now be signed | ||
axios.get("https://example.com/foo").then(res => { | ||
// ... | ||
}); | ||
``` | ||
Or you can add the interceptor to a specific instance of an Axios client: | ||
```typescript | ||
import axios from "axios"; | ||
import { aws4Interceptor } from "aws4-axios"; | ||
const client = axios.create(); | ||
const interceptor = aws4Interceptor({ | ||
region: "eu-west-2", | ||
service: "execute-api" | ||
}); | ||
client.interceptors.request.use(interceptor); | ||
// Requests made using Axios will now be signed | ||
client.get("https://example.com/foo").then(res => { | ||
// ... | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6504
8
97
57
6