@mui/x-license 7.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7295 -0
- package/LICENSE +11 -0
- package/README.md +3 -0
- package/Unstable_LicenseInfoProvider/LicenseInfoContext.d.ts +4 -0
- package/Unstable_LicenseInfoProvider/LicenseInfoContext.js +4 -0
- package/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts +13 -0
- package/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +19 -0
- package/Unstable_LicenseInfoProvider/index.d.ts +2 -0
- package/Unstable_LicenseInfoProvider/index.js +1 -0
- package/Unstable_LicenseInfoProvider/package.json +6 -0
- package/Watermark/Watermark.d.ts +8 -0
- package/Watermark/Watermark.js +46 -0
- package/Watermark/index.d.ts +1 -0
- package/Watermark/index.js +1 -0
- package/Watermark/package.json +6 -0
- package/encoding/base64.d.ts +2 -0
- package/encoding/base64.js +57 -0
- package/encoding/md5.d.ts +1 -0
- package/encoding/md5.js +42 -0
- package/generateLicense/generateLicense.d.ts +9 -0
- package/generateLicense/generateLicense.js +18 -0
- package/generateLicense/index.d.ts +1 -0
- package/generateLicense/index.js +1 -0
- package/generateLicense/package.json +6 -0
- package/index.d.ts +6 -0
- package/index.js +13 -0
- package/legacy/Unstable_LicenseInfoProvider/LicenseInfoContext.js +4 -0
- package/legacy/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +18 -0
- package/legacy/Unstable_LicenseInfoProvider/index.js +1 -0
- package/legacy/Watermark/Watermark.js +44 -0
- package/legacy/Watermark/index.js +1 -0
- package/legacy/encoding/base64.js +57 -0
- package/legacy/encoding/md5.js +42 -0
- package/legacy/generateLicense/generateLicense.js +18 -0
- package/legacy/generateLicense/index.js +1 -0
- package/legacy/index.js +13 -0
- package/legacy/useLicenseVerifier/index.js +1 -0
- package/legacy/useLicenseVerifier/useLicenseVerifier.js +59 -0
- package/legacy/utils/index.js +4 -0
- package/legacy/utils/licenseErrorMessageUtils.js +31 -0
- package/legacy/utils/licenseInfo.js +40 -0
- package/legacy/utils/licenseScope.js +1 -0
- package/legacy/utils/licenseStatus.js +11 -0
- package/legacy/utils/licensingModel.js +15 -0
- package/legacy/verifyLicense/index.js +1 -0
- package/legacy/verifyLicense/verifyLicense.js +167 -0
- package/modern/Unstable_LicenseInfoProvider/LicenseInfoContext.js +4 -0
- package/modern/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +19 -0
- package/modern/Unstable_LicenseInfoProvider/index.js +1 -0
- package/modern/Watermark/Watermark.js +46 -0
- package/modern/Watermark/index.js +1 -0
- package/modern/encoding/base64.js +57 -0
- package/modern/encoding/md5.js +42 -0
- package/modern/generateLicense/generateLicense.js +18 -0
- package/modern/generateLicense/index.js +1 -0
- package/modern/index.js +13 -0
- package/modern/useLicenseVerifier/index.js +1 -0
- package/modern/useLicenseVerifier/useLicenseVerifier.js +60 -0
- package/modern/utils/index.js +4 -0
- package/modern/utils/licenseErrorMessageUtils.js +34 -0
- package/modern/utils/licenseInfo.js +27 -0
- package/modern/utils/licenseScope.js +1 -0
- package/modern/utils/licenseStatus.js +11 -0
- package/modern/utils/licensingModel.js +15 -0
- package/modern/verifyLicense/index.js +1 -0
- package/modern/verifyLicense/verifyLicense.js +159 -0
- package/node/Unstable_LicenseInfoProvider/LicenseInfoContext.js +12 -0
- package/node/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +28 -0
- package/node/Unstable_LicenseInfoProvider/index.js +12 -0
- package/node/Watermark/Watermark.js +54 -0
- package/node/Watermark/index.js +16 -0
- package/node/encoding/base64.js +65 -0
- package/node/encoding/md5.js +48 -0
- package/node/generateLicense/generateLicense.js +24 -0
- package/node/generateLicense/index.js +16 -0
- package/node/index.js +78 -0
- package/node/useLicenseVerifier/index.js +12 -0
- package/node/useLicenseVerifier/useLicenseVerifier.js +70 -0
- package/node/utils/index.js +38 -0
- package/node/utils/licenseErrorMessageUtils.js +45 -0
- package/node/utils/licenseInfo.js +33 -0
- package/node/utils/licenseScope.js +7 -0
- package/node/utils/licenseStatus.js +17 -0
- package/node/utils/licensingModel.js +21 -0
- package/node/verifyLicense/index.js +16 -0
- package/node/verifyLicense/verifyLicense.js +166 -0
- package/package.json +42 -0
- package/useLicenseVerifier/index.d.ts +2 -0
- package/useLicenseVerifier/index.js +1 -0
- package/useLicenseVerifier/package.json +6 -0
- package/useLicenseVerifier/useLicenseVerifier.d.ts +13 -0
- package/useLicenseVerifier/useLicenseVerifier.js +60 -0
- package/utils/index.d.ts +5 -0
- package/utils/index.js +4 -0
- package/utils/licenseErrorMessageUtils.d.ts +19 -0
- package/utils/licenseErrorMessageUtils.js +34 -0
- package/utils/licenseInfo.d.ts +11 -0
- package/utils/licenseInfo.js +27 -0
- package/utils/licenseScope.d.ts +2 -0
- package/utils/licenseScope.js +1 -0
- package/utils/licenseStatus.d.ts +10 -0
- package/utils/licenseStatus.js +11 -0
- package/utils/licensingModel.d.ts +2 -0
- package/utils/licensingModel.js +15 -0
- package/utils/package.json +6 -0
- package/verifyLicense/index.d.ts +1 -0
- package/verifyLicense/index.js +1 -0
- package/verifyLicense/package.json +6 -0
- package/verifyLicense/verifyLicense.d.ts +11 -0
- package/verifyLicense/verifyLicense.js +159 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import { ponyfillGlobal } from '@mui/utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @ignore - do not document.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Store the license information in a global, so it can be shared
|
|
10
|
+
// when module duplication occurs. The duplication of the modules can happen
|
|
11
|
+
// if using multiple version of MUI X at the same time of the bundler
|
|
12
|
+
// decide to duplicate to improve the size of the chunks.
|
|
13
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
14
|
+
ponyfillGlobal.__MUI_LICENSE_INFO__ = ponyfillGlobal.__MUI_LICENSE_INFO__ || {
|
|
15
|
+
key: undefined
|
|
16
|
+
};
|
|
17
|
+
export var LicenseInfo = /*#__PURE__*/function () {
|
|
18
|
+
function LicenseInfo() {
|
|
19
|
+
_classCallCheck(this, LicenseInfo);
|
|
20
|
+
}
|
|
21
|
+
_createClass(LicenseInfo, null, [{
|
|
22
|
+
key: "getLicenseInfo",
|
|
23
|
+
value: function getLicenseInfo() {
|
|
24
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
25
|
+
return ponyfillGlobal.__MUI_LICENSE_INFO__;
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
key: "getLicenseKey",
|
|
29
|
+
value: function getLicenseKey() {
|
|
30
|
+
return LicenseInfo.getLicenseInfo().key;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "setLicenseKey",
|
|
34
|
+
value: function setLicenseKey(key) {
|
|
35
|
+
var licenseInfo = LicenseInfo.getLicenseInfo();
|
|
36
|
+
licenseInfo.key = key;
|
|
37
|
+
}
|
|
38
|
+
}]);
|
|
39
|
+
return LicenseInfo;
|
|
40
|
+
}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var LICENSE_SCOPES = ['pro', 'premium'];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2
|
+
export var LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STATUS) {
|
|
3
|
+
LICENSE_STATUS["NotFound"] = "NotFound";
|
|
4
|
+
LICENSE_STATUS["Invalid"] = "Invalid";
|
|
5
|
+
LICENSE_STATUS["ExpiredAnnual"] = "ExpiredAnnual";
|
|
6
|
+
LICENSE_STATUS["ExpiredAnnualGrace"] = "ExpiredAnnualGrace";
|
|
7
|
+
LICENSE_STATUS["ExpiredVersion"] = "ExpiredVersion";
|
|
8
|
+
LICENSE_STATUS["Valid"] = "Valid";
|
|
9
|
+
LICENSE_STATUS["OutOfScope"] = "OutOfScope";
|
|
10
|
+
return LICENSE_STATUS;
|
|
11
|
+
}({});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var LICENSING_MODELS = [
|
|
2
|
+
/**
|
|
3
|
+
* A license is outdated if the current version of the software was released after the expiry date of the license.
|
|
4
|
+
* But the license can be used indefinitely with an older version of the software.
|
|
5
|
+
*/
|
|
6
|
+
'perpetual',
|
|
7
|
+
/**
|
|
8
|
+
* On development, a license is outdated if the expiry date has been reached
|
|
9
|
+
* On production, a license is outdated if the current version of the software was released after the expiry date of the license (see "perpetual")
|
|
10
|
+
*/
|
|
11
|
+
'annual',
|
|
12
|
+
/**
|
|
13
|
+
* TODO 2025 remove, legacy name of annual.
|
|
14
|
+
*/
|
|
15
|
+
'subscription'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './verifyLicense';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { base64Decode, base64Encode } from '../encoding/base64';
|
|
3
|
+
import { md5 } from '../encoding/md5';
|
|
4
|
+
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
5
|
+
import { LICENSE_SCOPES } from '../utils/licenseScope';
|
|
6
|
+
import { LICENSING_MODELS } from '../utils/licensingModel';
|
|
7
|
+
var getDefaultReleaseDate = function getDefaultReleaseDate() {
|
|
8
|
+
var today = new Date();
|
|
9
|
+
today.setHours(0, 0, 0, 0);
|
|
10
|
+
return today;
|
|
11
|
+
};
|
|
12
|
+
export function generateReleaseInfo() {
|
|
13
|
+
var releaseDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultReleaseDate();
|
|
14
|
+
return base64Encode(releaseDate.getTime().toString());
|
|
15
|
+
}
|
|
16
|
+
var expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
|
|
17
|
+
/**
|
|
18
|
+
* Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
|
|
19
|
+
*/
|
|
20
|
+
var decodeLicenseVersion1 = function decodeLicenseVersion1(license) {
|
|
21
|
+
var expiryTimestamp;
|
|
22
|
+
try {
|
|
23
|
+
expiryTimestamp = parseInt(license.match(expiryReg)[1], 10);
|
|
24
|
+
if (!expiryTimestamp || Number.isNaN(expiryTimestamp)) {
|
|
25
|
+
expiryTimestamp = null;
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
expiryTimestamp = null;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
scope: 'pro',
|
|
32
|
+
licensingModel: 'perpetual',
|
|
33
|
+
expiryTimestamp: expiryTimestamp
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},KV=2`;
|
|
39
|
+
*/
|
|
40
|
+
var decodeLicenseVersion2 = function decodeLicenseVersion2(license) {
|
|
41
|
+
var licenseInfo = {
|
|
42
|
+
scope: null,
|
|
43
|
+
licensingModel: null,
|
|
44
|
+
expiryTimestamp: null
|
|
45
|
+
};
|
|
46
|
+
license.split(',').map(function (token) {
|
|
47
|
+
return token.split('=');
|
|
48
|
+
}).filter(function (el) {
|
|
49
|
+
return el.length === 2;
|
|
50
|
+
}).forEach(function (_ref) {
|
|
51
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
52
|
+
key = _ref2[0],
|
|
53
|
+
value = _ref2[1];
|
|
54
|
+
if (key === 'S') {
|
|
55
|
+
licenseInfo.scope = value;
|
|
56
|
+
}
|
|
57
|
+
if (key === 'LM') {
|
|
58
|
+
licenseInfo.licensingModel = value;
|
|
59
|
+
}
|
|
60
|
+
if (key === 'E') {
|
|
61
|
+
var expiryTimestamp = parseInt(value, 10);
|
|
62
|
+
if (expiryTimestamp && !Number.isNaN(expiryTimestamp)) {
|
|
63
|
+
licenseInfo.expiryTimestamp = expiryTimestamp;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return licenseInfo;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Decode the license based on its key version and return a version-agnostic `MuiLicense` object.
|
|
72
|
+
*/
|
|
73
|
+
var decodeLicense = function decodeLicense(encodedLicense) {
|
|
74
|
+
var license = base64Decode(encodedLicense);
|
|
75
|
+
if (license.includes('KEYVERSION=1')) {
|
|
76
|
+
return decodeLicenseVersion1(license);
|
|
77
|
+
}
|
|
78
|
+
if (license.includes('KV=2')) {
|
|
79
|
+
return decodeLicenseVersion2(license);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
export function verifyLicense(_ref3) {
|
|
84
|
+
var releaseInfo = _ref3.releaseInfo,
|
|
85
|
+
licenseKey = _ref3.licenseKey,
|
|
86
|
+
acceptedScopes = _ref3.acceptedScopes;
|
|
87
|
+
if (!releaseInfo) {
|
|
88
|
+
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
89
|
+
}
|
|
90
|
+
if (!licenseKey) {
|
|
91
|
+
return {
|
|
92
|
+
status: LICENSE_STATUS.NotFound
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
var hash = licenseKey.substr(0, 32);
|
|
96
|
+
var encoded = licenseKey.substr(32);
|
|
97
|
+
if (hash !== md5(encoded)) {
|
|
98
|
+
return {
|
|
99
|
+
status: LICENSE_STATUS.Invalid
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
var license = decodeLicense(encoded);
|
|
103
|
+
if (license == null) {
|
|
104
|
+
console.error('MUI X: Error checking license. Key version not found!');
|
|
105
|
+
return {
|
|
106
|
+
status: LICENSE_STATUS.Invalid
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (license.licensingModel == null || !LICENSING_MODELS.includes(license.licensingModel)) {
|
|
110
|
+
console.error('MUI X: Error checking license. Licensing model not found or invalid!');
|
|
111
|
+
return {
|
|
112
|
+
status: LICENSE_STATUS.Invalid
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (license.expiryTimestamp == null) {
|
|
116
|
+
console.error('MUI X: Error checking license. Expiry timestamp not found or invalid!');
|
|
117
|
+
return {
|
|
118
|
+
status: LICENSE_STATUS.Invalid
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (license.licensingModel === 'perpetual' || process.env.NODE_ENV === 'production') {
|
|
122
|
+
var pkgTimestamp = parseInt(base64Decode(releaseInfo), 10);
|
|
123
|
+
if (Number.isNaN(pkgTimestamp)) {
|
|
124
|
+
throw new Error('MUI X: The release information is invalid. Not able to validate license.');
|
|
125
|
+
}
|
|
126
|
+
if (license.expiryTimestamp < pkgTimestamp) {
|
|
127
|
+
return {
|
|
128
|
+
status: LICENSE_STATUS.ExpiredVersion
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
} else if (license.licensingModel === 'subscription' || license.licensingModel === 'annual') {
|
|
132
|
+
if (new Date().getTime() > license.expiryTimestamp) {
|
|
133
|
+
if (
|
|
134
|
+
// 30 days grace
|
|
135
|
+
new Date().getTime() < license.expiryTimestamp + 1000 * 3600 * 24 * 30 || process.env.NODE_ENV !== 'development') {
|
|
136
|
+
return {
|
|
137
|
+
status: LICENSE_STATUS.ExpiredAnnualGrace,
|
|
138
|
+
meta: {
|
|
139
|
+
expiryTimestamp: license.expiryTimestamp,
|
|
140
|
+
licenseKey: licenseKey
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
status: LICENSE_STATUS.ExpiredAnnual,
|
|
146
|
+
meta: {
|
|
147
|
+
expiryTimestamp: license.expiryTimestamp,
|
|
148
|
+
licenseKey: licenseKey
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (license.scope == null || !LICENSE_SCOPES.includes(license.scope)) {
|
|
154
|
+
console.error('Error checking license. scope not found or invalid!');
|
|
155
|
+
return {
|
|
156
|
+
status: LICENSE_STATUS.Invalid
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!acceptedScopes.includes(license.scope)) {
|
|
160
|
+
return {
|
|
161
|
+
status: LICENSE_STATUS.OutOfScope
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
status: LICENSE_STATUS.Valid
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import LicenseInfoContext from './LicenseInfoContext';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ignore - do not document.
|
|
6
|
+
*/
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* @ignore - do not document.
|
|
10
|
+
*/
|
|
11
|
+
export function LicenseInfoProvider({
|
|
12
|
+
info,
|
|
13
|
+
children
|
|
14
|
+
}) {
|
|
15
|
+
return /*#__PURE__*/_jsx(LicenseInfoContext.Provider, {
|
|
16
|
+
value: info,
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LicenseInfoProvider as Unstable_LicenseInfoProvider } from './LicenseInfoProvider';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLicenseVerifier } from '../useLicenseVerifier';
|
|
3
|
+
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
function getLicenseErrorMessage(licenseStatus) {
|
|
6
|
+
switch (licenseStatus) {
|
|
7
|
+
case LICENSE_STATUS.ExpiredAnnualGrace:
|
|
8
|
+
case LICENSE_STATUS.ExpiredAnnual:
|
|
9
|
+
return 'MUI X Expired license key';
|
|
10
|
+
case LICENSE_STATUS.ExpiredVersion:
|
|
11
|
+
return 'MUI X Expired package version';
|
|
12
|
+
case LICENSE_STATUS.Invalid:
|
|
13
|
+
return 'MUI X Invalid license key';
|
|
14
|
+
case LICENSE_STATUS.OutOfScope:
|
|
15
|
+
return 'MUI X License key plan mismatch';
|
|
16
|
+
case LICENSE_STATUS.NotFound:
|
|
17
|
+
return 'MUI X Missing license key';
|
|
18
|
+
default:
|
|
19
|
+
throw new Error('Unhandled MUI X license status.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function Watermark(props) {
|
|
23
|
+
const {
|
|
24
|
+
packageName,
|
|
25
|
+
releaseInfo
|
|
26
|
+
} = props;
|
|
27
|
+
const licenseStatus = useLicenseVerifier(packageName, releaseInfo);
|
|
28
|
+
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/_jsx("div", {
|
|
32
|
+
style: {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
pointerEvents: 'none',
|
|
35
|
+
color: '#8282829e',
|
|
36
|
+
zIndex: 100000,
|
|
37
|
+
width: '100%',
|
|
38
|
+
textAlign: 'center',
|
|
39
|
+
bottom: '50%',
|
|
40
|
+
right: 0,
|
|
41
|
+
letterSpacing: 5,
|
|
42
|
+
fontSize: 24
|
|
43
|
+
},
|
|
44
|
+
children: getLicenseErrorMessage(licenseStatus.status)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Watermark';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
const _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
3
|
+
function utf8Encode(str) {
|
|
4
|
+
for (let n = 0; n < str.length; n++) {
|
|
5
|
+
const c = str.charCodeAt(n);
|
|
6
|
+
if (c >= 128) {
|
|
7
|
+
throw new Error('ASCII only support');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
export const base64Decode = input => {
|
|
13
|
+
let output = '';
|
|
14
|
+
let chr1, chr2, chr3;
|
|
15
|
+
let enc1, enc2, enc3, enc4;
|
|
16
|
+
let i = 0;
|
|
17
|
+
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
|
18
|
+
while (i < input.length) {
|
|
19
|
+
enc1 = _keyStr.indexOf(input.charAt(i++));
|
|
20
|
+
enc2 = _keyStr.indexOf(input.charAt(i++));
|
|
21
|
+
enc3 = _keyStr.indexOf(input.charAt(i++));
|
|
22
|
+
enc4 = _keyStr.indexOf(input.charAt(i++));
|
|
23
|
+
chr1 = enc1 << 2 | enc2 >> 4;
|
|
24
|
+
chr2 = (enc2 & 15) << 4 | enc3 >> 2;
|
|
25
|
+
chr3 = (enc3 & 3) << 6 | enc4;
|
|
26
|
+
output = output + String.fromCharCode(chr1);
|
|
27
|
+
if (enc3 != 64) {
|
|
28
|
+
output = output + String.fromCharCode(chr2);
|
|
29
|
+
}
|
|
30
|
+
if (enc4 != 64) {
|
|
31
|
+
output = output + String.fromCharCode(chr3);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
};
|
|
36
|
+
export const base64Encode = input => {
|
|
37
|
+
let output = '';
|
|
38
|
+
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
39
|
+
let i = 0;
|
|
40
|
+
input = utf8Encode(input);
|
|
41
|
+
while (i < input.length) {
|
|
42
|
+
chr1 = input.charCodeAt(i++);
|
|
43
|
+
chr2 = input.charCodeAt(i++);
|
|
44
|
+
chr3 = input.charCodeAt(i++);
|
|
45
|
+
enc1 = chr1 >> 2;
|
|
46
|
+
enc2 = (chr1 & 3) << 4 | chr2 >> 4;
|
|
47
|
+
enc3 = (chr2 & 15) << 2 | chr3 >> 6;
|
|
48
|
+
enc4 = chr3 & 63;
|
|
49
|
+
if (isNaN(chr2)) {
|
|
50
|
+
enc3 = enc4 = 64;
|
|
51
|
+
} else if (isNaN(chr3)) {
|
|
52
|
+
enc4 = 64;
|
|
53
|
+
}
|
|
54
|
+
output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
|
55
|
+
}
|
|
56
|
+
return output;
|
|
57
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// See "precomputation" in notes
|
|
3
|
+
const k = [];
|
|
4
|
+
let i = 0;
|
|
5
|
+
for (; i < 64;) {
|
|
6
|
+
k[i] = 0 | Math.sin(++i % Math.PI) * 4294967296;
|
|
7
|
+
// k[i] = 0 | (Math.abs(Math.sin(++i)) * 4294967296);
|
|
8
|
+
}
|
|
9
|
+
export function md5(s) {
|
|
10
|
+
const words = [];
|
|
11
|
+
let b,
|
|
12
|
+
c,
|
|
13
|
+
d,
|
|
14
|
+
j = unescape(encodeURI(s)) + '\x80',
|
|
15
|
+
a = j.length;
|
|
16
|
+
const h = [b = 0x67452301, c = 0xefcdab89, ~b, ~c];
|
|
17
|
+
s = --a / 4 + 2 | 15;
|
|
18
|
+
|
|
19
|
+
// See "Length bits" in notes
|
|
20
|
+
words[--s] = a * 8;
|
|
21
|
+
for (; ~a;) {
|
|
22
|
+
// a !== -1
|
|
23
|
+
words[a >> 2] |= j.charCodeAt(a) << 8 * a--;
|
|
24
|
+
}
|
|
25
|
+
for (i = j = 0; i < s; i += 16) {
|
|
26
|
+
a = h;
|
|
27
|
+
for (; j < 64; a = [d = a[3], b + ((d = a[0] + [b & c | ~b & d, d & b | ~d & c, b ^ c ^ d, c ^ (b | ~d)][a = j >> 4] + k[j] + ~~words[i | [j, 5 * j + 1, 3 * j + 5, 7 * j][a] & 15]) << (a = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21][4 * a + j++ % 4]) | d >>> -a), b, c]) {
|
|
28
|
+
b = a[1] | 0;
|
|
29
|
+
c = a[2];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// See "Integer safety" in notes
|
|
33
|
+
for (j = 4; j;) h[--j] += a[j];
|
|
34
|
+
|
|
35
|
+
// j === 0
|
|
36
|
+
}
|
|
37
|
+
for (s = ''; j < 32;) {
|
|
38
|
+
s += (h[j >> 3] >> (1 ^ j++) * 4 & 15).toString(16);
|
|
39
|
+
// s += ((h[j >> 3] >> (4 ^ 4 * j++)) & 15).toString(16);
|
|
40
|
+
}
|
|
41
|
+
return s;
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { md5 } from '../encoding/md5';
|
|
2
|
+
import { base64Encode } from '../encoding/base64';
|
|
3
|
+
import { LICENSE_SCOPES } from '../utils/licenseScope';
|
|
4
|
+
import { LICENSING_MODELS } from '../utils/licensingModel';
|
|
5
|
+
const licenseVersion = '2';
|
|
6
|
+
function getClearLicenseString(details) {
|
|
7
|
+
if (details.scope && !LICENSE_SCOPES.includes(details.scope)) {
|
|
8
|
+
throw new Error('MUI X: Invalid scope');
|
|
9
|
+
}
|
|
10
|
+
if (details.licensingModel && !LICENSING_MODELS.includes(details.licensingModel)) {
|
|
11
|
+
throw new Error('MUI X: Invalid licensing model');
|
|
12
|
+
}
|
|
13
|
+
return `O=${details.orderNumber},E=${details.expiryDate.getTime()},S=${details.scope},LM=${details.licensingModel},KV=${licenseVersion}`;
|
|
14
|
+
}
|
|
15
|
+
export function generateLicense(details) {
|
|
16
|
+
const licenseStr = getClearLicenseString(details);
|
|
17
|
+
return `${md5(base64Encode(licenseStr))}${base64Encode(licenseStr)}`;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generateLicense';
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mui/x-license v7.0.0-beta.2
|
|
3
|
+
*
|
|
4
|
+
* @license MUI X Commercial
|
|
5
|
+
* This source code is licensed under the commercial license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export * from './generateLicense';
|
|
9
|
+
export * from './utils';
|
|
10
|
+
export * from './verifyLicense';
|
|
11
|
+
export * from './useLicenseVerifier';
|
|
12
|
+
export * from './Watermark';
|
|
13
|
+
export * from './Unstable_LicenseInfoProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLicenseVerifier } from './useLicenseVerifier';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { verifyLicense } from '../verifyLicense/verifyLicense';
|
|
4
|
+
import { LicenseInfo } from '../utils/licenseInfo';
|
|
5
|
+
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError } from '../utils/licenseErrorMessageUtils';
|
|
6
|
+
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
7
|
+
import LicenseInfoContext from '../Unstable_LicenseInfoProvider/LicenseInfoContext';
|
|
8
|
+
export const sharedLicenseStatuses = {};
|
|
9
|
+
export function useLicenseVerifier(packageName, releaseInfo) {
|
|
10
|
+
const {
|
|
11
|
+
key: contextKey
|
|
12
|
+
} = React.useContext(LicenseInfoContext);
|
|
13
|
+
return React.useMemo(() => {
|
|
14
|
+
const licenseKey = contextKey ?? LicenseInfo.getLicenseKey();
|
|
15
|
+
|
|
16
|
+
// Cache the response to not trigger the error twice.
|
|
17
|
+
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
18
|
+
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
19
|
+
}
|
|
20
|
+
const acceptedScopes = packageName.includes('premium') ? ['premium'] : ['pro', 'premium'];
|
|
21
|
+
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
22
|
+
const licenseStatus = verifyLicense({
|
|
23
|
+
releaseInfo,
|
|
24
|
+
licenseKey,
|
|
25
|
+
acceptedScopes
|
|
26
|
+
});
|
|
27
|
+
const fullPackageName = `@mui/${packageName}`;
|
|
28
|
+
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
29
|
+
// Skip
|
|
30
|
+
} else if (licenseStatus.status === LICENSE_STATUS.Invalid) {
|
|
31
|
+
showInvalidLicenseKeyError();
|
|
32
|
+
} else if (licenseStatus.status === LICENSE_STATUS.OutOfScope) {
|
|
33
|
+
showLicenseKeyPlanMismatchError();
|
|
34
|
+
} else if (licenseStatus.status === LICENSE_STATUS.NotFound) {
|
|
35
|
+
showMissingLicenseKeyError({
|
|
36
|
+
plan,
|
|
37
|
+
packageName: fullPackageName
|
|
38
|
+
});
|
|
39
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredAnnualGrace) {
|
|
40
|
+
showExpiredAnnualGraceLicenseKeyError(_extends({
|
|
41
|
+
plan
|
|
42
|
+
}, licenseStatus.meta));
|
|
43
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredAnnual) {
|
|
44
|
+
showExpiredAnnualLicenseKeyError(_extends({
|
|
45
|
+
plan
|
|
46
|
+
}, licenseStatus.meta));
|
|
47
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredVersion) {
|
|
48
|
+
showExpiredPackageVersionError({
|
|
49
|
+
packageName: fullPackageName
|
|
50
|
+
});
|
|
51
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
52
|
+
throw new Error('missing status handler');
|
|
53
|
+
}
|
|
54
|
+
sharedLicenseStatuses[packageName] = {
|
|
55
|
+
key: licenseKey,
|
|
56
|
+
licenseVerifier: licenseStatus
|
|
57
|
+
};
|
|
58
|
+
return licenseStatus;
|
|
59
|
+
}, [packageName, releaseInfo, contextKey]);
|
|
60
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function showError(message) {
|
|
2
|
+
console.error(['*************************************************************', '', ...message, '', '*************************************************************'].join('\n'));
|
|
3
|
+
}
|
|
4
|
+
export function showInvalidLicenseKeyError() {
|
|
5
|
+
showError(['MUI X: Invalid license key.', '', "Your MUI X license key format isn't valid. It could be because the license key is missing a character or has a typo.", '', 'To solve the issue, you need to double check that `setLicenseKey()` is called with the right argument', 'Please check the license key installation https://mui.com/r/x-license-key-installation.']);
|
|
6
|
+
}
|
|
7
|
+
export function showLicenseKeyPlanMismatchError() {
|
|
8
|
+
showError(['MUI X: License key plan mismatch.', '', 'Your use of MUI X is not compatible with the plan of your license key. The feature you are trying to use is not included in the plan of your license key. This happens if you try to use `DataGridPremium` with a license key for the Pro plan.', '', 'To solve the issue, you can upgrade your plan from Pro to Premium at https://mui.com/r/x-get-license?scope=premium.', "Of if you didn't intend to use Premium features, you can replace the import of `@mui/x-data-grid-premium` with `@mui/x-data-grid-pro`."]);
|
|
9
|
+
}
|
|
10
|
+
export function showMissingLicenseKeyError({
|
|
11
|
+
plan,
|
|
12
|
+
packageName
|
|
13
|
+
}) {
|
|
14
|
+
showError(['MUI X: Missing license key.', '', `The license key is missing. You might not be allowed to use \`${packageName}\` which is part of MUI X ${plan}.`, '', 'To solve the issue, you can check the free trial conditions: https://mui.com/r/x-license-trial.', 'If you are eligible no actions are required. If you are not eligible to the free trial, you need to purchase a license https://mui.com/r/x-get-license or stop using the software immediately.']);
|
|
15
|
+
}
|
|
16
|
+
export function showExpiredPackageVersionError({
|
|
17
|
+
packageName
|
|
18
|
+
}) {
|
|
19
|
+
showError(['MUI X: Expired package version.', '', `You have installed a version of \`${packageName}\` that is outside of the maintenance plan of your license key. By default, commercial licenses provide access to new versions released during the first year after the purchase.`, '', 'To solve the issue, you can renew your license https://mui.com/r/x-get-license or install an older version of the npm package that is compatible with your license key.']);
|
|
20
|
+
}
|
|
21
|
+
export function showExpiredAnnualGraceLicenseKeyError({
|
|
22
|
+
plan,
|
|
23
|
+
licenseKey,
|
|
24
|
+
expiryTimestamp
|
|
25
|
+
}) {
|
|
26
|
+
showError(['MUI X: Expired license key.', '', `Your annual license key to use MUI X ${plan}'s on non-production environments is expired. If you are seeing this development console message, you might be close to breach the license terms by making direct or indirect changes to the frontend of an app that render a MUI X ${plan} component (more details in https://mui.com/r/x-license-annual).`, '', 'To solve the problem you can either:', '', '- Renew your license https://mui.com/r/x-get-license and use the new key', `- Stop making changes to code depending directly or indirectly on MUI X ${plan}'s APIs`, '', 'Note that your license is perpetual in production environments with any version released before your license term ends.', '', `- License key expiry timestamp: ${new Date(expiryTimestamp)}`, `- Installed license key: ${licenseKey}`, '']);
|
|
27
|
+
}
|
|
28
|
+
export function showExpiredAnnualLicenseKeyError({
|
|
29
|
+
plan,
|
|
30
|
+
licenseKey,
|
|
31
|
+
expiryTimestamp
|
|
32
|
+
}) {
|
|
33
|
+
throw new Error(['MUI X: Expired license key.', '', `Your annual license key to use MUI X ${plan}'s on non-production environments is expired. If you are seeing this development console message, you might be close to breach the license terms by making direct or indirect changes to the frontend of an app that render a MUI X ${plan} component (more details in https://mui.com/r/x-license-annual).`, '', 'To solve the problem you can either:', '', '- Renew your license https://mui.com/r/x-get-license and use the new key', `- Stop making changes to code depending directly or indirectly on MUI X ${plan}'s APIs`, '', 'Note that your license is perpetual in production environments with any version released before your license term ends.', '', `- License key expiry timestamp: ${new Date(expiryTimestamp)}`, `- Installed license key: ${licenseKey}`, ''].join('\n'));
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ponyfillGlobal } from '@mui/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ignore - do not document.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Store the license information in a global, so it can be shared
|
|
8
|
+
// when module duplication occurs. The duplication of the modules can happen
|
|
9
|
+
// if using multiple version of MUI X at the same time of the bundler
|
|
10
|
+
// decide to duplicate to improve the size of the chunks.
|
|
11
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
12
|
+
ponyfillGlobal.__MUI_LICENSE_INFO__ = ponyfillGlobal.__MUI_LICENSE_INFO__ || {
|
|
13
|
+
key: undefined
|
|
14
|
+
};
|
|
15
|
+
export class LicenseInfo {
|
|
16
|
+
static getLicenseInfo() {
|
|
17
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
18
|
+
return ponyfillGlobal.__MUI_LICENSE_INFO__;
|
|
19
|
+
}
|
|
20
|
+
static getLicenseKey() {
|
|
21
|
+
return LicenseInfo.getLicenseInfo().key;
|
|
22
|
+
}
|
|
23
|
+
static setLicenseKey(key) {
|
|
24
|
+
const licenseInfo = LicenseInfo.getLicenseInfo();
|
|
25
|
+
licenseInfo.key = key;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2
|
+
export let LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STATUS) {
|
|
3
|
+
LICENSE_STATUS["NotFound"] = "NotFound";
|
|
4
|
+
LICENSE_STATUS["Invalid"] = "Invalid";
|
|
5
|
+
LICENSE_STATUS["ExpiredAnnual"] = "ExpiredAnnual";
|
|
6
|
+
LICENSE_STATUS["ExpiredAnnualGrace"] = "ExpiredAnnualGrace";
|
|
7
|
+
LICENSE_STATUS["ExpiredVersion"] = "ExpiredVersion";
|
|
8
|
+
LICENSE_STATUS["Valid"] = "Valid";
|
|
9
|
+
LICENSE_STATUS["OutOfScope"] = "OutOfScope";
|
|
10
|
+
return LICENSE_STATUS;
|
|
11
|
+
}({});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const LICENSING_MODELS = [
|
|
2
|
+
/**
|
|
3
|
+
* A license is outdated if the current version of the software was released after the expiry date of the license.
|
|
4
|
+
* But the license can be used indefinitely with an older version of the software.
|
|
5
|
+
*/
|
|
6
|
+
'perpetual',
|
|
7
|
+
/**
|
|
8
|
+
* On development, a license is outdated if the expiry date has been reached
|
|
9
|
+
* On production, a license is outdated if the current version of the software was released after the expiry date of the license (see "perpetual")
|
|
10
|
+
*/
|
|
11
|
+
'annual',
|
|
12
|
+
/**
|
|
13
|
+
* TODO 2025 remove, legacy name of annual.
|
|
14
|
+
*/
|
|
15
|
+
'subscription'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './verifyLicense';
|