mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-02-06 09:56:33 +01:00
Move api source code files
This commit is contained in:
@@ -3,7 +3,7 @@ import CliTable3 from 'cli-table3';
|
|||||||
import { HTTPError } from 'ky';
|
import { HTTPError } from 'ky';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import prompts from 'prompts';
|
import prompts from 'prompts';
|
||||||
import apiUtils from '../utils/api.js';
|
import apiUtils from '../utils/api/index.js';
|
||||||
import argvUtils from '../utils/argv.js';
|
import argvUtils from '../utils/argv.js';
|
||||||
import appConfig from '../utils/config.js';
|
import appConfig from '../utils/config.js';
|
||||||
import exitUtils from '../utils/exit.js';
|
import exitUtils from '../utils/exit.js';
|
||||||
@@ -40,7 +40,7 @@ async function mainCmdHandler() {
|
|||||||
if (needRetrieveToken === false) {
|
if (needRetrieveToken === false) {
|
||||||
try {
|
try {
|
||||||
logger.debug('Retrieving account service OAuth 2.0 code ...');
|
logger.debug('Retrieving account service OAuth 2.0 code ...');
|
||||||
oauth2TokenPreRsp = await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
|
oauth2TokenPreRsp = await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
|
||||||
cfg.appCode.accountService.osWinRel,
|
cfg.appCode.accountService.osWinRel,
|
||||||
argvUtils.getArgv()['token'],
|
argvUtils.getArgv()['token'],
|
||||||
);
|
);
|
||||||
@@ -86,7 +86,7 @@ async function mainCmdHandler() {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
logger.debug('Retrieving account service token ...');
|
logger.debug('Retrieving account service token ...');
|
||||||
const accSrvTokenRsp = await apiUtils.apiAkEndfield.accountService.user.auth.v1.tokenByEmailPassword(
|
const accSrvTokenRsp = await apiUtils.akEndfield.accountService.user.auth.v1.tokenByEmailPassword(
|
||||||
argvUtils.getArgv()['email'],
|
argvUtils.getArgv()['email'],
|
||||||
argvUtils.getArgv()['password'],
|
argvUtils.getArgv()['password'],
|
||||||
);
|
);
|
||||||
@@ -96,18 +96,18 @@ async function mainCmdHandler() {
|
|||||||
oauth2TokenPreRsp === null ? logger.debug('Retrieving account service OAuth 2.0 code ...') : undefined;
|
oauth2TokenPreRsp === null ? logger.debug('Retrieving account service OAuth 2.0 code ...') : undefined;
|
||||||
const oauth2TokenRsp =
|
const oauth2TokenRsp =
|
||||||
oauth2TokenPreRsp === null
|
oauth2TokenPreRsp === null
|
||||||
? await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
|
? await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
|
||||||
cfg.appCode.accountService.osWinRel,
|
cfg.appCode.accountService.osWinRel,
|
||||||
argvUtils.getArgv()['token'],
|
argvUtils.getArgv()['token'],
|
||||||
)
|
)
|
||||||
: oauth2TokenPreRsp;
|
: oauth2TokenPreRsp;
|
||||||
const oauth2TokenBindRsp = await apiUtils.apiAkEndfield.accountService.user.oauth2.v2.grant(
|
const oauth2TokenBindRsp = await apiUtils.akEndfield.accountService.user.oauth2.v2.grant(
|
||||||
cfg.appCode.accountService.binding,
|
cfg.appCode.accountService.binding,
|
||||||
argvUtils.getArgv()['token'],
|
argvUtils.getArgv()['token'],
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
logger.debug('Retrieving u8 access token ...');
|
logger.debug('Retrieving u8 access token ...');
|
||||||
const u8TokenRsp = await apiUtils.apiAkEndfield.u8.user.auth.v2.tokenByChToken(
|
const u8TokenRsp = await apiUtils.akEndfield.u8.user.auth.v2.tokenByChToken(
|
||||||
cfg.appCode.u8.osWinRel,
|
cfg.appCode.u8.osWinRel,
|
||||||
cfg.channel.osWinRel,
|
cfg.channel.osWinRel,
|
||||||
oauth2TokenRsp.data.code,
|
oauth2TokenRsp.data.code,
|
||||||
@@ -119,13 +119,13 @@ async function mainCmdHandler() {
|
|||||||
logger.info('Retrieving user information data ...');
|
logger.info('Retrieving user information data ...');
|
||||||
|
|
||||||
logger.debug('Retrieving user account data ...');
|
logger.debug('Retrieving user account data ...');
|
||||||
const userAccData = await apiUtils.apiAkEndfield.accountService.user.info.v1.basic(
|
const userAccData = await apiUtils.akEndfield.accountService.user.info.v1.basic(
|
||||||
cfg.appCode.accountService.osWinRel,
|
cfg.appCode.accountService.osWinRel,
|
||||||
argvUtils.getArgv()['token'],
|
argvUtils.getArgv()['token'],
|
||||||
);
|
);
|
||||||
logger.debug('Retrieving user game server data ...');
|
logger.debug('Retrieving user game server data ...');
|
||||||
const userGameData = await apiUtils.apiAkEndfield.u8.game.server.v1.serverList(u8TokenRsp.data.token);
|
const userGameData = await apiUtils.akEndfield.u8.game.server.v1.serverList(u8TokenRsp.data.token);
|
||||||
const userGameBindingData = await apiUtils.apiAkEndfield.binding.account.binding.v1.bindingList(
|
const userGameBindingData = await apiUtils.akEndfield.binding.account.binding.v1.bindingList(
|
||||||
oauth2TokenBindRsp.data.token,
|
oauth2TokenBindRsp.data.token,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ async function mainCmdHandler() {
|
|||||||
if (!selectedServerAccData) throw new Error('Game account not found');
|
if (!selectedServerAccData) throw new Error('Game account not found');
|
||||||
const id = selectedServerAccData.serverId;
|
const id = selectedServerAccData.serverId;
|
||||||
logger.debug('Confirming server availability ...');
|
logger.debug('Confirming server availability ...');
|
||||||
const confirmServerRsp = await apiUtils.apiAkEndfield.u8.game.role.v1.confirmServer(
|
const confirmServerRsp = await apiUtils.akEndfield.u8.game.role.v1.confirmServer(
|
||||||
u8TokenRsp.data.token,
|
u8TokenRsp.data.token,
|
||||||
parseInt(id),
|
parseInt(id),
|
||||||
);
|
);
|
||||||
@@ -157,7 +157,7 @@ async function mainCmdHandler() {
|
|||||||
for (const poolTypeEntry of poolTypeList) {
|
for (const poolTypeEntry of poolTypeList) {
|
||||||
let seqId: string | null = null;
|
let seqId: string | null = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
const rsp = await apiUtils.apiAkEndfield.webview.record.char(
|
const rsp = await apiUtils.akEndfield.webview.record.char(
|
||||||
u8TokenRsp.data.token,
|
u8TokenRsp.data.token,
|
||||||
parseInt(selectedServerId),
|
parseInt(selectedServerId),
|
||||||
poolTypeEntry,
|
poolTypeEntry,
|
||||||
@@ -179,7 +179,7 @@ async function mainCmdHandler() {
|
|||||||
const arr = [];
|
const arr = [];
|
||||||
const poolIdList = [...new Set(gachaRecordRsp.map((e) => e.poolId))];
|
const poolIdList = [...new Set(gachaRecordRsp.map((e) => e.poolId))];
|
||||||
for (const poolId of poolIdList) {
|
for (const poolId of poolIdList) {
|
||||||
const rsp = await apiUtils.apiAkEndfield.webview.content(parseInt(selectedServerId), poolId, 'ja-jp');
|
const rsp = await apiUtils.akEndfield.webview.content(parseInt(selectedServerId), poolId, 'ja-jp');
|
||||||
arr.push({ poolId, ...rsp.data.pool });
|
arr.push({ poolId, ...rsp.data.pool });
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import apiUtils from '../utils/api.js';
|
import apiUtils from '../utils/api/index.js';
|
||||||
import argvUtils from '../utils/argv.js';
|
import argvUtils from '../utils/argv.js';
|
||||||
import appConfig from '../utils/config.js';
|
import appConfig from '../utils/config.js';
|
||||||
import logger from '../utils/logger.js';
|
import logger from '../utils/logger.js';
|
||||||
@@ -99,7 +99,7 @@ async function mainCmdHandler() {
|
|||||||
for (const target of gameTargets) {
|
for (const target of gameTargets) {
|
||||||
await (async () => {
|
await (async () => {
|
||||||
logger.debug(`Fetching latestGame (${target.name}) ...`);
|
logger.debug(`Fetching latestGame (${target.name}) ...`);
|
||||||
const rsp = await apiUtils.apiAkEndfield.launcher.latestGame(
|
const rsp = await apiUtils.akEndfield.launcher.latestGame(
|
||||||
cfg.appCode.game.osWinRel,
|
cfg.appCode.game.osWinRel,
|
||||||
target.launcherAppCode,
|
target.launcherAppCode,
|
||||||
cfg.channel.osWinRel,
|
cfg.channel.osWinRel,
|
||||||
@@ -170,7 +170,7 @@ async function mainCmdHandler() {
|
|||||||
const queue = new PQueue({ concurrency: appConfig.threadCount.network });
|
const queue = new PQueue({ concurrency: appConfig.threadCount.network });
|
||||||
for (const ver of versionList) {
|
for (const ver of versionList) {
|
||||||
queue.add(async () => {
|
queue.add(async () => {
|
||||||
const rsp = await apiUtils.apiAkEndfield.launcher.latestGame(
|
const rsp = await apiUtils.akEndfield.launcher.latestGame(
|
||||||
cfg.appCode.game.osWinRel,
|
cfg.appCode.game.osWinRel,
|
||||||
target.launcherAppCode,
|
target.launcherAppCode,
|
||||||
cfg.channel.osWinRel,
|
cfg.channel.osWinRel,
|
||||||
@@ -244,7 +244,7 @@ async function mainCmdHandler() {
|
|||||||
|
|
||||||
const versionInfoList = (
|
const versionInfoList = (
|
||||||
(await Bun.file(gameAllJsonPath).json()).map((e: any) => e.rsp) as Awaited<
|
(await Bun.file(gameAllJsonPath).json()).map((e: any) => e.rsp) as Awaited<
|
||||||
ReturnType<typeof apiUtils.apiAkEndfield.launcher.latestGame>
|
ReturnType<typeof apiUtils.akEndfield.launcher.latestGame>
|
||||||
>[]
|
>[]
|
||||||
)
|
)
|
||||||
.map((e) => ({
|
.map((e) => ({
|
||||||
@@ -258,7 +258,7 @@ async function mainCmdHandler() {
|
|||||||
let isLatestWrote: boolean = false;
|
let isLatestWrote: boolean = false;
|
||||||
for (const versionInfoEntry of versionInfoList) {
|
for (const versionInfoEntry of versionInfoList) {
|
||||||
if (!versionInfoEntry.randStr) throw new Error('version rand_str not found');
|
if (!versionInfoEntry.randStr) throw new Error('version rand_str not found');
|
||||||
const rsp = await apiUtils.apiAkEndfield.launcher.latestGameResources(
|
const rsp = await apiUtils.akEndfield.launcher.latestGameResources(
|
||||||
cfg.appCode.game.osWinRel,
|
cfg.appCode.game.osWinRel,
|
||||||
versionInfoEntry.versionMinor,
|
versionInfoEntry.versionMinor,
|
||||||
versionInfoEntry.version,
|
versionInfoEntry.version,
|
||||||
@@ -292,7 +292,7 @@ async function mainCmdHandler() {
|
|||||||
logger.debug('Fetching latestLauncher ...');
|
logger.debug('Fetching latestLauncher ...');
|
||||||
const launcherTargetAppList = ['EndField', 'official'] as const;
|
const launcherTargetAppList = ['EndField', 'official'] as const;
|
||||||
for (const launcherTargetAppEntry of launcherTargetAppList) {
|
for (const launcherTargetAppEntry of launcherTargetAppList) {
|
||||||
const rsp = await apiUtils.apiAkEndfield.launcher.latestLauncher(
|
const rsp = await apiUtils.akEndfield.launcher.latestLauncher(
|
||||||
cfg.appCode.launcher.osWinRel,
|
cfg.appCode.launcher.osWinRel,
|
||||||
cfg.channel.osWinRel,
|
cfg.channel.osWinRel,
|
||||||
cfg.channel.osWinRel,
|
cfg.channel.osWinRel,
|
||||||
@@ -468,7 +468,7 @@ async function mainCmdHandler() {
|
|||||||
).json();
|
).json();
|
||||||
const resVersionSet: {
|
const resVersionSet: {
|
||||||
resVersion: string;
|
resVersion: string;
|
||||||
rsp: { rsp: Awaited<ReturnType<typeof apiUtils.apiAkEndfield.launcher.latestGameResources>> };
|
rsp: { rsp: Awaited<ReturnType<typeof apiUtils.akEndfield.launcher.latestGameResources>> };
|
||||||
versions: string[];
|
versions: string[];
|
||||||
}[] = (() => {
|
}[] = (() => {
|
||||||
const resVersions: string[] = [...new Set(gameAllJson.map((e: any) => e.rsp.res_version))] as string[];
|
const resVersions: string[] = [...new Set(gameAllJson.map((e: any) => e.rsp.res_version))] as string[];
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import accountService from './api/accountService.js';
|
|
||||||
import binding from './api/binding.js';
|
|
||||||
import launcher from './api/launcher.js';
|
|
||||||
import u8 from './api/u8.js';
|
|
||||||
import webview from './api/webview.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
apiAkEndfield: { launcher, accountService, u8, binding, webview },
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ky: {
|
ky: {
|
||||||
15
src/utils/api/akEndfield/index.ts
Normal file
15
src/utils/api/akEndfield/index.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import accountService from './accountService.js';
|
||||||
|
import binding from './binding.js';
|
||||||
|
import launcher from './launcher.js';
|
||||||
|
import launcherWeb from './launcherWeb.js';
|
||||||
|
import u8 from './u8.js';
|
||||||
|
import webview from './webview.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
accountService,
|
||||||
|
binding,
|
||||||
|
launcher,
|
||||||
|
launcherWeb,
|
||||||
|
u8,
|
||||||
|
webview,
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
import launcherWeb from './launcherWeb.js';
|
import launcherWeb from './launcherWeb.js';
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import ky from 'ky';
|
import ky from 'ky';
|
||||||
import * as TypesApiAkEndfield from '../../types/api/akEndfield/Api.js';
|
import * as TypesApiAkEndfield from '../../../types/api/akEndfield/Api.js';
|
||||||
import appConfig from '../config.js';
|
import appConfig from '../../config.js';
|
||||||
import defaultSettings from './defaultSettings.js';
|
import defaultSettings from './defaultSettings.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
5
src/utils/api/index.ts
Normal file
5
src/utils/api/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import akEndfield from './akEndfield/index.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
akEndfield,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user