Comparing version 3.0.8 to 3.1.0-0
@@ -93,6 +93,8 @@ 'use strict'; | ||
if (username && password) { | ||
store.authorization = 'Basic ' + btoa(username + ':' + password); | ||
// store.authorization = `Basic ${btoa(`${username}:${password}`)}` | ||
store.authParams = { login: username, api_key: password }; | ||
store.username = username; | ||
} else if (!conn) { | ||
delete store.authorization; | ||
// delete store.authorization | ||
delete store.authParams; | ||
delete store.username; | ||
@@ -139,4 +141,3 @@ } | ||
var _storage = storage(this), | ||
module = _storage.module, | ||
authorization = _storage.authorization; | ||
module = _storage.module; | ||
@@ -152,5 +153,2 @@ var method = options.method, | ||
if (authorization) { | ||
headers = _extends({}, headers, { authorization: authorization }); | ||
} | ||
@@ -204,4 +202,4 @@ if (module) { | ||
return new Promise(function (resolve, reject) { | ||
var method = options.method, | ||
query = options.query, | ||
var method = options.method; | ||
var query = options.query, | ||
body = options.body; | ||
@@ -211,3 +209,17 @@ var _options$headers2 = options.headers, | ||
var _storage2 = storage(_this), | ||
authParams = _storage2.authParams; | ||
if (authParams) { | ||
if (query) { | ||
query = _extends({}, authParams, query); | ||
} else if (!method || method === 'GET') { | ||
query = authParams; | ||
} else if (body) { | ||
body = _extends({}, authParams, body); | ||
} else { | ||
body = authParams; | ||
} | ||
} | ||
var reqBody = body && JSON.stringify(body); | ||
@@ -214,0 +226,0 @@ if (reqBody) { |
@@ -60,6 +60,8 @@ const { http, https, URL, btoa, fetch } = require('./requires.node') | ||
if (username && password) { | ||
store.authorization = `Basic ${btoa(`${username}:${password}`)}` | ||
// store.authorization = `Basic ${btoa(`${username}:${password}`)}` | ||
store.authParams = { login: username, api_key: password } | ||
store.username = username | ||
} else if (!conn) { | ||
delete store.authorization | ||
// delete store.authorization | ||
delete store.authParams | ||
delete store.username | ||
@@ -95,3 +97,3 @@ } | ||
request(options = {}) { | ||
const { module, authorization } = storage(this) | ||
const { module } = storage(this) | ||
@@ -102,5 +104,2 @@ const { method, path, body } = options | ||
let { headers = {} } = options | ||
if (authorization) { | ||
headers = { ...headers, authorization } | ||
} | ||
@@ -148,5 +147,19 @@ if (module) { | ||
return new Promise((resolve, reject) => { | ||
const { method, query, body } = options | ||
const { method } = options | ||
let { query, body } = options | ||
let { headers = {} } = options | ||
const { authParams } = storage(this) | ||
if (authParams) { | ||
if (query) { | ||
query = { ...authParams, ...query } | ||
} else if (!method || method === 'GET') { | ||
query = authParams | ||
} else if (body) { | ||
body = { ...authParams, ...body } | ||
} else { | ||
body = authParams | ||
} | ||
} | ||
const reqBody = body && JSON.stringify(body) | ||
@@ -153,0 +166,0 @@ if (reqBody) { |
{ | ||
"name": "danbooru", | ||
"version": "3.0.8", | ||
"version": "3.1.0-0", | ||
"description": "danbooru api wrapper", | ||
"keywords": ["danbooru", "booru", "api", "image", "anime", "manga"], | ||
"keywords": [ | ||
"danbooru", | ||
"booru", | ||
"api", | ||
"image", | ||
"anime", | ||
"manga" | ||
], | ||
"homepage": "https://github.com/stawberri/danbooru-node#readme", | ||
@@ -30,6 +37,6 @@ "bugs": { | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-env": "^1.7.0", | ||
"eslint": "^4.18.2", | ||
"husky": "^0.14.3", | ||
"jest": "^22.4.2", | ||
"jest": "^24.5.0", | ||
"nock": "^9.2.3", | ||
@@ -36,0 +43,0 @@ "node-fetch-polyfill": "^2.0.6", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
44782
909
1