feat: 对接解密解压

This commit is contained in:
Cheliangzhao 2024-04-25 11:27:18 +08:00
parent 02f2b34fe6
commit 14e8174d1e
3 changed files with 28 additions and 20 deletions

View File

@ -30,7 +30,7 @@ export class CombDataUpdater implements ICombUpdater {
private checker: ICombChecker private checker: ICombChecker
private parser: ICombParser private parser: ICombParser
private observer?: ICombObserver private observer?: ICombObserver
private verData: IVerData | null = null private verData?: IVerData
constructor(props: ICombDataUpdaterProps) { constructor(props: ICombDataUpdaterProps) {
this.dataStore = props.store this.dataStore = props.store
@ -49,6 +49,8 @@ export class CombDataUpdater implements ICombUpdater {
async update(isDiff: boolean = false) { async update(isDiff: boolean = false) {
const verData = this.verData ?? await this.getVer() const verData = this.verData ?? await this.getVer()
if (!verData) return
if (isDiff) await this.diffUpdate(verData.diff_url) if (isDiff) await this.diffUpdate(verData.diff_url)
else await this.fullUpdate(verData.full_url) else await this.fullUpdate(verData.full_url)
@ -67,6 +69,8 @@ export class CombDataUpdater implements ICombUpdater {
*/ */
private async fullUpdate(full_url: string) { private async fullUpdate(full_url: string) {
const res = await CombNetTools.getConfigFile(full_url) const res = await CombNetTools.getConfigFile(full_url)
if (!res) return
const fullFile = res.data const fullFile = res.data
const etag = res.etag const etag = res.etag
@ -84,6 +88,8 @@ export class CombDataUpdater implements ICombUpdater {
*/ */
private async diffUpdate(diff_url: string) { private async diffUpdate(diff_url: string) {
const res = await CombNetTools.getConfigFile(diff_url) const res = await CombNetTools.getConfigFile(diff_url)
if (!res) return
const diffFile = res.data const diffFile = res.data
const etag = res.etag const etag = res.etag

View File

@ -74,7 +74,7 @@ export interface IConfigFileRes1 {
export interface ICombUpdater { export interface ICombUpdater {
update: (isDiff: boolean) => Promise<void> update: (isDiff: boolean) => Promise<void>
getVer: () => Promise<IVerData> getVer: () => Promise<IVerData | undefined>
getIds: () => Promise<string[]> getIds: () => Promise<string[]>
} }

View File

@ -1,32 +1,34 @@
import { IConfigFileRes, IVerData } from '../comb_type/CombTypes' import { IConfigFileRes, IVerData } from '../comb_type/CombTypes'
import { android_comb_diff_cofig, android_comb_full_config } from '../data/androd_comb_config' import { android_comb_diff_cofig, android_comb_full_config } from '../data/androd_comb_config'
import { CombNetUtil } from './CombNetUtil'
export namespace CombNetTools { export namespace CombNetTools {
export async function getVer(): Promise<IVerData> {
export async function getVer(): Promise<IVerData | undefined> {
// honeycomb.wps.cn/api/v4/project/1/ver // honeycomb.wps.cn/api/v4/project/1/ver
// params: {ver: 2691; skv: 1665471000} // params: {ver: 2691; skv: 1665471000}
// headers: {Client-Type: wps-android; Client-Ver: 1; Client-Chann: 1;} // headers: {Client-Type: wps-android; Client-Ver: 1; Client-Chann: 1;}
return { const projectid = 1
"ver": 2694, const ver = 2700
"full_url": "https://honeycomb.wpscdn.cn/api/v3/file/project-v4-all-1-2703-prod-1-0111665471000", const skv = 1665471000
"diff_url": "https://honeycomb.wpscdn.cn/api/v3/file/project-v4-diff-1-2703-prod-2691_2703-0111665471000", try {
const res = await CombNetUtil.getVer(projectid, ver, skv)
return res
} catch (e) {
return
} }
} }
export async function getConfigFile(url: string): Promise<IConfigFileRes> { export async function getConfigFile(url: string): Promise<IConfigFileRes | undefined> {
let res = ''
let etag = ''
if (url === "https://honeycomb.wpscdn.cn/api/v3/file/project-v4-all-1-2703-prod-1-0111665471000") {
res = JSON.stringify(android_comb_full_config)
etag = 'de3e67818744fabd1b8139665a70a86d'
} else {
res = JSON.stringify(android_comb_diff_cofig)
etag = 'a33b0d21e7f2e402ef6d074c799ff0f6'
}
return { try {
data: res, const res = await CombNetUtil.getConfigFile(url)
etag: etag, const data = res.data.toString() // TODO
const etag = res.etag
return { data, etag }
} catch (e) {
return
} }
} }