Socket
Socket
Sign inDemoInstall

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


Version published
Weekly downloads
13
increased by30%
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

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

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