Socket
Socket
Sign inDemoInstall

blizzapi

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blizzapi - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

@interfaces/index.d.ts

3

dist/index.d.ts
import BlizzAPI from './lib/classes/BlizzAPI';
import * as BlizzUtils from './lib/utils';
export { BlizzAPI, BlizzUtils };
export default BlizzAPI;
//# sourceMappingURL=index.d.ts.map

@@ -5,14 +5,6 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var BlizzAPI_1 = __importDefault(require("./lib/classes/BlizzAPI"));
exports.BlizzAPI = BlizzAPI_1.default;
var BlizzUtils = __importStar(require("./lib/utils"));
exports.BlizzUtils = BlizzUtils;
exports.default = BlizzAPI_1.default;
(typeof module !== "undefined") && (module.exports = BlizzAPI_1.default);
//# sourceMappingURL=index.js.map

@@ -1,11 +0,13 @@

import { ClientId, ClientSecret, RegionIdOrName, AccessToken } from '../../types';
import OAuth2API from './OAuth2API';
export default abstract class BattleNetAPI extends OAuth2API {
readonly region: RegionIdOrName;
accessToken: AccessToken;
constructor(region: RegionIdOrName, clientId: ClientId, clientSecret: ClientSecret, accessToken?: AccessToken);
readonly getAccessToken: () => string | Promise<string>;
readonly setAccessToken: () => Promise<string>;
static validateAccessToken: (region: RegionIdOrName, accessToken: AccessToken) => Promise<boolean>;
}
declare const _default: {
new (region: string | number, clientId: string, clientSecret: string, accessToken?: string | undefined): {
readonly region: string | number;
accessToken: string | undefined;
readonly getAccessToken: () => string | Promise<string>;
readonly setAccessToken: () => Promise<string>;
readonly clientId: string;
readonly clientSecret: string;
};
validateAccessToken: (region: string | number, accessToken: string | undefined) => Promise<boolean>;
};
export = _default;
//# sourceMappingURL=BattleNetAPI.d.ts.map

@@ -60,33 +60,33 @@ "use strict";

};
var _a;
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
"use strict";
var OAuth2API_1 = __importDefault(require("./OAuth2API"));
var tokenUris_1 = require("../../utils/oauth/tokenUris");
var oauthHelpers = __importStar(require("../../helpers/oauth"));
var BattleNetAPI = (function (_super) {
__extends(BattleNetAPI, _super);
function BattleNetAPI(region, clientId, clientSecret, accessToken) {
var _this = _super.call(this, clientId, clientSecret) || this;
_this.getAccessToken = function () { return (_this.accessToken ? _this.accessToken : _this.setAccessToken()); };
_this.setAccessToken = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this;
return [4, oauthHelpers.getAccessToken(tokenUris_1.getTokenUriByRegion(this.region), this.clientId, this.clientSecret)];
case 1: return [2, (_a.accessToken = _b.sent())];
}
});
}); };
_this.region = region;
_this.accessToken = accessToken || null;
return _this;
}
BattleNetAPI.validateAccessToken = function (region, accessToken) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2, oauthHelpers.validateAccessToken(region, accessToken)];
}); }); };
return BattleNetAPI;
}(OAuth2API_1.default));
exports.default = BattleNetAPI;
var OAuthHelpers = __importStar(require("../../helpers/oauth"));
module.exports = (_a = (function (_super) {
__extends(BattleNetAPI, _super);
function BattleNetAPI(region, clientId, clientSecret, accessToken) {
var _this = _super.call(this, clientId, clientSecret) || this;
_this.getAccessToken = function () { return (_this.accessToken ? _this.accessToken : _this.setAccessToken()); };
_this.setAccessToken = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this;
return [4, OAuthHelpers.getAccessToken(this.region, this.clientId, this.clientSecret)];
case 1: return [2, (_a.accessToken = _b.sent())];
}
});
}); };
_this.region = region;
_this.accessToken = accessToken || undefined;
return _this;
}
return BattleNetAPI;
}(OAuth2API_1.default)),
_a.validateAccessToken = function (region, accessToken) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2, OAuthHelpers.validateAccessToken(region, accessToken)];
}); }); },
_a);
//# sourceMappingURL=BattleNetAPI.js.map

@@ -1,7 +0,6 @@

export default abstract class OAuth2API {
export default class OAuth2API {
readonly clientId: string;
readonly clientSecret: string;
constructor(clientId: string, clientSecret: string);
abstract query(uri: string): object;
}
//# sourceMappingURL=OAuth2API.d.ts.map

@@ -1,11 +0,42 @@

import { RegionIdOrName, ClientId, ClientSecret, AccessToken } from '../types';
import { QueryOptions } from '../interfaces';
import BattleNetAPI from './abstract/BattleNetAPI';
import * as utils from '../utils';
import { RegionIdOrName } from '../../../@types';
import BattleNetAPI = require('./abstract/BattleNetAPI');
export interface BlizzAPIOptions {
validateAccessTokenOnEachQuery?: boolean;
refreshExpiredAccessToken?: boolean;
onAccessTokenExpire?: Function | undefined;
onAccessTokenRefresh?: Function | undefined;
}
export interface BattleNetOptions extends BlizzAPIOptions {
region: RegionIdOrName;
clientId: string;
clientSecret: string;
accessToken?: string;
}
export default class BlizzAPI extends BattleNetAPI {
readonly options: QueryOptions;
constructor(region: RegionIdOrName, clientId: ClientId, clientSecret: ClientSecret, accessToken?: AccessToken, options?: QueryOptions);
readonly options: BlizzAPIOptions;
constructor(options: BattleNetOptions);
query: (endpoint: string) => Promise<any>;
querySearch: (endpoint: string, selector: string) => Promise<any>;
queryBatch: (endpoints: ReadonlyArray<string>, options?: QueryOptions) => Promise<any[]>;
getAccessToken: () => Promise<string>;
validateAccessToken: (regionIdOrName: string | number, accessToken: string | undefined) => Promise<boolean>;
static getAllRegions: () => Readonly<import("../../../@interfaces").RegionIdProperties<readonly string[]>>;
static getAllRegionIds: () => readonly number[];
static getAllRegionNames: () => string[];
static getRegionNameById: (regionId: string | number) => readonly string[];
static validateRegionId: (regionId: string | number) => boolean;
static getRegionIdByName: (regionName: string) => number;
static validateRegionName: (regionName: string) => boolean;
static getAllLocales: () => Readonly<import("../../../@interfaces").RegionIdProperties<readonly string[]>>;
static getAllLocaleNames: () => string[];
static getLocalesByRegionId: (regionId: string | number) => readonly string[];
static checkIfLocaleLooksValid: (locale: string) => boolean;
static validateLocale: (locale: string) => boolean;
static isLocaleValidForRegionId: (locale: string, regionId: string | number) => boolean;
static getAllSc2Realms: () => Readonly<import("../../../@interfaces").RegionIdProperties<readonly number[]>>;
static getAllAvailableSc2Realms: typeof utils.getAllAvailableSc2Realms;
static getSc2RealmsByRegionId: (regionId: string | number) => readonly number[];
static checkIfSc2RealmLooksValid: (sc2Realm: string | number) => boolean;
static validateSc2Realm: (sc2Realm: string | number) => boolean;
static isSc2RealmValidForRegionId: (sc2Realm: string | number, regionId: string | number) => boolean;
}
//# sourceMappingURL=BlizzAPI.d.ts.map

@@ -50,5 +50,2 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {

@@ -62,12 +59,13 @@ if (mod && mod.__esModule) return mod;

Object.defineProperty(exports, "__esModule", { value: true });
var BattleNetAPI_1 = __importDefault(require("./abstract/BattleNetAPI"));
var bnetHelpers = __importStar(require("../helpers/bnet"));
var helpers = __importStar(require("../helpers"));
var utils = __importStar(require("../utils"));
var BattleNetAPI = require("./abstract/BattleNetAPI");
var BlizzAPI = (function (_super) {
__extends(BlizzAPI, _super);
function BlizzAPI(region, clientId, clientSecret, accessToken, options) {
var _this = _super.call(this, region, clientId, clientSecret, accessToken) || this;
function BlizzAPI(options) {
var _this = _super.call(this, options.region, options.clientId, options.clientSecret, options.accessToken) || this;
_this.query = function (endpoint) { return __awaiter(_this, void 0, void 0, function () { var _a, _b, _c; return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_b = (_a = bnetHelpers).query;
_b = (_a = helpers).query;
_c = [this.region, endpoint];

@@ -78,31 +76,41 @@ return [4, this.getAccessToken()];

}); }); };
_this.querySearch = function (endpoint, selector) { return __awaiter(_this, void 0, void 0, function () { var _a, _b, _c; return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_b = (_a = bnetHelpers).querySearch;
_c = [this.region, endpoint, selector];
return [4, this.getAccessToken()];
case 1: return [2, _b.apply(_a, _c.concat([_d.sent()]))];
}
_this.getAccessToken = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2, helpers.getAccessToken(this.region, this.clientId, this.clientSecret)];
}); }); };
_this.queryBatch = function (endpoints, options) {
if (options === void 0) { options = _this.options; }
return __awaiter(_this, void 0, void 0, function () { var _a, _b, _c; return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_b = (_a = bnetHelpers).queryBatch;
_c = [this.region, endpoints];
return [4, this.getAccessToken()];
case 1: return [2, _b.apply(_a, _c.concat([_d.sent(), options]))];
}
}); });
_this.validateAccessToken = function (regionIdOrName, accessToken) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2, helpers.validateAccessToken(regionIdOrName, accessToken)];
}); }); };
_this.options = {
validateAccessTokenOnEachQuery: options.validateAccessTokenOnEachQuery
? options.validateAccessTokenOnEachQuery
: false,
refreshExpiredAccessToken: options.refreshExpiredAccessToken
? options.refreshExpiredAccessToken
: false,
onAccessTokenRefresh: options.onAccessTokenRefresh ? options.onAccessTokenRefresh : undefined,
};
_this.options = options || {
batchQueryInterval: 500,
};
return _this;
}
BlizzAPI.getAllRegions = utils.getAllRegions;
BlizzAPI.getAllRegionIds = utils.getAllRegionIds;
BlizzAPI.getAllRegionNames = utils.getAllRegionNames;
BlizzAPI.getRegionNameById = utils.getRegionNameById;
BlizzAPI.validateRegionId = utils.validateRegionId;
BlizzAPI.getRegionIdByName = utils.getRegionIdByName;
BlizzAPI.validateRegionName = utils.validateRegionName;
BlizzAPI.getAllLocales = utils.getAllLocales;
BlizzAPI.getAllLocaleNames = utils.getAllLocaleNames;
BlizzAPI.getLocalesByRegionId = utils.getLocalesByRegionId;
BlizzAPI.checkIfLocaleLooksValid = utils.checkIfLocaleLooksValid;
BlizzAPI.validateLocale = utils.validateLocale;
BlizzAPI.isLocaleValidForRegionId = utils.isLocaleValidForRegionId;
BlizzAPI.getAllSc2Realms = utils.getAllSc2Realms;
BlizzAPI.getAllAvailableSc2Realms = utils.getAllAvailableSc2Realms;
BlizzAPI.getSc2RealmsByRegionId = utils.getSc2RealmsByRegionId;
BlizzAPI.checkIfSc2RealmLooksValid = utils.checkIfSc2RealmLooksValid;
BlizzAPI.validateSc2Realm = utils.validateSc2Realm;
BlizzAPI.isSc2RealmValidForRegionId = utils.isSc2RealmValidForRegionId;
return BlizzAPI;
}(BattleNetAPI_1.default));
}(BattleNetAPI));
exports.default = BlizzAPI;
//# sourceMappingURL=BlizzAPI.js.map

@@ -1,2 +0,2 @@

export { default as hosts } from './hosts';
export { default as regionHosts } from './regionHosts';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var hosts_1 = require("./hosts");
exports.hosts = hosts_1.default;
var regionHosts_1 = require("./regionHosts");
exports.regionHosts = regionHosts_1.default;
//# sourceMappingURL=index.js.map
declare const CONSTANTS: {
REGIONS: Readonly<import("../interfaces").RegionIdProperties<ReadonlyArray<string>>>;
LOCALES: Readonly<import("../interfaces").RegionIdProperties<ReadonlyArray<string>>>;
DEFAULT_LOCALES: Readonly<import("../interfaces").RegionIdProperties<number>>;
SC2_REALMS: Readonly<import("../interfaces").RegionIdProperties<ReadonlyArray<number>>>;
REGION_API_HOSTS: Readonly<import("../interfaces").RegionIdProperties<string>>;
OAUTH_AUTHORIZE_URIS: Readonly<import("../interfaces").RegionIdProperties<string>>;
OAUTH_TOKEN_URIS: Readonly<import("../interfaces").RegionIdProperties<string>>;
OAUTH_CHECK_TOKEN_URIS: Readonly<import("../interfaces").RegionIdProperties<string>>;
REGIONS: Readonly<import("../../../@interfaces").RegionIdProperties<readonly string[]>>;
LOCALES: Readonly<import("../../../@interfaces").RegionIdProperties<readonly string[]>>;
DEFAULT_LOCALES: Readonly<import("../../../@interfaces").RegionIdProperties<number>>;
SC2_REALMS: Readonly<import("../../../@interfaces").RegionIdProperties<readonly number[]>>;
REGION_API_HOSTS: Readonly<import("../../../@interfaces").RegionIdProperties<string | readonly string[]>>;
OAUTH_AUTHORIZE_URIS: Readonly<import("../../../@interfaces").RegionIdProperties<string>>;
OAUTH_TOKEN_URIS: Readonly<import("../../../@interfaces").RegionIdProperties<string>>;
OAUTH_CHECK_TOKEN_URIS: Readonly<import("../../../@interfaces").RegionIdProperties<string>>;
};
export default CONSTANTS;
//# sourceMappingURL=index.d.ts.map

@@ -9,6 +9,9 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var localization = __importStar(require("./localization"));
var api = __importStar(require("./api"));
var oauth = __importStar(require("./oauth"));
var oauth_1 = __importDefault(require("./oauth"));
var CONSTANTS = {

@@ -19,8 +22,8 @@ REGIONS: localization.regions,

SC2_REALMS: localization.sc2Realms,
REGION_API_HOSTS: api.hosts,
OAUTH_AUTHORIZE_URIS: oauth.authorizeUris,
OAUTH_TOKEN_URIS: oauth.tokenUris,
OAUTH_CHECK_TOKEN_URIS: oauth.checkTokenUris,
REGION_API_HOSTS: api.regionHosts,
OAUTH_AUTHORIZE_URIS: oauth_1.default.authorizeUris,
OAUTH_TOKEN_URIS: oauth_1.default.tokenUris,
OAUTH_CHECK_TOKEN_URIS: oauth_1.default.checkTokenUris,
};
exports.default = CONSTANTS;
//# sourceMappingURL=index.js.map

@@ -1,4 +0,4 @@

import { RegionIdProperties } from '../../interfaces';
import { RegionIdProperties } from '../../../../@interfaces';
declare const _default: Readonly<RegionIdProperties<number>>;
export default _default;
//# sourceMappingURL=defaultLocales.d.ts.map

@@ -1,4 +0,4 @@

import { RegionIdProperties } from '../../interfaces';
declare const _default: Readonly<RegionIdProperties<ReadonlyArray<string>>>;
import { RegionIdProperties } from '../../../../@interfaces';
declare const _default: Readonly<RegionIdProperties<readonly string[]>>;
export default _default;
//# sourceMappingURL=locales.d.ts.map

@@ -1,4 +0,4 @@

import { RegionIdProperties } from '../../interfaces';
declare const _default: Readonly<RegionIdProperties<ReadonlyArray<string>>>;
import { RegionIdProperties } from '../../../../@interfaces';
declare const _default: Readonly<RegionIdProperties<readonly string[]>>;
export default _default;
//# sourceMappingURL=regions.d.ts.map

@@ -1,4 +0,4 @@

import { RegionIdProperties } from '../../interfaces';
declare const _default: Readonly<RegionIdProperties<ReadonlyArray<number>>>;
import { RegionIdProperties } from '../../../../@interfaces';
declare const _default: Readonly<RegionIdProperties<readonly number[]>>;
export default _default;
//# sourceMappingURL=sc2Realms.d.ts.map

@@ -1,4 +0,8 @@

export { default as authorizeUris } from './authorizeUris';
export { default as tokenUris } from './tokenUris';
export { default as checkTokenUris } from './checkTokenUris';
import { RegionIdProperties } from '../../../../@interfaces';
declare const _default: {
authorizeUris: Readonly<RegionIdProperties<string>>;
tokenUris: Readonly<RegionIdProperties<string>>;
checkTokenUris: Readonly<RegionIdProperties<string>>;
};
export default _default;
//# sourceMappingURL=index.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var authorizeUris_1 = require("./authorizeUris");
exports.authorizeUris = authorizeUris_1.default;
var tokenUris_1 = require("./tokenUris");
exports.tokenUris = tokenUris_1.default;
var checkTokenUris_1 = require("./checkTokenUris");
exports.checkTokenUris = checkTokenUris_1.default;
var OAuthHosts_1 = __importDefault(require("./OAuthHosts"));
var getRegionPropertyArray = function (endpoint) { return ({
1: "" + OAuthHosts_1.default[1] + endpoint,
2: "" + OAuthHosts_1.default[2] + endpoint,
3: "" + OAuthHosts_1.default[3] + endpoint,
5: "" + OAuthHosts_1.default[5] + endpoint,
}); };
var authorizeEndpoint = '/oauth/authorize';
var tokenEndpoint = '/oauth/token';
var checkTokenEndpoint = '/oauth/check_token?token=';
var authorizeUris = getRegionPropertyArray(authorizeEndpoint);
var tokenUris = getRegionPropertyArray(tokenEndpoint);
var checkTokenUris = getRegionPropertyArray(checkTokenEndpoint);
exports.default = {
authorizeUris: Object.freeze(authorizeUris),
tokenUris: Object.freeze(tokenUris),
checkTokenUris: Object.freeze(checkTokenUris),
};
//# sourceMappingURL=index.js.map
export { default as query } from './query';
export { default as queryBatch } from './queryBatch';
export { default as querySearch } from './querySearch';
export { default as querySearchBatch } from './querySearchBatch';
//# sourceMappingURL=index.d.ts.map

@@ -5,8 +5,2 @@ "use strict";

exports.query = query_1.default;
var queryBatch_1 = require("./queryBatch");
exports.queryBatch = queryBatch_1.default;
var querySearch_1 = require("./querySearch");
exports.querySearch = querySearch_1.default;
var querySearchBatch_1 = require("./querySearchBatch");
exports.querySearchBatch = querySearchBatch_1.default;
//# sourceMappingURL=index.js.map

@@ -1,4 +0,3 @@

import { RegionIdOrName, AccessToken } from '../../types';
declare const _default: (region: RegionIdOrName, endpoint: string, accessToken: AccessToken) => Promise<any>;
declare const _default: (region: string | number, endpoint: string, accessToken: string | undefined) => Promise<any>;
export default _default;
//# sourceMappingURL=query.d.ts.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -42,15 +6,13 @@ var validators_1 = require("../validators");

var fetch_1 = require("../fetch");
exports.default = (function (region, endpoint, accessToken) { return __awaiter(_this, void 0, void 0, function () {
var validEndpoint, apiHost, requestUri, headers;
return __generator(this, function (_a) {
validEndpoint = validators_1.endpoint(endpoint);
if (!validEndpoint)
throw new RangeError(endpoint + " is not a valid endpoint.");
apiHost = api_1.getApiHostByRegion(region);
requestUri = "" + apiHost + endpoint;
headers = new Headers();
headers.append('Authorization', "Bearer " + accessToken);
return [2, fetch_1.fetchFromUri(requestUri, 'GET', headers)];
});
}); });
exports.default = (function (region, endpoint, accessToken) {
var validEndpoint = validators_1.endpoint(endpoint);
if (!validEndpoint)
throw new RangeError(endpoint + " is not a valid endpoint.");
var apiHost = api_1.getApiHostByRegion(region);
var requestUri = "" + apiHost + endpoint;
var headers = {
Authorization: "Bearer " + accessToken,
};
return fetch_1.fetchFromUri(requestUri, 'GET', headers);
});
//# sourceMappingURL=query.js.map

@@ -1,5 +0,4 @@

import { HttpMethod } from '../../types';
import 'cross-fetch/polyfill';
declare const _default: (uri: string, method?: HttpMethod, headers?: Headers | undefined, params?: URLSearchParams | undefined) => Promise<any>;
import { HttpMethod } from '../../../../@types';
declare const _default: (uri: string, method?: HttpMethod, headers?: object | Headers | undefined, params?: URLSearchParams | undefined) => Promise<any>;
export default _default;
//# sourceMappingURL=fetchFromUri.d.ts.map

@@ -37,13 +37,17 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = __importDefault(require("axios"));
var validators_1 = require("../validators");
require("cross-fetch/polyfill");
exports.default = (function (uri, method, headers, params) {
if (method === void 0) { method = 'GET'; }
return __awaiter(_this, void 0, void 0, function () {
var requestOptions, response, _a;
return __generator(this, function (_b) {
switch (_b.label) {
var requestOptions, response, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
if (!validators_1.uri(uri)) {

@@ -58,15 +62,11 @@ throw new RangeError("'" + uri + "' is not a valid parameter for fetchFromUri()");

if (method === 'POST')
Object.assign(requestOptions, { body: params });
return [4, fetch(uri, requestOptions)];
Object.assign(requestOptions, { params: params });
return [4, axios_1.default.get(uri, requestOptions)];
case 1:
response = _b.sent();
if (!response.ok) return [3, 3];
return [4, response.json()];
response = _a.sent();
return [2, response.data];
case 2:
_a = _b.sent();
return [3, 4];
case 3:
_a = response;
_b.label = 4;
case 4: return [2, _a];
error_1 = _a.sent();
throw error_1;
case 3: return [2];
}

@@ -73,0 +73,0 @@ });

export * from './bnet';
export * from './common';
export * from './fetch';
export * from './json';
export * from './oauth';
export * from './validators';
//# sourceMappingURL=index.d.ts.map

@@ -7,7 +7,5 @@ "use strict";

__export(require("./bnet"));
__export(require("./common"));
__export(require("./fetch"));
__export(require("./json"));
__export(require("./oauth"));
__export(require("./validators"));
//# sourceMappingURL=index.js.map

@@ -13,8 +13,9 @@ "use strict";

exports.default = (function (oauthUri, clientId, clientSecret) {
var headers = new Headers();
var params = new URLSearchParams();
headers.append('Authorization', "Basic " + base64.encode(clientId + ":" + clientSecret));
params.append('grant_type', 'client_credentials');
var headers = {
Authorization: "Basic " + base64.encode(clientId + ":" + clientSecret)
};
return fetch_1.fetchFromUri(oauthUri, 'POST', headers, params);
});
//# sourceMappingURL=fetchAccessToken.js.map

@@ -1,3 +0,3 @@

declare const _default: (oauthUri: string, clientId: string, clientSecret: string) => Promise<string>;
declare const _default: (region: string | number, clientId: string, clientSecret: string) => Promise<string>;
export default _default;
//# sourceMappingURL=getAccessToken.d.ts.map

@@ -43,7 +43,10 @@ "use strict";

var fetchAccessToken_1 = __importDefault(require("./fetchAccessToken"));
exports.default = (function (oauthUri, clientId, clientSecret) { return __awaiter(_this, void 0, void 0, function () {
var accessTokenObject;
var utils_1 = require("../../utils");
exports.default = (function (region, clientId, clientSecret) { return __awaiter(_this, void 0, void 0, function () {
var oauthUri, accessTokenObject;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, fetchAccessToken_1.default(oauthUri, clientId, clientSecret)];
case 0:
oauthUri = utils_1.getTokenUriByRegion(region);
return [4, fetchAccessToken_1.default(oauthUri, clientId, clientSecret)];
case 1:

@@ -50,0 +53,0 @@ accessTokenObject = _a.sent();

@@ -1,4 +0,3 @@

import { RegionIdOrName, AccessToken } from '../../types';
declare const _default: (regionIdOrName: RegionIdOrName, accessToken: AccessToken) => Promise<boolean>;
declare const _default: (regionIdOrName: string | number, accessToken: string | undefined) => Promise<boolean>;
export default _default;
//# sourceMappingURL=validateAccessToken.d.ts.map

@@ -42,3 +42,3 @@ "use strict";

exports.default = (function (regionIdOrName, accessToken) { return __awaiter(_this, void 0, void 0, function () {
var checkTokenUri, requestPath, response, validationResult;
var checkTokenUri, requestPath, response;
return __generator(this, function (_a) {

@@ -52,6 +52,3 @@ switch (_a.label) {

response = _a.sent();
return [4, response.json()];
case 2:
validationResult = _a.sent();
return [2, !(validationResult.error && validationResult.error === 'invalid_token')];
return [2, !(response.error && response.error === 'invalid_token')];
}

@@ -58,0 +55,0 @@ });

export { default as endpoint } from './endpoint';
export { default as selector } from './selector';
export { default as endpoints } from './endpoints';
export { default as uri } from './uri';
export { default as endpointsWithSelectors } from './endpointsWithSelectors';
//# sourceMappingURL=index.d.ts.map

@@ -5,10 +5,4 @@ "use strict";

exports.endpoint = endpoint_1.default;
var selector_1 = require("./selector");
exports.selector = selector_1.default;
var endpoints_1 = require("./endpoints");
exports.endpoints = endpoints_1.default;
var uri_1 = require("./uri");
exports.uri = uri_1.default;
var endpointsWithSelectors_1 = require("./endpointsWithSelectors");
exports.endpointsWithSelectors = endpointsWithSelectors_1.default;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export * from './hosts';
export * from './regionHosts';
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./hosts"));
__export(require("./regionHosts"));
//# sourceMappingURL=index.js.map

@@ -1,5 +0,5 @@

import { ConstantKey, RegionIdOrName } from '../../types';
export declare const getConstantByRegion: (regionIdOrName: RegionIdOrName, constantKey: ConstantKey) => string | number | ReadonlyArray<number> | ReadonlyArray<string>;
export declare const getConstantByRegionId: (regionId: RegionIdOrName, constantKey: ConstantKey) => string | number | ReadonlyArray<number> | ReadonlyArray<string>;
export declare const getConstantByRegionName: (regionName: string, constantKey: ConstantKey) => string | number | ReadonlyArray<number> | ReadonlyArray<string>;
import { ConstantKey } from '../../../../@types';
export declare const getConstantByRegion: (regionIdOrName: string | number, constantKey: ConstantKey) => string | number | readonly string[] | readonly number[];
export declare const getConstantByRegionId: (regionId: string | number, constantKey: ConstantKey) => string | number | readonly string[] | readonly number[];
export declare const getConstantByRegionName: (regionName: string, constantKey: ConstantKey) => string | number | readonly string[] | readonly number[];
//# sourceMappingURL=index.d.ts.map

@@ -9,10 +9,8 @@ "use strict";

exports.getConstantByRegion = function (regionIdOrName, constantKey) {
var validRegionId = regions_1.validateRegionId(regionIdOrName);
if (validRegionId) {
return exports.getConstantByRegionId(regionIdOrName, constantKey);
}
return exports.getConstantByRegionName(regionIdOrName.toString(), constantKey);
return regions_1.validateRegionId(regionIdOrName)
? exports.getConstantByRegionId(regionIdOrName, constantKey)
: exports.getConstantByRegionName(regionIdOrName.toString(), constantKey);
};
exports.getConstantByRegionId = function (regionId, constantKey) {
var regionIdAsString = regionId.toString();
var regionIdAsString = typeof regionId !== 'string' ? regionId : regionId.toString();
var isRegionIdValid = regions_1.validateRegionId(regionIdAsString);

@@ -19,0 +17,0 @@ if (!isRegionIdValid) {

@@ -1,6 +0,6 @@

import { RegionIdProperties } from '../../interfaces';
import { RegionIdProperties } from '../../../../@interfaces';
export declare const getAllDefaultLocaleIndexes: () => Readonly<RegionIdProperties<number>>;
export declare const getDefaultLocaleIndexForRegionId: (regionId: import("../../types").RegionIdOrName) => number;
export declare const getDefaultLocaleNameForRegionId: (regionId: import("../../types").RegionIdOrName) => string;
export declare const getDefaultLocaleIndexForRegionId: (regionId: string | number) => number;
export declare const getDefaultLocaleNameForRegionId: (regionId: string | number) => string;
export declare const getAllDefaultLocaleNames: () => RegionIdProperties<string>;
//# sourceMappingURL=defaultLocales.d.ts.map

@@ -1,7 +0,7 @@

export declare const getAllLocales: () => Readonly<import("../../interfaces").RegionIdProperties<ReadonlyArray<string>>>;
export declare const getAllLocales: () => Readonly<import("../../../../@interfaces").RegionIdProperties<readonly string[]>>;
export declare const getAllLocaleNames: () => string[];
export declare const getLocalesByRegionId: (regionId: import("../../types").RegionIdOrName) => ReadonlyArray<string>;
export declare const getLocalesByRegionId: (regionId: string | number) => readonly string[];
export declare const checkIfLocaleLooksValid: (locale: string) => boolean;
export declare const validateLocale: (locale: string) => boolean;
export declare const isLocaleValidForRegionId: (locale: string, regionId: import("../../types").RegionIdOrName) => boolean;
export declare const isLocaleValidForRegionId: (locale: string, regionId: string | number) => boolean;
//# sourceMappingURL=locales.d.ts.map

@@ -30,3 +30,5 @@ "use strict";

}
var lowerCaseLocaleList = exports.getAllLocaleNames().map(function (localeName) { return localeName.toLowerCase(); });
var lowerCaseLocaleList = exports.getAllLocaleNames().map(function (localeName) {
return localeName.toLowerCase();
});
var lowerCaseLocale = locale.toLowerCase();

@@ -33,0 +35,0 @@ return lowerCaseLocaleList.includes(lowerCaseLocale);

@@ -1,8 +0,8 @@

export declare const getAllRegions: () => Readonly<import("../../interfaces").RegionIdProperties<ReadonlyArray<string>>>;
export declare const getAllRegionIds: () => ReadonlyArray<number>;
export declare const getAllRegionNames: () => ReadonlyArray<string>;
export declare const getRegionNameById: (regionId: import("../../types").RegionIdOrName) => ReadonlyArray<string>;
export declare const validateRegionId: (regionId: import("../../types").RegionIdOrName) => boolean;
export declare const getAllRegions: () => Readonly<import("../../../../@interfaces").RegionIdProperties<readonly string[]>>;
export declare const getAllRegionIds: () => readonly number[];
export declare const getAllRegionNames: () => string[];
export declare const getRegionNameById: (regionId: string | number) => readonly string[];
export declare const validateRegionId: (regionId: string | number) => boolean;
export declare const getRegionIdByName: (regionName: string) => number;
export declare const validateRegionName: (regionName: string) => boolean;
//# sourceMappingURL=regions.d.ts.map

@@ -1,8 +0,8 @@

import { Sc2RealmList } from '../../types';
export declare const getAllSc2Realms: () => Readonly<import("../../interfaces").RegionIdProperties<ReadonlyArray<number>>>;
import { Sc2RealmList } from '../../../../@types';
export declare const getAllSc2Realms: () => Readonly<import("../../../../@interfaces").RegionIdProperties<readonly number[]>>;
export declare function getAllAvailableSc2Realms(): Sc2RealmList;
export declare const getSc2RealmsByRegionId: (regionId: import("../../types").RegionIdOrName) => ReadonlyArray<number>;
export declare const checkIfSc2RealmLooksValid: (sc2Realm: import("../../types").RegionIdOrName) => boolean;
export declare const validateSc2Realm: (sc2Realm: import("../../types").RegionIdOrName) => boolean;
export declare const isSc2RealmValidForRegionId: (sc2Realm: import("../../types").RegionIdOrName, regionId: import("../../types").RegionIdOrName) => boolean;
export declare const getSc2RealmsByRegionId: (regionId: string | number) => readonly number[];
export declare const checkIfSc2RealmLooksValid: (sc2Realm: string | number) => boolean;
export declare const validateSc2Realm: (sc2Realm: string | number) => boolean;
export declare const isSc2RealmValidForRegionId: (sc2Realm: string | number, regionId: string | number) => boolean;
//# sourceMappingURL=sc2Realms.d.ts.map

@@ -1,4 +0,3 @@

import { RegionIdOrName } from '../../types';
export declare const getAllAuthorizeUris: () => Readonly<import("../../interfaces").RegionIdProperties<string>>;
export declare const getAuthorizeUriByRegion: (regionIdOrName: RegionIdOrName) => string | number | ReadonlyArray<number> | ReadonlyArray<string>;
export declare const getAllAuthorizeUris: () => Readonly<import("../../../../@interfaces").RegionIdProperties<string>>;
export declare const getAuthorizeUriByRegion: (regionIdOrName: string | number) => string | number | readonly string[] | readonly number[];
//# sourceMappingURL=authorizeUris.d.ts.map

@@ -1,4 +0,3 @@

import { RegionIdOrName } from '../../types';
export declare const getAllCheckTokenUris: () => Readonly<import("../../interfaces").RegionIdProperties<string>>;
export declare const getCheckTokenUriByRegion: (regionIdOrName: RegionIdOrName) => string | number | ReadonlyArray<number> | ReadonlyArray<string>;
export declare const getAllCheckTokenUris: () => Readonly<import("../../../../@interfaces").RegionIdProperties<string>>;
export declare const getCheckTokenUriByRegion: (regionIdOrName: string | number) => string | number | readonly string[] | readonly number[];
//# sourceMappingURL=checkTokenUris.d.ts.map

@@ -1,4 +0,3 @@

import { RegionIdOrName } from '../../types';
export declare const getAllTokenUris: () => Readonly<import("../../interfaces").RegionIdProperties<string>>;
export declare const getTokenUriByRegion: (regionIdOrName: RegionIdOrName) => string;
export declare const getAllTokenUris: () => Readonly<import("../../../../@interfaces").RegionIdProperties<string>>;
export declare const getTokenUriByRegion: (regionIdOrName: string | number) => string;
//# sourceMappingURL=tokenUris.d.ts.map
{
"name": "blizzapi",
"version": "0.0.8",
"version": "0.1.0",
"description": "Feature-rich library for Blizzard Battle.net API",

@@ -10,3 +10,3 @@ "homepage": "https://blizzapi.lukem.net",

"name": "Łukasz Wójcik",
"url": "https://www.lukaszwojcik.net/"
"url": "https://www.lukem.net/"
},

@@ -16,47 +16,44 @@ "license": "MIT",

"type": "git",
"url": "git://github.com/lukemnet/BlizzAPI.git"
"url": "git://github.com/lukemnet/blizzapi.git"
},
"bugs": {
"url": "https://github.com/lukemnet/BlizzAPI/issues"
"url": "https://github.com/lukemnet/blizzapi/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/lukem.net/BlizzAPI/blob/master/LICENSE"
}],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/lukemnet/blizzapi/blob/master/LICENSE"
}
],
"scripts": {
"test": "jest",
"clearTestCache": "jest --clearCache",
"build": "tsc",
"watch": "tsc -w",
"clean": "rimraf dist/*",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "tslint --project tsconfig.json"
"lint": "tslint --project tsconfig.json",
"build": "npm run lint && npm run test && npm run clean && tsc",
"dev": "tsc -w"
},
"jest": {
"automock": false
},
"dependencies": {
"base-64": "0.1.0",
"cross-fetch": "3.0.1",
"jsonata": "1.6.4"
"axios": "0.19.0",
"base-64": "0.1.0"
},
"jest": {
"automock": false,
"setupFiles": [
"./setupJest.ts"
]
},
"devDependencies": {
"@types/base-64": "0.1.2",
"@types/jest": "23.3.9",
"@types/jsonata": "1.3.0",
"@types/node": "11.9.1",
"jest": "23.6.0",
"jest-each": "23.6.0",
"jest-fetch-mock": "2.1.0",
"prettier": "1.15.2",
"ts-jest": "23.10.5",
"tslint": "5.11.0",
"@types/base-64": "0.1.3",
"@types/jest": "24.0.15",
"@types/node": "12.6.2",
"jest": "24.8.0",
"prettier": "1.18.2",
"rimraf": "2.6.3",
"ts-jest": "24.0.2",
"tslint": "5.18.0",
"tslint-config-airbnb": "5.11.1",
"tslint-config-prettier": "1.16.0",
"tslint-config-prettier": "1.18.0",
"tslint-eslint-rules": "5.4.0",
"tslint-immutable": "5.1.2",
"tslint-immutable": "6.0.1",
"tslint-plugin-prettier": "2.0.1",
"typescript": "3.3.3"
"typescript": "3.5.3"
},

@@ -68,2 +65,3 @@ "keywords": [

"battle-net-api",
"blizzapi",
"api",

@@ -78,2 +76,2 @@ "starcraft2",

]
}
}
# BlizzAPI
[![Travis CI Build Status](https://travis-ci.org/lukemnet/BlizzAPI.svg?branch=master)](https://travis-ci.org/lukemnet/BlizzAPI)
[![npm (latest)](https://img.shields.io/npm/v/blizzapi/latest.svg)](https://www.npmjs.com/package/blizzapi)
[![Travis CI Build Status](https://travis-ci.org/lukemnet/blizzapi.svg?branch=master)](https://travis-ci.org/lukemnet/blizzapi)
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/syfiarwau11435nq/branch/master?svg=true)](https://ci.appveyor.com/project/lwojcik/blizzapi/branch/master)
[![Maintainability](https://api.codeclimate.com/v1/badges/5ae9076ca1825968b9bb/maintainability)](https://codeclimate.com/github/lukemnet/BlizzAPI/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/5ae9076ca1825968b9bb/test_coverage)](https://codeclimate.com/github/lukemnet/BlizzAPI/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/8c2b8e4efe8441ad055f/maintainability)](https://codeclimate.com/github/lukemnet/blizzapi/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/8c2b8e4efe8441ad055f/test_coverage)](https://codeclimate.com/github/lukemnet/blizzapi/test_coverage)

@@ -8,0 +9,0 @@ Feature-rich library for easy access to [Battle.net API](https://develop.battle.net/).

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

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

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