🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-native-digest-fetch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-digest-fetch

Fetch which responds to digest challenges, built for react native

1.0.5
latest
Source
npm
Version published
Weekly downloads
53
43.24%
Maintainers
1
Weekly downloads
 
Created
Source

Description

This package implements digest authentication for react native using the fetch library

Digest fetch takes the same parameters as whatwg/fetch, with the addition of two parameters: username and password.

If the server does not respond with a www-authenticate header this function will act exactly like fetch typically does.

Install

npm install --save react-native-digest-fetch

Usage

import fetch from 'react-native-digest-fetch';

...

digestFetch('http://api.test.com/endpoint/', {
  method: 'POST',
  headers: {
    'content-type': 'application/json',
    'custom-header': 'anythingyouwant',
  },
  body: JSON.stringify({
    hello: 'world',
  }),
  username: 'DIGEST_AUTH_USERNAME',
  password: 'DIGEST_AUTH_PASSWORD',
});

Advanced Usage

If you would like to use your own http interaction library, and just need the Digest header value, you can import getDigestHeaderValue like so:

import { getDigestHeaderValue } from 'react-native-digest-fetch';

and use it like so

getDigestHeaderValue(serverHeaders['www-authenticate'], { url, method, headers, username, password });

Web usage

This library has been tested on react-native and vanilla node, but has not been tested on a front-end node project.

Keywords

react-native

FAQs

Package last updated on 03 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts