Comparing version 1.3.0 to 1.3.1
@@ -41,7 +41,8 @@ "use strict"; | ||
this.setAccessToken = () => __awaiter(this, void 0, void 0, function* () { | ||
return (this.accessToken = yield OAuthHelpers.getAccessToken({ | ||
this.accessToken = yield OAuthHelpers.getAccessToken({ | ||
region: this.region, | ||
clientId: this.clientId, | ||
clientSecret: this.clientSecret, | ||
})); | ||
}); | ||
return this.accessToken; | ||
}); | ||
@@ -48,0 +49,0 @@ this.region = options.region; |
@@ -46,6 +46,6 @@ "use strict"; | ||
if (error.response && error.response.status === 401) { | ||
onAccessTokenExpired && onAccessTokenExpired(); | ||
onAccessTokenExpired === null || onAccessTokenExpired === void 0 ? void 0 : onAccessTokenExpired(); | ||
if (refreshExpiredAccessToken) { | ||
const newAccessToken = yield oauth_1.getAccessToken(queryOptions); | ||
onAccessTokenRefresh && onAccessTokenRefresh(newAccessToken); | ||
onAccessTokenRefresh === null || onAccessTokenRefresh === void 0 ? void 0 : onAccessTokenRefresh(newAccessToken); | ||
return queryWithAccessToken(queryOptions, newAccessToken); | ||
@@ -52,0 +52,0 @@ } |
@@ -20,17 +20,12 @@ "use strict"; | ||
const method = options.method || 'GET'; | ||
try { | ||
if (!validators_1.uri(uri)) { | ||
throw new RangeError(`'${uri}' is not a valid parameter for fetchFromUri()`); | ||
} | ||
const requestOptions = Object.assign(Object.assign(Object.assign(Object.assign({ method, url: encodeURI(uri), timeout: timeout || 10000 }, headers && { headers }), params && { params }), auth && { auth }), data && { data }); | ||
const response = yield axios_1.default.request(requestOptions); | ||
const lastModified = response.headers['last-modified'] | ||
? response.headers['last-modified'] | ||
: null; | ||
return Object.assign(Object.assign({}, response.data), lastModified && { lastModified }); | ||
if (!validators_1.uri(uri)) { | ||
throw new RangeError(`'${uri}' is not a valid parameter for fetchFromUri()`); | ||
} | ||
catch (error) { | ||
throw error; | ||
} | ||
const requestOptions = Object.assign(Object.assign(Object.assign(Object.assign({ method, url: encodeURI(uri), timeout: timeout || 10000 }, headers && { headers }), params && { params }), auth && { auth }), data && { data }); | ||
const response = yield axios_1.default.request(requestOptions); | ||
const lastModified = response.headers['last-modified'] | ||
? response.headers['last-modified'] | ||
: null; | ||
return Object.assign(Object.assign({}, response.data), lastModified && { lastModified }); | ||
}); | ||
//# sourceMappingURL=fetchFromUri.js.map |
@@ -13,3 +13,3 @@ "use strict"; | ||
const checkTokenUris_1 = require("../../utils/oauth/checkTokenUris"); | ||
const fetch_1 = require("../../helpers/fetch"); | ||
const fetch_1 = require("../fetch"); | ||
exports.default = (regionIdOrName, accessToken) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -16,0 +16,0 @@ try { |
@@ -6,3 +6,3 @@ "use strict"; | ||
const validators = [startsWithSlash, isLongEnough]; | ||
exports.default = (endpoint) => validators.every(validator => validator(endpoint)); | ||
exports.default = (endpoint) => validators.every((validator) => validator(endpoint)); | ||
//# sourceMappingURL=endpoint.js.map |
import { ConstantKey, RegionIdOrName, RegionIdAsNumberOrString, RegionName } from '../../types'; | ||
export declare const getConstantByRegion: (regionIdOrName: RegionIdOrName, constantKey: ConstantKey) => string | number | readonly string[] | import("../../types").Sc2RealmArray; | ||
export declare const getConstantByRegionId: (regionId: RegionIdAsNumberOrString, constantKey: ConstantKey) => string | number | readonly string[] | import("../../types").Sc2RealmArray; | ||
export declare const getConstantByRegionName: (regionName: RegionName, constantKey: ConstantKey) => string | number | readonly string[] | import("../../types").Sc2RealmArray; | ||
export declare const getConstantByRegion: (regionIdOrName: RegionIdOrName, constantKey: ConstantKey) => string | number | readonly string[] | import("../../types").Sc2RealmArray; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,12 +6,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getConstantByRegionName = exports.getConstantByRegionId = exports.getConstantByRegion = void 0; | ||
exports.getConstantByRegion = exports.getConstantByRegionName = exports.getConstantByRegionId = void 0; | ||
const constants_1 = __importDefault(require("../../constants")); | ||
const regions_1 = require("../localization/regions"); | ||
exports.getConstantByRegion = (regionIdOrName, constantKey) => { | ||
return regions_1.validateRegionId(regionIdOrName) | ||
? exports.getConstantByRegionId(regionIdOrName, constantKey) | ||
: exports.getConstantByRegionName(regionIdOrName.toString(), constantKey); | ||
}; | ||
exports.getConstantByRegionId = (regionId, constantKey) => { | ||
const regionIdAsString = typeof regionId !== 'string' ? regionId : regionId.toString(); | ||
const regionIdAsString = typeof regionId !== 'string' | ||
? regionId | ||
: regionId.toString(); | ||
const isRegionIdValid = regions_1.validateRegionId(regionIdAsString); | ||
@@ -31,2 +28,5 @@ if (!isRegionIdValid) { | ||
}; | ||
exports.getConstantByRegion = (regionIdOrName, constantKey) => (regions_1.validateRegionId(regionIdOrName) | ||
? exports.getConstantByRegionId(regionIdOrName, constantKey) | ||
: exports.getConstantByRegionName(regionIdOrName.toString(), constantKey)); | ||
//# sourceMappingURL=index.js.map |
@@ -31,3 +31,3 @@ "use strict"; | ||
const allLocaleKeys = Object.keys(allLocales); | ||
return Object.assign({}, ...allLocaleKeys.map(regionId => ({ | ||
return Object.assign({}, ...allLocaleKeys.map((regionId) => ({ | ||
[regionId]: exports.getDefaultLocaleNameForRegionId(regionId), | ||
@@ -34,0 +34,0 @@ }))); |
@@ -11,3 +11,3 @@ "use strict"; | ||
const regionKeys = Object.keys(constants_1.default.REGIONS); | ||
return regionKeys.map(regionKey => parseInt(regionKey, 10)); | ||
return regionKeys.map((regionKey) => parseInt(regionKey, 10)); | ||
}; | ||
@@ -40,3 +40,3 @@ exports.getAllRegionNames = () => { | ||
const regionKeys = Object.keys(regions); | ||
const regionIdArray = regionKeys.filter(key => regions[key].includes(regionNameLowercase)); | ||
const regionIdArray = regionKeys.filter((key) => regions[key].includes(regionNameLowercase)); | ||
const regionId = Number(regionIdArray[0]) || false; | ||
@@ -43,0 +43,0 @@ if (!regionId) { |
{ | ||
"name": "blizzapi", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Flexible and feature-rich Node.js library for Blizzard Battle.net API", | ||
@@ -31,5 +31,6 @@ "homepage": "https://blizzapi.lukem.net", | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
"lint": "tslint --project tsconfig.json", | ||
"build": "npm run lint && npm run test && npm run clean && tsc", | ||
"dev": "tsc -w", | ||
"lint": "eslint . --ext .ts", | ||
"compile": "tsc --project tsconfig.json", | ||
"build": "npm run lint && npm run test && npm run clean && npm run compile", | ||
"dev": "tsc -w --project tsconfig.json", | ||
"prepublishOnly": "npm run build" | ||
@@ -46,10 +47,12 @@ }, | ||
"@types/node": "^14.10.3", | ||
"@typescript-eslint/eslint-plugin": "^4.4.0", | ||
"@typescript-eslint/parser": "^4.4.0", | ||
"eslint": "^7.10.0", | ||
"eslint-config-airbnb-typescript": "^11.0.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.0", | ||
"jest": "^26.4.2", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.3.0", | ||
"tslint": "^6.1.3", | ||
"tslint-config-airbnb": "^5.11.2", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"tslint-immutable": "^6.0.1", | ||
"typescript": "^4.0.2" | ||
"typescript": "^4.0.3" | ||
}, | ||
@@ -56,0 +59,0 @@ "keywords": [ |
@@ -67,3 +67,3 @@ <img src="https://raw.githubusercontent.com/lukemnet/blizzapi-docs/master/docs/.vuepress/public/logo.png" alt="BlizzAPI logo" width="200" height="200"> | ||
We maintain an [AUTHORS](https://github.com/lukemnet/blizzapi/blob/master/AUTHORS.md) file where we keep a list of all project contributors. Please consider adding your name there with your next PR. | ||
We maintain an [AUTHORS](https://github.com/lukemnet/blizzapi/blob/master/AUTHORS) file where we keep a list of all project contributors. Please consider adding your name there with your next PR. | ||
@@ -70,0 +70,0 @@ ## License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
101052
164
1102
12