digest-fetch
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -16,2 +16,6 @@ const canRequire = typeof(require) == 'function' | ||
this.logger = options.logger | ||
// Custom authentication failure code for avoiding browser prompt: | ||
// https://stackoverflow.com/questions/9859627/how-to-prevent-browser-to-invoke-basic-auth-popup-and-handle-401-error-using-jqu | ||
this.statusCode = options.statusCode || 401 | ||
} | ||
@@ -21,3 +25,3 @@ | ||
const resp = await fetch(url, this.addAuth(url, options)) | ||
if (resp.status == 401) { | ||
if (resp.status == this.statusCode) { | ||
this.hasAuth = false | ||
@@ -27,3 +31,3 @@ await this.parseAuth(resp) | ||
const respFinal = await fetch(url, this.addAuth(url, options)) | ||
if (respFinal.status == 401) { | ||
if (respFinal.status == this.statusCode) { | ||
this.hasAuth = false | ||
@@ -105,2 +109,3 @@ } else { | ||
if (typeof(window) === "object") window.DigestFetch = DigestClient | ||
module.exports = DigestClient |
{ | ||
"name": "digest-fetch", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "digest auth request plugin for fetch/node-fetch", | ||
@@ -26,6 +26,7 @@ "main": "digest-fetch-src.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.1.6", | ||
"@babel/preset-env": "^7.1.6", | ||
"@babel/core": "^7.4.5", | ||
"@babel/preset-env": "^7.4.5", | ||
"after": "^0.8.2", | ||
"babel-loader": "^8.0.4", | ||
"babel-polyfill": "^6.26.0", | ||
"eslint": "^5.9.0", | ||
@@ -32,0 +33,0 @@ "eslint-plugin-markdown": "^1.0.0-rc.0", |
@@ -14,3 +14,3 @@ # digest-fetch | ||
// dependencies for node | ||
npm install crypto-js node-fetch | ||
npm install node-fetch | ||
@@ -24,6 +24,12 @@ // for browers, if to use it directly, please indcude file `digest-fetch.js` in a <script/> | ||
const DigestFetch = require('digest-fetch') | ||
// In browser: const DigestFetch = window.DigestFetch; | ||
const digestOptions = { | ||
cnonceSize: 32, // length of cnonce, default: 32 | ||
logger: console, // logger for debug, default: none | ||
algorithm: 'MD5' // only 'MD5' is supported now | ||
cnonceSize: 32, // length of cnonce, default: 32 | ||
logger: console, // logger for debug, default: none | ||
algorithm: 'MD5', // only 'MD5' is supported now | ||
// Custom authentication failure code for avoiding browser prompt: | ||
// https://stackoverflow.com/questions/9859627/how-to-prevent-browser-to-invoke-basic-auth-popup-and-handle-401-error-using-jqu | ||
statusCode: 401 // default 401 | ||
} | ||
@@ -30,0 +36,0 @@ |
@@ -0,1 +1,2 @@ | ||
require("babel-polyfill"); | ||
const webpack = require('webpack') | ||
@@ -6,4 +7,6 @@ const path = require('path') | ||
mode: 'production', | ||
target: "web", | ||
context: path.join(__dirname, './digest-fetch-src.js'), | ||
entry: [ | ||
"babel-polyfill", | ||
path.join(__dirname, './digest-fetch-src.js') | ||
@@ -10,0 +13,0 @@ ], |
Sorry, the diff of this file is too big to display
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
161500
11
650
65
12