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

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 (38) hide show
  1. package/CHANGELOG.md +560 -75
  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/node/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +2 -2
  11. package/node/Unstable_LicenseInfoProvider/{LicenseInfoContext.js → MuiLicenseInfoContext.js} +6 -2
  12. package/node/index.js +1 -1
  13. package/node/useLicenseVerifier/useLicenseVerifier.js +2 -2
  14. package/package.json +3 -4
  15. package/useLicenseVerifier/useLicenseVerifier.js +2 -2
  16. package/Unstable_LicenseInfoProvider/LicenseInfoContext.d.ts +0 -4
  17. package/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
  18. package/legacy/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
  19. package/legacy/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +0 -18
  20. package/legacy/Unstable_LicenseInfoProvider/index.js +0 -1
  21. package/legacy/Watermark/Watermark.js +0 -44
  22. package/legacy/Watermark/index.js +0 -1
  23. package/legacy/encoding/base64.js +0 -57
  24. package/legacy/encoding/md5.js +0 -42
  25. package/legacy/generateLicense/generateLicense.js +0 -18
  26. package/legacy/generateLicense/index.js +0 -1
  27. package/legacy/index.js +0 -13
  28. package/legacy/useLicenseVerifier/index.js +0 -1
  29. package/legacy/useLicenseVerifier/useLicenseVerifier.js +0 -59
  30. package/legacy/utils/index.js +0 -4
  31. package/legacy/utils/licenseErrorMessageUtils.js +0 -31
  32. package/legacy/utils/licenseInfo.js +0 -40
  33. package/legacy/utils/licenseScope.js +0 -1
  34. package/legacy/utils/licenseStatus.js +0 -11
  35. package/legacy/utils/licensingModel.js +0 -15
  36. package/legacy/verifyLicense/index.js +0 -1
  37. package/legacy/verifyLicense/verifyLicense.js +0 -167
  38. package/modern/Unstable_LicenseInfoProvider/LicenseInfoContext.js +0 -4
@@ -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
- });