* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
// import * as tea from '@/napcat-core/packet/utils/crypto/tea';
|
|
import { NapProtoMsg } from '@napneko/nap-proto-core';
|
|
import { PacketHighwayTrans } from '@/napcat-core/packet/highway/client';
|
|
import { PacketLogger } from '@/napcat-core/packet/context/loggerContext';
|
|
import * as proto from '@/napcat-core/packet/transformer/proto';
|
|
|
|
export abstract class IHighwayUploader {
|
|
readonly trans: PacketHighwayTrans;
|
|
readonly logger: PacketLogger;
|
|
|
|
constructor (trans: PacketHighwayTrans, logger: PacketLogger) {
|
|
this.trans = trans;
|
|
this.logger = logger;
|
|
}
|
|
|
|
// TODO: 没用到的加密方法先注释掉
|
|
// private encryptTransExt (key: Uint8Array) {
|
|
// if (!this.trans.encrypt) return;
|
|
// this.trans.ext = tea.encrypt(Buffer.from(this.trans.ext), Buffer.from(key));
|
|
// }
|
|
|
|
protected timeout (): Promise<void> {
|
|
return new Promise<void>((_resolve, reject) => {
|
|
setTimeout(() => {
|
|
reject(new Error(`[Highway] timeout after ${this.trans.timeout}s`));
|
|
}, (this.trans.timeout ?? Infinity) * 1000
|
|
);
|
|
});
|
|
}
|
|
|
|
buildPicUpHead (offset: number, bodyLength: number, bodyMd5: Uint8Array): Uint8Array {
|
|
return new NapProtoMsg(proto.ReqDataHighwayHead).encode({
|
|
msgBaseHead: {
|
|
version: 1,
|
|
uin: this.trans.uin,
|
|
command: 'PicUp.DataUp',
|
|
seq: 0,
|
|
retryTimes: 0,
|
|
appId: 1600001604,
|
|
dataFlag: 16,
|
|
commandId: this.trans.cmd,
|
|
},
|
|
msgSegHead: {
|
|
serviceId: 0,
|
|
filesize: BigInt(this.trans.size),
|
|
dataOffset: BigInt(offset),
|
|
dataLength: bodyLength,
|
|
serviceTicket: this.trans.ticket,
|
|
md5: bodyMd5,
|
|
fileMd5: this.trans.sum,
|
|
cacheAddr: 0,
|
|
cachePort: 0,
|
|
},
|
|
bytesReqExtendInfo: this.trans.ext,
|
|
timestamp: BigInt(0),
|
|
msgLoginSigHead: {
|
|
uint32LoginSigType: 8,
|
|
appId: 1600001604,
|
|
},
|
|
});
|
|
}
|
|
|
|
abstract upload (): Promise<void>;
|
|
}
|