New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa78-upinfo

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa78-upinfo - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

3

dist/index.d.ts

@@ -51,2 +51,4 @@ export default class UpInfo {

private _decodeBase64;
private static _masterInstance;
static setMaster(up: UpInfo): void;
static getMaster(): UpInfo;

@@ -58,2 +60,3 @@ static getGuest(): UpInfo;

inOrder(cols: string[]): boolean;
clone(): UpInfo;
}

35

dist/index.js

@@ -69,3 +69,4 @@ "use strict";

if (ctx.params) {
this.apisys = ctx.params.msys;
this.apiver = ctx.params.apiver;
this.apisys = ctx.params.apisys;
this.apiobj = ctx.params.apiobj;

@@ -83,3 +84,3 @@ this.apifun = ctx.params.apifun;

pars = req.header;
this.method = req.header["path"];
this.method = req.header["method"];
const [apiver, apisys, apiobj, apifun] = this.method.split("/");

@@ -95,3 +96,3 @@ this.apiver = apiver;

this.bcid = pars.bcid ?? "d4856531-e9d3-20f3-4c22-fe3c65fb009c";
this.v = req.header['v'] ?? pars.v ?? 24;
this.v = +(req.header['v'] ?? pars.v ?? 24);
this.getstart = +(pars.getstart ?? 0);

@@ -112,3 +113,3 @@ this.parsn = pars["pars[]"] ?? pars.pars ?? "";

this.colsn = pars["cols[]"] ?? pars.cols ?? ["all"];
this.order = pars.order ?? 'idpk';
this.order = pars.order ?? 'idpk desc';
this.jsonp = pars.jsonp ?? false;

@@ -173,3 +174,3 @@ this.backtype = pars.backtype ?? "json";

else {
console.log('无效的 parsn 类型');
console.log('error parsn kind');
this.pars = [];

@@ -182,15 +183,8 @@ }

}
static _masterInstance = this.getGuest();
static setMaster(up) {
this._masterInstance = up;
}
static getMaster() {
const up2 = new UpInfo(null);
Object.assign(up2, {
sid: 'ba',
cid: 'd4c',
bcid: 'd4',
mid: this.getNewid(),
uname: 'ss',
pars: [],
getstart: 0,
ip: "127.0.0.1"
});
return up2;
return this._masterInstance;
}

@@ -255,3 +249,10 @@ ;

;
clone() {
const clonedUpInfo = new UpInfo(null);
clonedUpInfo.sid = this.sid;
clonedUpInfo.uname = this.uname;
clonedUpInfo.bcid = this.bcid;
return clonedUpInfo;
}
}
exports.default = UpInfo;
{
"name": "koa78-upinfo",
"version": "4.0.0",
"version": "4.1.0",
"description": "nodejs koa78封装 上传类",

@@ -27,4 +27,4 @@ "main": "dist/index.js",

"scripts": {
"dev": "git checkout develop && git merge main && git push origin develop",
"main": "git checkout main && git pull origin main && git merge develop --strategy-option theirs --no-edit",
"dev": "git checkout develop && git merge main",
"main": "node hooks/mergeBranches.js",
"build": "tsc",

@@ -38,3 +38,6 @@ "test": "npm run build && npx jest",

"version:minor": "npm version minor",
"version:major": "npm version major"
"version:major": "npm version major",
"precommit": "node hooks/pre-commit.js",
"prepush": "node hooks/pre-push.js",
"hooks": "node hooks/install-hooks.js"
},

@@ -63,2 +66,3 @@ "engines": {

"phantom": "^6.3.0",
"shelljs": "^0.8.5",
"supertest": "^4.0.2",

@@ -65,0 +69,0 @@ "ts-jest": "^29.2.5",

@@ -1,278 +0,272 @@


import dayjs from 'dayjs';
import dayjs from 'dayjs';
export default class UpInfo {
// 数据获取非必填字段
getstart: number = 0;
getnumber: number = 15;
order: string = "idpk";
bcid: string = "";
mid: string = "";
pars: string[] = [];
cols: string[] = [];
midpk: number = 0;
upid: number = 0;
type: number = 0;
// 数据获取非必填字段
getstart: number = 0;
getnumber: number = 15;
order: string = "idpk";
bcid: string = "";
mid: string = "";
pars: string[] = [];
cols: string[] = [];
// 调试监控用
debug: boolean = false;
pcid: string = "";
pcname: string = "";
source: string = "";
v: number = 24;
cache: string = "";
midpk: number = 0;
upid: number = 0;
type: number = 0;
// 自动获取或服务器生成
ip: string = "";
ctx: any = null;
method: string = "";
apisys: string = "";
apiobj: string = "";
apifun: string = "";
apiver: string = "";
uptime: Date = new Date();
utime: string = dayjs().format('YYYY-MM-DD HH:mm:ss');
errmessage: string = "";
// 调试监控用
debug: boolean = false;
pcid: string = "";
pcname: string = "";
source: string = "";
v: number = 24;
cache: string = "";
// 上传临时存 验证后再用
cidn: string = "";
parsn: string | string[] = "";
colsn: string | string[] = "";
// 需数据库读取验证
sid: string = "";
cid: string = "";
uid: string = "";
coname: string = '测试帐套';
uname: string | undefined;
// 自动获取或服务器生成
ip: string = "";
ctx: any = null;
method: string = "";
pwd: string = "";
weixin: string = "";
idceo: string = "";
truename: string = "";
mobile: string = "";
idpk: number = 0;
// 返回用
res: number = 0;
errmsg: string = "";
backtype: string = "json";
apisys: string = "";
apiobj: string = "";
apifun: string = "";
apiver: string = "";
uptime: Date = new Date();
utime: string = dayjs().format('YYYY-MM-DD HH:mm:ss');
errmessage: string = "";
jsonp: boolean = false;
base64: boolean = false;
json: boolean = true;
// 弃用下版删除
jsonbase64: boolean = false;
// 上传临时存 验证后再用
cidn: string = "";
parsn: string | string[] = "";
colsn: string | string[] = "";
constructor(ctx: any) {
if (!ctx) return;
this.ctx = ctx;
const { request: req } = ctx;
this.method = req.path;
// 需数据库读取验证
sid: string = "";
cid: string = "";
uid: string = "";
coname: string = '测试帐套';
uname: string | undefined;
if (ctx.params) {
this.apisys = ctx.params.msys;
this.apiobj = ctx.params.apiobj;
this.apifun = ctx.params.apifun;
}
let pars: any = null;
if (req.method === "GET") {
pars = req.query;
} else if (req.method === "POST") {
pars = req.fields ?? req.body;
} else if (req.method === "SOCK") {
pars = req.header;
this.method = req.header["path"];
const [apiver, apisys, apiobj, apifun] = this.method.split("/");
this.apiver = apiver;
this.apisys = apisys;
this.apiobj = apiobj;
this.apifun = apifun;
}
pwd: string = "";
weixin: string = "";
idceo: string = "";
truename: string = "";
mobile: string = "";
idpk: number = 0;
if (!pars) return;
// 返回用
res: number = 0;
errmsg: string = "";
backtype: string = "json";
this.type = pars.type ?? 0;
this.bcid = pars.bcid ?? "d4856531-e9d3-20f3-4c22-fe3c65fb009c";
this.v = req.header['v'] ?? pars.v ?? 24;
this.getstart = +(pars.getstart ?? 0);
this.parsn = pars["pars[]"] ?? pars.pars ?? "";
this.source = req.header['source'] ?? pars.source ?? 'no';
this.uname = req.header['uname'] ?? pars.uname ?? 'guest';
this.pwd = req.header['pwd'] ?? pars.pwd ?? '';
this.sid = req.header['sid'] ?? pars.sid ?? '';
this.sid ??= "";
this.mid = pars.mid ?? UpInfo.getNewid();
this.midpk = pars.midpk ?? -1;
this.getnumber = +(pars.getnumber ?? 15);
this.pcid = req.header['pcid'] ?? pars.pcid ?? '';
this.pcname = req.header['pcname'] ?? pars.pcname ?? '';
this.ip = req.header['x-forwarded-for'] ?? "";
this.ip = this.ip.includes("ffff") ? this.ip.substring(this.ip.indexOf("ffff") + 5) : this.ip;
this.colsn = pars["cols[]"] ?? pars.cols ?? ["all"];
this.order = pars.order ?? 'idpk';
this.jsonp = pars.jsonp ?? false;
this.backtype = pars.backtype ?? "json";
this.upid = pars.upid ?? UpInfo.getNewid();
this.cache = req.header['cache'] ?? pars.cache ?? this.mid;
this.cols = typeof this.colsn === 'string' ? JSON.parse(this.colsn) : this.colsn;
this.base64 = pars.base64 ?? false;
if (this.v >= 24) {
this.json = pars.json ?? true;
this.jsonbase64 = pars.jsonbase64 ?? false;
} else if (this.v >= 17.01) {
this.json = pars.json ?? false;
this.jsonbase64 = pars.jsonbase64 ?? true;
this.uname = this._decodeBase64(this.uname ?? '');
if (this.pcname !== "") {
this.pcname = this._decodeBase64(this.pcname);
}
} else if (this.v === 17) {
this.jsonbase64 = pars.jsonbase64 ?? false;
this.cidn = pars.cid ?? "";
}
jsonp: boolean = false;
base64: boolean = false;
json: boolean = true;
if (this.parsn === "") {
this.pars = [];
return;
}
// 弃用下版删除
jsonbase64: boolean = false;
if (this.json) {
try {
this.pars = typeof this.parsn === 'string' ? JSON.parse(this.parsn) : this.parsn;
} catch (e) {
console.log(`${this.method} ${JSON.stringify(this.colsn)} json eval err: ${JSON.stringify(this.parsn)}`);
}
}
if (this.jsonbase64) {
try {
const decodedPars = typeof this.parsn === 'string'
? this._decodeBase64(this.parsn)
: '';
constructor(ctx: any) {
if (!ctx) return;
if (this.v >= 22) {
this.pars = decodedPars !== "null" ? decodedPars.split(",~") : [];
} else {
this.pars = typeof this.pars === 'string' && this.pars !== "null" ? JSON.parse(this.pars) : [];
}
} catch (e) {
console.log(`jsonbase eval err: ${JSON.stringify(e)}`);
console.log(`${this.method} ${JSON.stringify(this.colsn)} jsonbase eval err: ${JSON.stringify(this.parsn)}`);
}
}
if (this.base64) {
if (typeof this.parsn === 'string') {
this.pars = [this._decodeBase64(this.parsn)];
} else if (Array.isArray(this.parsn)) {
this.pars = this.parsn.map(p => this._decodeBase64(p));
} else {
console.log('无效的 parsn 类型');
this.pars = [];
}
}
this.ctx = ctx;
const { request: req } = ctx;
this.method = req.path;
if (ctx.params) {
this.apiver = ctx.params.apiver;
this.apisys = ctx.params.apisys;
this.apiobj = ctx.params.apiobj;
this.apifun = ctx.params.apifun;
}
private _decodeBase64(encodestr: string): string {
return Buffer.from(encodestr.replace(/\*/g, "+").replace(/-/g, "/").replace(/\./g, "="), 'base64').toString();
let pars: any = null;
if (req.method === "GET") {
pars = req.query;
} else if (req.method === "POST") {
pars = req.fields ?? req.body;
} else if (req.method === "SOCK") {
pars = req.header;
this.method = req.header["method"];
const [apiver, apisys, apiobj, apifun] = this.method.split("/");
this.apiver = apiver;
this.apisys = apisys;
this.apiobj = apiobj;
this.apifun = apifun;
}
static getMaster(): UpInfo {
const up2 = new UpInfo(null);
Object.assign(up2, {
sid: 'ba',
cid: 'd4c',
bcid: 'd4',
mid: this.getNewid(),
uname: 'ss',
pars: [],
getstart: 0,
ip: "127.0.0.1"
});
return up2;
};
if (!pars) return;
static getGuest(): UpInfo {
const up2 = new UpInfo(null);
Object.assign(up2, {
sid: 'GUEST888-8888-8888-8888-GUEST88GUEST',
cid: 'GUEST000-8888-8888-8888-GUEST00GUEST',
bcid: 'd4856531-e9d3-20f3-4c22-fe3c65fb009c',
mid: this.getNewid(),
uname: 'guest',
pars: [],
getstart: 0,
ip: "127.0.0.1"
});
return up2;
};
this.type = pars.type ?? 0;
static getNewid(): string {
const s4 = (): string => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
this.bcid = pars.bcid ?? "d4856531-e9d3-20f3-4c22-fe3c65fb009c";
this.v = +(req.header['v'] ?? pars.v ?? 24);
this.getstart = +(pars.getstart ?? 0);
this.parsn = pars["pars[]"] ?? pars.pars ?? "";
this.source = req.header['source'] ?? pars.source ?? 'no';
this.uname = req.header['uname'] ?? pars.uname ?? 'guest';
this.pwd = req.header['pwd'] ?? pars.pwd ?? '';
this.sid = req.header['sid'] ?? pars.sid ?? '';
this.sid ??= "";
this.mid = pars.mid ?? UpInfo.getNewid();
this.midpk = pars.midpk ?? -1;
this.getnumber = +(pars.getnumber ?? 15);
this.pcid = req.header['pcid'] ?? pars.pcid ?? '';
this.pcname = req.header['pcname'] ?? pars.pcname ?? '';
this.ip = req.header['x-forwarded-for'] ?? "";
this.ip = this.ip.includes("ffff") ? this.ip.substring(this.ip.indexOf("ffff") + 5) : this.ip;
this.colsn = pars["cols[]"] ?? pars.cols ?? ["all"];
this.order = pars.order ?? 'idpk desc';
this.jsonp = pars.jsonp ?? false;
this.backtype = pars.backtype ?? "json";
this.upid = pars.upid ?? UpInfo.getNewid();
this.cache = req.header['cache'] ?? pars.cache ?? this.mid;
this.cols = typeof this.colsn === 'string' ? JSON.parse(this.colsn) : this.colsn;
this.base64 = pars.base64 ?? false;
if (this.v >= 24) {
this.json = pars.json ?? true;
this.jsonbase64 = pars.jsonbase64 ?? false;
} else if (this.v >= 17.01) {
this.json = pars.json ?? false;
this.jsonbase64 = pars.jsonbase64 ?? true;
this.uname = this._decodeBase64(this.uname ?? '');
if (this.pcname !== "") {
this.pcname = this._decodeBase64(this.pcname);
}
} else if (this.v === 17) {
this.jsonbase64 = pars.jsonbase64 ?? false;
this.cidn = pars.cid ?? "";
}
inArray(o: string, cols: string[]): boolean {
return cols.includes(o);
if (this.parsn === "") {
this.pars = [];
return;
}
checkCols(cols: string[]): string {
if (this.cols.length === 1 && (this.cols[0] === 'all' || this.cols[0] === 'idpk')) {
return "checkcolsallok";
if (this.json) {
try {
this.pars = typeof this.parsn === 'string' ? JSON.parse(this.parsn) : this.parsn;
} catch (e) {
console.log(`${this.method} ${JSON.stringify(this.colsn)} json eval err: ${JSON.stringify(this.parsn)}`);
}
}
if (this.jsonbase64) {
try {
const decodedPars = typeof this.parsn === 'string'
? this._decodeBase64(this.parsn)
: '';
if (this.v >= 22) {
this.pars = decodedPars !== "null" ? decodedPars.split(",~") : [];
} else {
this.pars = typeof this.pars === 'string' && this.pars !== "null" ? JSON.parse(this.pars) : [];
}
let isback = "checkcolsallok";
try {
this.cols.forEach(item => {
if (!cols.includes(item))
isback = item;
});
} catch (e) {
console.log(`checkCols err: ${e}`);
return isback;
}
} catch (e) {
console.log(`jsonbase eval err: ${JSON.stringify(e)}`);
console.log(`${this.method} ${JSON.stringify(this.colsn)} jsonbase eval err: ${JSON.stringify(this.parsn)}`);
}
}
if (this.base64) {
if (typeof this.parsn === 'string') {
this.pars = [this._decodeBase64(this.parsn)];
} else if (Array.isArray(this.parsn)) {
this.pars = this.parsn.map(p => this._decodeBase64(p));
} else {
console.log('error parsn kind');
this.pars = [];
}
}
return isback;
};
}
inOrder(cols: string[]): boolean {
let isin = true;
private _decodeBase64(encodestr: string): string {
return Buffer.from(encodestr.replace(/\*/g, "+").replace(/-/g, "/").replace(/\./g, "="), 'base64').toString();
}
const orders = this.order.split(",");
for (const o of orders) {
let order = o;
const descIndex = o.indexOf(" desc");
if (descIndex >= 0 && descIndex === o.length - 5)
order = o.substr(0, descIndex);
if (order === 'id' || order === 'idpk' || order === 'uptime' || order === 'upby')
continue;
private static _masterInstance: UpInfo = this.getGuest();
if (order !== 'id' && order !== 'idpk' && !cols.includes(order)) {
return false;
}
}
return isin;
};
static setMaster(up: UpInfo): void {
this._masterInstance = up;
}
}
static getMaster(): UpInfo {
return this._masterInstance;
};
static getGuest(): UpInfo {
const up2 = new UpInfo(null);
Object.assign(up2, {
sid: 'GUEST888-8888-8888-8888-GUEST88GUEST',
cid: 'GUEST000-8888-8888-8888-GUEST00GUEST',
bcid: 'd4856531-e9d3-20f3-4c22-fe3c65fb009c',
mid: this.getNewid(),
uname: 'guest',
pars: [],
getstart: 0,
ip: "127.0.0.1"
});
return up2;
};
static getNewid(): string {
const s4 = (): string => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
}
inArray(o: string, cols: string[]): boolean {
return cols.includes(o);
}
checkCols(cols: string[]): string {
if (this.cols.length === 1 && (this.cols[0] === 'all' || this.cols[0] === 'idpk')) {
return "checkcolsallok";
}
let isback = "checkcolsallok";
try {
this.cols.forEach(item => {
if (!cols.includes(item))
isback = item;
});
} catch (e) {
console.log(`checkCols err: ${e}`);
return isback;
}
return isback;
};
inOrder(cols: string[]): boolean {
let isin = true;
const orders = this.order.split(",");
for (const o of orders) {
let order = o;
const descIndex = o.indexOf(" desc");
if (descIndex >= 0 && descIndex === o.length - 5)
order = o.substr(0, descIndex);
if (order === 'id' || order === 'idpk' || order === 'uptime' || order === 'upby')
continue;
if (order !== 'id' && order !== 'idpk' && !cols.includes(order)) {
return false;
}
}
return isin;
};
clone(): UpInfo {
const clonedUpInfo = new UpInfo(null);
clonedUpInfo.sid = this.sid;
clonedUpInfo.uname = this.uname;
clonedUpInfo.bcid = this.bcid;
return clonedUpInfo;
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc