Object
[
"defineProperty"
](exports,
"__esModule"
, {
value: !
0
});
var tslib_1
=
require(
"tslib"
),
_
=
require(
"lodash"
),
path
=
require(
"path"
),
fs
=
require(
"fs"
),
moment
=
require(
"moment"
),
commonUtils_1
=
require(
"./commonUtils"
),
consts
=
require(
"./consts"
),
enums_1
=
require(
"./enums"
),
config
=
require(
"./Configuration"
),
MAX_TRIAL_DAYS
=
150
,
TRIAL_DAYS
=
30
,
Trial_Days
=
function () {
var e
=
(x
=
path[
"resolve"
](commonUtils_1[
"userDataDir"
](),
"../mongobooster"
), fs[
"existsSync"
](x) ?
60
: TRIAL_DAYS),
x,
a
=
parseInt(process.env[
"MB_TRIAL_DAYS"
]) || e;
return
MAX_TRIAL_DAYS < a ? MAX_TRIAL_DAYS : a;
}(),
TEMP_LM_FILE_V3
=
"pREQZNKj8C9MBv97Emb.dat"
,
TEMP_LM_FILE_V4
=
"pREQZNKj8C9MBv940mb.dat"
,
TEMP_LM_FILE_V5
=
"pREQZNKj8454acf83b3a50mb.dat"
,
LicenseType;
function getLicenseTypeDescName(e) {
var x,
a
=
((x
=
{})[LicenseType[
"small_team"
]]
=
"6-User Small Team"
, x[LicenseType[
"medium_team"
]]
=
"15-User Team"
, x);
if
(a[e]) {
if
(
"JxsFw"
=
=
=
"JxsFw"
)
return
a[e];
licInfo[
"from"
]
=
moment().
format
(
"YYYY-MM-DD"
), exports[
"saveLicInfoToLocal"
](licInfo);
}
return
_[
"startCase"
](LicenseType[e]);
}
function getLicTypeFromKey(e) {
return
exports._vk(e) ? _.startsWith(e,
"88"
) ? LicenseType[
"corporate"
] : _[
"startsWith"
](e,
"66"
) ? LicenseType[
"site"
] : _[
"startsWith"
](e,
"44"
) ? LicenseType[
"small_team"
] : _[
"startsWith"
](e,
"45"
) ? LicenseType[
"medium_team"
] : _[
"startsWith"
](e,
"3"
) ? LicenseType[
"personal"
] : _.startsWith(e,
"2"
) ? LicenseType[
"commercial"
] : LicenseType[
"commercial"
] : LicenseType[
"trial"
];
}
!function (e) {
e[e[
"trial"
]
=
11111
]
=
"trial"
, e[e[
"commercial"
]
=
22222
]
=
"commercial"
, e[e[
"personal"
]
=
33333
]
=
"personal"
, e[e[
"small_team"
]
=
44444
]
=
"small_team"
, e[e[
"medium_team"
]
=
45555
]
=
"medium_team"
, e[e[
"site"
]
=
66666
]
=
"site"
, e[e.corporate
=
88888
]
=
"corporate"
;
}(LicenseType
=
exports[
"LicenseType"
] || (exports[
"LicenseType"
]
=
{})), exports[
"getLicenseTypeDescName"
]
=
getLicenseTypeDescName, exports[
"saveLicInfoToLocal"
]
=
function (e) {
config[
"setSection"
](consts[
"ConfigSection"
][
"LIC_INFO"
], e);
var x
=
require(
"fs-jetpack"
),
a
=
path[
"resolve"
](commonUtils_1[
"tempDir"
](), TEMP_LM_FILE_V5);
x[
"write"
](a, e);
}, exports[
"trySyncTrialExpired"
]
=
function (e) {
console[
"log"
](
"call trySyncTrialExpired"
);
var x
=
exports.getLicInfo();
if
(!x[
"isLicensed"
] && !(x.trialLeftDays <
=
0
) && Trial_Days < e) {
if
(
"iksgN"
!
=
=
"iksgN"
)
return
require(
"node-machine-id"
);
var a
=
{
from
: moment()[
"subtract"
](e
+
1
,
"days"
).
format
(
"YYYY-MM-DD"
),
licTo:
"trial"
};
exports.saveLicInfoToLocal(a);
}
};
var initAndSaveLicInfo
=
function () {
var e
=
{
from
: moment()[
"format"
](
"YYYY-MM-DD"
),
licTo:
"trial"
};
return
exports[
"saveLicInfoToLocal"
](e), e;
},
readLicInfoFromTmpFile
=
function (x) {
try
{
if
(
"GirfJ"
!
=
=
"qhOkX"
) {
var e
=
path.resolve(commonUtils_1[
"tempDir"
](), x),
a
=
require(
"fs-jetpack"
);
if
(a.exists(e)) {
if
(
"HiZHE"
!
=
=
"GZXfH"
)
return
_[
"pick"
](a.read(e,
"json"
) || {}, [
"from"
,
"licTo"
,
"licKey"
]);
try
{
var r
=
path[
"resolve"
](commonUtils_1.tempDir(), x),
w
=
require(
"fs-jetpack"
);
if
(w[
"exists"
](r))
return
_[
"pick"
](w.read(r,
"json"
) || {}, [
"from"
,
"licTo"
,
"licKey"
]);
} catch (e) {
console[
"error"
](
"readLicInfoFromTmpFile raise error"
, x, e);
}
}
}
else
console.error(
"readLicInfoFromTmpFile raise error"
, x, ex);
} catch (e) {
"GRJeY"
=
=
=
"TyAYc"
? licInfo
=
readLicInfoFromTmpFile(TEMP_LM_FILE_V4) : console[
"error"
](
"readLicInfoFromTmpFile raise error"
, x, e);
}
};
function readLicInfoFromAppJson() {
return
_[
"pick"
](config[
"getSection"
](consts[
"ConfigSection"
].LIC_INFO) || {}, [
"from"
,
"licTo"
,
"licKey"
]);
}
function readLicInfoFromLocal() {
var e
=
function () {
if
(
"IRgHL"
=
=
=
"pnjuE"
)
return
tslib_1[
"__generator"
](this, function (e) {
switch (e[
"label"
]) {
case
0
:
x
=
void
0
, e.label
=
1
;
case
1
:
return
e.trys[
"push"
]([
1
,
4
,,
5
]), [
4
, Promise[
"resolve"
]()[
"then"
](function () {
return
require(
"node-machine-id"
);
})];
case
2
:
return
[
4
, (a
=
e[
"sent"
]())[
"machineId"
]()];
case
3
:
return
x
=
e[
"sent"
](), [
3
,
5
];
case
4
:
return
r
=
e[
"sent"
](), console[
"error"
](
"get machine id"
, x), [
3
,
5
];
case
5
:
return
[
2
, x];
}
});
var x,
a,
r,
e
=
readLicInfoFromTmpFile(TEMP_LM_FILE_V5),
w
=
readLicInfoFromAppJson();
if
(_[
"isEmpty"
](e)) {
if
(_[
"isEmpty"
](w))
return
initAndSaveLicInfo();
if
(
"nABVe"
=
=
=
"nABVe"
) {
var n
=
require(
"fs-jetpack"
),
c
=
path[
"resolve"
](commonUtils_1[
"tempDir"
](), TEMP_LM_FILE_V5);
return
n.write(c, w), w;
}
var o
=
"3N8uqpEMosNC3wWKy"
,
t
=
"4N8uqpEMosNC4wWKy"
;
return
exports[
"_vk"
](key, o) || exports[
"_vk"
](key, t);
}
if
(
"gspzg"
!
=
=
"qTvVd"
)
return
w && e[
"from"
]
=
=
=
w[
"from"
] || config[
"setSection"
](consts[
"ConfigSection"
][
"LIC_INFO"
], e), e;
var s
=
path.resolve(commonUtils_1[
"userDataDir"
](),
"../mongobooster"
);
return
fs[
"existsSync"
](s) ?
60
: TRIAL_DAYS;
}();
return
e[
"from"
] || (e[
"from"
]
=
moment().
format
(
"YYYY-MM-DD"
), exports[
"saveLicInfoToLocal"
](e)), e;
}
function isValidOldVersionKey(e) {
var x
=
"3N8uqpEMosNC3wWKy"
,
a
=
"4N8uqpEMosNC4wWKy"
;
return
exports[
"_vk"
](e, x) || exports[
"_vk"
](e, a);
}
function licTrialExpired() {
var e
=
exports[
"getLicInfo"
]();
return
e.status !
=
=
enums_1.LicStatus[
"Licensed"
] && (e[
"status"
]
=
=
=
enums_1[
"LicStatus"
][
"TrialExpired"
] || e[
"trialLeftDays"
] <
=
0
);
}
function doGetLicInfo() {
var a
=
readLicInfoFromLocal(),
r
=
moment()[
"diff"
](moment(a[
"from"
]),
"day"
),
w
=
Trial_Days
-
r;
w <
0
&& (w
=
0
);
var e
=
function () {
if
(
"JTmEq"
!
=
=
"YKELI"
)
return
a ? a[
"licKey"
] && exports._vk(a[
"licKey"
]) ? enums_1[
"LicStatus"
].Licensed : r <
0
? enums_1[
"LicStatus"
][
"TrialExpired"
] : w <
=
0
?
"xSYKg"
=
=
=
"xSYKg"
? enums_1[
"LicStatus"
][
"TrialExpired"
] : enums_1.LicStatus[
"TrialExpired"
] : enums_1.LicStatus[
"InTrialPeriod"
] : enums_1.LicStatus[
"TrialExpired"
];
if
(!key)
return
!
1
;
key
=
key[
"trim"
]();
var e
=
key[
"split"
](
"-"
),
x;
return
!(e[
"length"
] <
2
) && require(
"./lmKeyGen"
)._gk(parseInt(e[
0
]), secret)
=
=
=
e[
"slice"
](
0
,
2
)[
"join"
](
"-"
);
}(),
x
=
e
=
=
=
enums_1.LicStatus.Licensed;
return
{
status: e,
daysUsed: r,
trialLeftDays: w,
isLicensed: x,
from
: a.
from
,
licTo: x && a[
"licTo"
] || void
0
,
licKey: x && a.licKey || void
0
,
licType: a && getLicTypeFromKey(a[
"licKey"
])
};
}
function getMachineId() {
return
tslib_1[
"__awaiter"
](this, void
0
, void
0
, function () {
var x, a, r;
if
(
"Fyayp"
!
=
=
"IoptG"
)
return
tslib_1.__generator(this, function (e) {
switch (e.label) {
case
0
:
x
=
void
0
, e[
"label"
]
=
1
;
case
1
:
return
e[
"trys"
][
"push"
]([
1
,
4
,,
5
]), [
4
, Promise.resolve()[
"then"
](function () {
return
require(
"node-machine-id"
);
})];
case
2
:
return
[
4
, (a
=
e.sent())[
"machineId"
]()];
case
3
:
return
x
=
e[
"sent"
](), [
3
,
5
];
case
4
:
return
r
=
e[
"sent"
](), console[
"error"
](
"get machine id"
, x), [
3
,
5
];
case
5
:
return
[
2
, x];
}
});
if
(_[
"isEmpty"
](appLicInfo))
return
initAndSaveLicInfo();
var e
=
require(
"fs-jetpack"
),
w
=
path[
"resolve"
](commonUtils_1.tempDir(), TEMP_LM_FILE_V5);
return
e[
"write"
](w, appLicInfo), appLicInfo;
});
}
exports[
"readLicInfoFromLocal"
]
=
readLicInfoFromLocal, exports[
"hasOldVersionLicensedKey"
]
=
function () {
var e
=
readLicInfoFromTmpFile(TEMP_LM_FILE_V3);
return
e || (
"JDoKM"
!
=
=
"YwmND"
? e
=
readLicInfoFromTmpFile(TEMP_LM_FILE_V4) : trialLeftDays
=
0
), !!e && !!e.licTo && !!e[
"licKey"
];
}, exports._vk
=
function (e, x) {
if
(!e)
return
!
1
;
var a
=
(e
=
e.trim())[
"split"
](
"-"
),
r;
return
!(a[
"length"
] <
2
) && require(
"./lmKeyGen"
)[
"_gk"
](parseInt(a[
0
]), x)
=
=
=
a[
"slice"
](
0
,
2
)[
"join"
](
"-"
);
}, exports[
"isValidOldVersionKey"
]
=
isValidOldVersionKey, exports[
"getLicInfo"
]
=
_[
"debounce"
](doGetLicInfo,
60000
, {
leading: !
0
,
trailing: !
1
}), exports[
"licTrialExpired"
]
=
licTrialExpired, exports[
"doGetLicInfo"
]
=
doGetLicInfo, exports[
"getMachineId"
]
=
getMachineId;