michos_api
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -21,2 +21,3 @@ "use strict"; | ||
__reExport(client_exports, require("./hoyolab"), module.exports); | ||
__reExport(client_exports, require("./hoyowiki"), module.exports); | ||
__reExport(client_exports, require("./hsr"), module.exports); | ||
@@ -29,4 +30,5 @@ __reExport(client_exports, require("./zzz"), module.exports); | ||
...require("./hoyolab"), | ||
...require("./hoyowiki"), | ||
...require("./hsr"), | ||
...require("./zzz") | ||
}); |
@@ -50,15 +50,19 @@ "use strict"; | ||
]; | ||
cookieString.split("; ").forEach((cookie) => { | ||
const cookieSplited = cookie.trim().split(/=(?=.+)/); | ||
if (keys.includes(cookieSplited[0]) === false) { | ||
return; | ||
cookieString.split(";").forEach((item) => { | ||
const [key, value] = item.split("="); | ||
if (keys.includes(key.trim())) { | ||
const camelCaseKey = (0, import_cookie.toCamelCase)(key.trim()); | ||
const decodedValue = decodeURIComponent(value).trim(); | ||
cookies.set(camelCaseKey, decodedValue); | ||
if (["ltuid", "ltuidV2", "accountId", "accountIdV2"].includes( | ||
camelCaseKey | ||
)) { | ||
cookies.set(camelCaseKey, parseInt(cookies.get(camelCaseKey), 10)); | ||
} else if (key === "mi18nLang") { | ||
cookies.set( | ||
key, | ||
decodedValue || import_language.Language.parseLang(cookies.get(key)) | ||
); | ||
} | ||
} | ||
const key = (0, import_cookie.toCamelCase)(cookieSplited[0]).trim(); | ||
const val = decodeURIComponent(cookieSplited[1]).replace(";", "").trim(); | ||
cookies.set(key, val); | ||
if (["ltuid", "account_id", "account_id_v2"].includes(cookieSplited[0])) { | ||
cookies.set(key, parseInt(cookies.get(key), 10)); | ||
} else if (cookieSplited[0] === "mi18nLang") { | ||
cookies.set(key, import_language.Language.parseLang(cookies.get(key))); | ||
} | ||
}); | ||
@@ -76,3 +80,3 @@ const ltuid = cookies.get("ltuid"); | ||
} | ||
if (!cookies.get("ltoken") || !cookies.get("ltuid")) { | ||
if (!cookies.get("ltokenV2") || !cookies.get("ltuidV2")) { | ||
throw new import_error.HoyoAPIError("Cookie key ltuid or ltoken doesnt exist !"); | ||
@@ -79,0 +83,0 @@ } |
@@ -118,2 +118,6 @@ "use strict"; | ||
} | ||
setRequestHeaders(key, value) { | ||
this.headers[key] = value; | ||
return this; | ||
} | ||
/** | ||
@@ -120,0 +124,0 @@ * Set to used Dynamic Security or not |
export * from './gi'; | ||
export * from './hi'; | ||
export * from './hoyolab'; | ||
export * from './hoyowiki'; | ||
export * from './hsr'; | ||
export * from './zzz'; |
@@ -66,2 +66,3 @@ /// <reference types="node" /> | ||
setLang(lang: string): this; | ||
setRequestHeaders(key: string, value: string): this; | ||
/** | ||
@@ -68,0 +69,0 @@ * Set to used Dynamic Security or not |
{ | ||
"name": "michos_api", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Michos API is an unofficial API Wrapper library developed to facilitate communication with the official HoYoLab API.", | ||
@@ -5,0 +5,0 @@ "exports": { |
<div align="center"> | ||
<h1>Michos API - TypeScript/JavaScript for HoYoLab API</h1> | ||
<h1>Michos API - TypeScript/JavaScript HoYoAPI</h1> | ||
</div> | ||
This project Fork form [HoYoAPI](https://github.com/vermaysha/hoyoapi) | ||
This is a NodeJS library designed as a connector to the Official HoYoLab API, commonly accessed by browsers easily and quickly. This library supports both ESM and CJS, but can only be used in NodeJS environments starting from version 8.17 and above. | ||
@@ -9,8 +11,78 @@ | ||
For NPM <br/> | ||
`npm install michos-api` | ||
For Yarn <br/> | ||
`yarn install michos-api` | ||
## Features | ||
| Features | Genshin Impact | Honkai Impact | Honkai Star Rails | | ||
| ----------------- | ------------------ | ------------------ | ------------------ | | ||
| Daily Check-In | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
| Redeem | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
| Battle Chronicles | :white_check_mark: | :white_check_mark: | :white_check_mark: | | ||
| Diary | :white_check_mark: | :x: | :x: | | ||
| Daily Note | :white_check_mark: | :x: | :white_check_mark: | | ||
| TCG | :white_check_mark: | :x: | :x: | | ||
## How to obtain HoYoLab Cookie | ||
1. To begin, login with your [HoYoLab](https://www.hoyolab.com/home) Account or from [Battlepass](https://act.hoyolab.com/app/community-game-records-sea/index.html?bbs_presentation_style=fullscreen&bbs_auth_required=true&gid=2&user_id=122516750&utm_source=hoyolab&utm_medium=gamecard&bbs_theme=light&bbs_theme_device=1#/ys). | ||
2. Type `java` in the address bar followed by the script down below. | ||
3. ```javascript | ||
script: (function () { | ||
if ( | ||
document.cookie.includes('ltoken') && | ||
document.cookie.includes('ltuid') | ||
) { | ||
const e = document.createElement('input'); | ||
(e.value = document.cookie), | ||
document.body.appendChild(e), | ||
e.focus(), | ||
e.select(); | ||
var t = document.execCommand('copy'); | ||
document.body.removeChild(e), | ||
t | ||
? alert('HoYoLAB cookie copied to clipboard') | ||
: prompt( | ||
'Failed to copy cookie. Manually copy the cookie below:\n\n', | ||
e.value | ||
); | ||
} else alert('Please logout and log back in. Cookie is expired/invalid!'); | ||
})(); | ||
``` | ||
4. Once you've successfully ran the script, click the Click here to copy! button to copy the cookie. | ||
5. Finally, you can copy your cookie | ||
## About a cookieTokenV2 | ||
cookieTokenV2 can be obtained on the redeem code page of each game, for example, [Genshin Impact Gift](https://genshin.hoyoverse.com/en/gift). However, it is important to note that cookieTokenV2 has a short expiration time, so if it has expired, it needs to be manually refreshed. It has been observed that every few days, when logging in to the game Hoyoverse, it always requests reauthentication first. | ||
## Documentation | ||
[![view - Documentation](https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge)](https://vermaysha.github.io/hoyoapi/ 'Go to project documentation') | ||
## License | ||
MIT License | ||
Copyright (c) 2023 Ashary Vermaysha | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
420213
195
12481
88