mirror of https://github.com/certd/certd
chore: plus
parent
db9d27468e
commit
ab7a1673ff
|
@ -1,9 +1,10 @@
|
||||||
import { createVerify } from "node:crypto";
|
import { createVerify } from "node:crypto";
|
||||||
import { logger } from "../utils/index.js";
|
import { logger } from "../utils/index.js";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
const SecreteKey =
|
const SecreteKey =
|
||||||
"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQkNnS0NBUUVBMjdoZDM0NjRYbyt3TkpmTTNCWjE5MXlQK2NLaTd3ck9CbXdjTWJPZUdsNlJOMUVtTGhyMgplOFdvOGpmMW9IVXc5RFV6L2I2ZHU3Q3ZXMXZNUDA1Q3dSS3lNd2U3Q1BYRGQ2U01mSkwxRFZyUkw5Ylh0cEYzCjJkQVA5UENrakFJcFMvRE5jVkhLRXk1QW8yMnFFenpTKzlUT0JVY2srREdZcmo4KzI5U3h2aEZDRE5ZbEE2d1EKbEkyRWc5TWNBV2xDU3p1S1JWa2ZWUWdYVlU3SmE5OXp1Um1oWWtYZjFxQzBLcVAwQkpDakdDNEV6ZHorMmwyaAo2T3RxVHVVLzRkemlYYnRMUS8vU0JqNEgxdi9PZ3dUZjJkSVBjUnRHOXlWVTB2ZlQzVzdUTkdlMjU3em5ESDBYCkd6Wm4zdWJxTXJuL084b2ltMHRrS3ZHZXZ1V2ZraWNwVVFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";
|
"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQXY3TGtMaUp1dGM0NzhTU3RaTExjajVGZXh1YjJwR2NLMGxwa0hwVnlZWjhMY29rRFhuUlAKUGQ5UlJSTVRTaGJsbFl2Mzd4QUhOV1ZIQ0ZsWHkrQklVU001bUlBU1NDQTV0azlJNmpZZ2F4bEFDQm1BY0lGMwozKzBjeGZIYVkrVW9YdVluMkZ6YUt2Ym5GdFZIZ0lkMDg4a3d4clZTZzlCT3BDRVZIR1pxR2I5TWN5MXVHVXhUClFTVENCbmpoTWZlZ0p6cXVPYWVOY0ZPSE5tbmtWRWpLTythbTBPeEhNS1lyS3ZnQnVEbzdoVnFENlBFMUd6V3AKZHdwZUV4QXZDSVJxL2pWTkdRK3FtMkRWOVNJZ3U5bmF4MktmSUtFeU50dUFFS1VpekdqL0VmRFhDM1cxMExhegpKaGNYNGw1SUFZU1o3L3JWVmpGbExWSVl0WDU1T054L1Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K";
|
||||||
export const appKey = "GGtrKRWRknFdIID0rW";
|
export const appKey = "z4nXOeTeSnnpUpnmsV";
|
||||||
export type LicenseVerifyReq = {
|
export type LicenseVerifyReq = {
|
||||||
subjectId: string;
|
subjectId: string;
|
||||||
license: string;
|
license: string;
|
||||||
|
@ -40,7 +41,7 @@ class LicenseVerifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPlus(value: boolean, info: any = {}) {
|
setPlus(value: boolean, info: any = {}) {
|
||||||
if (value && !info) {
|
if (value && info) {
|
||||||
holder.isPlus = true;
|
holder.isPlus = true;
|
||||||
holder.expireTime = info.expireTime;
|
holder.expireTime = info.expireTime;
|
||||||
holder.level = info.level;
|
holder.level = info.level;
|
||||||
|
@ -71,7 +72,10 @@ class LicenseVerifier {
|
||||||
logger.warn("授权已过期");
|
logger.warn("授权已过期");
|
||||||
return this.setPlus(false, { message: "授权已过期" });
|
return this.setPlus(false, { message: "授权已过期" });
|
||||||
}
|
}
|
||||||
const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.activeTime},${json.duration},${json.expireTime},${json.version}`;
|
const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.level},${json.activeTime},${json.duration},${json.expireTime},${json.version}`;
|
||||||
|
// content := fmt.Sprintf("%s,%s,%s,%s,%d,%d,%d,%d,%d", entity.AppKey, entity.SubjectId, entity.Code, entity.Secret, entity.Level, entity.ActiveTime, entity.Duration, entity.ExpireTime, entity.Version)
|
||||||
|
//z4nXOeTeSnnpUpnmsV,_m9jFTdNHktdaEN4xBDw_,HZz7rAAR3h3zGlDMhScO1wGBYPjXpZ9S_1,uUpr9I8p6K3jWSzu2Wh5NECvgG2FNynU,0,1724199847470,365,1787271324416,1
|
||||||
|
logger.debug("content:", content);
|
||||||
const publicKey = Buffer.from(SecreteKey, "base64").toString();
|
const publicKey = Buffer.from(SecreteKey, "base64").toString();
|
||||||
const res = this.verifySignature(content, json.signature, publicKey);
|
const res = this.verifySignature(content, json.signature, publicKey);
|
||||||
this.checked = true;
|
this.checked = true;
|
||||||
|
@ -79,6 +83,7 @@ class LicenseVerifier {
|
||||||
logger.warn("授权校验失败");
|
logger.warn("授权校验失败");
|
||||||
return this.setPlus(false, { message: "授权校验失败" });
|
return this.setPlus(false, { message: "授权校验失败" });
|
||||||
}
|
}
|
||||||
|
logger.info(`授权校验成功,到期时间:${dayjs(json.expireTime).format("YYYY-MM-DD HH:mm:ss")}`);
|
||||||
return this.setPlus(true, {
|
return this.setPlus(true, {
|
||||||
expireTime: json.expireTime,
|
expireTime: json.expireTime,
|
||||||
level: json.level || 1,
|
level: json.level || 1,
|
||||||
|
|
|
@ -53,8 +53,7 @@ export function createAxiosService({ logger }: { logger: Logger }) {
|
||||||
logger.error(`请求出错:url:${error?.response?.config.url},method:${error?.response?.config?.method},status:${error?.response?.status}`);
|
logger.error(`请求出错:url:${error?.response?.config.url},method:${error?.response?.config?.method},status:${error?.response?.status}`);
|
||||||
logger.info("返回数据:", JSON.stringify(error?.response?.data));
|
logger.info("返回数据:", JSON.stringify(error?.response?.data));
|
||||||
delete error.config;
|
delete error.config;
|
||||||
delete error.response;
|
return Promise.reject(error.response || error);
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return service;
|
return service;
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
<fs-icon icon="mingcute:vip-1-line"></fs-icon>
|
<fs-icon icon="mingcute:vip-1-line"></fs-icon>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<span v-if="userStore.plusInfo?.isPlus">
|
<span v-if="userStore.plusInfo?.isPlus">
|
||||||
<span>专业版</span>
|
<a-tooltip>
|
||||||
<span>{{ expireTime }}</span>
|
<template #title> 到期时间:{{ expireTime }} </template>
|
||||||
|
<span>专业版</span>
|
||||||
|
</a-tooltip>
|
||||||
</span>
|
</span>
|
||||||
<span v-else @click="openUpgrade"> 当前免费版 </span>
|
<span v-else @click="openUpgrade"> 当前免费版 </span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,8 +57,9 @@ function openUpgrade() {
|
||||||
<div class="mt-10 mb-10">
|
<div class="mt-10 mb-10">
|
||||||
<a-input v-model:value={formState.code} placeholder={placeholder} />
|
<a-input v-model:value={formState.code} placeholder={placeholder} />
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
|
没有激活码?
|
||||||
<a href="https://afdian.com/a/greper" target="_blank">
|
<a href="https://afdian.com/a/greper" target="_blank">
|
||||||
爱发电赞助获取激活码
|
爱发电赞助获取
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||||
import { SysSettingsService } from '../service/sys-settings-service.js';
|
import { SysSettingsService } from '../service/sys-settings-service.js';
|
||||||
import { BaseController } from '../../../basic/base-controller.js';
|
import { BaseController } from '../../../basic/base-controller.js';
|
||||||
import { appKey, utils, verify } from '@certd/pipeline';
|
import { appKey, verify } from '@certd/pipeline';
|
||||||
import { SysInstallInfo, SysLicenseInfo } from '../service/models.js';
|
import { SysInstallInfo, SysLicenseInfo } from '../service/models.js';
|
||||||
import { logger } from '../../../utils/logger.js';
|
import { logger } from '../../../utils/logger.js';
|
||||||
|
import { request } from '../../../utils/http.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -22,8 +23,9 @@ export class SysPlusController extends BaseController {
|
||||||
code,
|
code,
|
||||||
subjectId: installInfo.siteId,
|
subjectId: installInfo.siteId,
|
||||||
};
|
};
|
||||||
const res: any = await utils.http({
|
|
||||||
url: 'https://api.ai.handsfree.work/activation/active',
|
const res: any = await request({
|
||||||
|
url: 'http://localhost:11007/activation/active',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { utils } from '@certd/pipeline';
|
||||||
|
|
||||||
|
export async function request(config: any) {
|
||||||
|
try {
|
||||||
|
return await utils.http(config);
|
||||||
|
} catch (e) {
|
||||||
|
const data = e.data || e.response?.data;
|
||||||
|
if (data) {
|
||||||
|
throw new Error(data.message || data.msg || data.error || data);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue