@transferwise/approve-api-action-helpers
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "@transferwise/approve-api-action-helpers", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An http client that handles SCA required requests gracefully", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
# Approve api action helpers | ||
> Documentation will be added soon.. | ||
A tiny library that lets you handle Strong Customer Authentication (SCA) required calls easily. | ||
## Usage | ||
### Installing | ||
`npm install @transferwise/approve-api-action-helpers` to install it. | ||
### Consuming | ||
This library exports a single function, `create`, which creates an SCA request wrapper with a provided config (see available options below). Use it like so: | ||
```javascript | ||
import { create } from '@transferwise/approve-api-action-helpers'; | ||
const request = create({ | ||
flow: 'iframe', | ||
mode: 'production', | ||
}); | ||
``` | ||
The request function it returns is essentially the same as [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch), except when the backend returns that SCA is required, it will run the user through an SCA flow and retry that request. Also, it will throw an error if you get a `4xx` or `5xx` response. | ||
**NB! make sure that your backend proxies 'x-2fa-approval' response header to the frontend and forwards it back to TransferWise when this library passes it back. Also please reflect the response status (403) back to the frontend.** | ||
```javascript | ||
const res = await request('https://my-backend-api.com/sca-protected-call', { options } | ||
``` | ||
#### Configuration options for `create` | ||
| key | optional | default | alternatives | | ||
|------|----------|----------------------|--------------| | ||
| flow | yes | 'iframe' | 'tab' | | ||
| mode | yes | 'production' | 'sandbox' | | ||
## Example | ||
### iFrame flow | ||
![sca-iframe-1](https://user-images.githubusercontent.com/39053304/97004007-096d0b00-1545-11eb-8af1-429220cbb065.gif) | ||
### New tab flow | ||
![sca-new-tab-1](https://user-images.githubusercontent.com/39053304/97004032-14c03680-1545-11eb-82b1-204484819cdf.gif) | ||
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
27559
46