Comparing version 1.3.5-beta.2 to 1.3.5-beta.3
@@ -1,462 +0,1 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const startsWithSlash = (endpoint) => endpoint[0] === "/"; | ||
const isLongEnough = (endpoint) => endpoint.length > 3; | ||
const validators = [startsWithSlash, isLongEnough]; | ||
var validateEndpoint = (endpoint) => validators.every((validator) => validator(endpoint)); | ||
var validateUri = (uri) => { | ||
const uriTestRegex = /(?:http[s]?:\/\/)[^\s(["<,>]*\.[^\s[",><]*/gm; | ||
return uriTestRegex.test(uri); | ||
}; | ||
var fetchFromUri = async (options) => { | ||
const { | ||
uri, | ||
timeout, | ||
headers, | ||
params, | ||
data, | ||
auth | ||
} = options; | ||
const method = options.method || "GET"; | ||
if (!validateUri(uri)) { | ||
throw new RangeError(`'${uri}' is not a valid parameter for fetchFromUri()`); | ||
} | ||
const requestOptions = { | ||
method, | ||
url: encodeURI(uri), | ||
timeout: timeout || 1e4, | ||
...headers && {headers}, | ||
...params && {params}, | ||
...auth && {auth}, | ||
...data && {data} | ||
}; | ||
const response = await axios.request(requestOptions); | ||
const lastModified = response.headers["last-modified"] ? response.headers["last-modified"] : null; | ||
return { | ||
...response.data, | ||
...lastModified && {lastModified} | ||
}; | ||
}; | ||
var fetchAccessToken = (options) => { | ||
const { | ||
oauthUri, | ||
clientId, | ||
clientSecret | ||
} = options; | ||
const auth = { | ||
username: clientId, | ||
password: clientSecret | ||
}; | ||
const data = "grant_type=client_credentials"; | ||
return fetchFromUri({ | ||
data, | ||
auth, | ||
uri: oauthUri, | ||
method: "POST" | ||
}); | ||
}; | ||
const defaultLocales = { | ||
1: 0, | ||
2: 0, | ||
3: 0, | ||
5: 0 | ||
}; | ||
var defaultLocales$1 = Object.freeze(defaultLocales); | ||
const locales = { | ||
1: Object.freeze(["en_US", "es_MX", "pt_BR"]), | ||
2: Object.freeze(["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT"]), | ||
3: Object.freeze(["ko_KR", "zh_TW"]), | ||
5: Object.freeze(["zh_CN"]) | ||
}; | ||
var locales$1 = Object.freeze(locales); | ||
const regions = { | ||
1: Object.freeze(["us"]), | ||
2: Object.freeze(["eu"]), | ||
3: Object.freeze(["kr", "tw"]), | ||
5: Object.freeze(["cn"]) | ||
}; | ||
var regions$1 = Object.freeze(regions); | ||
const sc2Realms = { | ||
1: Object.freeze([1, 2]), | ||
2: Object.freeze([1, 2]), | ||
3: Object.freeze([1, 2]), | ||
5: Object.freeze([1]) | ||
}; | ||
var sc2Realms$1 = Object.freeze(sc2Realms); | ||
const hosts = { | ||
1: "https://us.api.blizzard.com", | ||
2: "https://eu.api.blizzard.com", | ||
3: ["https://kr.api.blizzard.com", "https://tw.api.blizzard.com/"], | ||
5: "https://gateway.battlenet.com.cn/" | ||
}; | ||
var regionHosts = Object.freeze(hosts); | ||
const oAuthHosts = { | ||
1: "https://us.battle.net", | ||
2: "https://eu.battle.net", | ||
3: "https://apac.battle.net", | ||
5: "https://www.battlenet.com.cn" | ||
}; | ||
var OAuthHosts = Object.freeze(oAuthHosts); | ||
const getRegionPropertyArray = (endpoint) => ({ | ||
1: `${OAuthHosts[1]}${endpoint}`, | ||
2: `${OAuthHosts[2]}${endpoint}`, | ||
3: `${OAuthHosts[3]}${endpoint}`, | ||
5: `${OAuthHosts[5]}${endpoint}` | ||
}); | ||
const authorizeEndpoint = "/oauth/authorize"; | ||
const tokenEndpoint = "/oauth/token"; | ||
const checkTokenEndpoint = "/oauth/check_token?token="; | ||
const authorizeUris = getRegionPropertyArray(authorizeEndpoint); | ||
const tokenUris = getRegionPropertyArray(tokenEndpoint); | ||
const checkTokenUris = getRegionPropertyArray(checkTokenEndpoint); | ||
var oauth = { | ||
authorizeUris: Object.freeze(authorizeUris), | ||
tokenUris: Object.freeze(tokenUris), | ||
checkTokenUris: Object.freeze(checkTokenUris) | ||
}; | ||
const CONSTANTS = { | ||
REGIONS: regions$1, | ||
LOCALES: locales$1, | ||
DEFAULT_LOCALES: defaultLocales$1, | ||
SC2_REALMS: sc2Realms$1, | ||
REGION_API_HOSTS: regionHosts, | ||
OAUTH_AUTHORIZE_URIS: oauth.authorizeUris, | ||
OAUTH_TOKEN_URIS: oauth.tokenUris, | ||
OAUTH_CHECK_TOKEN_URIS: oauth.checkTokenUris | ||
}; | ||
const getAllRegions = () => CONSTANTS.REGIONS; | ||
const getAllRegionIds = () => { | ||
const regionKeys = Object.keys(CONSTANTS.REGIONS); | ||
return regionKeys.map((regionKey) => parseInt(regionKey, 10)); | ||
}; | ||
const getAllRegionNames = () => { | ||
const regionNames = Object.values(CONSTANTS.REGIONS); | ||
const flattenedRegionNames = [].concat(...regionNames); | ||
return flattenedRegionNames.map((regionName) => regionName.toString()); | ||
}; | ||
const getRegionNameById = (regionId) => { | ||
const regionIds = Object.keys(CONSTANTS.REGIONS); | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = regionIds.includes(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getRegionNameById()`); | ||
} | ||
return CONSTANTS.REGIONS[regionIdAsString]; | ||
}; | ||
const validateRegionId = (regionId) => { | ||
try { | ||
return Boolean(getRegionNameById(regionId)); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const getRegionIdByName = (regionName) => { | ||
const regionNameLowercase = regionName.toLowerCase(); | ||
const regions = CONSTANTS.REGIONS; | ||
const regionKeys = Object.keys(regions); | ||
const regionIdArray = regionKeys.filter((key) => regions[key].includes(regionNameLowercase)); | ||
const regionId = Number(regionIdArray[0]) || false; | ||
if (!regionId) { | ||
throw new RangeError(`"${regionName}" is not a valid parameter for getRegionIdByName()`); | ||
} | ||
return regionId; | ||
}; | ||
const validateRegionName = (regionName) => { | ||
try { | ||
return Boolean(getRegionIdByName(regionName)); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const getConstantByRegionId = (regionId, constantKey) => { | ||
const regionIdAsString = typeof regionId !== "string" ? regionId : regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getConstantByRegionId(${regionId}, '${constantKey}')`); | ||
} | ||
return CONSTANTS[constantKey][regionIdAsString]; | ||
}; | ||
const getConstantByRegionName = (regionName, constantKey) => { | ||
const isRegionNameValid = validateRegionName(regionName); | ||
if (!isRegionNameValid) { | ||
throw new RangeError(`${regionName} is not a valid parameter for getConstantByRegionName(${regionName}, '${constantKey}')`); | ||
} | ||
const regionId = getRegionIdByName(regionName); | ||
return CONSTANTS[constantKey][regionId]; | ||
}; | ||
const getConstantByRegion = (regionIdOrName, constantKey) => validateRegionId(regionIdOrName) ? getConstantByRegionId(regionIdOrName, constantKey) : getConstantByRegionName(regionIdOrName.toString(), constantKey); | ||
const getAllLocales = () => CONSTANTS.LOCALES; | ||
const getAllLocaleNames = () => { | ||
const locales = Object.values(CONSTANTS.LOCALES); | ||
const flattenedLocales = [].concat(...locales); | ||
const localesAsStrings = flattenedLocales.map((locale) => locale.toString()); | ||
return localesAsStrings; | ||
}; | ||
const getLocalesByRegionId = (regionId) => getConstantByRegionId(regionId, "LOCALES"); | ||
const checkIfLocaleLooksValid = (locale) => { | ||
const localeRegexPattern = /^(?:[a-z]{2}_[a-z]{2})$/gi; | ||
const doesLocaleLookValid = localeRegexPattern.test(locale); | ||
return doesLocaleLookValid; | ||
}; | ||
const validateLocale = (locale) => { | ||
const doesLocaleLookValid = checkIfLocaleLooksValid(locale); | ||
if (!doesLocaleLookValid) { | ||
throw new RangeError(`${locale} is not a valid parameter for validateLocale()`); | ||
} | ||
const lowerCaseLocaleList = getAllLocaleNames().map((localeName) => localeName.toLowerCase()); | ||
const lowerCaseLocale = locale.toLowerCase(); | ||
return lowerCaseLocaleList.includes(lowerCaseLocale); | ||
}; | ||
const isLocaleValidForRegionId = (locale, regionId) => { | ||
const lowerCaseLocale = locale.toLowerCase(); | ||
const doesLocaleLookValid = validateLocale(lowerCaseLocale) || false; | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!doesLocaleLookValid) { | ||
throw new RangeError(`${locale} is not a valid locale parameter for isLocaleValidForRegionId()`); | ||
} | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionId} is not a valid regionId parameter for isLocaleValidForRegionId()`); | ||
} | ||
const localesForRegionId = getLocalesByRegionId(regionId).map((localeName) => localeName.toLowerCase()); | ||
return localesForRegionId.includes(lowerCaseLocale); | ||
}; | ||
const getDefaultLocaleNameForRegionId = (regionId) => { | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getDefaultLocaleNameForRegionId()`); | ||
} | ||
const defaultLocaleIndex = CONSTANTS.DEFAULT_LOCALES[regionIdAsString]; | ||
return CONSTANTS.LOCALES[regionId][defaultLocaleIndex]; | ||
}; | ||
const getAllDefaultLocaleNames = () => { | ||
const allLocales = getAllLocales(); | ||
const allLocaleKeys = Object.keys(allLocales); | ||
return Object.assign({}, ...allLocaleKeys.map((regionId) => ({ | ||
[regionId]: getDefaultLocaleNameForRegionId(regionId) | ||
}))); | ||
}; | ||
const getAllSc2Realms = () => CONSTANTS.SC2_REALMS; | ||
const getAllAvailableSc2Realms = () => { | ||
const sc2Realms = Object.values(CONSTANTS.SC2_REALMS); | ||
const flattenedSc2Realms = [].concat(...sc2Realms); | ||
return flattenedSc2Realms.filter((el, i, a) => i === a.indexOf(el)); | ||
}; | ||
const getSc2RealmsByRegionId = (regionId) => getConstantByRegionId(regionId, "SC2_REALMS"); | ||
const checkIfSc2RealmLooksValid = (sc2Realm) => { | ||
const sc2RealmAsString = sc2Realm.toString(); | ||
const sc2RealmRegexPattern = /^([1-9]{1})$/gi; | ||
const doesSc2RealmLookValid = sc2RealmRegexPattern.test(sc2RealmAsString); | ||
return doesSc2RealmLookValid; | ||
}; | ||
const validateSc2Realm = (sc2Realm) => { | ||
const doesSc2RealmLookValid = checkIfSc2RealmLooksValid(sc2Realm); | ||
if (!doesSc2RealmLookValid) { | ||
throw new RangeError(`${sc2Realm} is not a valid parameter for validateSc2Realm()`); | ||
} | ||
const sc2RealmList = getAllAvailableSc2Realms(); | ||
const sc2RealmAsNumber = typeof sc2Realm === "number" ? sc2Realm : parseInt(sc2Realm, 10); | ||
return sc2RealmList.includes(sc2RealmAsNumber); | ||
}; | ||
const isSc2RealmValidForRegionId = (sc2Realm, regionId) => { | ||
const doesSc2RealmLookValid = checkIfSc2RealmLooksValid(sc2Realm); | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!doesSc2RealmLookValid) { | ||
throw new RangeError(`${sc2Realm} is not a valid sc2Realm parameter for isSc2RealmValidForRegionId()`); | ||
} | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionId} is not a valid regionId parameter for isSc2RealmValidForRegionId()`); | ||
} | ||
const sc2RealmsForRegionId = getSc2RealmsByRegionId(regionId); | ||
const sc2RealmAsNumber = typeof sc2Realm === "number" ? sc2Realm : parseInt(sc2Realm, 10); | ||
return sc2RealmsForRegionId.includes(sc2RealmAsNumber); | ||
}; | ||
const getApiHostByRegion = (regionIdOrName) => { | ||
const apiHost = getConstantByRegion(regionIdOrName, "REGION_API_HOSTS"); | ||
return typeof regionIdOrName === "string" && regionIdOrName.toLowerCase() === "kr" ? apiHost[0] : typeof regionIdOrName === "string" && regionIdOrName.toLowerCase() === "tw" ? apiHost[1] : apiHost; | ||
}; | ||
const getCheckTokenUriByRegion = (regionIdOrName) => getConstantByRegion(regionIdOrName, "OAUTH_CHECK_TOKEN_URIS"); | ||
const getTokenUriByRegion = (regionIdOrName) => getConstantByRegion(regionIdOrName, "OAUTH_TOKEN_URIS"); | ||
var getAccessToken = async (options) => { | ||
const {region, clientId, clientSecret} = options; | ||
const oauthUri = getTokenUriByRegion(region); | ||
const accessTokenObject = await fetchAccessToken({oauthUri, clientId, clientSecret}); | ||
return accessTokenObject.access_token; | ||
}; | ||
var validateAccessToken = async (regionIdOrName, accessToken) => { | ||
try { | ||
const checkTokenUri = getCheckTokenUriByRegion(regionIdOrName); | ||
const requestPath = `${checkTokenUri}${accessToken}`; | ||
const response = await fetchFromUri({uri: requestPath}); | ||
return !(response.error && response.error === "invalid_token"); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const queryWithAccessToken = (queryOptions, accessToken) => { | ||
const { | ||
region, | ||
endpoint, | ||
options | ||
} = queryOptions; | ||
const { | ||
headers, | ||
params, | ||
timeout | ||
} = options; | ||
const validEndpoint = validateEndpoint(endpoint); | ||
if (!validEndpoint) | ||
throw new RangeError(`${endpoint} is not a valid endpoint.`); | ||
const apiHost = getApiHostByRegion(region); | ||
const requestUri = `${apiHost}${endpoint}`; | ||
const authHeaders = { | ||
Authorization: `Bearer ${accessToken}` | ||
}; | ||
const fetchHeaders = { | ||
...headers, | ||
...authHeaders | ||
}; | ||
return fetchFromUri({ | ||
uri: requestUri, | ||
method: "GET", | ||
headers: fetchHeaders, | ||
...params && {params}, | ||
...timeout && {timeout} | ||
}); | ||
}; | ||
var query = async (queryOptions) => { | ||
const {region, accessToken} = queryOptions; | ||
const { | ||
validateAccessTokenOnEachQuery, | ||
refreshExpiredAccessToken, | ||
onAccessTokenExpired, | ||
onAccessTokenRefresh | ||
} = queryOptions.options; | ||
if (validateAccessTokenOnEachQuery) { | ||
const invalidAccessToken = !await validateAccessToken(region, accessToken); | ||
if (invalidAccessToken) { | ||
return { | ||
error: "access_token_invalid" | ||
}; | ||
} | ||
} | ||
try { | ||
return await queryWithAccessToken(queryOptions, accessToken); | ||
} catch (error) { | ||
if (error.response && error.response.status === 401) { | ||
onAccessTokenExpired?.(); | ||
if (refreshExpiredAccessToken) { | ||
const newAccessToken = await getAccessToken(queryOptions); | ||
onAccessTokenRefresh?.(newAccessToken); | ||
return queryWithAccessToken(queryOptions, newAccessToken); | ||
} | ||
return Promise.resolve({ | ||
error: "access_token_invalid" | ||
}); | ||
} | ||
throw error; | ||
} | ||
}; | ||
class OAuth2API { | ||
constructor(clientId, clientSecret) { | ||
this.clientId = clientId; | ||
this.clientSecret = clientSecret; | ||
} | ||
} | ||
class BattleNetAPI extends OAuth2API { | ||
constructor(options) { | ||
super(options.clientId, options.clientSecret); | ||
this.getAccessToken = () => this.accessToken || this.setAccessToken(); | ||
this.setAccessToken = async () => { | ||
this.accessToken = await getAccessToken({ | ||
region: this.region, | ||
clientId: this.clientId, | ||
clientSecret: this.clientSecret | ||
}); | ||
return this.accessToken; | ||
}; | ||
this.region = options.region; | ||
this.accessToken = options.accessToken || void 0; | ||
} | ||
} | ||
BattleNetAPI.validateAccessToken = (region, accessToken) => validateAccessToken(region, accessToken); | ||
class BlizzAPI extends BattleNetAPI { | ||
constructor(options) { | ||
super({ | ||
region: options.region, | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret, | ||
accessToken: options.accessToken | ||
}); | ||
this.query = async (endpoint, options) => query({ | ||
endpoint, | ||
region: this.region, | ||
clientId: this.clientId, | ||
clientSecret: this.clientSecret, | ||
accessToken: await this.getAccessToken(), | ||
options: { | ||
...this.options, | ||
...options | ||
} | ||
}); | ||
this.options = { | ||
validateAccessTokenOnEachQuery: options.validateAccessTokenOnEachQuery || false, | ||
refreshExpiredAccessToken: options.refreshExpiredAccessToken || false, | ||
onAccessTokenExpired: options.onAccessTokenExpired || void 0, | ||
onAccessTokenRefresh: options.onAccessTokenRefresh || void 0 | ||
}; | ||
} | ||
} | ||
BlizzAPI.getAllRegions = getAllRegions; | ||
BlizzAPI.getAllRegionIds = getAllRegionIds; | ||
BlizzAPI.getAllRegionNames = getAllRegionNames; | ||
BlizzAPI.getRegionNameById = getRegionNameById; | ||
BlizzAPI.validateRegionId = validateRegionId; | ||
BlizzAPI.getRegionIdByName = getRegionIdByName; | ||
BlizzAPI.validateRegionName = validateRegionName; | ||
BlizzAPI.getAllLocales = getAllLocales; | ||
BlizzAPI.getAllLocaleNames = getAllLocaleNames; | ||
BlizzAPI.getLocalesByRegionId = getLocalesByRegionId; | ||
BlizzAPI.checkIfLocaleLooksValid = checkIfLocaleLooksValid; | ||
BlizzAPI.validateLocale = validateLocale; | ||
BlizzAPI.isLocaleValidForRegionId = isLocaleValidForRegionId; | ||
BlizzAPI.getAllSc2Realms = getAllSc2Realms; | ||
BlizzAPI.getAllAvailableSc2Realms = getAllAvailableSc2Realms; | ||
BlizzAPI.getSc2RealmsByRegionId = getSc2RealmsByRegionId; | ||
BlizzAPI.checkIfSc2RealmLooksValid = checkIfSc2RealmLooksValid; | ||
BlizzAPI.validateSc2Realm = validateSc2Realm; | ||
BlizzAPI.isSc2RealmValidForRegionId = isSc2RealmValidForRegionId; | ||
BlizzAPI.getDefaultLocaleNameForRegionId = getDefaultLocaleNameForRegionId; | ||
BlizzAPI.getAllDefaultLocaleNames = getAllDefaultLocaleNames; | ||
exports.BlizzAPI = BlizzAPI; | ||
//# sourceMappingURL=blizzapi.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const startsWithSlash=e=>e[0]==="/",isLongEnough=e=>e.length>3,validators=[startsWithSlash,isLongEnough];var validateEndpoint=e=>validators.every(t=>t(e)),validateUri=e=>/(?:http[s]?:\/\/)[^\s(["<,>]*\.[^\s[",><]*/gm.test(e),__defProp$2=Object.defineProperty,__hasOwnProp$2=Object.prototype.hasOwnProperty,__getOwnPropSymbols$2=Object.getOwnPropertySymbols,__propIsEnum$2=Object.prototype.propertyIsEnumerable,__defNormalProp$2=(e,t,o)=>t in e?__defProp$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__objSpread$2=(e,t)=>{for(var o in t||(t={}))__hasOwnProp$2.call(t,o)&&__defNormalProp$2(e,o,t[o]);if(__getOwnPropSymbols$2)for(var o of __getOwnPropSymbols$2(t))__propIsEnum$2.call(t,o)&&__defNormalProp$2(e,o,t[o]);return e},__async$5=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),fetchFromUri=e=>__async$5(this,null,function*(){const{uri:t,timeout:o,headers:s,params:n,data:c,auth:l}=e,a=e.method||"GET";if(!validateUri(t))throw new RangeError(`'${t}' is not a valid parameter for fetchFromUri()`);const r=__objSpread$2(__objSpread$2(__objSpread$2(__objSpread$2({method:a,url:encodeURI(t),timeout:o||1e4},s&&{headers:s}),n&&{params:n}),l&&{auth:l}),c&&{data:c}),i=yield axios.request(r),d=i.headers["last-modified"]?i.headers["last-modified"]:null;return __objSpread$2(__objSpread$2({},i.data),d&&{lastModified:d})}),fetchAccessToken=e=>{const{oauthUri:t,clientId:o,clientSecret:s}=e;return fetchFromUri({data:"grant_type=client_credentials",auth:{username:o,password:s},uri:t,method:"POST"})};const defaultLocales={1:0,2:0,3:0,5:0};var defaultLocales$1=Object.freeze(defaultLocales);const locales={1:Object.freeze(["en_US","es_MX","pt_BR"]),2:Object.freeze(["en_GB","es_ES","fr_FR","ru_RU","de_DE","pt_PT","it_IT"]),3:Object.freeze(["ko_KR","zh_TW"]),5:Object.freeze(["zh_CN"])};var locales$1=Object.freeze(locales);const regions={1:Object.freeze(["us"]),2:Object.freeze(["eu"]),3:Object.freeze(["kr","tw"]),5:Object.freeze(["cn"])};var regions$1=Object.freeze(regions);const sc2Realms={1:Object.freeze([1,2]),2:Object.freeze([1,2]),3:Object.freeze([1,2]),5:Object.freeze([1])};var sc2Realms$1=Object.freeze(sc2Realms);const hosts={1:"https://us.api.blizzard.com",2:"https://eu.api.blizzard.com",3:["https://kr.api.blizzard.com","https://tw.api.blizzard.com/"],5:"https://gateway.battlenet.com.cn/"};var regionHosts=Object.freeze(hosts);const oAuthHosts={1:"https://us.battle.net",2:"https://eu.battle.net",3:"https://apac.battle.net",5:"https://www.battlenet.com.cn"};var OAuthHosts=Object.freeze(oAuthHosts);const getRegionPropertyArray=e=>({1:`${OAuthHosts[1]}${e}`,2:`${OAuthHosts[2]}${e}`,3:`${OAuthHosts[3]}${e}`,5:`${OAuthHosts[5]}${e}`}),authorizeEndpoint="/oauth/authorize",tokenEndpoint="/oauth/token",checkTokenEndpoint="/oauth/check_token?token=",authorizeUris=getRegionPropertyArray(authorizeEndpoint),tokenUris=getRegionPropertyArray(tokenEndpoint),checkTokenUris=getRegionPropertyArray(checkTokenEndpoint);var oauth={authorizeUris:Object.freeze(authorizeUris),tokenUris:Object.freeze(tokenUris),checkTokenUris:Object.freeze(checkTokenUris)};const CONSTANTS={REGIONS:regions$1,LOCALES:locales$1,DEFAULT_LOCALES:defaultLocales$1,SC2_REALMS:sc2Realms$1,REGION_API_HOSTS:regionHosts,OAUTH_AUTHORIZE_URIS:oauth.authorizeUris,OAUTH_TOKEN_URIS:oauth.tokenUris,OAUTH_CHECK_TOKEN_URIS:oauth.checkTokenUris},getAllRegions=()=>CONSTANTS.REGIONS,getAllRegionIds=()=>Object.keys(CONSTANTS.REGIONS).map(t=>parseInt(t,10)),getAllRegionNames=()=>{const e=Object.values(CONSTANTS.REGIONS);return[].concat(...e).map(o=>o.toString())},getRegionNameById=e=>{const t=Object.keys(CONSTANTS.REGIONS),o=e.toString();if(!t.includes(o))throw new RangeError(`${o} is not a valid parameter for getRegionNameById()`);return CONSTANTS.REGIONS[o]},validateRegionId=e=>{try{return Boolean(getRegionNameById(e))}catch(t){return!1}},getRegionIdByName=e=>{const t=e.toLowerCase(),o=CONSTANTS.REGIONS,n=Object.keys(o).filter(l=>o[l].includes(t)),c=Number(n[0])||!1;if(!c)throw new RangeError(`"${e}" is not a valid parameter for getRegionIdByName()`);return c},validateRegionName=e=>{try{return Boolean(getRegionIdByName(e))}catch(t){return!1}},getConstantByRegionId=(e,t)=>{const o=typeof e!="string"?e:e.toString();if(!validateRegionId(o))throw new RangeError(`${o} is not a valid parameter for getConstantByRegionId(${e}, '${t}')`);return CONSTANTS[t][o]},getConstantByRegionName=(e,t)=>{if(!validateRegionName(e))throw new RangeError(`${e} is not a valid parameter for getConstantByRegionName(${e}, '${t}')`);const s=getRegionIdByName(e);return CONSTANTS[t][s]},getConstantByRegion=(e,t)=>validateRegionId(e)?getConstantByRegionId(e,t):getConstantByRegionName(e.toString(),t),getAllLocales=()=>CONSTANTS.LOCALES,getAllLocaleNames=()=>{const e=Object.values(CONSTANTS.LOCALES);return[].concat(...e).map(s=>s.toString())},getLocalesByRegionId=e=>getConstantByRegionId(e,"LOCALES"),checkIfLocaleLooksValid=e=>/^(?:[a-z]{2}_[a-z]{2})$/gi.test(e),validateLocale=e=>{if(!checkIfLocaleLooksValid(e))throw new RangeError(`${e} is not a valid parameter for validateLocale()`);const o=getAllLocaleNames().map(n=>n.toLowerCase()),s=e.toLowerCase();return o.includes(s)},isLocaleValidForRegionId=(e,t)=>{const o=e.toLowerCase(),s=validateLocale(o)||!1,n=t.toString(),c=validateRegionId(n);if(!s)throw new RangeError(`${e} is not a valid locale parameter for isLocaleValidForRegionId()`);if(!c)throw new RangeError(`${t} is not a valid regionId parameter for isLocaleValidForRegionId()`);return getLocalesByRegionId(t).map(a=>a.toLowerCase()).includes(o)},getDefaultLocaleNameForRegionId=e=>{const t=e.toString();if(!validateRegionId(t))throw new RangeError(`${t} is not a valid parameter for getDefaultLocaleNameForRegionId()`);const s=CONSTANTS.DEFAULT_LOCALES[t];return CONSTANTS.LOCALES[e][s]},getAllDefaultLocaleNames=()=>{const e=getAllLocales(),t=Object.keys(e);return Object.assign({},...t.map(o=>({[o]:getDefaultLocaleNameForRegionId(o)})))},getAllSc2Realms=()=>CONSTANTS.SC2_REALMS,getAllAvailableSc2Realms=()=>{const e=Object.values(CONSTANTS.SC2_REALMS);return[].concat(...e).filter((o,s,n)=>s===n.indexOf(o))},getSc2RealmsByRegionId=e=>getConstantByRegionId(e,"SC2_REALMS"),checkIfSc2RealmLooksValid=e=>{const t=e.toString();return/^([1-9]{1})$/gi.test(t)},validateSc2Realm=e=>{if(!checkIfSc2RealmLooksValid(e))throw new RangeError(`${e} is not a valid parameter for validateSc2Realm()`);const o=getAllAvailableSc2Realms(),s=typeof e=="number"?e:parseInt(e,10);return o.includes(s)},isSc2RealmValidForRegionId=(e,t)=>{const o=checkIfSc2RealmLooksValid(e),s=t.toString(),n=validateRegionId(s);if(!o)throw new RangeError(`${e} is not a valid sc2Realm parameter for isSc2RealmValidForRegionId()`);if(!n)throw new RangeError(`${t} is not a valid regionId parameter for isSc2RealmValidForRegionId()`);const c=getSc2RealmsByRegionId(t),l=typeof e=="number"?e:parseInt(e,10);return c.includes(l)},getApiHostByRegion=e=>{const t=getConstantByRegion(e,"REGION_API_HOSTS");return typeof e=="string"&&e.toLowerCase()==="kr"?t[0]:typeof e=="string"&&e.toLowerCase()==="tw"?t[1]:t},getCheckTokenUriByRegion=e=>getConstantByRegion(e,"OAUTH_CHECK_TOKEN_URIS"),getTokenUriByRegion=e=>getConstantByRegion(e,"OAUTH_TOKEN_URIS");var __async$4=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),getAccessToken=e=>__async$4(this,null,function*(){const{region:t,clientId:o,clientSecret:s}=e,n=getTokenUriByRegion(t);return(yield fetchAccessToken({oauthUri:n,clientId:o,clientSecret:s})).access_token}),__async$3=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),validateAccessToken=(e,t)=>__async$3(this,null,function*(){try{const s=`${getCheckTokenUriByRegion(e)}${t}`,n=yield fetchFromUri({uri:s});return!(n.error&&n.error==="invalid_token")}catch(o){return!1}}),__defProp$1=Object.defineProperty,__hasOwnProp$1=Object.prototype.hasOwnProperty,__getOwnPropSymbols$1=Object.getOwnPropertySymbols,__propIsEnum$1=Object.prototype.propertyIsEnumerable,__defNormalProp$1=(e,t,o)=>t in e?__defProp$1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__objSpread$1=(e,t)=>{for(var o in t||(t={}))__hasOwnProp$1.call(t,o)&&__defNormalProp$1(e,o,t[o]);if(__getOwnPropSymbols$1)for(var o of __getOwnPropSymbols$1(t))__propIsEnum$1.call(t,o)&&__defNormalProp$1(e,o,t[o]);return e},__async$2=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});const queryWithAccessToken=(e,t)=>{const{region:o,endpoint:s,options:n}=e,{headers:c,params:l,timeout:a}=n;if(!validateEndpoint(s))throw new RangeError(`${s} is not a valid endpoint.`);const d=`${getApiHostByRegion(o)}${s}`,u={Authorization:`Bearer ${t}`},g=__objSpread$1(__objSpread$1({},c),u);return fetchFromUri(__objSpread$1(__objSpread$1({uri:d,method:"GET",headers:g},l&&{params:l}),a&&{timeout:a}))};var query=e=>__async$2(this,null,function*(){const{region:t,accessToken:o}=e,{validateAccessTokenOnEachQuery:s,refreshExpiredAccessToken:n,onAccessTokenExpired:c,onAccessTokenRefresh:l}=e.options;if(s&&!(yield validateAccessToken(t,o)))return{error:"access_token_invalid"};try{return yield queryWithAccessToken(e,o)}catch(a){if(a.response&&a.response.status===401){if(c==null||c(),n){const r=yield getAccessToken(e);return l==null||l(r),queryWithAccessToken(e,r)}return Promise.resolve({error:"access_token_invalid"})}throw a}});class OAuth2API{constructor(t,o){this.clientId=t,this.clientSecret=o}}var __async$1=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});class BattleNetAPI extends OAuth2API{constructor(t){super(t.clientId,t.clientSecret);this.getAccessToken=()=>this.accessToken||this.setAccessToken(),this.setAccessToken=()=>__async$1(this,null,function*(){return this.accessToken=yield getAccessToken({region:this.region,clientId:this.clientId,clientSecret:this.clientSecret}),this.accessToken}),this.region=t.region,this.accessToken=t.accessToken||void 0}}BattleNetAPI.validateAccessToken=(e,t)=>validateAccessToken(e,t);var __defProp=Object.defineProperty,__hasOwnProp=Object.prototype.hasOwnProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__objSpread=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__async=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});class BlizzAPI extends BattleNetAPI{constructor(t){super({region:t.region,clientId:t.clientId,clientSecret:t.clientSecret,accessToken:t.accessToken});this.query=(o,s)=>__async(this,null,function*(){return query({endpoint:o,region:this.region,clientId:this.clientId,clientSecret:this.clientSecret,accessToken:yield this.getAccessToken(),options:__objSpread(__objSpread({},this.options),s)})}),this.options={validateAccessTokenOnEachQuery:t.validateAccessTokenOnEachQuery||!1,refreshExpiredAccessToken:t.refreshExpiredAccessToken||!1,onAccessTokenExpired:t.onAccessTokenExpired||void 0,onAccessTokenRefresh:t.onAccessTokenRefresh||void 0}}}BlizzAPI.getAllRegions=getAllRegions,BlizzAPI.getAllRegionIds=getAllRegionIds,BlizzAPI.getAllRegionNames=getAllRegionNames,BlizzAPI.getRegionNameById=getRegionNameById,BlizzAPI.validateRegionId=validateRegionId,BlizzAPI.getRegionIdByName=getRegionIdByName,BlizzAPI.validateRegionName=validateRegionName,BlizzAPI.getAllLocales=getAllLocales,BlizzAPI.getAllLocaleNames=getAllLocaleNames,BlizzAPI.getLocalesByRegionId=getLocalesByRegionId,BlizzAPI.checkIfLocaleLooksValid=checkIfLocaleLooksValid,BlizzAPI.validateLocale=validateLocale,BlizzAPI.isLocaleValidForRegionId=isLocaleValidForRegionId,BlizzAPI.getAllSc2Realms=getAllSc2Realms,BlizzAPI.getAllAvailableSc2Realms=getAllAvailableSc2Realms,BlizzAPI.getSc2RealmsByRegionId=getSc2RealmsByRegionId,BlizzAPI.checkIfSc2RealmLooksValid=checkIfSc2RealmLooksValid,BlizzAPI.validateSc2Realm=validateSc2Realm,BlizzAPI.isSc2RealmValidForRegionId=isSc2RealmValidForRegionId,BlizzAPI.getDefaultLocaleNameForRegionId=getDefaultLocaleNameForRegionId,BlizzAPI.getAllDefaultLocaleNames=getAllDefaultLocaleNames,exports.BlizzAPI=BlizzAPI; |
@@ -1,468 +0,1 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BlizzAPI = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
const startsWithSlash = (endpoint) => endpoint[0] === "/"; | ||
const isLongEnough = (endpoint) => endpoint.length > 3; | ||
const validators = [startsWithSlash, isLongEnough]; | ||
var validateEndpoint = (endpoint) => validators.every((validator) => validator(endpoint)); | ||
var validateUri = (uri) => { | ||
const uriTestRegex = /(?:http[s]?:\/\/)[^\s(["<,>]*\.[^\s[",><]*/gm; | ||
return uriTestRegex.test(uri); | ||
}; | ||
var fetchFromUri = async (options) => { | ||
const { | ||
uri, | ||
timeout, | ||
headers, | ||
params, | ||
data, | ||
auth | ||
} = options; | ||
const method = options.method || "GET"; | ||
if (!validateUri(uri)) { | ||
throw new RangeError(`'${uri}' is not a valid parameter for fetchFromUri()`); | ||
} | ||
const requestOptions = { | ||
method, | ||
url: encodeURI(uri), | ||
timeout: timeout || 1e4, | ||
...headers && {headers}, | ||
...params && {params}, | ||
...auth && {auth}, | ||
...data && {data} | ||
}; | ||
const response = await axios.request(requestOptions); | ||
const lastModified = response.headers["last-modified"] ? response.headers["last-modified"] : null; | ||
return { | ||
...response.data, | ||
...lastModified && {lastModified} | ||
}; | ||
}; | ||
var fetchAccessToken = (options) => { | ||
const { | ||
oauthUri, | ||
clientId, | ||
clientSecret | ||
} = options; | ||
const auth = { | ||
username: clientId, | ||
password: clientSecret | ||
}; | ||
const data = "grant_type=client_credentials"; | ||
return fetchFromUri({ | ||
data, | ||
auth, | ||
uri: oauthUri, | ||
method: "POST" | ||
}); | ||
}; | ||
const defaultLocales = { | ||
1: 0, | ||
2: 0, | ||
3: 0, | ||
5: 0 | ||
}; | ||
var defaultLocales$1 = Object.freeze(defaultLocales); | ||
const locales = { | ||
1: Object.freeze(["en_US", "es_MX", "pt_BR"]), | ||
2: Object.freeze(["en_GB", "es_ES", "fr_FR", "ru_RU", "de_DE", "pt_PT", "it_IT"]), | ||
3: Object.freeze(["ko_KR", "zh_TW"]), | ||
5: Object.freeze(["zh_CN"]) | ||
}; | ||
var locales$1 = Object.freeze(locales); | ||
const regions = { | ||
1: Object.freeze(["us"]), | ||
2: Object.freeze(["eu"]), | ||
3: Object.freeze(["kr", "tw"]), | ||
5: Object.freeze(["cn"]) | ||
}; | ||
var regions$1 = Object.freeze(regions); | ||
const sc2Realms = { | ||
1: Object.freeze([1, 2]), | ||
2: Object.freeze([1, 2]), | ||
3: Object.freeze([1, 2]), | ||
5: Object.freeze([1]) | ||
}; | ||
var sc2Realms$1 = Object.freeze(sc2Realms); | ||
const hosts = { | ||
1: "https://us.api.blizzard.com", | ||
2: "https://eu.api.blizzard.com", | ||
3: ["https://kr.api.blizzard.com", "https://tw.api.blizzard.com/"], | ||
5: "https://gateway.battlenet.com.cn/" | ||
}; | ||
var regionHosts = Object.freeze(hosts); | ||
const oAuthHosts = { | ||
1: "https://us.battle.net", | ||
2: "https://eu.battle.net", | ||
3: "https://apac.battle.net", | ||
5: "https://www.battlenet.com.cn" | ||
}; | ||
var OAuthHosts = Object.freeze(oAuthHosts); | ||
const getRegionPropertyArray = (endpoint) => ({ | ||
1: `${OAuthHosts[1]}${endpoint}`, | ||
2: `${OAuthHosts[2]}${endpoint}`, | ||
3: `${OAuthHosts[3]}${endpoint}`, | ||
5: `${OAuthHosts[5]}${endpoint}` | ||
}); | ||
const authorizeEndpoint = "/oauth/authorize"; | ||
const tokenEndpoint = "/oauth/token"; | ||
const checkTokenEndpoint = "/oauth/check_token?token="; | ||
const authorizeUris = getRegionPropertyArray(authorizeEndpoint); | ||
const tokenUris = getRegionPropertyArray(tokenEndpoint); | ||
const checkTokenUris = getRegionPropertyArray(checkTokenEndpoint); | ||
var oauth = { | ||
authorizeUris: Object.freeze(authorizeUris), | ||
tokenUris: Object.freeze(tokenUris), | ||
checkTokenUris: Object.freeze(checkTokenUris) | ||
}; | ||
const CONSTANTS = { | ||
REGIONS: regions$1, | ||
LOCALES: locales$1, | ||
DEFAULT_LOCALES: defaultLocales$1, | ||
SC2_REALMS: sc2Realms$1, | ||
REGION_API_HOSTS: regionHosts, | ||
OAUTH_AUTHORIZE_URIS: oauth.authorizeUris, | ||
OAUTH_TOKEN_URIS: oauth.tokenUris, | ||
OAUTH_CHECK_TOKEN_URIS: oauth.checkTokenUris | ||
}; | ||
const getAllRegions = () => CONSTANTS.REGIONS; | ||
const getAllRegionIds = () => { | ||
const regionKeys = Object.keys(CONSTANTS.REGIONS); | ||
return regionKeys.map((regionKey) => parseInt(regionKey, 10)); | ||
}; | ||
const getAllRegionNames = () => { | ||
const regionNames = Object.values(CONSTANTS.REGIONS); | ||
const flattenedRegionNames = [].concat(...regionNames); | ||
return flattenedRegionNames.map((regionName) => regionName.toString()); | ||
}; | ||
const getRegionNameById = (regionId) => { | ||
const regionIds = Object.keys(CONSTANTS.REGIONS); | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = regionIds.includes(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getRegionNameById()`); | ||
} | ||
return CONSTANTS.REGIONS[regionIdAsString]; | ||
}; | ||
const validateRegionId = (regionId) => { | ||
try { | ||
return Boolean(getRegionNameById(regionId)); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const getRegionIdByName = (regionName) => { | ||
const regionNameLowercase = regionName.toLowerCase(); | ||
const regions = CONSTANTS.REGIONS; | ||
const regionKeys = Object.keys(regions); | ||
const regionIdArray = regionKeys.filter((key) => regions[key].includes(regionNameLowercase)); | ||
const regionId = Number(regionIdArray[0]) || false; | ||
if (!regionId) { | ||
throw new RangeError(`"${regionName}" is not a valid parameter for getRegionIdByName()`); | ||
} | ||
return regionId; | ||
}; | ||
const validateRegionName = (regionName) => { | ||
try { | ||
return Boolean(getRegionIdByName(regionName)); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const getConstantByRegionId = (regionId, constantKey) => { | ||
const regionIdAsString = typeof regionId !== "string" ? regionId : regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getConstantByRegionId(${regionId}, '${constantKey}')`); | ||
} | ||
return CONSTANTS[constantKey][regionIdAsString]; | ||
}; | ||
const getConstantByRegionName = (regionName, constantKey) => { | ||
const isRegionNameValid = validateRegionName(regionName); | ||
if (!isRegionNameValid) { | ||
throw new RangeError(`${regionName} is not a valid parameter for getConstantByRegionName(${regionName}, '${constantKey}')`); | ||
} | ||
const regionId = getRegionIdByName(regionName); | ||
return CONSTANTS[constantKey][regionId]; | ||
}; | ||
const getConstantByRegion = (regionIdOrName, constantKey) => validateRegionId(regionIdOrName) ? getConstantByRegionId(regionIdOrName, constantKey) : getConstantByRegionName(regionIdOrName.toString(), constantKey); | ||
const getAllLocales = () => CONSTANTS.LOCALES; | ||
const getAllLocaleNames = () => { | ||
const locales = Object.values(CONSTANTS.LOCALES); | ||
const flattenedLocales = [].concat(...locales); | ||
const localesAsStrings = flattenedLocales.map((locale) => locale.toString()); | ||
return localesAsStrings; | ||
}; | ||
const getLocalesByRegionId = (regionId) => getConstantByRegionId(regionId, "LOCALES"); | ||
const checkIfLocaleLooksValid = (locale) => { | ||
const localeRegexPattern = /^(?:[a-z]{2}_[a-z]{2})$/gi; | ||
const doesLocaleLookValid = localeRegexPattern.test(locale); | ||
return doesLocaleLookValid; | ||
}; | ||
const validateLocale = (locale) => { | ||
const doesLocaleLookValid = checkIfLocaleLooksValid(locale); | ||
if (!doesLocaleLookValid) { | ||
throw new RangeError(`${locale} is not a valid parameter for validateLocale()`); | ||
} | ||
const lowerCaseLocaleList = getAllLocaleNames().map((localeName) => localeName.toLowerCase()); | ||
const lowerCaseLocale = locale.toLowerCase(); | ||
return lowerCaseLocaleList.includes(lowerCaseLocale); | ||
}; | ||
const isLocaleValidForRegionId = (locale, regionId) => { | ||
const lowerCaseLocale = locale.toLowerCase(); | ||
const doesLocaleLookValid = validateLocale(lowerCaseLocale) || false; | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!doesLocaleLookValid) { | ||
throw new RangeError(`${locale} is not a valid locale parameter for isLocaleValidForRegionId()`); | ||
} | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionId} is not a valid regionId parameter for isLocaleValidForRegionId()`); | ||
} | ||
const localesForRegionId = getLocalesByRegionId(regionId).map((localeName) => localeName.toLowerCase()); | ||
return localesForRegionId.includes(lowerCaseLocale); | ||
}; | ||
const getDefaultLocaleNameForRegionId = (regionId) => { | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionIdAsString} is not a valid parameter for getDefaultLocaleNameForRegionId()`); | ||
} | ||
const defaultLocaleIndex = CONSTANTS.DEFAULT_LOCALES[regionIdAsString]; | ||
return CONSTANTS.LOCALES[regionId][defaultLocaleIndex]; | ||
}; | ||
const getAllDefaultLocaleNames = () => { | ||
const allLocales = getAllLocales(); | ||
const allLocaleKeys = Object.keys(allLocales); | ||
return Object.assign({}, ...allLocaleKeys.map((regionId) => ({ | ||
[regionId]: getDefaultLocaleNameForRegionId(regionId) | ||
}))); | ||
}; | ||
const getAllSc2Realms = () => CONSTANTS.SC2_REALMS; | ||
const getAllAvailableSc2Realms = () => { | ||
const sc2Realms = Object.values(CONSTANTS.SC2_REALMS); | ||
const flattenedSc2Realms = [].concat(...sc2Realms); | ||
return flattenedSc2Realms.filter((el, i, a) => i === a.indexOf(el)); | ||
}; | ||
const getSc2RealmsByRegionId = (regionId) => getConstantByRegionId(regionId, "SC2_REALMS"); | ||
const checkIfSc2RealmLooksValid = (sc2Realm) => { | ||
const sc2RealmAsString = sc2Realm.toString(); | ||
const sc2RealmRegexPattern = /^([1-9]{1})$/gi; | ||
const doesSc2RealmLookValid = sc2RealmRegexPattern.test(sc2RealmAsString); | ||
return doesSc2RealmLookValid; | ||
}; | ||
const validateSc2Realm = (sc2Realm) => { | ||
const doesSc2RealmLookValid = checkIfSc2RealmLooksValid(sc2Realm); | ||
if (!doesSc2RealmLookValid) { | ||
throw new RangeError(`${sc2Realm} is not a valid parameter for validateSc2Realm()`); | ||
} | ||
const sc2RealmList = getAllAvailableSc2Realms(); | ||
const sc2RealmAsNumber = typeof sc2Realm === "number" ? sc2Realm : parseInt(sc2Realm, 10); | ||
return sc2RealmList.includes(sc2RealmAsNumber); | ||
}; | ||
const isSc2RealmValidForRegionId = (sc2Realm, regionId) => { | ||
const doesSc2RealmLookValid = checkIfSc2RealmLooksValid(sc2Realm); | ||
const regionIdAsString = regionId.toString(); | ||
const isRegionIdValid = validateRegionId(regionIdAsString); | ||
if (!doesSc2RealmLookValid) { | ||
throw new RangeError(`${sc2Realm} is not a valid sc2Realm parameter for isSc2RealmValidForRegionId()`); | ||
} | ||
if (!isRegionIdValid) { | ||
throw new RangeError(`${regionId} is not a valid regionId parameter for isSc2RealmValidForRegionId()`); | ||
} | ||
const sc2RealmsForRegionId = getSc2RealmsByRegionId(regionId); | ||
const sc2RealmAsNumber = typeof sc2Realm === "number" ? sc2Realm : parseInt(sc2Realm, 10); | ||
return sc2RealmsForRegionId.includes(sc2RealmAsNumber); | ||
}; | ||
const getApiHostByRegion = (regionIdOrName) => { | ||
const apiHost = getConstantByRegion(regionIdOrName, "REGION_API_HOSTS"); | ||
return typeof regionIdOrName === "string" && regionIdOrName.toLowerCase() === "kr" ? apiHost[0] : typeof regionIdOrName === "string" && regionIdOrName.toLowerCase() === "tw" ? apiHost[1] : apiHost; | ||
}; | ||
const getCheckTokenUriByRegion = (regionIdOrName) => getConstantByRegion(regionIdOrName, "OAUTH_CHECK_TOKEN_URIS"); | ||
const getTokenUriByRegion = (regionIdOrName) => getConstantByRegion(regionIdOrName, "OAUTH_TOKEN_URIS"); | ||
var getAccessToken = async (options) => { | ||
const {region, clientId, clientSecret} = options; | ||
const oauthUri = getTokenUriByRegion(region); | ||
const accessTokenObject = await fetchAccessToken({oauthUri, clientId, clientSecret}); | ||
return accessTokenObject.access_token; | ||
}; | ||
var validateAccessToken = async (regionIdOrName, accessToken) => { | ||
try { | ||
const checkTokenUri = getCheckTokenUriByRegion(regionIdOrName); | ||
const requestPath = `${checkTokenUri}${accessToken}`; | ||
const response = await fetchFromUri({uri: requestPath}); | ||
return !(response.error && response.error === "invalid_token"); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
const queryWithAccessToken = (queryOptions, accessToken) => { | ||
const { | ||
region, | ||
endpoint, | ||
options | ||
} = queryOptions; | ||
const { | ||
headers, | ||
params, | ||
timeout | ||
} = options; | ||
const validEndpoint = validateEndpoint(endpoint); | ||
if (!validEndpoint) | ||
throw new RangeError(`${endpoint} is not a valid endpoint.`); | ||
const apiHost = getApiHostByRegion(region); | ||
const requestUri = `${apiHost}${endpoint}`; | ||
const authHeaders = { | ||
Authorization: `Bearer ${accessToken}` | ||
}; | ||
const fetchHeaders = { | ||
...headers, | ||
...authHeaders | ||
}; | ||
return fetchFromUri({ | ||
uri: requestUri, | ||
method: "GET", | ||
headers: fetchHeaders, | ||
...params && {params}, | ||
...timeout && {timeout} | ||
}); | ||
}; | ||
var query = async (queryOptions) => { | ||
const {region, accessToken} = queryOptions; | ||
const { | ||
validateAccessTokenOnEachQuery, | ||
refreshExpiredAccessToken, | ||
onAccessTokenExpired, | ||
onAccessTokenRefresh | ||
} = queryOptions.options; | ||
if (validateAccessTokenOnEachQuery) { | ||
const invalidAccessToken = !await validateAccessToken(region, accessToken); | ||
if (invalidAccessToken) { | ||
return { | ||
error: "access_token_invalid" | ||
}; | ||
} | ||
} | ||
try { | ||
return await queryWithAccessToken(queryOptions, accessToken); | ||
} catch (error) { | ||
if (error.response && error.response.status === 401) { | ||
onAccessTokenExpired?.(); | ||
if (refreshExpiredAccessToken) { | ||
const newAccessToken = await getAccessToken(queryOptions); | ||
onAccessTokenRefresh?.(newAccessToken); | ||
return queryWithAccessToken(queryOptions, newAccessToken); | ||
} | ||
return Promise.resolve({ | ||
error: "access_token_invalid" | ||
}); | ||
} | ||
throw error; | ||
} | ||
}; | ||
class OAuth2API { | ||
constructor(clientId, clientSecret) { | ||
this.clientId = clientId; | ||
this.clientSecret = clientSecret; | ||
} | ||
} | ||
class BattleNetAPI extends OAuth2API { | ||
constructor(options) { | ||
super(options.clientId, options.clientSecret); | ||
this.getAccessToken = () => this.accessToken || this.setAccessToken(); | ||
this.setAccessToken = async () => { | ||
this.accessToken = await getAccessToken({ | ||
region: this.region, | ||
clientId: this.clientId, | ||
clientSecret: this.clientSecret | ||
}); | ||
return this.accessToken; | ||
}; | ||
this.region = options.region; | ||
this.accessToken = options.accessToken || void 0; | ||
} | ||
} | ||
BattleNetAPI.validateAccessToken = (region, accessToken) => validateAccessToken(region, accessToken); | ||
class BlizzAPI extends BattleNetAPI { | ||
constructor(options) { | ||
super({ | ||
region: options.region, | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret, | ||
accessToken: options.accessToken | ||
}); | ||
this.query = async (endpoint, options) => query({ | ||
endpoint, | ||
region: this.region, | ||
clientId: this.clientId, | ||
clientSecret: this.clientSecret, | ||
accessToken: await this.getAccessToken(), | ||
options: { | ||
...this.options, | ||
...options | ||
} | ||
}); | ||
this.options = { | ||
validateAccessTokenOnEachQuery: options.validateAccessTokenOnEachQuery || false, | ||
refreshExpiredAccessToken: options.refreshExpiredAccessToken || false, | ||
onAccessTokenExpired: options.onAccessTokenExpired || void 0, | ||
onAccessTokenRefresh: options.onAccessTokenRefresh || void 0 | ||
}; | ||
} | ||
} | ||
BlizzAPI.getAllRegions = getAllRegions; | ||
BlizzAPI.getAllRegionIds = getAllRegionIds; | ||
BlizzAPI.getAllRegionNames = getAllRegionNames; | ||
BlizzAPI.getRegionNameById = getRegionNameById; | ||
BlizzAPI.validateRegionId = validateRegionId; | ||
BlizzAPI.getRegionIdByName = getRegionIdByName; | ||
BlizzAPI.validateRegionName = validateRegionName; | ||
BlizzAPI.getAllLocales = getAllLocales; | ||
BlizzAPI.getAllLocaleNames = getAllLocaleNames; | ||
BlizzAPI.getLocalesByRegionId = getLocalesByRegionId; | ||
BlizzAPI.checkIfLocaleLooksValid = checkIfLocaleLooksValid; | ||
BlizzAPI.validateLocale = validateLocale; | ||
BlizzAPI.isLocaleValidForRegionId = isLocaleValidForRegionId; | ||
BlizzAPI.getAllSc2Realms = getAllSc2Realms; | ||
BlizzAPI.getAllAvailableSc2Realms = getAllAvailableSc2Realms; | ||
BlizzAPI.getSc2RealmsByRegionId = getSc2RealmsByRegionId; | ||
BlizzAPI.checkIfSc2RealmLooksValid = checkIfSc2RealmLooksValid; | ||
BlizzAPI.validateSc2Realm = validateSc2Realm; | ||
BlizzAPI.isSc2RealmValidForRegionId = isSc2RealmValidForRegionId; | ||
BlizzAPI.getDefaultLocaleNameForRegionId = getDefaultLocaleNameForRegionId; | ||
BlizzAPI.getAllDefaultLocaleNames = getAllDefaultLocaleNames; | ||
exports.BlizzAPI = BlizzAPI; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=blizzapi.umd.js.map | ||
(function(f,v){typeof exports=="object"&&typeof module!="undefined"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(f=typeof globalThis!="undefined"?globalThis:f||self,v(f.BlizzAPI={}))})(this,function(f){"use strict";const W=[e=>e[0]==="/",e=>e.length>3];var q=e=>W.every(t=>t(e)),Q=e=>/(?:http[s]?:\/\/)[^\s(["<,>]*\.[^\s[",><]*/gm.test(e),X=Object.defineProperty,Z=Object.prototype.hasOwnProperty,L=Object.getOwnPropertySymbols,J=Object.prototype.propertyIsEnumerable,w=(e,t,o)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))Z.call(t,o)&&w(e,o,t[o]);if(L)for(var o of L(t))J.call(t,o)&&w(e,o,t[o]);return e},Y=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),S=e=>Y(this,null,function*(){const{uri:t,timeout:o,headers:s,params:n,data:c,auth:l}=e,a=e.method||"GET";if(!Q(t))throw new RangeError(`'${t}' is not a valid parameter for fetchFromUri()`);const r=h(h(h(h({method:a,url:encodeURI(t),timeout:o||1e4},s&&{headers:s}),n&&{params:n}),l&&{auth:l}),c&&{data:c}),i=yield axios.request(r),m=i.headers["last-modified"]?i.headers["last-modified"]:null;return h(h({},i.data),m&&{lastModified:m})}),ee=e=>{const{oauthUri:t,clientId:o,clientSecret:s}=e;return S({data:"grant_type=client_credentials",auth:{username:o,password:s},uri:t,method:"POST"})},te=Object.freeze({1:0,2:0,3:0,5:0});const oe={1:Object.freeze(["en_US","es_MX","pt_BR"]),2:Object.freeze(["en_GB","es_ES","fr_FR","ru_RU","de_DE","pt_PT","it_IT"]),3:Object.freeze(["ko_KR","zh_TW"]),5:Object.freeze(["zh_CN"])};var re=Object.freeze(oe);const se={1:Object.freeze(["us"]),2:Object.freeze(["eu"]),3:Object.freeze(["kr","tw"]),5:Object.freeze(["cn"])};var ne=Object.freeze(se);const ae={1:Object.freeze([1,2]),2:Object.freeze([1,2]),3:Object.freeze([1,2]),5:Object.freeze([1])};var ce=Object.freeze(ae),ie=Object.freeze({1:"https://us.api.blizzard.com",2:"https://eu.api.blizzard.com",3:["https://kr.api.blizzard.com","https://tw.api.blizzard.com/"],5:"https://gateway.battlenet.com.cn/"}),p=Object.freeze({1:"https://us.battle.net",2:"https://eu.battle.net",3:"https://apac.battle.net",5:"https://www.battlenet.com.cn"});const _=e=>({1:`${p[1]}${e}`,2:`${p[2]}${e}`,3:`${p[3]}${e}`,5:`${p[5]}${e}`}),le="/oauth/authorize",de="/oauth/token",ue="/oauth/check_token?token=",fe=_(le),he=_(de),ge=_(ue);var y={authorizeUris:Object.freeze(fe),tokenUris:Object.freeze(he),checkTokenUris:Object.freeze(ge)};const u={REGIONS:ne,LOCALES:re,DEFAULT_LOCALES:te,SC2_REALMS:ce,REGION_API_HOSTS:ie,OAUTH_AUTHORIZE_URIS:y.authorizeUris,OAUTH_TOKEN_URIS:y.tokenUris,OAUTH_CHECK_TOKEN_URIS:y.checkTokenUris},ve=()=>u.REGIONS,pe=()=>Object.keys(u.REGIONS).map(t=>parseInt(t,10)),Re=()=>{const e=Object.values(u.REGIONS);return[].concat(...e).map(o=>o.toString())},E=e=>{const t=Object.keys(u.REGIONS),o=e.toString();if(!t.includes(o))throw new RangeError(`${o} is not a valid parameter for getRegionNameById()`);return u.REGIONS[o]},g=e=>{try{return Boolean(E(e))}catch(t){return!1}},A=e=>{const t=e.toLowerCase(),o=u.REGIONS,n=Object.keys(o).filter(l=>o[l].includes(t)),c=Number(n[0])||!1;if(!c)throw new RangeError(`"${e}" is not a valid parameter for getRegionIdByName()`);return c},T=e=>{try{return Boolean(A(e))}catch(t){return!1}},O=(e,t)=>{const o=typeof e!="string"?e:e.toString();if(!g(o))throw new RangeError(`${o} is not a valid parameter for getConstantByRegionId(${e}, '${t}')`);return u[t][o]},me=(e,t)=>{if(!T(e))throw new RangeError(`${e} is not a valid parameter for getConstantByRegionName(${e}, '${t}')`);const s=A(e);return u[t][s]},k=(e,t)=>g(e)?O(e,t):me(e.toString(),t),b=()=>u.LOCALES,$=()=>{const e=Object.values(u.LOCALES);return[].concat(...e).map(s=>s.toString())},P=e=>O(e,"LOCALES"),z=e=>/^(?:[a-z]{2}_[a-z]{2})$/gi.test(e),j=e=>{if(!z(e))throw new RangeError(`${e} is not a valid parameter for validateLocale()`);const o=$().map(n=>n.toLowerCase()),s=e.toLowerCase();return o.includes(s)},Se=(e,t)=>{const o=e.toLowerCase(),s=j(o)||!1,n=t.toString(),c=g(n);if(!s)throw new RangeError(`${e} is not a valid locale parameter for isLocaleValidForRegionId()`);if(!c)throw new RangeError(`${t} is not a valid regionId parameter for isLocaleValidForRegionId()`);return P(t).map(a=>a.toLowerCase()).includes(o)},N=e=>{const t=e.toString();if(!g(t))throw new RangeError(`${t} is not a valid parameter for getDefaultLocaleNameForRegionId()`);const s=u.DEFAULT_LOCALES[t];return u.LOCALES[e][s]},_e=()=>{const e=b(),t=Object.keys(e);return Object.assign({},...t.map(o=>({[o]:N(o)})))},ye=()=>u.SC2_REALMS,U=()=>{const e=Object.values(u.SC2_REALMS);return[].concat(...e).filter((o,s,n)=>s===n.indexOf(o))},C=e=>O(e,"SC2_REALMS"),I=e=>{const t=e.toString();return/^([1-9]{1})$/gi.test(t)},Ae=e=>{if(!I(e))throw new RangeError(`${e} is not a valid parameter for validateSc2Realm()`);const o=U(),s=typeof e=="number"?e:parseInt(e,10);return o.includes(s)},Oe=(e,t)=>{const o=I(e),s=t.toString(),n=g(s);if(!o)throw new RangeError(`${e} is not a valid sc2Realm parameter for isSc2RealmValidForRegionId()`);if(!n)throw new RangeError(`${t} is not a valid regionId parameter for isSc2RealmValidForRegionId()`);const c=C(t),l=typeof e=="number"?e:parseInt(e,10);return c.includes(l)},ke=e=>{const t=k(e,"REGION_API_HOSTS");return typeof e=="string"&&e.toLowerCase()==="kr"?t[0]:typeof e=="string"&&e.toLowerCase()==="tw"?t[1]:t},Ie=e=>k(e,"OAUTH_CHECK_TOKEN_URIS"),Le=e=>k(e,"OAUTH_TOKEN_URIS");var we=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),V=e=>we(this,null,function*(){const{region:t,clientId:o,clientSecret:s}=e,n=Le(t);return(yield ee({oauthUri:n,clientId:o,clientSecret:s})).access_token}),Ee=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())}),B=(e,t)=>Ee(this,null,function*(){try{const s=`${Ie(e)}${t}`,n=yield S({uri:s});return!(n.error&&n.error==="invalid_token")}catch(o){return!1}}),Te=Object.defineProperty,be=Object.prototype.hasOwnProperty,H=Object.getOwnPropertySymbols,$e=Object.prototype.propertyIsEnumerable,x=(e,t,o)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,R=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&x(e,o,t[o]);if(H)for(var o of H(t))$e.call(t,o)&&x(e,o,t[o]);return e},Pe=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});const F=(e,t)=>{const{region:o,endpoint:s,options:n}=e,{headers:c,params:l,timeout:a}=n;if(!q(s))throw new RangeError(`${s} is not a valid endpoint.`);const m=`${ke(o)}${s}`,He={Authorization:`Bearer ${t}`},xe=R(R({},c),He);return S(R(R({uri:m,method:"GET",headers:xe},l&&{params:l}),a&&{timeout:a}))};var ze=e=>Pe(this,null,function*(){const{region:t,accessToken:o}=e,{validateAccessTokenOnEachQuery:s,refreshExpiredAccessToken:n,onAccessTokenExpired:c,onAccessTokenRefresh:l}=e.options;if(s&&!(yield B(t,o)))return{error:"access_token_invalid"};try{return yield F(e,o)}catch(a){if(a.response&&a.response.status===401){if(c==null||c(),n){const r=yield V(e);return l==null||l(r),F(e,r)}return Promise.resolve({error:"access_token_invalid"})}throw a}});class je{constructor(t,o){this.clientId=t,this.clientSecret=o}}var Ne=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});class G extends je{constructor(t){super(t.clientId,t.clientSecret);this.getAccessToken=()=>this.accessToken||this.setAccessToken(),this.setAccessToken=()=>Ne(this,null,function*(){return this.accessToken=yield V({region:this.region,clientId:this.clientId,clientSecret:this.clientSecret}),this.accessToken}),this.region=t.region,this.accessToken=t.accessToken||void 0}}G.validateAccessToken=(e,t)=>B(e,t);var Ue=Object.defineProperty,Ce=Object.prototype.hasOwnProperty,K=Object.getOwnPropertySymbols,Ve=Object.prototype.propertyIsEnumerable,D=(e,t,o)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,M=(e,t)=>{for(var o in t||(t={}))Ce.call(t,o)&&D(e,o,t[o]);if(K)for(var o of K(t))Ve.call(t,o)&&D(e,o,t[o]);return e},Be=(e,t,o)=>new Promise((s,n)=>{var c=r=>{try{a(o.next(r))}catch(i){n(i)}},l=r=>{try{a(o.throw(r))}catch(i){n(i)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(c,l);a((o=o.apply(e,t)).next())});class d extends G{constructor(t){super({region:t.region,clientId:t.clientId,clientSecret:t.clientSecret,accessToken:t.accessToken});this.query=(o,s)=>Be(this,null,function*(){return ze({endpoint:o,region:this.region,clientId:this.clientId,clientSecret:this.clientSecret,accessToken:yield this.getAccessToken(),options:M(M({},this.options),s)})}),this.options={validateAccessTokenOnEachQuery:t.validateAccessTokenOnEachQuery||!1,refreshExpiredAccessToken:t.refreshExpiredAccessToken||!1,onAccessTokenExpired:t.onAccessTokenExpired||void 0,onAccessTokenRefresh:t.onAccessTokenRefresh||void 0}}}d.getAllRegions=ve,d.getAllRegionIds=pe,d.getAllRegionNames=Re,d.getRegionNameById=E,d.validateRegionId=g,d.getRegionIdByName=A,d.validateRegionName=T,d.getAllLocales=b,d.getAllLocaleNames=$,d.getLocalesByRegionId=P,d.checkIfLocaleLooksValid=z,d.validateLocale=j,d.isLocaleValidForRegionId=Se,d.getAllSc2Realms=ye,d.getAllAvailableSc2Realms=U,d.getSc2RealmsByRegionId=C,d.checkIfSc2RealmLooksValid=I,d.validateSc2Realm=Ae,d.isSc2RealmValidForRegionId=Oe,d.getDefaultLocaleNameForRegionId=N,d.getAllDefaultLocaleNames=_e,f.BlizzAPI=d,Object.defineProperty(f,"__esModule",{value:!0})}); |
{ | ||
"name": "blizzapi", | ||
"version": "1.3.5-beta.2", | ||
"version": "1.3.5-beta.3", | ||
"description": "Flexible and feature-rich Node.js library for Blizzard Battle.net API", | ||
@@ -47,18 +47,18 @@ "homepage": "https://blizzapi.lukem.net", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^14.14.7", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"@types/node": "^15.6.0", | ||
"@typescript-eslint/eslint-plugin": "^4.25.0", | ||
"@typescript-eslint/parser": "^4.25.0", | ||
"esbuild": "^0.11.16", | ||
"eslint": "^7.25.0", | ||
"eslint": "^7.27.0", | ||
"eslint-config-airbnb-typescript": "^12.3.1", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-import": "^2.23.3", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"jest": "^26.6.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.45.2", | ||
"rollup-plugin-dts": "^3.0.1", | ||
"rollup": "^2.49.0", | ||
"rollup-plugin-dts": "^3.0.2", | ||
"rollup-plugin-esbuild": "^4.2.3", | ||
"rollup-plugin-external-globals": "^0.6.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^26.5.5", | ||
"ts-jest": "^26.5.6", | ||
"tslib": "^2.2.0", | ||
"typescript": "^4.2.4" | ||
@@ -65,0 +65,0 @@ }, |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
43787
7
225
1