@mui/x-license 7.7.1 → 7.8.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.
- package/CHANGELOG.md +100 -1
- package/Watermark/Watermark.d.ts +1 -1
- package/index.js +1 -1
- package/modern/index.js +1 -1
- package/modern/useLicenseVerifier/useLicenseVerifier.js +1 -5
- package/modern/utils/commercialPackages.js +1 -0
- package/modern/utils/licenseScope.js +1 -11
- package/modern/verifyLicense/verifyLicense.js +22 -11
- package/node/index.js +1 -1
- package/node/useLicenseVerifier/useLicenseVerifier.js +1 -5
- package/node/utils/commercialPackages.js +5 -0
- package/node/utils/licenseScope.js +2 -14
- package/node/verifyLicense/verifyLicense.js +22 -11
- package/package.json +1 -1
- package/useLicenseVerifier/index.d.ts +0 -1
- package/useLicenseVerifier/useLicenseVerifier.d.ts +1 -1
- package/useLicenseVerifier/useLicenseVerifier.js +1 -5
- package/utils/commercialPackages.d.ts +1 -0
- package/utils/commercialPackages.js +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/licenseScope.d.ts +0 -4
- package/utils/licenseScope.js +1 -11
- package/verifyLicense/verifyLicense.d.ts +3 -4
- package/verifyLicense/verifyLicense.js +22 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,105 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.8.0
|
|
7
|
+
|
|
8
|
+
_Jun 28, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🛰 Introduce server-side data source for improved server integration in the Data Grid.
|
|
13
|
+
|
|
14
|
+
Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
|
|
15
|
+
|
|
16
|
+
To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
const dataSource = {
|
|
20
|
+
getRows: async (params: GridServerGetRowsParams) => {
|
|
21
|
+
const data = await fetch(
|
|
22
|
+
`https://api.example.com/data?${new URLSearchParams({
|
|
23
|
+
page: params.page,
|
|
24
|
+
pageSize: params.pageSize,
|
|
25
|
+
sortModel: JSON.stringify(params.sortModel),
|
|
26
|
+
filterModel: JSON.stringify(params.filterModel),
|
|
27
|
+
}).toString()}`,
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
rows: data.rows,
|
|
31
|
+
totalRows: data.totalRows,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
<DataGridPro
|
|
36
|
+
unstable_dataSource={dataSource}
|
|
37
|
+
{...otherProps}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
|
|
42
|
+
|
|
43
|
+
- 📈 Support Date data on the BarChart component
|
|
44
|
+
- ↕️ Support custom column sort icons on the Data Grid
|
|
45
|
+
- 🖱️ Support modifying the expansion trigger on the Tree View components
|
|
46
|
+
|
|
47
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
48
|
+
|
|
49
|
+
### Data Grid
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-data-grid@7.8.0`
|
|
52
|
+
|
|
53
|
+
- [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
|
|
54
|
+
- [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
|
|
55
|
+
- [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
|
|
56
|
+
|
|
57
|
+
#### `@mui/x-data-grid-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
58
|
+
|
|
59
|
+
Same changes as in `@mui/x-data-grid@7.8.0`, plus:
|
|
60
|
+
|
|
61
|
+
- [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
|
|
62
|
+
- [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-data-grid-premium@7.8.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-data-grid-pro@7.8.0`.
|
|
67
|
+
|
|
68
|
+
### Date and Time Pickers
|
|
69
|
+
|
|
70
|
+
#### `@mui/x-date-pickers@7.8.0`
|
|
71
|
+
|
|
72
|
+
- [fields] Fix section clearing behavior on Android (#13652) @LukasTy
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-date-pickers-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
75
|
+
|
|
76
|
+
Same changes as in `@mui/x-date-pickers@7.8.0`.
|
|
77
|
+
|
|
78
|
+
### Charts
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-charts@7.8.0`
|
|
81
|
+
|
|
82
|
+
- [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
|
|
83
|
+
- [charts] Support BarChart with `Date` data (#13471) @alexfauquette
|
|
84
|
+
- [charts] Support RTL for y-axis (#13614) @alexfauquette
|
|
85
|
+
- [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
|
|
86
|
+
|
|
87
|
+
### Tree View
|
|
88
|
+
|
|
89
|
+
#### `@mui/x-tree-view@7.8.0`
|
|
90
|
+
|
|
91
|
+
- [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
|
|
92
|
+
- [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
|
|
93
|
+
|
|
94
|
+
### Docs
|
|
95
|
+
|
|
96
|
+
- [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
|
|
97
|
+
- [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
|
|
98
|
+
|
|
99
|
+
### Core
|
|
100
|
+
|
|
101
|
+
- [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
|
|
102
|
+
- [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
|
|
103
|
+
- [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
|
|
104
|
+
|
|
6
105
|
## 7.7.1
|
|
7
106
|
|
|
8
107
|
_Jun 21, 2024_
|
|
@@ -44,7 +143,7 @@ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
|
|
|
44
143
|
- [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
|
|
45
144
|
- [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
|
|
46
145
|
- [pickers] Fix controlled `view` behavior (#13552) @LukasTy
|
|
47
|
-
- [TimePicker] Improves RTL verification for the time pickers default views
|
|
146
|
+
- [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
|
|
48
147
|
|
|
49
148
|
#### `@mui/x-date-pickers-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
50
149
|
|
package/Watermark/Watermark.d.ts
CHANGED
package/index.js
CHANGED
package/modern/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { verifyLicense } from '../verifyLicense/verifyLicense';
|
|
|
4
4
|
import { LicenseInfo } from '../utils/licenseInfo';
|
|
5
5
|
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
|
|
6
6
|
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
7
|
-
import { extractAcceptedScopes, extractProductScope } from '../utils/licenseScope';
|
|
8
7
|
import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
|
|
9
8
|
export const sharedLicenseStatuses = {};
|
|
10
9
|
export function useLicenseVerifier(packageName, releaseInfo) {
|
|
@@ -18,14 +17,11 @@ export function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
18
17
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
19
18
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
20
19
|
}
|
|
21
|
-
const acceptedScopes = extractAcceptedScopes(packageName);
|
|
22
|
-
const productScope = extractProductScope(packageName);
|
|
23
20
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
24
21
|
const licenseStatus = verifyLicense({
|
|
25
22
|
releaseInfo,
|
|
26
23
|
licenseKey,
|
|
27
|
-
|
|
28
|
-
productScope
|
|
24
|
+
packageName
|
|
29
25
|
});
|
|
30
26
|
const fullPackageName = `@mui/${packageName}`;
|
|
31
27
|
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
2
|
-
export const
|
|
3
|
-
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
4
|
-
export const extractProductScope = packageName => {
|
|
5
|
-
// extract the part between "x-" and "-pro"/"-premium"
|
|
6
|
-
const regex = /x-(.*?)(-pro|-premium)?$/;
|
|
7
|
-
const match = packageName.match(regex);
|
|
8
|
-
return match[1];
|
|
9
|
-
};
|
|
10
|
-
export const extractAcceptedScopes = packageName => {
|
|
11
|
-
return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
|
|
12
|
-
};
|
|
2
|
+
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
@@ -11,7 +11,20 @@ const getDefaultReleaseDate = () => {
|
|
|
11
11
|
export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
12
12
|
return base64Encode(releaseDate.getTime().toString());
|
|
13
13
|
}
|
|
14
|
+
function isLicenseScopeSufficient(packageName, licenseScope) {
|
|
15
|
+
let acceptedScopes;
|
|
16
|
+
if (packageName.includes('-pro')) {
|
|
17
|
+
acceptedScopes = ['pro', 'premium'];
|
|
18
|
+
} else if (packageName.includes('-premium')) {
|
|
19
|
+
acceptedScopes = ['premium'];
|
|
20
|
+
} else {
|
|
21
|
+
acceptedScopes = [];
|
|
22
|
+
}
|
|
23
|
+
return acceptedScopes.includes(licenseScope);
|
|
24
|
+
}
|
|
14
25
|
const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
|
|
26
|
+
const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
29
|
* Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
|
|
17
30
|
*/
|
|
@@ -79,8 +92,7 @@ const decodeLicense = encodedLicense => {
|
|
|
79
92
|
export function verifyLicense({
|
|
80
93
|
releaseInfo,
|
|
81
94
|
licenseKey,
|
|
82
|
-
|
|
83
|
-
productScope
|
|
95
|
+
packageName
|
|
84
96
|
}) {
|
|
85
97
|
if (!releaseInfo) {
|
|
86
98
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -154,19 +166,18 @@ export function verifyLicense({
|
|
|
154
166
|
status: LICENSE_STATUS.Invalid
|
|
155
167
|
};
|
|
156
168
|
}
|
|
157
|
-
if (license.
|
|
158
|
-
// 'charts-pro' or 'tree-view-pro' can only be used with a newer license
|
|
159
|
-
if (productScope === 'charts' || productScope === 'tree-view') {
|
|
160
|
-
return {
|
|
161
|
-
status: LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (!acceptedScopes.includes(license.scope)) {
|
|
169
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
166
170
|
return {
|
|
167
171
|
status: LICENSE_STATUS.OutOfScope
|
|
168
172
|
};
|
|
169
173
|
}
|
|
174
|
+
|
|
175
|
+
// 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
|
|
176
|
+
if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
|
|
177
|
+
return {
|
|
178
|
+
status: LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
179
|
+
};
|
|
180
|
+
}
|
|
170
181
|
return {
|
|
171
182
|
status: LICENSE_STATUS.Valid
|
|
172
183
|
};
|
package/node/index.js
CHANGED
|
@@ -12,7 +12,6 @@ var _verifyLicense = require("../verifyLicense/verifyLicense");
|
|
|
12
12
|
var _licenseInfo = require("../utils/licenseInfo");
|
|
13
13
|
var _licenseErrorMessageUtils = require("../utils/licenseErrorMessageUtils");
|
|
14
14
|
var _licenseStatus = require("../utils/licenseStatus");
|
|
15
|
-
var _licenseScope = require("../utils/licenseScope");
|
|
16
15
|
var _MuiLicenseInfoContext = _interopRequireDefault(require("../Unstable_LicenseInfoProvider/MuiLicenseInfoContext"));
|
|
17
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -28,14 +27,11 @@ function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
28
27
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
29
28
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
30
29
|
}
|
|
31
|
-
const acceptedScopes = (0, _licenseScope.extractAcceptedScopes)(packageName);
|
|
32
|
-
const productScope = (0, _licenseScope.extractProductScope)(packageName);
|
|
33
30
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
34
31
|
const licenseStatus = (0, _verifyLicense.verifyLicense)({
|
|
35
32
|
releaseInfo,
|
|
36
33
|
licenseKey,
|
|
37
|
-
|
|
38
|
-
productScope
|
|
34
|
+
packageName
|
|
39
35
|
});
|
|
40
36
|
const fullPackageName = `@mui/${packageName}`;
|
|
41
37
|
if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.Valid) {
|
|
@@ -3,18 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.PLAN_VERSIONS = exports.LICENSE_SCOPES = void 0;
|
|
7
7
|
const LICENSE_SCOPES = exports.LICENSE_SCOPES = ['pro', 'premium'];
|
|
8
|
-
const
|
|
9
|
-
const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
10
|
-
const extractProductScope = packageName => {
|
|
11
|
-
// extract the part between "x-" and "-pro"/"-premium"
|
|
12
|
-
const regex = /x-(.*?)(-pro|-premium)?$/;
|
|
13
|
-
const match = packageName.match(regex);
|
|
14
|
-
return match[1];
|
|
15
|
-
};
|
|
16
|
-
exports.extractProductScope = extractProductScope;
|
|
17
|
-
const extractAcceptedScopes = packageName => {
|
|
18
|
-
return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
|
|
19
|
-
};
|
|
20
|
-
exports.extractAcceptedScopes = extractAcceptedScopes;
|
|
8
|
+
const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
@@ -18,7 +18,20 @@ const getDefaultReleaseDate = () => {
|
|
|
18
18
|
function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
19
19
|
return (0, _base.base64Encode)(releaseDate.getTime().toString());
|
|
20
20
|
}
|
|
21
|
+
function isLicenseScopeSufficient(packageName, licenseScope) {
|
|
22
|
+
let acceptedScopes;
|
|
23
|
+
if (packageName.includes('-pro')) {
|
|
24
|
+
acceptedScopes = ['pro', 'premium'];
|
|
25
|
+
} else if (packageName.includes('-premium')) {
|
|
26
|
+
acceptedScopes = ['premium'];
|
|
27
|
+
} else {
|
|
28
|
+
acceptedScopes = [];
|
|
29
|
+
}
|
|
30
|
+
return acceptedScopes.includes(licenseScope);
|
|
31
|
+
}
|
|
21
32
|
const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
|
|
33
|
+
const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
|
|
34
|
+
|
|
22
35
|
/**
|
|
23
36
|
* Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
|
|
24
37
|
*/
|
|
@@ -86,8 +99,7 @@ const decodeLicense = encodedLicense => {
|
|
|
86
99
|
function verifyLicense({
|
|
87
100
|
releaseInfo,
|
|
88
101
|
licenseKey,
|
|
89
|
-
|
|
90
|
-
productScope
|
|
102
|
+
packageName
|
|
91
103
|
}) {
|
|
92
104
|
if (!releaseInfo) {
|
|
93
105
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -161,19 +173,18 @@ function verifyLicense({
|
|
|
161
173
|
status: _licenseStatus.LICENSE_STATUS.Invalid
|
|
162
174
|
};
|
|
163
175
|
}
|
|
164
|
-
if (license.
|
|
165
|
-
// 'charts-pro' or 'tree-view-pro' can only be used with a newer license
|
|
166
|
-
if (productScope === 'charts' || productScope === 'tree-view') {
|
|
167
|
-
return {
|
|
168
|
-
status: _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (!acceptedScopes.includes(license.scope)) {
|
|
176
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
173
177
|
return {
|
|
174
178
|
status: _licenseStatus.LICENSE_STATUS.OutOfScope
|
|
175
179
|
};
|
|
176
180
|
}
|
|
181
|
+
|
|
182
|
+
// 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
|
|
183
|
+
if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
|
|
184
|
+
return {
|
|
185
|
+
status: _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
186
|
+
};
|
|
187
|
+
}
|
|
177
188
|
return {
|
|
178
189
|
status: _licenseStatus.LICENSE_STATUS.Valid
|
|
179
190
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LicenseStatus } from '../utils/licenseStatus';
|
|
2
|
-
|
|
2
|
+
import { MuiCommercialPackageName } from '../utils/commercialPackages';
|
|
3
3
|
export declare const sharedLicenseStatuses: {
|
|
4
4
|
[packageName in MuiCommercialPackageName]?: {
|
|
5
5
|
key: string | undefined;
|
|
@@ -4,7 +4,6 @@ import { verifyLicense } from '../verifyLicense/verifyLicense';
|
|
|
4
4
|
import { LicenseInfo } from '../utils/licenseInfo';
|
|
5
5
|
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
|
|
6
6
|
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
7
|
-
import { extractAcceptedScopes, extractProductScope } from '../utils/licenseScope';
|
|
8
7
|
import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
|
|
9
8
|
export const sharedLicenseStatuses = {};
|
|
10
9
|
export function useLicenseVerifier(packageName, releaseInfo) {
|
|
@@ -18,14 +17,11 @@ export function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
18
17
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
19
18
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
20
19
|
}
|
|
21
|
-
const acceptedScopes = extractAcceptedScopes(packageName);
|
|
22
|
-
const productScope = extractProductScope(packageName);
|
|
23
20
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
24
21
|
const licenseStatus = verifyLicense({
|
|
25
22
|
releaseInfo,
|
|
26
23
|
licenseKey,
|
|
27
|
-
|
|
28
|
-
productScope
|
|
24
|
+
packageName
|
|
29
25
|
});
|
|
30
26
|
const fullPackageName = `@mui/${packageName}`;
|
|
31
27
|
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MuiCommercialPackageName = 'x-data-grid-pro' | 'x-data-grid-premium' | 'x-date-pickers-pro' | 'x-tree-view-pro' | 'x-charts-pro';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/utils/index.d.ts
CHANGED
package/utils/licenseScope.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export declare const LICENSE_SCOPES: readonly ["pro", "premium"];
|
|
2
|
-
export declare const PRODUCT_SCOPES: readonly ["data-grid", "date-pickers", "charts", "tree-view"];
|
|
3
2
|
export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024"];
|
|
4
3
|
export type LicenseScope = (typeof LICENSE_SCOPES)[number];
|
|
5
|
-
export type ProductScope = (typeof PRODUCT_SCOPES)[number];
|
|
6
4
|
export type PlanVersion = (typeof PLAN_VERSIONS)[number];
|
|
7
|
-
export declare const extractProductScope: (packageName: string) => ProductScope;
|
|
8
|
-
export declare const extractAcceptedScopes: (packageName: string) => readonly LicenseScope[];
|
package/utils/licenseScope.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
2
|
-
export const
|
|
3
|
-
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
4
|
-
export const extractProductScope = packageName => {
|
|
5
|
-
// extract the part between "x-" and "-pro"/"-premium"
|
|
6
|
-
const regex = /x-(.*?)(-pro|-premium)?$/;
|
|
7
|
-
const match = packageName.match(regex);
|
|
8
|
-
return match[1];
|
|
9
|
-
};
|
|
10
|
-
export const extractAcceptedScopes = packageName => {
|
|
11
|
-
return packageName.includes('premium') ? LICENSE_SCOPES.filter(scope => scope.includes('premium')) : LICENSE_SCOPES;
|
|
12
|
-
};
|
|
2
|
+
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { LicenseStatus } from '../utils/licenseStatus';
|
|
2
|
-
import {
|
|
2
|
+
import { MuiCommercialPackageName } from '../utils/commercialPackages';
|
|
3
3
|
export declare function generateReleaseInfo(releaseDate?: Date): string;
|
|
4
|
-
export declare function verifyLicense({ releaseInfo, licenseKey,
|
|
4
|
+
export declare function verifyLicense({ releaseInfo, licenseKey, packageName, }: {
|
|
5
5
|
releaseInfo: string;
|
|
6
6
|
licenseKey?: string;
|
|
7
|
-
|
|
8
|
-
productScope: ProductScope;
|
|
7
|
+
packageName: MuiCommercialPackageName;
|
|
9
8
|
}): {
|
|
10
9
|
status: LicenseStatus;
|
|
11
10
|
meta?: any;
|
|
@@ -11,7 +11,20 @@ const getDefaultReleaseDate = () => {
|
|
|
11
11
|
export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
12
12
|
return base64Encode(releaseDate.getTime().toString());
|
|
13
13
|
}
|
|
14
|
+
function isLicenseScopeSufficient(packageName, licenseScope) {
|
|
15
|
+
let acceptedScopes;
|
|
16
|
+
if (packageName.includes('-pro')) {
|
|
17
|
+
acceptedScopes = ['pro', 'premium'];
|
|
18
|
+
} else if (packageName.includes('-premium')) {
|
|
19
|
+
acceptedScopes = ['premium'];
|
|
20
|
+
} else {
|
|
21
|
+
acceptedScopes = [];
|
|
22
|
+
}
|
|
23
|
+
return acceptedScopes.includes(licenseScope);
|
|
24
|
+
}
|
|
14
25
|
const expiryReg = /^.*EXPIRY=([0-9]+),.*$/;
|
|
26
|
+
const PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN = ['x-data-grid-pro', 'x-date-pickers-pro'];
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
29
|
* Format: ORDER:${orderNumber},EXPIRY=${expiryTimestamp},KEYVERSION=1
|
|
17
30
|
*/
|
|
@@ -79,8 +92,7 @@ const decodeLicense = encodedLicense => {
|
|
|
79
92
|
export function verifyLicense({
|
|
80
93
|
releaseInfo,
|
|
81
94
|
licenseKey,
|
|
82
|
-
|
|
83
|
-
productScope
|
|
95
|
+
packageName
|
|
84
96
|
}) {
|
|
85
97
|
if (!releaseInfo) {
|
|
86
98
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -154,19 +166,18 @@ export function verifyLicense({
|
|
|
154
166
|
status: LICENSE_STATUS.Invalid
|
|
155
167
|
};
|
|
156
168
|
}
|
|
157
|
-
if (license.
|
|
158
|
-
// 'charts-pro' or 'tree-view-pro' can only be used with a newer license
|
|
159
|
-
if (productScope === 'charts' || productScope === 'tree-view') {
|
|
160
|
-
return {
|
|
161
|
-
status: LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (!acceptedScopes.includes(license.scope)) {
|
|
169
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
166
170
|
return {
|
|
167
171
|
status: LICENSE_STATUS.OutOfScope
|
|
168
172
|
};
|
|
169
173
|
}
|
|
174
|
+
|
|
175
|
+
// 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
|
|
176
|
+
if (license.planVersion === 'initial' && license.scope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
|
|
177
|
+
return {
|
|
178
|
+
status: LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
179
|
+
};
|
|
180
|
+
}
|
|
170
181
|
return {
|
|
171
182
|
status: LICENSE_STATUS.Valid
|
|
172
183
|
};
|