@mui/x-license 7.0.0-beta.2 → 7.0.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +865 -81
  2. package/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +2 -2
  3. package/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts +4 -0
  4. package/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js +8 -0
  5. package/index.js +1 -1
  6. package/modern/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +2 -2
  7. package/modern/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js +8 -0
  8. package/modern/index.js +1 -1
  9. package/modern/useLicenseVerifier/useLicenseVerifier.js +2 -2
  10. package/modern/utils/licenseErrorMessageUtils.js +2 -2
  11. package/node/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +2 -2
  12. package/node/Unstable_LicenseInfoProvider/{LicenseInfoContext.js → MuiLicenseInfoContext.js} +6 -2
  13. package/node/index.js +1 -1
  14. package/node/useLicenseVerifier/useLicenseVerifier.js +2 -2
  15. package/node/utils/licenseErrorMessageUtils.js +2 -2
  16. package/package.json +3 -4
  17. package/useLicenseVerifier/useLicenseVerifier.js +3 -3
  18. package/utils/licenseErrorMessageUtils.js +2 -2
  19. package/Unstable_LicenseInfoProvider/LicenseInfoContext.d.ts +0 -4
  20. package/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
  21. package/legacy/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
  22. package/legacy/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +0 -18
  23. package/legacy/Unstable_LicenseInfoProvider/index.js +0 -1
  24. package/legacy/Watermark/Watermark.js +0 -44
  25. package/legacy/Watermark/index.js +0 -1
  26. package/legacy/encoding/base64.js +0 -57
  27. package/legacy/encoding/md5.js +0 -42
  28. package/legacy/generateLicense/generateLicense.js +0 -18
  29. package/legacy/generateLicense/index.js +0 -1
  30. package/legacy/index.js +0 -13
  31. package/legacy/useLicenseVerifier/index.js +0 -1
  32. package/legacy/useLicenseVerifier/useLicenseVerifier.js +0 -59
  33. package/legacy/utils/index.js +0 -4
  34. package/legacy/utils/licenseErrorMessageUtils.js +0 -31
  35. package/legacy/utils/licenseInfo.js +0 -40
  36. package/legacy/utils/licenseScope.js +0 -1
  37. package/legacy/utils/licenseStatus.js +0 -11
  38. package/legacy/utils/licensingModel.js +0 -15
  39. package/legacy/verifyLicense/index.js +0 -1
  40. package/legacy/verifyLicense/verifyLicense.js +0 -167
  41. package/modern/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
@@ -1,40 +0,0 @@
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
- }();
@@ -1 +0,0 @@
1
- export var LICENSE_SCOPES = ['pro', 'premium'];
@@ -1,11 +0,0 @@
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
- }({});
@@ -1,15 +0,0 @@
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'];
@@ -1 +0,0 @@
1
- export * from './verifyLicense';
@@ -1,167 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- export default /*#__PURE__*/React.createContext({
3
- key: undefined
4
- });