@mui/x-license 7.7.0 → 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 +181 -0
- package/Watermark/Watermark.d.ts +1 -1
- package/Watermark/Watermark.js +2 -0
- package/generateLicense/generateLicense.d.ts +2 -1
- package/generateLicense/generateLicense.js +2 -1
- package/index.js +1 -1
- package/modern/Watermark/Watermark.js +2 -0
- package/modern/generateLicense/generateLicense.js +2 -1
- package/modern/index.js +1 -1
- package/modern/useLicenseVerifier/useLicenseVerifier.js +4 -3
- package/modern/utils/commercialPackages.js +1 -0
- package/modern/utils/licenseErrorMessageUtils.js +3 -0
- package/modern/utils/licenseScope.js +2 -1
- package/modern/utils/licenseStatus.js +1 -0
- package/modern/verifyLicense/verifyLicense.js +31 -6
- package/node/Watermark/Watermark.js +2 -0
- package/node/generateLicense/generateLicense.js +2 -1
- package/node/index.js +1 -1
- package/node/useLicenseVerifier/useLicenseVerifier.js +3 -2
- package/node/utils/commercialPackages.js +5 -0
- package/node/utils/licenseErrorMessageUtils.js +4 -0
- package/node/utils/licenseScope.js +3 -2
- package/node/utils/licenseStatus.js +1 -0
- package/node/verifyLicense/verifyLicense.js +31 -6
- package/package.json +2 -2
- package/useLicenseVerifier/index.d.ts +0 -1
- package/useLicenseVerifier/useLicenseVerifier.d.ts +1 -1
- package/useLicenseVerifier/useLicenseVerifier.js +4 -3
- package/utils/commercialPackages.d.ts +1 -0
- package/utils/commercialPackages.js +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/licenseErrorMessageUtils.d.ts +1 -0
- package/utils/licenseErrorMessageUtils.js +3 -0
- package/utils/licenseScope.d.ts +2 -0
- package/utils/licenseScope.js +2 -1
- package/utils/licenseStatus.d.ts +2 -1
- package/utils/licenseStatus.js +1 -0
- package/verifyLicense/verifyLicense.d.ts +4 -4
- package/verifyLicense/verifyLicense.js +31 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,187 @@
|
|
|
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
|
+
|
|
105
|
+
## 7.7.1
|
|
106
|
+
|
|
107
|
+
_Jun 21, 2024_
|
|
108
|
+
|
|
109
|
+
We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
110
|
+
|
|
111
|
+
- 🌍 Improve Portuguese (pt-PT) locale on the Data Grid
|
|
112
|
+
- 🌍 Improve Danish (da-DK) locale on the Date and Time Pickers
|
|
113
|
+
- 🐞 Bugfixes
|
|
114
|
+
- 📚 Documentation improvements
|
|
115
|
+
|
|
116
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
117
|
+
|
|
118
|
+
### Data Grid
|
|
119
|
+
|
|
120
|
+
#### `@mui/x-data-grid@7.7.1`
|
|
121
|
+
|
|
122
|
+
- [DataGrid][docs] Clarify enabling pagination (#13350) @oliviertassinari
|
|
123
|
+
- [DataGrid] Fix CSV export escaping for non-string values (#13560) @joeycumines-scw
|
|
124
|
+
- [l10n] Improve Portuguese (pt-PT) locale (#13348) @joaosreis
|
|
125
|
+
|
|
126
|
+
#### `@mui/x-data-grid-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
127
|
+
|
|
128
|
+
Same changes as in `@mui/x-data-grid@7.7.1`, plus:
|
|
129
|
+
|
|
130
|
+
- [DataGrid] Warn about `getTreeDataPath` reference (#13519) @cherniavskii
|
|
131
|
+
|
|
132
|
+
#### `@mui/x-data-grid-premium@7.7.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
133
|
+
|
|
134
|
+
Same changes as in `@mui/x-data-grid-pro@7.7.1`.
|
|
135
|
+
|
|
136
|
+
### Date and Time Pickers
|
|
137
|
+
|
|
138
|
+
#### `@mui/x-date-pickers@7.7.1`
|
|
139
|
+
|
|
140
|
+
- [fields] Prevent digit editing on the `Space` key down (#13510) @flaviendelangle
|
|
141
|
+
- [l10n] Improve Danish (da-DK) locale (#13375) @jacrowland1
|
|
142
|
+
- [pickers] Add context to `onAccept` callback (#13511) @flaviendelangle
|
|
143
|
+
- [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
|
|
144
|
+
- [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
|
|
145
|
+
- [pickers] Fix controlled `view` behavior (#13552) @LukasTy
|
|
146
|
+
- [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
|
|
147
|
+
|
|
148
|
+
#### `@mui/x-date-pickers-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
149
|
+
|
|
150
|
+
Same changes as in `@mui/x-date-pickers@7.7.1`, plus:
|
|
151
|
+
|
|
152
|
+
- [DateRangePicker] Add accessible name to calendar grid (#13538) @LukasTy
|
|
153
|
+
|
|
154
|
+
### Charts
|
|
155
|
+
|
|
156
|
+
#### `@mui/x-charts@7.7.1`
|
|
157
|
+
|
|
158
|
+
- [charts] Divide `CartesianProvider` to use logic in Pro package (#13531) @JCQuintas
|
|
159
|
+
- [charts] Do not publish the pro package (#13539) @alexfauquette
|
|
160
|
+
- [charts] Export `Pro` versions of regular charts (#13547) @JCQuintas
|
|
161
|
+
- [charts] Prepare `ChartContainerPro` for future Zoom changes (#13532) @JCQuintas
|
|
162
|
+
- [charts] Remove unnecessary proptypes from internal component (#13518) @JCQuintas
|
|
163
|
+
|
|
164
|
+
### Tree View
|
|
165
|
+
|
|
166
|
+
#### `@mui/x-tree-view@7.7.1`
|
|
167
|
+
|
|
168
|
+
- [TreeView] Improve typing to support optional dependencies in plugins and in the item (#13523) @flaviendelangle
|
|
169
|
+
- [TreeView] Move `useTreeViewId` to the core plugins (#13566) @flaviendelangle
|
|
170
|
+
- [TreeView] Remove unused state from `useTreeViewId` (#13579) @flaviendelangle
|
|
171
|
+
- [TreeView] Support `itemId` with escaping characters when using `SimpleTreeView` (#13487) @oukunan
|
|
172
|
+
|
|
173
|
+
### Docs
|
|
174
|
+
|
|
175
|
+
- [docs] Add section about the new uncovered product watermark (#13568) @michelengelen
|
|
176
|
+
- [docs] Document the `PickerValidDate` type override (#13476) @flaviendelangle
|
|
177
|
+
- [docs] Fix typo (#13507) @anshtiwatne
|
|
178
|
+
- [docs] Remove "-" in heat-map and tree-map urls (#13569) @alexfauquette
|
|
179
|
+
- [docs] Use dedicated tab for weather dataset (#13513) @alexfauquette
|
|
180
|
+
- [x-license] license update proposal (#13459) @michelengelen
|
|
181
|
+
|
|
182
|
+
### Core
|
|
183
|
+
|
|
184
|
+
- [core] Fix failing CI test (#13574) @alexfauquette
|
|
185
|
+
- [infra] Remove explicit `@testing-library/react` dependency (#13478) @LukasTy
|
|
186
|
+
|
|
6
187
|
## 7.7.0
|
|
7
188
|
|
|
8
189
|
_Jun 13, 2024_
|
package/Watermark/Watermark.d.ts
CHANGED
package/Watermark/Watermark.js
CHANGED
|
@@ -13,6 +13,8 @@ function getLicenseErrorMessage(licenseStatus) {
|
|
|
13
13
|
return 'MUI X Invalid license key';
|
|
14
14
|
case LICENSE_STATUS.OutOfScope:
|
|
15
15
|
return 'MUI X License key plan mismatch';
|
|
16
|
+
case LICENSE_STATUS.NotAvailableInInitialProPlan:
|
|
17
|
+
return 'MUI X Product not covered by plan';
|
|
16
18
|
case LICENSE_STATUS.NotFound:
|
|
17
19
|
return 'MUI X Missing license key';
|
|
18
20
|
default:
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { LicenseScope } from '../utils/licenseScope';
|
|
1
|
+
import { LicenseScope, PlanVersion } from '../utils/licenseScope';
|
|
2
2
|
import { LicensingModel } from '../utils/licensingModel';
|
|
3
3
|
export interface LicenseDetails {
|
|
4
4
|
orderNumber: string;
|
|
5
5
|
expiryDate: Date;
|
|
6
6
|
scope: LicenseScope;
|
|
7
7
|
licensingModel: LicensingModel;
|
|
8
|
+
planVersion: PlanVersion;
|
|
8
9
|
}
|
|
9
10
|
export declare function generateLicense(details: LicenseDetails): string;
|
|
@@ -10,7 +10,8 @@ function getClearLicenseString(details) {
|
|
|
10
10
|
if (details.licensingModel && !LICENSING_MODELS.includes(details.licensingModel)) {
|
|
11
11
|
throw new Error('MUI X: Invalid licensing model');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.scope}`, `LM=${details.licensingModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
|
|
14
|
+
return keyParts.join(',');
|
|
14
15
|
}
|
|
15
16
|
export function generateLicense(details) {
|
|
16
17
|
const licenseStr = getClearLicenseString(details);
|
package/index.js
CHANGED
|
@@ -13,6 +13,8 @@ function getLicenseErrorMessage(licenseStatus) {
|
|
|
13
13
|
return 'MUI X Invalid license key';
|
|
14
14
|
case LICENSE_STATUS.OutOfScope:
|
|
15
15
|
return 'MUI X License key plan mismatch';
|
|
16
|
+
case LICENSE_STATUS.NotAvailableInInitialProPlan:
|
|
17
|
+
return 'MUI X Product not covered by plan';
|
|
16
18
|
case LICENSE_STATUS.NotFound:
|
|
17
19
|
return 'MUI X Missing license key';
|
|
18
20
|
default:
|
|
@@ -10,7 +10,8 @@ function getClearLicenseString(details) {
|
|
|
10
10
|
if (details.licensingModel && !LICENSING_MODELS.includes(details.licensingModel)) {
|
|
11
11
|
throw new Error('MUI X: Invalid licensing model');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.scope}`, `LM=${details.licensingModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
|
|
14
|
+
return keyParts.join(',');
|
|
14
15
|
}
|
|
15
16
|
export function generateLicense(details) {
|
|
16
17
|
const licenseStr = getClearLicenseString(details);
|
package/modern/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { verifyLicense } from '../verifyLicense/verifyLicense';
|
|
4
4
|
import { LicenseInfo } from '../utils/licenseInfo';
|
|
5
|
-
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError } from '../utils/licenseErrorMessageUtils';
|
|
5
|
+
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
|
|
6
6
|
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
7
7
|
import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
|
|
8
8
|
export const sharedLicenseStatuses = {};
|
|
@@ -17,18 +17,19 @@ export function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
17
17
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
18
18
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
19
19
|
}
|
|
20
|
-
const acceptedScopes = packageName.includes('premium') ? ['premium'] : ['pro', 'premium'];
|
|
21
20
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
22
21
|
const licenseStatus = verifyLicense({
|
|
23
22
|
releaseInfo,
|
|
24
23
|
licenseKey,
|
|
25
|
-
|
|
24
|
+
packageName
|
|
26
25
|
});
|
|
27
26
|
const fullPackageName = `@mui/${packageName}`;
|
|
28
27
|
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
29
28
|
// Skip
|
|
30
29
|
} else if (licenseStatus.status === LICENSE_STATUS.Invalid) {
|
|
31
30
|
showInvalidLicenseKeyError();
|
|
31
|
+
} else if (licenseStatus.status === LICENSE_STATUS.NotAvailableInInitialProPlan) {
|
|
32
|
+
showNotAvailableInInitialProPlanError();
|
|
32
33
|
} else if (licenseStatus.status === LICENSE_STATUS.OutOfScope) {
|
|
33
34
|
showLicenseKeyPlanMismatchError();
|
|
34
35
|
} else if (licenseStatus.status === LICENSE_STATUS.NotFound) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,9 @@ export function showInvalidLicenseKeyError() {
|
|
|
7
7
|
export function showLicenseKeyPlanMismatchError() {
|
|
8
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
9
|
}
|
|
10
|
+
export function showNotAvailableInInitialProPlanError() {
|
|
11
|
+
showError(['MUI X: Component not included in your license.', '', 'The component you are trying to use is not included in the Pro Plan you purchased.', '', 'Your license is from an old version of the Pro Plan that is only compatible with the `@mui/x-data-grid-pro` and `@mui/x-date-pickers-pro` commercial packages.', '', 'To start using another Pro package, please consider reaching to our sales team to upgrade your license or visit https://mui.com/r/x-get-license to get a new license key.']);
|
|
12
|
+
}
|
|
10
13
|
export function showMissingLicenseKeyError({
|
|
11
14
|
plan,
|
|
12
15
|
packageName
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
1
|
+
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
2
|
+
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
@@ -7,5 +7,6 @@ export let LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STATUS) {
|
|
|
7
7
|
LICENSE_STATUS["ExpiredVersion"] = "ExpiredVersion";
|
|
8
8
|
LICENSE_STATUS["Valid"] = "Valid";
|
|
9
9
|
LICENSE_STATUS["OutOfScope"] = "OutOfScope";
|
|
10
|
+
LICENSE_STATUS["NotAvailableInInitialProPlan"] = "NotAvailableInInitialProPlan";
|
|
10
11
|
return LICENSE_STATUS;
|
|
11
12
|
}({});
|
|
@@ -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
|
*/
|
|
@@ -28,18 +41,20 @@ const decodeLicenseVersion1 = license => {
|
|
|
28
41
|
return {
|
|
29
42
|
scope: 'pro',
|
|
30
43
|
licensingModel: 'perpetual',
|
|
31
|
-
expiryTimestamp
|
|
44
|
+
expiryTimestamp,
|
|
45
|
+
planVersion: 'initial'
|
|
32
46
|
};
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
/**
|
|
36
|
-
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},KV=2`;
|
|
50
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},PV=${planVersion},KV=2`;
|
|
37
51
|
*/
|
|
38
52
|
const decodeLicenseVersion2 = license => {
|
|
39
53
|
const licenseInfo = {
|
|
40
54
|
scope: null,
|
|
41
55
|
licensingModel: null,
|
|
42
|
-
expiryTimestamp: null
|
|
56
|
+
expiryTimestamp: null,
|
|
57
|
+
planVersion: 'initial'
|
|
43
58
|
};
|
|
44
59
|
license.split(',').map(token => token.split('=')).filter(el => el.length === 2).forEach(([key, value]) => {
|
|
45
60
|
if (key === 'S') {
|
|
@@ -54,6 +69,9 @@ const decodeLicenseVersion2 = license => {
|
|
|
54
69
|
licenseInfo.expiryTimestamp = expiryTimestamp;
|
|
55
70
|
}
|
|
56
71
|
}
|
|
72
|
+
if (key === 'PV') {
|
|
73
|
+
licenseInfo.planVersion = value;
|
|
74
|
+
}
|
|
57
75
|
});
|
|
58
76
|
return licenseInfo;
|
|
59
77
|
};
|
|
@@ -74,7 +92,7 @@ const decodeLicense = encodedLicense => {
|
|
|
74
92
|
export function verifyLicense({
|
|
75
93
|
releaseInfo,
|
|
76
94
|
licenseKey,
|
|
77
|
-
|
|
95
|
+
packageName
|
|
78
96
|
}) {
|
|
79
97
|
if (!releaseInfo) {
|
|
80
98
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -143,16 +161,23 @@ export function verifyLicense({
|
|
|
143
161
|
}
|
|
144
162
|
}
|
|
145
163
|
if (license.scope == null || !LICENSE_SCOPES.includes(license.scope)) {
|
|
146
|
-
console.error('Error checking license. scope not found or invalid!');
|
|
164
|
+
console.error('MUI X: Error checking license. scope not found or invalid!');
|
|
147
165
|
return {
|
|
148
166
|
status: LICENSE_STATUS.Invalid
|
|
149
167
|
};
|
|
150
168
|
}
|
|
151
|
-
if (!
|
|
169
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
152
170
|
return {
|
|
153
171
|
status: LICENSE_STATUS.OutOfScope
|
|
154
172
|
};
|
|
155
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
|
+
}
|
|
156
181
|
return {
|
|
157
182
|
status: LICENSE_STATUS.Valid
|
|
158
183
|
};
|
|
@@ -21,6 +21,8 @@ function getLicenseErrorMessage(licenseStatus) {
|
|
|
21
21
|
return 'MUI X Invalid license key';
|
|
22
22
|
case _licenseStatus.LICENSE_STATUS.OutOfScope:
|
|
23
23
|
return 'MUI X License key plan mismatch';
|
|
24
|
+
case _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan:
|
|
25
|
+
return 'MUI X Product not covered by plan';
|
|
24
26
|
case _licenseStatus.LICENSE_STATUS.NotFound:
|
|
25
27
|
return 'MUI X Missing license key';
|
|
26
28
|
default:
|
|
@@ -16,7 +16,8 @@ function getClearLicenseString(details) {
|
|
|
16
16
|
if (details.licensingModel && !_licensingModel.LICENSING_MODELS.includes(details.licensingModel)) {
|
|
17
17
|
throw new Error('MUI X: Invalid licensing model');
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.scope}`, `LM=${details.licensingModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
|
|
20
|
+
return keyParts.join(',');
|
|
20
21
|
}
|
|
21
22
|
function generateLicense(details) {
|
|
22
23
|
const licenseStr = getClearLicenseString(details);
|
package/node/index.js
CHANGED
|
@@ -27,18 +27,19 @@ function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
27
27
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
28
28
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
29
29
|
}
|
|
30
|
-
const acceptedScopes = packageName.includes('premium') ? ['premium'] : ['pro', 'premium'];
|
|
31
30
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
32
31
|
const licenseStatus = (0, _verifyLicense.verifyLicense)({
|
|
33
32
|
releaseInfo,
|
|
34
33
|
licenseKey,
|
|
35
|
-
|
|
34
|
+
packageName
|
|
36
35
|
});
|
|
37
36
|
const fullPackageName = `@mui/${packageName}`;
|
|
38
37
|
if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.Valid) {
|
|
39
38
|
// Skip
|
|
40
39
|
} else if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.Invalid) {
|
|
41
40
|
(0, _licenseErrorMessageUtils.showInvalidLicenseKeyError)();
|
|
41
|
+
} else if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan) {
|
|
42
|
+
(0, _licenseErrorMessageUtils.showNotAvailableInInitialProPlanError)();
|
|
42
43
|
} else if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.OutOfScope) {
|
|
43
44
|
(0, _licenseErrorMessageUtils.showLicenseKeyPlanMismatchError)();
|
|
44
45
|
} else if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.NotFound) {
|
|
@@ -9,6 +9,7 @@ exports.showExpiredPackageVersionError = showExpiredPackageVersionError;
|
|
|
9
9
|
exports.showInvalidLicenseKeyError = showInvalidLicenseKeyError;
|
|
10
10
|
exports.showLicenseKeyPlanMismatchError = showLicenseKeyPlanMismatchError;
|
|
11
11
|
exports.showMissingLicenseKeyError = showMissingLicenseKeyError;
|
|
12
|
+
exports.showNotAvailableInInitialProPlanError = showNotAvailableInInitialProPlanError;
|
|
12
13
|
function showError(message) {
|
|
13
14
|
console.error(['*************************************************************', '', ...message, '', '*************************************************************'].join('\n'));
|
|
14
15
|
}
|
|
@@ -18,6 +19,9 @@ function showInvalidLicenseKeyError() {
|
|
|
18
19
|
function showLicenseKeyPlanMismatchError() {
|
|
19
20
|
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`."]);
|
|
20
21
|
}
|
|
22
|
+
function showNotAvailableInInitialProPlanError() {
|
|
23
|
+
showError(['MUI X: Component not included in your license.', '', 'The component you are trying to use is not included in the Pro Plan you purchased.', '', 'Your license is from an old version of the Pro Plan that is only compatible with the `@mui/x-data-grid-pro` and `@mui/x-date-pickers-pro` commercial packages.', '', 'To start using another Pro package, please consider reaching to our sales team to upgrade your license or visit https://mui.com/r/x-get-license to get a new license key.']);
|
|
24
|
+
}
|
|
21
25
|
function showMissingLicenseKeyError({
|
|
22
26
|
plan,
|
|
23
27
|
packageName
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LICENSE_SCOPES = void 0;
|
|
7
|
-
const LICENSE_SCOPES = exports.LICENSE_SCOPES = ['pro', 'premium'];
|
|
6
|
+
exports.PLAN_VERSIONS = exports.LICENSE_SCOPES = void 0;
|
|
7
|
+
const LICENSE_SCOPES = exports.LICENSE_SCOPES = ['pro', 'premium'];
|
|
8
|
+
const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
@@ -13,5 +13,6 @@ let LICENSE_STATUS = exports.LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STA
|
|
|
13
13
|
LICENSE_STATUS["ExpiredVersion"] = "ExpiredVersion";
|
|
14
14
|
LICENSE_STATUS["Valid"] = "Valid";
|
|
15
15
|
LICENSE_STATUS["OutOfScope"] = "OutOfScope";
|
|
16
|
+
LICENSE_STATUS["NotAvailableInInitialProPlan"] = "NotAvailableInInitialProPlan";
|
|
16
17
|
return LICENSE_STATUS;
|
|
17
18
|
}({});
|
|
@@ -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
|
*/
|
|
@@ -35,18 +48,20 @@ const decodeLicenseVersion1 = license => {
|
|
|
35
48
|
return {
|
|
36
49
|
scope: 'pro',
|
|
37
50
|
licensingModel: 'perpetual',
|
|
38
|
-
expiryTimestamp
|
|
51
|
+
expiryTimestamp,
|
|
52
|
+
planVersion: 'initial'
|
|
39
53
|
};
|
|
40
54
|
};
|
|
41
55
|
|
|
42
56
|
/**
|
|
43
|
-
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},KV=2`;
|
|
57
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},PV=${planVersion},KV=2`;
|
|
44
58
|
*/
|
|
45
59
|
const decodeLicenseVersion2 = license => {
|
|
46
60
|
const licenseInfo = {
|
|
47
61
|
scope: null,
|
|
48
62
|
licensingModel: null,
|
|
49
|
-
expiryTimestamp: null
|
|
63
|
+
expiryTimestamp: null,
|
|
64
|
+
planVersion: 'initial'
|
|
50
65
|
};
|
|
51
66
|
license.split(',').map(token => token.split('=')).filter(el => el.length === 2).forEach(([key, value]) => {
|
|
52
67
|
if (key === 'S') {
|
|
@@ -61,6 +76,9 @@ const decodeLicenseVersion2 = license => {
|
|
|
61
76
|
licenseInfo.expiryTimestamp = expiryTimestamp;
|
|
62
77
|
}
|
|
63
78
|
}
|
|
79
|
+
if (key === 'PV') {
|
|
80
|
+
licenseInfo.planVersion = value;
|
|
81
|
+
}
|
|
64
82
|
});
|
|
65
83
|
return licenseInfo;
|
|
66
84
|
};
|
|
@@ -81,7 +99,7 @@ const decodeLicense = encodedLicense => {
|
|
|
81
99
|
function verifyLicense({
|
|
82
100
|
releaseInfo,
|
|
83
101
|
licenseKey,
|
|
84
|
-
|
|
102
|
+
packageName
|
|
85
103
|
}) {
|
|
86
104
|
if (!releaseInfo) {
|
|
87
105
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -150,16 +168,23 @@ function verifyLicense({
|
|
|
150
168
|
}
|
|
151
169
|
}
|
|
152
170
|
if (license.scope == null || !_licenseScope.LICENSE_SCOPES.includes(license.scope)) {
|
|
153
|
-
console.error('Error checking license. scope not found or invalid!');
|
|
171
|
+
console.error('MUI X: Error checking license. scope not found or invalid!');
|
|
154
172
|
return {
|
|
155
173
|
status: _licenseStatus.LICENSE_STATUS.Invalid
|
|
156
174
|
};
|
|
157
175
|
}
|
|
158
|
-
if (!
|
|
176
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
159
177
|
return {
|
|
160
178
|
status: _licenseStatus.LICENSE_STATUS.OutOfScope
|
|
161
179
|
};
|
|
162
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
|
+
}
|
|
163
188
|
return {
|
|
164
189
|
status: _licenseStatus.LICENSE_STATUS.Valid
|
|
165
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-license",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "MUI X License verification",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.24.7",
|
|
28
|
-
"@mui/utils": "^5.15.
|
|
28
|
+
"@mui/utils": "^5.15.20"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^17.0.0 || ^18.0.0"
|
|
@@ -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;
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { verifyLicense } from '../verifyLicense/verifyLicense';
|
|
4
4
|
import { LicenseInfo } from '../utils/licenseInfo';
|
|
5
|
-
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError } from '../utils/licenseErrorMessageUtils';
|
|
5
|
+
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from '../utils/licenseErrorMessageUtils';
|
|
6
6
|
import { LICENSE_STATUS } from '../utils/licenseStatus';
|
|
7
7
|
import MuiLicenseInfoContext from '../Unstable_LicenseInfoProvider/MuiLicenseInfoContext';
|
|
8
8
|
export const sharedLicenseStatuses = {};
|
|
@@ -17,18 +17,19 @@ export function useLicenseVerifier(packageName, releaseInfo) {
|
|
|
17
17
|
if (sharedLicenseStatuses[packageName] && sharedLicenseStatuses[packageName].key === licenseKey) {
|
|
18
18
|
return sharedLicenseStatuses[packageName].licenseVerifier;
|
|
19
19
|
}
|
|
20
|
-
const acceptedScopes = packageName.includes('premium') ? ['premium'] : ['pro', 'premium'];
|
|
21
20
|
const plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
22
21
|
const licenseStatus = verifyLicense({
|
|
23
22
|
releaseInfo,
|
|
24
23
|
licenseKey,
|
|
25
|
-
|
|
24
|
+
packageName
|
|
26
25
|
});
|
|
27
26
|
const fullPackageName = `@mui/${packageName}`;
|
|
28
27
|
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
29
28
|
// Skip
|
|
30
29
|
} else if (licenseStatus.status === LICENSE_STATUS.Invalid) {
|
|
31
30
|
showInvalidLicenseKeyError();
|
|
31
|
+
} else if (licenseStatus.status === LICENSE_STATUS.NotAvailableInInitialProPlan) {
|
|
32
|
+
showNotAvailableInInitialProPlanError();
|
|
32
33
|
} else if (licenseStatus.status === LICENSE_STATUS.OutOfScope) {
|
|
33
34
|
showLicenseKeyPlanMismatchError();
|
|
34
35
|
} else if (licenseStatus.status === LICENSE_STATUS.NotFound) {
|
|
@@ -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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function showInvalidLicenseKeyError(): void;
|
|
2
2
|
export declare function showLicenseKeyPlanMismatchError(): void;
|
|
3
|
+
export declare function showNotAvailableInInitialProPlanError(): void;
|
|
3
4
|
export declare function showMissingLicenseKeyError({ plan, packageName, }: {
|
|
4
5
|
plan: string;
|
|
5
6
|
packageName: string;
|
|
@@ -7,6 +7,9 @@ export function showInvalidLicenseKeyError() {
|
|
|
7
7
|
export function showLicenseKeyPlanMismatchError() {
|
|
8
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
9
|
}
|
|
10
|
+
export function showNotAvailableInInitialProPlanError() {
|
|
11
|
+
showError(['MUI X: Component not included in your license.', '', 'The component you are trying to use is not included in the Pro Plan you purchased.', '', 'Your license is from an old version of the Pro Plan that is only compatible with the `@mui/x-data-grid-pro` and `@mui/x-date-pickers-pro` commercial packages.', '', 'To start using another Pro package, please consider reaching to our sales team to upgrade your license or visit https://mui.com/r/x-get-license to get a new license key.']);
|
|
12
|
+
}
|
|
10
13
|
export function showMissingLicenseKeyError({
|
|
11
14
|
plan,
|
|
12
15
|
packageName
|
package/utils/licenseScope.d.ts
CHANGED
package/utils/licenseScope.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
1
|
+
export const LICENSE_SCOPES = ['pro', 'premium'];
|
|
2
|
+
export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
package/utils/licenseStatus.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare enum LICENSE_STATUS {
|
|
|
5
5
|
ExpiredAnnualGrace = "ExpiredAnnualGrace",
|
|
6
6
|
ExpiredVersion = "ExpiredVersion",
|
|
7
7
|
Valid = "Valid",
|
|
8
|
-
OutOfScope = "OutOfScope"
|
|
8
|
+
OutOfScope = "OutOfScope",
|
|
9
|
+
NotAvailableInInitialProPlan = "NotAvailableInInitialProPlan"
|
|
9
10
|
}
|
|
10
11
|
export type LicenseStatus = keyof typeof LICENSE_STATUS;
|
package/utils/licenseStatus.js
CHANGED
|
@@ -7,5 +7,6 @@ export let LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STATUS) {
|
|
|
7
7
|
LICENSE_STATUS["ExpiredVersion"] = "ExpiredVersion";
|
|
8
8
|
LICENSE_STATUS["Valid"] = "Valid";
|
|
9
9
|
LICENSE_STATUS["OutOfScope"] = "OutOfScope";
|
|
10
|
+
LICENSE_STATUS["NotAvailableInInitialProPlan"] = "NotAvailableInInitialProPlan";
|
|
10
11
|
return LICENSE_STATUS;
|
|
11
12
|
}({});
|
|
@@ -1,10 +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
|
-
licenseKey
|
|
7
|
-
|
|
6
|
+
licenseKey?: string;
|
|
7
|
+
packageName: MuiCommercialPackageName;
|
|
8
8
|
}): {
|
|
9
9
|
status: LicenseStatus;
|
|
10
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
|
*/
|
|
@@ -28,18 +41,20 @@ const decodeLicenseVersion1 = license => {
|
|
|
28
41
|
return {
|
|
29
42
|
scope: 'pro',
|
|
30
43
|
licensingModel: 'perpetual',
|
|
31
|
-
expiryTimestamp
|
|
44
|
+
expiryTimestamp,
|
|
45
|
+
planVersion: 'initial'
|
|
32
46
|
};
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
/**
|
|
36
|
-
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},KV=2`;
|
|
50
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${scope},LM=${licensingModel},PV=${planVersion},KV=2`;
|
|
37
51
|
*/
|
|
38
52
|
const decodeLicenseVersion2 = license => {
|
|
39
53
|
const licenseInfo = {
|
|
40
54
|
scope: null,
|
|
41
55
|
licensingModel: null,
|
|
42
|
-
expiryTimestamp: null
|
|
56
|
+
expiryTimestamp: null,
|
|
57
|
+
planVersion: 'initial'
|
|
43
58
|
};
|
|
44
59
|
license.split(',').map(token => token.split('=')).filter(el => el.length === 2).forEach(([key, value]) => {
|
|
45
60
|
if (key === 'S') {
|
|
@@ -54,6 +69,9 @@ const decodeLicenseVersion2 = license => {
|
|
|
54
69
|
licenseInfo.expiryTimestamp = expiryTimestamp;
|
|
55
70
|
}
|
|
56
71
|
}
|
|
72
|
+
if (key === 'PV') {
|
|
73
|
+
licenseInfo.planVersion = value;
|
|
74
|
+
}
|
|
57
75
|
});
|
|
58
76
|
return licenseInfo;
|
|
59
77
|
};
|
|
@@ -74,7 +92,7 @@ const decodeLicense = encodedLicense => {
|
|
|
74
92
|
export function verifyLicense({
|
|
75
93
|
releaseInfo,
|
|
76
94
|
licenseKey,
|
|
77
|
-
|
|
95
|
+
packageName
|
|
78
96
|
}) {
|
|
79
97
|
if (!releaseInfo) {
|
|
80
98
|
throw new Error('MUI X: The release information is missing. Not able to validate license.');
|
|
@@ -143,16 +161,23 @@ export function verifyLicense({
|
|
|
143
161
|
}
|
|
144
162
|
}
|
|
145
163
|
if (license.scope == null || !LICENSE_SCOPES.includes(license.scope)) {
|
|
146
|
-
console.error('Error checking license. scope not found or invalid!');
|
|
164
|
+
console.error('MUI X: Error checking license. scope not found or invalid!');
|
|
147
165
|
return {
|
|
148
166
|
status: LICENSE_STATUS.Invalid
|
|
149
167
|
};
|
|
150
168
|
}
|
|
151
|
-
if (!
|
|
169
|
+
if (!isLicenseScopeSufficient(packageName, license.scope)) {
|
|
152
170
|
return {
|
|
153
171
|
status: LICENSE_STATUS.OutOfScope
|
|
154
172
|
};
|
|
155
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
|
+
}
|
|
156
181
|
return {
|
|
157
182
|
status: LICENSE_STATUS.Valid
|
|
158
183
|
};
|