09cc02ca9824e6bfbeff753d44896033f7a169bb
[motion2.git] / server / config / license / util.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x579f=['crypto','util','moment','./hardware','../environment','../../mysqldb','license','isEmpty','License\x20key\x20value\x20not\x20found','data1','split','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','demo','uuid','getUuid','session','gray','deadline','add','grayReason','machineUuid','2027-01-01T00:00:00.000Z','Breaking\x20license','message','Demo\x20license','getLicense','License','defaults','then','checkLicense'];(function(_0x2c2c98,_0x3fa0bd){var _0x53c893=function(_0x2dc1a4){while(--_0x2dc1a4){_0x2c2c98['push'](_0x2c2c98['shift']());}};_0x53c893(++_0x3fa0bd);}(_0x579f,0x14d));var _0xf579=function(_0x4a7d15,_0xb669ce){_0x4a7d15=_0x4a7d15-0x0;var _0x1e8dce=_0x579f[_0x4a7d15];return _0x1e8dce;};'use strict';var crypto=require(_0xf579('0x0'));var util=require(_0xf579('0x1'));var _=require('lodash');var moment=require(_0xf579('0x2'));var hardware=require(_0xf579('0x3'));var config=require(_0xf579('0x4'));var db=require(_0xf579('0x5'))['db'];function checkLicense(_0x42a7c2,_0x16dfb5){if(_0x42a7c2){try{var _0x2bddb7=_0x16dfb5||_0x42a7c2[_0xf579('0x6')];if(_[_0xf579('0x7')](_0x2bddb7)){throw new Error(_0xf579('0x8'));}var _0x279b3b=_0x42a7c2[_0xf579('0x9')];var _0xba7a9e=_0x42a7c2['data2'];var _0x232e8f=_0x279b3b[_0xf579('0xa')]('-')[0x4];var _0x399c09=_0x279b3b['split']('-')[0x0];var _0x338a7f=crypto['createDecipher'](_0xf579('0xb'),util[_0xf579('0xc')](_0xf579('0xd'),_0x232e8f,_0x279b3b,_0x399c09));var _0x84b2cb=_0x338a7f[_0xf579('0xe')](_0x2bddb7,_0xf579('0xf'),_0xf579('0x10'));_0x84b2cb+=_0x338a7f[_0xf579('0x11')]('utf8');var _0x1745c6=JSON[_0xf579('0x12')](_0x84b2cb);_0x1745c6[_0xf579('0x13')]=![];_0x1745c6[_0xf579('0x14')]=_0x279b3b;_0x1745c6['machineUuid']=hardware[_0xf579('0x15')]();if(_0xba7a9e){var _0x469bf1=crypto['createDecipher']('aes-256-ctr',config['secrets'][_0xf579('0x16')]);var _0x2c15ac=_0x469bf1[_0xf579('0xe')](_0xba7a9e,_0xf579('0xf'),_0xf579('0x10'));_0x2c15ac+=_0x469bf1[_0xf579('0x11')](_0xf579('0x10'));_0x1745c6[_0xf579('0x17')]=_0x2c15ac;_0x1745c6[_0xf579('0x18')]=moment(_0x2c15ac)[_0xf579('0x19')](0x7,'days')[_0xf579('0xc')]();_0x1745c6[_0xf579('0x1a')]=_0x1745c6['uuid']!=_0x1745c6[_0xf579('0x1b')]?'changed':'disabled';}return _0x1745c6;}catch(_0x42b4c1){return{'breaking':!![],'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0xf579('0x1c'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'update':![],'description':_0xf579('0x1d'),'uuid':_0x42a7c2[_0xf579('0x9')],'machineUuid':hardware['getUuid'](),'message':_0x42b4c1[_0xf579('0x1e')],'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};}}return{'demo':!![],'agents':0x2,'telephones':0x0,'users':0x1,'expiration':_0xf579('0x1c'),'chat':![],'mail':![],'fax':![],'messaging':![],'whatsapp':![],'cm':![],'dialer':![],'jscripty':![],'openchannel':![],'callysquare':0x2,'webrtc':![],'jaws':![],'custom':![],'description':_0xf579('0x1f'),'uuid':_0x42a7c2[_0xf579('0x9')],'machineUuid':hardware[_0xf579('0x15')](),'virtual':0x0,'voice':!![],'screenrecording':![],'preferred':![],'ai':![]};}exports[_0xf579('0x20')]=function(_0x4f63f0){return db[_0xf579('0x21')]['find'](_[_0xf579('0x22')](_0x4f63f0,{'raw':!![],'where':{'id':0x1}}))[_0xf579('0x23')](function(_0x4668c1){return checkLicense(_0x4668c1,null);});};exports[_0xf579('0x24')]=checkLicense;