Socket
Socket
Sign inDemoInstall

@vermaysha/hoyolab-api

Package Overview
Dependencies
13
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.1 to 3.1.2

dist/index.mjs

6

dist/index.d.ts

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

import { SearchParameters } from 'got';
interface IResponse {

@@ -129,6 +127,6 @@ retcode: number;

*
* @param params SearchParameters Object of query parameter
* @param params BodyType Object of query parameter
* @returns {this}
*/
setParams(params: SearchParameters): this;
setParams(params: BodyType): this;
/**

@@ -135,0 +133,0 @@ * Set to used Dynamic Security or not

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

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {

@@ -6,3 +12,43 @@ for (var name in all)

};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
AbyssScheduleEnum: () => AbyssScheduleEnum,
Cache: () => Cache,
Cookie: () => Cookie,
DiaryEnum: () => DiaryEnum,
DiaryMonthEnum: () => DiaryMonthEnum,
GamesEnum: () => GamesEnum,
Genshin: () => Genshin,
HonkaiStarRail: () => HonkaiStarRail,
Hoyolab: () => Hoyolab,
HoyolabError: () => HoyolabError,
LanguageEnum: () => LanguageEnum,
Request: () => Request,
Route: () => routes_exports,
getServerRegion: () => getServerRegion,
parseLang: () => parseLang,
toCamelCase: () => toCamelCase,
toSnakeCase: () => toSnakeCase
});
module.exports = __toCommonJS(src_exports);
// src/HoyolabError.ts

@@ -82,5 +128,4 @@ var HoyolabError = class extends Error {

// src/Request.ts
import got from "got";
import crypto from "crypto";
import { HTTPError } from "got";
var import_axios = __toESM(require("axios"));
var import_md5 = __toESM(require("md5"));

@@ -133,3 +178,3 @@ // src/Cache.ts

*
* @param params SearchParameters Object of query parameter
* @param params BodyType Object of query parameter
* @returns {this}

@@ -170,34 +215,22 @@ */

async send(url, method = "GET") {
const bodyOrParam = method === "POST" ? got.extend({
json: this.body,
searchParams: this.params
}) : got.extend({
searchParams: this.params
});
const main = got.extend({
if (this.ds) {
this.headers.DS = this.generateDS();
}
const config = {
method,
// cache: this.cache,
retry: {
limit: 30
},
params: this.params,
headers: this.headers,
responseType: "json"
});
const hook = got.extend({
hooks: {
beforeRequest: [
(options) => {
if (this.ds)
options.headers.DS = this.generateDS();
}
]
}
});
};
if (method === "POST") {
config.data = this.body;
}
try {
const request = got.extend(hook, main, bodyOrParam);
const result = await request(url).json();
const request = (await (0, import_axios.default)(url, config)).data;
const result = await request;
this.body = {};
return result;
} catch (error) {
if (error instanceof HTTPError) {
if (error instanceof import_axios.AxiosError) {
console.log(error);
throw new HoyolabError(`[${error.code}] - ${error.message}`);

@@ -229,3 +262,5 @@ } else {

}
const hash = crypto.createHash("md5").update(`salt=${salt}&t=${time}&r=${random}`).digest("hex");
const hash = (0, import_md5.default)(`salt=${salt}&t=${time}&r=${random}`, {
encoding: "hex"
});
return `${time},${random},${hash}`;

@@ -864,3 +899,4 @@ }

};
export {
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AbyssScheduleEnum,

@@ -878,3 +914,3 @@ Cache,

Request,
routes_exports as Route,
Route,
getServerRegion,

@@ -884,2 +920,2 @@ parseLang,

toSnakeCase
};
});
{
"name": "@vermaysha/hoyolab-api",
"version": "3.1.1",
"version": "3.1.2",
"description": "Its unofficial HoYoLab API Wrapper for getting hoyoverse some in-game data, including Genshin Impact, Honkai Impact 3rd.",
"type": "module",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.esm",
"types": "./dist/index.d.ts",
"require": "./dist/index.js"
}
},
"scripts": {

@@ -59,9 +65,7 @@ "format": "prettier src/**/* -w",

"timeout": "5m",
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm",
"--experimental-specifier-resolution=node",
"--no-warnings"
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]

@@ -71,2 +75,3 @@ },

"@types/eslint": "^8.37.0",
"@types/md5": "^2.3.2",
"@types/node": "^18.15.11",

@@ -96,4 +101,5 @@ "@types/prettier": "^2.7.2",

"dependencies": {
"got": "^12.6.0"
"axios": "^1.3.4",
"md5": "^2.3.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc