Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@transferwise/approve-api-action-helpers

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transferwise/approve-api-action-helpers - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc