563 lines
16 KiB
JavaScript
563 lines
16 KiB
JavaScript
$s = class {
|
|
constructor() {
|
|
gl(this, "root_url", "https://www.cloudtentacles.com");
|
|
gl(this, "cache", new Map)
|
|
}
|
|
static getInstance() {
|
|
return $s.instance || ($s.instance = new $s)
|
|
}
|
|
PemToArrayBuffer(t) {
|
|
const r = t.split(`
|
|
`).filter(s => s.trim() && !s.includes("---")).join("")
|
|
, a = window.atob(r)
|
|
, o = new Uint8Array(a.length);
|
|
for (let s = 0; s < a.length; s++)
|
|
o[s] = a.charCodeAt(s);
|
|
return o.buffer
|
|
}
|
|
async encryptWithPublicKey(t) {
|
|
for (let s in t)
|
|
(t[s] === void 0 || t[s] === null || t[s] === "") && delete t[s];
|
|
const n = Date.now()
|
|
, r = Math.random().toString(16)
|
|
, a = "ct-client"
|
|
, o = JSON.stringify(Object.assign({
|
|
t: n,
|
|
r,
|
|
s: a
|
|
}, t));
|
|
try {
|
|
if (window.crypto && window.crypto.subtle && window.crypto.subtle.importKey) {
|
|
const i = await window.crypto.subtle.importKey("spki", this.PemToArrayBuffer($s.PublicKey), {
|
|
name: "RSA-OAEP",
|
|
hash: {
|
|
name: "SHA-256"
|
|
}
|
|
}, !0, ["encrypt"])
|
|
, u = new TextEncoder().encode(o)
|
|
, c = await window.crypto.subtle.encrypt({
|
|
name: "RSA-OAEP"
|
|
}, i, u)
|
|
, f = new Uint8Array(c);
|
|
let p = "";
|
|
for (let h = 0; h < f.byteLength; h++)
|
|
p += String.fromCharCode(f[h]);
|
|
return {
|
|
covert: window.btoa(p),
|
|
t: n,
|
|
r
|
|
}
|
|
}
|
|
console.warn("\u5F53\u524D\u5904\u4E8E\u975E\u5B89\u5168\u73AF\u5883\u6216\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebCrypto\uFF0C\u5DF2\u56DE\u9000\u5230 forge \u52A0\u5BC6");
|
|
const l = Td.pki.publicKeyFromPem($s.PublicKey).encrypt(o, "RSA-OAEP", {
|
|
md: Td.md.sha256.create(),
|
|
mgf1: {
|
|
md: Td.md.sha256.create()
|
|
}
|
|
});
|
|
return {
|
|
covert: Td.util.encode64(l),
|
|
t: n,
|
|
r
|
|
}
|
|
} catch (s) {
|
|
throw console.error("\u52A0\u5BC6\u5931\u8D25:", s),
|
|
"\u52A0\u5BC6\u5904\u7406\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u73AF\u5883"
|
|
}
|
|
}
|
|
cacheCheck(t, n) {
|
|
if (n > 0) {
|
|
const r = this.cache.get(t);
|
|
if (r && Date.now() - r.time <= n)
|
|
return JSON.parse(JSON.stringify(r.value))
|
|
}
|
|
return null
|
|
}
|
|
parametersToKey(t, n) {
|
|
let r = t;
|
|
for (let a in n)
|
|
a !== "token" && (r += `${a}:${n[a]}`);
|
|
return r
|
|
}
|
|
async httpProto(t, n, r) {
|
|
const a = this.parametersToKey(t, n)
|
|
, o = this.cacheCheck(a, r.interval || 0);
|
|
if (o)
|
|
return o;
|
|
const s = await B6({
|
|
url: t,
|
|
data: n,
|
|
method: r.type
|
|
})
|
|
, {data: l, code: i, message: u, token: c} = s.data;
|
|
switch (i) {
|
|
case bu.AlreadyExpired:
|
|
throw hs().setToken(""),
|
|
ei.replace("/login"),
|
|
"\u767B\u5F55\u5DF2\u8FC7\u671F";
|
|
case bu.UpdateSuccess:
|
|
hs().setToken(c);
|
|
case bu.Success:
|
|
return r.interval && r.interval > 0 && this.cache.set(a, {
|
|
time: Date.now(),
|
|
value: JSON.parse(JSON.stringify(l))
|
|
}),
|
|
l;
|
|
case bu.Fail:
|
|
throw u;
|
|
default:
|
|
throw "\u672A\u77E5\u9519\u8BEF"
|
|
}
|
|
}
|
|
async https(t, n={}, r={}) {
|
|
return await this.httpProto(t, n, Object.assign({}, $s.default_header, r))
|
|
}
|
|
async getVerifCode(t, n) {
|
|
const r = await this.encryptWithPublicKey({
|
|
account: t,
|
|
phone: n
|
|
});
|
|
await this.https("/public/verif_code", r)
|
|
}
|
|
async logIn(t, n, r, a) {
|
|
const o = await this.encryptWithPublicKey({
|
|
account: t,
|
|
password: cu(n),
|
|
phone: r,
|
|
code: a
|
|
});
|
|
return await this.https("/public/login", o)
|
|
}
|
|
async getUserInfo() {
|
|
return await this.https("/user/info", {}, {
|
|
load: !1
|
|
})
|
|
}
|
|
async getAsset() {
|
|
return await this.https("/user/get_asset", {}, {
|
|
type: "GET",
|
|
load: !1
|
|
})
|
|
}
|
|
async getPermission() {
|
|
return await this.https("/user/get_permission", {}, {
|
|
type: "GET",
|
|
load: !1
|
|
})
|
|
}
|
|
async getRecordRange(t, n, r) {
|
|
return await this.https("/record/range", {
|
|
record_code: t,
|
|
start_date: n,
|
|
end_date: r
|
|
}, {
|
|
load: !1
|
|
})
|
|
}
|
|
async getSkuList() {
|
|
return await this.https("/sku/list", {}, {
|
|
type: "GET",
|
|
interval: 6e4
|
|
})
|
|
}
|
|
async selectSkuList(t) {
|
|
return await this.https("/sku/select_list", {
|
|
id: t
|
|
})
|
|
}
|
|
async getCategoryList() {
|
|
return await this.https("/categories/get", {}, {
|
|
type: "GET",
|
|
interval: 6e4
|
|
})
|
|
}
|
|
async getSubList() {
|
|
return await this.https("/user/sub", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async updatePwd(t, n) {
|
|
const r = await this.encryptWithPublicKey({
|
|
o_password: cu(t),
|
|
n_password: cu(n)
|
|
});
|
|
return await this.https("/user/modify_pwd", r)
|
|
}
|
|
async giveAmount(t, n, r) {
|
|
return await this.https("/user/give", {
|
|
amount: t,
|
|
sub_id: n,
|
|
notes: r
|
|
})
|
|
}
|
|
async giveSku(t, n, r, a) {
|
|
return await this.https("/user/give_sku", {
|
|
sku_id: t,
|
|
sub_id: n,
|
|
count: r,
|
|
notes: a
|
|
})
|
|
}
|
|
async recoveryAmount(t, n, r) {
|
|
return await this.https("/user/recovery", {
|
|
amount: t,
|
|
sub_id: n,
|
|
notes: r
|
|
})
|
|
}
|
|
async getUserPreferentialPolicies() {
|
|
return await this.https("/sku/user_pref_poli", {}, {
|
|
type: "GET",
|
|
interval: 6e4
|
|
})
|
|
}
|
|
async buyGoods(t, n) {
|
|
return await this.https("/sku/buy", {
|
|
id: t,
|
|
count: n
|
|
})
|
|
}
|
|
async getKnapsack() {
|
|
const t = await this.https("/user/get_knapsack", {}, {
|
|
type: "GET"
|
|
});
|
|
return R8e().setKnapsackInfo(t),
|
|
t
|
|
}
|
|
async use(t) {
|
|
return await this.https("/sku/use", t)
|
|
}
|
|
async getIdleVirtualNumber(t) {
|
|
return await this.https("/vn/list", {
|
|
key: t
|
|
})
|
|
}
|
|
async getVirtualNumberBindUrl(t, n) {
|
|
return await this.https("/vn/bind_url", {
|
|
id: t,
|
|
key: n
|
|
})
|
|
}
|
|
async getVirtualNumberGameUserName(t, n) {
|
|
return await this.https("/vn/bind_info", [{
|
|
id: t,
|
|
key: n
|
|
}])
|
|
}
|
|
async inquiryUID(t, n) {
|
|
return await this.https("/vn/inquiry", {
|
|
uid: t,
|
|
key: n
|
|
})
|
|
}
|
|
async applyVirtualNumber(t, n) {
|
|
return await this.https("/vn/appoint", {
|
|
key: t,
|
|
phone: n
|
|
})
|
|
}
|
|
async returnVirtualNumber(t, n) {
|
|
return await this.https("/vn/back", {
|
|
key: t,
|
|
id: n
|
|
})
|
|
}
|
|
async generateLoginCode(t, n) {
|
|
return await this.https("/vn/generate_login_code", {
|
|
key: t,
|
|
id: n
|
|
})
|
|
}
|
|
async verifyLoginCode(t, n, r) {
|
|
return await this.https("/vn/verify_login_code", {
|
|
key: t,
|
|
id: n,
|
|
code: r
|
|
})
|
|
}
|
|
async vnVerifCode(t, n) {
|
|
return await this.https("/public/vn_verif_code", {
|
|
key: t,
|
|
phone: n
|
|
})
|
|
}
|
|
async getRecordList(t, n, r, a, o) {
|
|
return await this.https("/record/paging", {
|
|
record_code: t,
|
|
page: n,
|
|
size: r,
|
|
start_date: a,
|
|
end_date: o
|
|
})
|
|
}
|
|
async sendEMailCode(t, n, r) {
|
|
return await this.https("/vn/send_email_code", {
|
|
id: t,
|
|
key: n,
|
|
uid: r
|
|
})
|
|
}
|
|
async verifyEMailBindGame(t, n, r, a) {
|
|
return await this.https("/vn/verify_email_code", {
|
|
id: t,
|
|
key: n,
|
|
uid: r,
|
|
code: a
|
|
})
|
|
}
|
|
async direct_bind(t, n, r) {
|
|
return await this.https("/vn/direct_bind", {
|
|
id: t,
|
|
key: n,
|
|
uid: r
|
|
})
|
|
}
|
|
async getUserAuthority(t) {
|
|
return await this.https("/admin/get_user_permissions", {
|
|
id: t
|
|
})
|
|
}
|
|
async updateUserAuthority(t) {
|
|
return await this.https("/admin/modify_user_permissions", t)
|
|
}
|
|
async modifyUser(t) {
|
|
return await this.https("/admin/modify_user", t)
|
|
}
|
|
async getUserList() {
|
|
return await this.https("/user/list", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async getRelationshipList() {
|
|
return await this.https("/relationship/list", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async addRelationshipList(t, n) {
|
|
return await this.https("/relationship/add", {
|
|
user_id: t,
|
|
sub_id: n
|
|
})
|
|
}
|
|
async delRelationshipList(t, n) {
|
|
return await this.https("/relationship/del", {
|
|
user_id: t,
|
|
sub_id: n
|
|
})
|
|
}
|
|
async editRelationship(t, n) {
|
|
return await this.https("/relationship/modify", {
|
|
id: t,
|
|
open_repay: n
|
|
})
|
|
}
|
|
async getCategoryAllList() {
|
|
return await this.https("/admin/get_categories_list", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async getSkuAllList() {
|
|
return await this.https("/admin/get_sku_list", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async getPreferentialPoliciesAll() {
|
|
return await this.https("/preferential/list", {}, {
|
|
type: "GET"
|
|
})
|
|
}
|
|
async getUserPreferentialPoliciesToID(t) {
|
|
return await this.https("/preferential/get_relationship", {
|
|
id: t
|
|
})
|
|
}
|
|
async createUser(t) {
|
|
const n = cu(t.password);
|
|
return await this.https("/admin/creator_user", Object.assign(t, {
|
|
password: n
|
|
}))
|
|
}
|
|
async updateUserPassword(t, n) {
|
|
const r = await this.encryptWithPublicKey({
|
|
account: t,
|
|
n_password: cu(n)
|
|
});
|
|
return await this.https("/admin/modify_pwd", r)
|
|
}
|
|
async updateUserStatus(t, n) {
|
|
return await this.https("/admin/ban_user", {
|
|
id: t,
|
|
expire: n
|
|
})
|
|
}
|
|
async createSku(t) {
|
|
return await this.https("/admin/add_sku", t)
|
|
}
|
|
async createCategory(t) {
|
|
return await this.https("/admin/add_category", t)
|
|
}
|
|
async createPreferentialPolicies(t) {
|
|
return await this.https("/preferential/add", t)
|
|
}
|
|
async addUserPreferentialPolicies(t, n, r, a) {
|
|
return await this.https("/preferential/add_relationship", {
|
|
p_id: t,
|
|
u_id: n,
|
|
show_time: r,
|
|
hide_time: a
|
|
})
|
|
}
|
|
async addRelationshipLow(t) {
|
|
return await this.https("/preferential/add_relationship_low", t)
|
|
}
|
|
async batchRelationshipLow(t) {
|
|
return await this.https("/preferential/batch_relationship_low", t)
|
|
}
|
|
async delUserPreferentialPolicies(t, n) {
|
|
return await this.https("/preferential/del_Relationship", {
|
|
p_id: t,
|
|
u_id: n
|
|
})
|
|
}
|
|
async updateCategory(t) {
|
|
return await this.https("/admin/modify_category", t)
|
|
}
|
|
async updateSku(t) {
|
|
return await this.https("/admin/modify_sku", t)
|
|
}
|
|
async updatePreferentialPolicies(t) {
|
|
return await this.https("/preferential/modify", t)
|
|
}
|
|
async upsertCustom(t) {
|
|
return await this.https("/record/edit_custom", t)
|
|
}
|
|
async delCustom(t) {
|
|
return await this.https("/record/remove_custom", {
|
|
id: t
|
|
})
|
|
}
|
|
async subRangeRecord(t) {
|
|
return await this.https("/record/sub_range", {
|
|
ids: t
|
|
})
|
|
}
|
|
async transaction_record() {
|
|
return await this.https("/record/transaction_record")
|
|
}
|
|
async recipient_record() {
|
|
return await this.https("/record/recipient_record")
|
|
}
|
|
async observerSalesRecords(t, n, r) {
|
|
return await this.https("/observer/sales_records", {
|
|
ids: t,
|
|
start_date: n,
|
|
end_date: r
|
|
})
|
|
}
|
|
async observerTransactionRecord(t) {
|
|
return await this.https("/observer/transaction_record", {
|
|
ids: t
|
|
})
|
|
}
|
|
async observerHoldConsume(t) {
|
|
return await this.https("/observer/hold_consume", {
|
|
ids: t
|
|
})
|
|
}
|
|
async observerPaging(t, n, r, a, o, s) {
|
|
return await this.https("/observer/paging", {
|
|
ids: t,
|
|
record_code: n,
|
|
page: r,
|
|
size: a,
|
|
start_date: o,
|
|
end_date: s
|
|
})
|
|
}
|
|
async observerSub(t) {
|
|
return await this.https("/observer/sub", {
|
|
ids: t
|
|
})
|
|
}
|
|
async getYeZiList() {
|
|
return await this.https("/utils/list")
|
|
}
|
|
async applyYeZiPhone(t) {
|
|
return await this.https("/utils/apply", {
|
|
id: t
|
|
})
|
|
}
|
|
async releaseYeZiPhone(t) {
|
|
return await this.https("/utils/release", {
|
|
phone: t
|
|
})
|
|
}
|
|
async messageYeZiPhone(t) {
|
|
return await this.https("/utils/message", {
|
|
phone: t
|
|
})
|
|
}
|
|
async getProjectList() {
|
|
return await this.https("/utils/project_list")
|
|
}
|
|
async getHaoZhuList() {
|
|
return await this.https("/utils/list_hz")
|
|
}
|
|
async applyHaoZhuPhone(t) {
|
|
return await this.https("/utils/apply_hz", {
|
|
id: t + ""
|
|
})
|
|
}
|
|
async releaseHaoZhuPhone(t) {
|
|
return await this.https("/utils/release_hz", {
|
|
phone: t
|
|
})
|
|
}
|
|
async messageHaoZhuPhone(t) {
|
|
return await this.https("/utils/message_hz", {
|
|
phone: t
|
|
})
|
|
}
|
|
async getHaoZhuProjectList() {
|
|
return await this.https("/utils/project_list_hz")
|
|
}
|
|
async returnOfGoods(t) {
|
|
return await this.https("/admin/return_of_goods", t)
|
|
}
|
|
async customRepay(t) {
|
|
return await this.https("/admin/custom_repay", t)
|
|
}
|
|
async upsertSKU(t) {
|
|
return await this.https("/sku/upsert", {
|
|
data: t
|
|
})
|
|
}
|
|
async upsertCDK(t) {
|
|
await this.https("/admin/upsert_cdk", {
|
|
data: t
|
|
})
|
|
}
|
|
async getCDKList(t, n) {
|
|
return await this.https("/admin/cdk", {
|
|
page: t,
|
|
size: n
|
|
})
|
|
}
|
|
}
|
|
;
|
|
let Sr = $s;
|
|
gl(Sr, "instance"),
|
|
gl(Sr, "default_header", {
|
|
type: "POST",
|
|
interval: 0
|
|
}),
|
|
gl(Sr, "PublicKey", `-----BEGIN PUBLIC KEY-----
|
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsSzjk+9st2f8IpYqYaM5
|
|
F7K27ZR2IvzxTr2w4zgZAS2+BRdgMvXUOITdFQT+ytYF/r3pIgTkL7MF9UQuylmb
|
|
S57DiqGBLNBS7FzKyYzWTOc9yYA3+KrarbvpUn/Bm3UK+KKB17viPy+0pnNAHysJ
|
|
pzqadmAtQhI1ZDujJ2sW+FkV/pC8KIFahiyPIHjncy1ZG/BbRF3BDhvDcr6O7scO
|
|
GsHstGf9XsZBIITS5LYmlai7OdY4ZIVxUtQbfWzibihO+YDJJzFgt47drX0Ajo85
|
|
PfQTPNA++KsXtwRX9M6Re3vkTDRsutIIWKtj8jqhUbbYS3vzS8GJnAWavUFVkR15
|
|
0wIDAQAB
|
|
-----END PUBLIC KEY-----`),
|
|
gl(Sr, "LocalCacheKey", "YCJ-LocalCacheKey"); |