Compare commits
No commits in common. "55f33ad490dee16ef042e68e6b4af7ce2d2de869" and "f42e70df2784f7591030c02e34258a13486044ac" have entirely different histories.
55f33ad490
...
f42e70df27
2423
package-lock.json
generated
2423
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -30,27 +30,25 @@
|
|||||||
"join-js": "^1.0.0",
|
"join-js": "^1.0.0",
|
||||||
"jsonwebtoken": "^8.2.1",
|
"jsonwebtoken": "^8.2.1",
|
||||||
"kcors": "^2.2.1",
|
"kcors": "^2.2.1",
|
||||||
"knex": "^0.95.10",
|
"knex": "^0.14.6",
|
||||||
"koa": "^2.5.1",
|
"koa": "^2.5.1",
|
||||||
"koa-bodyparser": "^4.2.0",
|
"koa-bodyparser": "^4.2.0",
|
||||||
"koa-helmet": "^4.0.0",
|
"koa-helmet": "^4.0.0",
|
||||||
"koa-jwt": "^3.3.1",
|
"koa-jwt": "^3.3.1",
|
||||||
"koa-logger": "^3.2.0",
|
"koa-logger": "^3.2.0",
|
||||||
"koa-mount": "^4.0.0",
|
|
||||||
"koa-response-time": "^2.0.0",
|
"koa-response-time": "^2.0.0",
|
||||||
"koa-router": "^7.4.0",
|
"koa-router": "^7.4.0",
|
||||||
"koa-static": "^5.0.0",
|
"lodash": "^4.17.10",
|
||||||
"lodash": "^4.17.21",
|
|
||||||
"mysql": "^2.15.0",
|
"mysql": "^2.15.0",
|
||||||
"pg": "^7.4.1",
|
"pg": "^7.4.1",
|
||||||
"qs": "^6.5.1",
|
"qs": "^6.5.1",
|
||||||
"request": "^2.85.0",
|
"request": "^2.85.0",
|
||||||
"request-promise": "^4.2.2",
|
"request-promise": "^4.2.2",
|
||||||
"slug": "^0.9.4",
|
"slug": "^0.9.1",
|
||||||
"uuid": "^3.2.1",
|
"uuid": "^3.2.1",
|
||||||
"validator": "^9.4.1",
|
"validator": "^9.4.1",
|
||||||
"winston": "^2.4.2",
|
"winston": "^2.4.2",
|
||||||
"yup": "^0.32.9"
|
"yup": "^0.24.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"faker": "^4.1.0",
|
"faker": "^4.1.0",
|
||||||
|
|||||||
@ -30,8 +30,6 @@ app.use(logger())
|
|||||||
|
|
||||||
app.use(camelizeMiddleware)
|
app.use(camelizeMiddleware)
|
||||||
|
|
||||||
app.use(require('koa-mount')('/temp/license-activator-tool', require('koa-static')('./public')))
|
|
||||||
|
|
||||||
app.use(error)
|
app.use(error)
|
||||||
app.use(db(app))
|
app.use(db(app))
|
||||||
app.use(cors(config.cors))
|
app.use(cors(config.cors))
|
||||||
|
|||||||
@ -2,18 +2,10 @@
|
|||||||
* Pick parameters which are significant for including into license file
|
* Pick parameters which are significant for including into license file
|
||||||
*/
|
*/
|
||||||
exports.pickParams = function (appId, systemParams) {
|
exports.pickParams = function (appId, systemParams) {
|
||||||
let appParams = ['biosSerialNum', 'osId', 'mainboardSerialNum', 'diskSerialNum', 'nicMac'];
|
// if (appId === 'coc') {
|
||||||
let requiredParams = 2;
|
const appParams = ['biosSerialNum', 'osId', 'mainboardSerialNum', 'diskSerialNum', 'nicMac'];
|
||||||
|
const requiredParams = 2;
|
||||||
if (appId === 'cocserver') {
|
// }
|
||||||
if (systemParams.hasOwnProperty("cpuIdHypervisor")) {
|
|
||||||
appParams = ['osId', 'computerUUID', 'cpuIdModel', 'nicMac', 'diskSerialNum', 'nicMac', 'mainboardSerialNum', 'computerSerial'];
|
|
||||||
requiredParams = 3
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
appParams = ['osId', 'computerUUID', 'mainboardSerialNum', 'computerSerial', 'diskSerialNum', 'nicMac', 'cpuIdModel'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let resParams = {};
|
let resParams = {};
|
||||||
console.log(systemParams)
|
console.log(systemParams)
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
const apiV1 = require('./apiV1-controller')
|
const apiV1 = require('./apiV1-controller')
|
||||||
const temp = require('./temp-controller')
|
|
||||||
const products = require('./products-controller')
|
const products = require('./products-controller')
|
||||||
const login = require('./login-controller')
|
const login = require('./login-controller')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
apiV1,
|
apiV1,
|
||||||
temp,
|
|
||||||
products,
|
products,
|
||||||
login
|
login
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
const base32 = require('hi-base32')
|
|
||||||
const crypto = require('crypto')
|
|
||||||
const { parseOfflinePreactivationRequest } = require('../lib/generateLicenseFile')
|
|
||||||
|
|
||||||
|
|
||||||
function checkRequestString(requestString) {
|
|
||||||
if (requestString !== null && typeof requestString === 'string') {
|
|
||||||
if (requestString.length > 0) {
|
|
||||||
return (requestString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error('Invalid request string')
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
async generateNewLicense(ctx) {
|
|
||||||
const licenseNum = base32.encode(crypto.randomBytes(15))
|
|
||||||
const licenseNumNice = licenseNum.match(/.{4}/g).join('-')
|
|
||||||
ctx.body = '<html><body>' +
|
|
||||||
`License for client: <pre>${licenseNumNice}</pre>` +
|
|
||||||
'SQL command to insert license into database with 2 licensed modules <strong>ccengine</strong> (windows app) and <strong>cndata</strong> (CN data): <pre>' +
|
|
||||||
`Insert Into License (productId, licenseNum, customerId) Values ('coc', '${licenseNum}', '123456');\n` +
|
|
||||||
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'ccengine');\n` +
|
|
||||||
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'cndata');\n` +
|
|
||||||
'</pre>' +
|
|
||||||
'</body></html>';
|
|
||||||
},
|
|
||||||
|
|
||||||
async parseOfflineActivationRequest(ctx) {
|
|
||||||
const { body } = ctx.request
|
|
||||||
console.log(body)
|
|
||||||
ctx.body = await parseOfflinePreactivationRequest(checkRequestString(body.requestString))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -39,34 +39,3 @@ exports.generateLicenseFile = async function (activationId, productId, systemPar
|
|||||||
console.log(output.toString('hex'));
|
console.log(output.toString('hex'));
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.parseOfflinePreactivationRequest = async function (activationRequest) {
|
|
||||||
const beginTag = "-BEGIN ACTIVATION REQUEST-----"
|
|
||||||
let beginPos = activationRequest.indexOf(beginTag)
|
|
||||||
if (beginPos < 0) {
|
|
||||||
throw "Invalid activation request format"
|
|
||||||
}
|
|
||||||
beginPos = beginPos + beginTag.length;
|
|
||||||
activationRequest = activationRequest.substring(beginPos)
|
|
||||||
|
|
||||||
const endTag = "-----END ACTIVATION REQUEST-"
|
|
||||||
let endPos = activationRequest.indexOf(endTag)
|
|
||||||
if (endPos < 0) {
|
|
||||||
throw "Invalid activation request format"
|
|
||||||
}
|
|
||||||
const data = activationRequest.substring(0, endPos)
|
|
||||||
|
|
||||||
const buff = Buffer.from(data, 'base64');
|
|
||||||
|
|
||||||
const algorithm = 'aes-256-gcm';
|
|
||||||
const password = Buffer.from('e73db572349005f1c41979baf8166a0900745119fa096b9c3efbcee11ddd8b88', 'hex');
|
|
||||||
const decipher = crypto.createDecipheriv(algorithm, password, buff.subarray(0, 16))
|
|
||||||
decipher.setAuthTag(buff.subarray(-16))
|
|
||||||
let decrypted = decipher.update(buff.subarray(16, -16))
|
|
||||||
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
||||||
console.log(decrypted)
|
|
||||||
const inflateRaw = denodeify(zlib.inflateRaw)
|
|
||||||
const decompressed = await inflateRaw(decrypted);
|
|
||||||
console.log(JSON.stringify(JSON.parse(decompressed.toString()), null, 4))
|
|
||||||
return JSON.parse(decompressed.toString('utf-8'));
|
|
||||||
}
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ const backend = new Router()
|
|||||||
|
|
||||||
const apiV1 = require('./apiV1-router')
|
const apiV1 = require('./apiV1-router')
|
||||||
api.use(apiV1)
|
api.use(apiV1)
|
||||||
const temp = require('./temp-router')
|
|
||||||
|
|
||||||
const products = require('./products-router')
|
const products = require('./products-router')
|
||||||
const login = require('./login-router')
|
const login = require('./login-router')
|
||||||
@ -14,7 +13,21 @@ backend.use(products)
|
|||||||
backend.use(login)
|
backend.use(login)
|
||||||
|
|
||||||
router.use('/api', api.routes())
|
router.use('/api', api.routes())
|
||||||
router.use('/temp', temp)
|
|
||||||
router.use('/backend', backend.routes())
|
router.use('/backend', backend.routes())
|
||||||
|
|
||||||
|
const base32 = require('hi-base32')
|
||||||
|
const crypto = require('crypto')
|
||||||
|
router.get('/temp/generate-new-license', async function(ctx) {
|
||||||
|
const licenseNum = base32.encode(crypto.randomBytes(15))
|
||||||
|
const licenseNumNice = licenseNum.match(/.{4}/g).join('-')
|
||||||
|
ctx.body = '<html><body>' +
|
||||||
|
`License for client: <pre>${licenseNumNice}</pre>` +
|
||||||
|
'SQL command to insert license into database with 2 licensed modules <strong>ccengine</strong> (windows app) and <strong>cndata</strong> (CN data): <pre>' +
|
||||||
|
`Insert Into License (productId, licenseNum, customerId) Values ('coc', '${licenseNum}', '123456');\n` +
|
||||||
|
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'ccengine');\n` +
|
||||||
|
`Insert Into LicensedModule (productId, licenseNum, moduleId) Values ('coc', '${licenseNum}', 'cndata');\n` +
|
||||||
|
'</pre>' +
|
||||||
|
'</body></html>'
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
const Router = require('koa-router')
|
|
||||||
const ctrl = require('controllers').temp
|
|
||||||
const router = new Router()
|
|
||||||
|
|
||||||
router.get('/generate-new-license', ctrl.generateNewLicense);
|
|
||||||
router.get('/parse-offline-activation-request', ctrl.parseOfflineActivationRequest);
|
|
||||||
|
|
||||||
module.exports = router.routes()
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
const Koa = require('koa')
|
|
||||||
const Router = require('koa-router')
|
|
||||||
const app = new Koa()
|
|
||||||
const cors = require('kcors')
|
|
||||||
const bodyParser = require('koa-bodyparser')
|
|
||||||
const { generateNewLicense, parseOfflineActivationRequest } = require("../src/controllers/temp-controller.js")
|
|
||||||
|
|
||||||
const router = new Router()
|
|
||||||
|
|
||||||
router.get('/temp/generate-new-license', generateNewLicense)
|
|
||||||
router.post('/temp/parse-offline-activation-request', parseOfflineActivationRequest);
|
|
||||||
|
|
||||||
app.use(require('koa-mount')('/temp/license-activator-tool', require('koa-static')('c:/work/license-activator-tool/build')))
|
|
||||||
|
|
||||||
app.use(cors({
|
|
||||||
origin: '*',
|
|
||||||
exposeHeaders: ['Authorization'],
|
|
||||||
credentials: true,
|
|
||||||
allowMethods: ['GET', 'PUT', 'POST', 'DELETE'],
|
|
||||||
allowHeaders: ['Authorization', 'Content-Type'],
|
|
||||||
keepHeadersOnError: true
|
|
||||||
}))
|
|
||||||
|
|
||||||
app.use(bodyParser({
|
|
||||||
enableTypes: ['json']
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
// response
|
|
||||||
app.use(router.routes())
|
|
||||||
|
|
||||||
app.listen(3001, () => console.log('server started 3001'))
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
const { parseOfflinePreactivationRequest} = require('../src/lib/generateLicenseFile')
|
|
||||||
|
|
||||||
parseOfflinePreactivationRequest(`-----BEGIN ACTIVATION REQUEST-----
|
|
||||||
8o4j86i3bfbWkHQ/quJGsjdjeDwkdaKFQb7L/+7nxueACWZ/x3msv8pt8iEbDoSX
|
|
||||||
i/MDZ5TRgav6Xw/bNl2K4uWvyBsHjnIn8+M3oxCVtxkLbXyOzdJfKrbls616mIUP
|
|
||||||
FiiQzW1Pa9P7L2ebXAPTDFe4v5OWyGRFfcrFvDMeK570KT4Ol/xwIE/obRF8WhXe
|
|
||||||
x2vr
|
|
||||||
-----END ACTIVATION REQUEST-----`).then(() => 0)
|
|
||||||
.catch((reason) => console.log(reason))
|
|
||||||
Loading…
Reference in New Issue
Block a user