@mui/x-license 8.0.0-alpha.11 → 8.0.0-alpha.12
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 +161 -1
- package/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts +7 -4
- package/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +13 -5
- package/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts +2 -2
- package/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js +8 -2
- package/Unstable_LicenseInfoProvider/index.d.ts +2 -2
- package/Unstable_LicenseInfoProvider/index.js +12 -1
- package/Watermark/Watermark.d.ts +4 -4
- package/Watermark/Watermark.js +23 -17
- package/Watermark/index.d.ts +1 -1
- package/Watermark/index.js +16 -1
- package/encoding/base64.d.ts +1 -1
- package/encoding/base64.js +11 -3
- package/encoding/md5.d.ts +1 -1
- package/encoding/md5.js +7 -1
- package/esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts +16 -0
- package/esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +19 -0
- package/esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts +4 -0
- package/esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js +10 -0
- package/esm/Unstable_LicenseInfoProvider/index.d.ts +2 -0
- package/esm/Unstable_LicenseInfoProvider/index.js +1 -0
- package/esm/Watermark/Watermark.d.ts +9 -0
- package/esm/Watermark/Watermark.js +51 -0
- package/esm/Watermark/index.d.ts +1 -0
- package/esm/Watermark/index.js +1 -0
- package/esm/encoding/base64.d.ts +2 -0
- package/{node → esm}/encoding/base64.js +3 -11
- package/esm/encoding/md5.d.ts +1 -0
- package/{node → esm}/encoding/md5.js +1 -7
- package/esm/generateLicense/generateLicense.d.ts +10 -0
- package/esm/generateLicense/generateLicense.js +19 -0
- package/esm/generateLicense/index.d.ts +1 -0
- package/esm/generateLicense/index.js +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +13 -0
- package/esm/package.json +1 -0
- package/esm/useLicenseVerifier/index.d.ts +1 -0
- package/esm/useLicenseVerifier/index.js +1 -0
- package/esm/useLicenseVerifier/useLicenseVerifier.d.ts +11 -0
- package/esm/useLicenseVerifier/useLicenseVerifier.js +61 -0
- package/esm/utils/commercialPackages.d.ts +1 -0
- package/esm/utils/commercialPackages.js +1 -0
- package/esm/utils/index.d.ts +6 -0
- package/esm/utils/index.js +4 -0
- package/esm/utils/licenseErrorMessageUtils.d.ts +33 -0
- package/{node → esm}/utils/licenseErrorMessageUtils.js +7 -19
- package/esm/utils/licenseInfo.d.ts +11 -0
- package/{node → esm}/utils/licenseInfo.js +5 -11
- package/esm/utils/licenseModel.d.ts +2 -0
- package/{node → esm}/utils/licenseModel.js +1 -7
- package/esm/utils/licenseStatus.d.ts +11 -0
- package/{node → esm}/utils/licenseStatus.js +1 -7
- package/esm/utils/plan.d.ts +4 -0
- package/esm/utils/plan.js +2 -0
- package/esm/verifyLicense/index.d.ts +1 -0
- package/esm/verifyLicense/index.js +1 -0
- package/esm/verifyLicense/verifyLicense.d.ts +15 -0
- package/{node → esm}/verifyLicense/verifyLicense.js +25 -32
- package/generateLicense/generateLicense.d.ts +8 -8
- package/generateLicense/generateLicense.js +14 -8
- package/generateLicense/index.d.ts +1 -1
- package/generateLicense/index.js +16 -1
- package/index.d.ts +6 -6
- package/index.js +72 -7
- package/modern/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts +16 -0
- package/modern/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts +4 -0
- package/modern/Unstable_LicenseInfoProvider/index.d.ts +2 -0
- package/modern/Watermark/Watermark.d.ts +9 -0
- package/modern/Watermark/index.d.ts +1 -0
- package/modern/encoding/base64.d.ts +2 -0
- package/modern/encoding/md5.d.ts +1 -0
- package/modern/generateLicense/generateLicense.d.ts +10 -0
- package/modern/generateLicense/index.d.ts +1 -0
- package/modern/index.d.ts +6 -0
- package/modern/index.js +1 -1
- package/modern/package.json +1 -0
- package/modern/useLicenseVerifier/index.d.ts +1 -0
- package/modern/useLicenseVerifier/useLicenseVerifier.d.ts +11 -0
- package/modern/utils/commercialPackages.d.ts +1 -0
- package/modern/utils/index.d.ts +6 -0
- package/modern/utils/licenseErrorMessageUtils.d.ts +33 -0
- package/modern/utils/licenseInfo.d.ts +11 -0
- package/modern/utils/licenseModel.d.ts +2 -0
- package/modern/utils/licenseStatus.d.ts +11 -0
- package/modern/utils/plan.d.ts +4 -0
- package/modern/verifyLicense/index.d.ts +1 -0
- package/modern/verifyLicense/verifyLicense.d.ts +15 -0
- package/package.json +36 -6
- package/tsconfig.build.tsbuildinfo +1 -0
- package/useLicenseVerifier/index.d.ts +1 -1
- package/useLicenseVerifier/index.js +12 -1
- package/useLicenseVerifier/useLicenseVerifier.d.ts +10 -12
- package/useLicenseVerifier/useLicenseVerifier.js +36 -27
- package/utils/commercialPackages.d.ts +1 -1
- package/utils/commercialPackages.js +5 -1
- package/utils/index.d.ts +4 -4
- package/utils/index.js +38 -4
- package/utils/licenseErrorMessageUtils.d.ts +27 -14
- package/utils/licenseErrorMessageUtils.js +19 -7
- package/utils/licenseInfo.d.ts +5 -5
- package/utils/licenseInfo.js +11 -5
- package/utils/licenseModel.d.ts +1 -1
- package/utils/licenseModel.js +7 -1
- package/utils/licenseStatus.d.ts +9 -9
- package/utils/licenseStatus.js +7 -1
- package/utils/plan.d.ts +1 -1
- package/utils/plan.js +8 -2
- package/verifyLicense/index.d.ts +1 -1
- package/verifyLicense/index.js +16 -1
- package/verifyLicense/verifyLicense.d.ts +13 -9
- package/verifyLicense/verifyLicense.js +32 -25
- package/Unstable_LicenseInfoProvider/package.json +0 -6
- package/Watermark/package.json +0 -6
- package/generateLicense/package.json +0 -6
- package/node/Unstable_LicenseInfoProvider/LicenseInfoProvider.js +0 -27
- package/node/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js +0 -16
- package/node/Unstable_LicenseInfoProvider/index.js +0 -12
- package/node/Watermark/Watermark.js +0 -57
- package/node/Watermark/index.js +0 -16
- package/node/generateLicense/generateLicense.js +0 -25
- package/node/generateLicense/index.js +0 -16
- package/node/index.js +0 -78
- package/node/useLicenseVerifier/index.js +0 -12
- package/node/useLicenseVerifier/useLicenseVerifier.js +0 -70
- package/node/utils/commercialPackages.js +0 -5
- package/node/utils/index.js +0 -38
- package/node/utils/plan.js +0 -8
- package/node/verifyLicense/index.js +0 -16
- package/useLicenseVerifier/package.json +0 -6
- package/utils/package.json +0 -6
- package/verifyLicense/package.json +0 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { md5 } from "../encoding/md5.js";
|
|
2
|
+
import { base64Encode } from "../encoding/base64.js";
|
|
3
|
+
import { PLAN_SCOPES } from "../utils/plan.js";
|
|
4
|
+
import { LICENSE_MODELS } from "../utils/licenseModel.js";
|
|
5
|
+
const licenseVersion = '2';
|
|
6
|
+
function getClearLicenseString(details) {
|
|
7
|
+
if (details.planScope && !PLAN_SCOPES.includes(details.planScope)) {
|
|
8
|
+
throw new Error('MUI X: Invalid scope');
|
|
9
|
+
}
|
|
10
|
+
if (details.licenseModel && !LICENSE_MODELS.includes(details.licenseModel)) {
|
|
11
|
+
throw new Error('MUI X: Invalid licensing model');
|
|
12
|
+
}
|
|
13
|
+
const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.planScope}`, `LM=${details.licenseModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
|
|
14
|
+
return keyParts.join(',');
|
|
15
|
+
}
|
|
16
|
+
export function generateLicense(details) {
|
|
17
|
+
const licenseStr = getClearLicenseString(details);
|
|
18
|
+
return `${md5(base64Encode(licenseStr))}${base64Encode(licenseStr)}`;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./generateLicense.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./generateLicense.js";
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./generateLicense/index.js";
|
|
2
|
+
export * from "./utils/index.js";
|
|
3
|
+
export * from "./verifyLicense/index.js";
|
|
4
|
+
export * from "./useLicenseVerifier/index.js";
|
|
5
|
+
export * from "./Watermark/index.js";
|
|
6
|
+
export * from "./Unstable_LicenseInfoProvider/index.js";
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mui/x-license v8.0.0-alpha.12
|
|
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/index.js";
|
|
9
|
+
export * from "./utils/index.js";
|
|
10
|
+
export * from "./verifyLicense/index.js";
|
|
11
|
+
export * from "./useLicenseVerifier/index.js";
|
|
12
|
+
export * from "./Watermark/index.js";
|
|
13
|
+
export * from "./Unstable_LicenseInfoProvider/index.js";
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module","sideEffects":false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLicenseVerifier } from "./useLicenseVerifier.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLicenseVerifier } from "./useLicenseVerifier.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LicenseStatus } from "../utils/licenseStatus.js";
|
|
2
|
+
import { MuiCommercialPackageName } from "../utils/commercialPackages.js";
|
|
3
|
+
export declare const sharedLicenseStatuses: { [packageName in MuiCommercialPackageName]?: {
|
|
4
|
+
key: string | undefined;
|
|
5
|
+
licenseVerifier: {
|
|
6
|
+
status: LicenseStatus;
|
|
7
|
+
};
|
|
8
|
+
} };
|
|
9
|
+
export declare function useLicenseVerifier(packageName: MuiCommercialPackageName, releaseInfo: string): {
|
|
10
|
+
status: LicenseStatus;
|
|
11
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { verifyLicense } from "../verifyLicense/verifyLicense.js";
|
|
4
|
+
import { LicenseInfo } from "../utils/licenseInfo.js";
|
|
5
|
+
import { showExpiredAnnualGraceLicenseKeyError, showExpiredAnnualLicenseKeyError, showInvalidLicenseKeyError, showMissingLicenseKeyError, showLicenseKeyPlanMismatchError, showExpiredPackageVersionError, showNotAvailableInInitialProPlanError } from "../utils/licenseErrorMessageUtils.js";
|
|
6
|
+
import { LICENSE_STATUS } from "../utils/licenseStatus.js";
|
|
7
|
+
import MuiLicenseInfoContext from "../Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js";
|
|
8
|
+
export const sharedLicenseStatuses = {};
|
|
9
|
+
export function useLicenseVerifier(packageName, releaseInfo) {
|
|
10
|
+
const {
|
|
11
|
+
key: contextKey
|
|
12
|
+
} = React.useContext(MuiLicenseInfoContext);
|
|
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 plan = packageName.includes('premium') ? 'Premium' : 'Pro';
|
|
21
|
+
const licenseStatus = verifyLicense({
|
|
22
|
+
releaseInfo,
|
|
23
|
+
licenseKey,
|
|
24
|
+
packageName
|
|
25
|
+
});
|
|
26
|
+
const fullPackageName = `@mui/${packageName}`;
|
|
27
|
+
if (licenseStatus.status === LICENSE_STATUS.Valid) {
|
|
28
|
+
// Skip
|
|
29
|
+
} else if (licenseStatus.status === LICENSE_STATUS.Invalid) {
|
|
30
|
+
showInvalidLicenseKeyError();
|
|
31
|
+
} else if (licenseStatus.status === LICENSE_STATUS.NotAvailableInInitialProPlan) {
|
|
32
|
+
showNotAvailableInInitialProPlanError();
|
|
33
|
+
} else if (licenseStatus.status === LICENSE_STATUS.OutOfScope) {
|
|
34
|
+
showLicenseKeyPlanMismatchError();
|
|
35
|
+
} else if (licenseStatus.status === LICENSE_STATUS.NotFound) {
|
|
36
|
+
showMissingLicenseKeyError({
|
|
37
|
+
plan,
|
|
38
|
+
packageName: fullPackageName
|
|
39
|
+
});
|
|
40
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredAnnualGrace) {
|
|
41
|
+
showExpiredAnnualGraceLicenseKeyError(_extends({
|
|
42
|
+
plan
|
|
43
|
+
}, licenseStatus.meta));
|
|
44
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredAnnual) {
|
|
45
|
+
showExpiredAnnualLicenseKeyError(_extends({
|
|
46
|
+
plan
|
|
47
|
+
}, licenseStatus.meta));
|
|
48
|
+
} else if (licenseStatus.status === LICENSE_STATUS.ExpiredVersion) {
|
|
49
|
+
showExpiredPackageVersionError({
|
|
50
|
+
packageName: fullPackageName
|
|
51
|
+
});
|
|
52
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
53
|
+
throw new Error('missing status handler');
|
|
54
|
+
}
|
|
55
|
+
sharedLicenseStatuses[packageName] = {
|
|
56
|
+
key: licenseKey,
|
|
57
|
+
licenseVerifier: licenseStatus
|
|
58
|
+
};
|
|
59
|
+
return licenseStatus;
|
|
60
|
+
}, [packageName, releaseInfo, contextKey]);
|
|
61
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./licenseErrorMessageUtils.js";
|
|
2
|
+
export * from "./licenseInfo.js";
|
|
3
|
+
export * from "./licenseStatus.js";
|
|
4
|
+
export type { PlanScope } from './plan';
|
|
5
|
+
export type { LicenseModel } from './licenseModel';
|
|
6
|
+
export type { MuiCommercialPackageName } from './commercialPackages';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare function showInvalidLicenseKeyError(): void;
|
|
2
|
+
export declare function showLicenseKeyPlanMismatchError(): void;
|
|
3
|
+
export declare function showNotAvailableInInitialProPlanError(): void;
|
|
4
|
+
export declare function showMissingLicenseKeyError({
|
|
5
|
+
plan,
|
|
6
|
+
packageName
|
|
7
|
+
}: {
|
|
8
|
+
plan: string;
|
|
9
|
+
packageName: string;
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function showExpiredPackageVersionError({
|
|
12
|
+
packageName
|
|
13
|
+
}: {
|
|
14
|
+
packageName: string;
|
|
15
|
+
}): void;
|
|
16
|
+
export declare function showExpiredAnnualGraceLicenseKeyError({
|
|
17
|
+
plan,
|
|
18
|
+
licenseKey,
|
|
19
|
+
expiryTimestamp
|
|
20
|
+
}: {
|
|
21
|
+
plan: string;
|
|
22
|
+
licenseKey: string;
|
|
23
|
+
expiryTimestamp: number;
|
|
24
|
+
}): void;
|
|
25
|
+
export declare function showExpiredAnnualLicenseKeyError({
|
|
26
|
+
plan,
|
|
27
|
+
licenseKey,
|
|
28
|
+
expiryTimestamp
|
|
29
|
+
}: {
|
|
30
|
+
plan: string;
|
|
31
|
+
licenseKey: string;
|
|
32
|
+
expiryTimestamp: number;
|
|
33
|
+
}): void;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.showExpiredAnnualGraceLicenseKeyError = showExpiredAnnualGraceLicenseKeyError;
|
|
7
|
-
exports.showExpiredAnnualLicenseKeyError = showExpiredAnnualLicenseKeyError;
|
|
8
|
-
exports.showExpiredPackageVersionError = showExpiredPackageVersionError;
|
|
9
|
-
exports.showInvalidLicenseKeyError = showInvalidLicenseKeyError;
|
|
10
|
-
exports.showLicenseKeyPlanMismatchError = showLicenseKeyPlanMismatchError;
|
|
11
|
-
exports.showMissingLicenseKeyError = showMissingLicenseKeyError;
|
|
12
|
-
exports.showNotAvailableInInitialProPlanError = showNotAvailableInInitialProPlanError;
|
|
13
1
|
/**
|
|
14
2
|
* Workaround for the codesadbox preview error.
|
|
15
3
|
*
|
|
@@ -25,34 +13,34 @@ function showError(message) {
|
|
|
25
13
|
const logger = isCodeSandbox ? console.log : console.error;
|
|
26
14
|
logger(['*************************************************************', '', ...message, '', '*************************************************************'].join('\n'));
|
|
27
15
|
}
|
|
28
|
-
function showInvalidLicenseKeyError() {
|
|
16
|
+
export function showInvalidLicenseKeyError() {
|
|
29
17
|
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.']);
|
|
30
18
|
}
|
|
31
|
-
function showLicenseKeyPlanMismatchError() {
|
|
19
|
+
export function showLicenseKeyPlanMismatchError() {
|
|
32
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 Data Grid Premium 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`."]);
|
|
33
21
|
}
|
|
34
|
-
function showNotAvailableInInitialProPlanError() {
|
|
22
|
+
export function showNotAvailableInInitialProPlanError() {
|
|
35
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.']);
|
|
36
24
|
}
|
|
37
|
-
function showMissingLicenseKeyError({
|
|
25
|
+
export function showMissingLicenseKeyError({
|
|
38
26
|
plan,
|
|
39
27
|
packageName
|
|
40
28
|
}) {
|
|
41
29
|
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.']);
|
|
42
30
|
}
|
|
43
|
-
function showExpiredPackageVersionError({
|
|
31
|
+
export function showExpiredPackageVersionError({
|
|
44
32
|
packageName
|
|
45
33
|
}) {
|
|
46
34
|
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.']);
|
|
47
35
|
}
|
|
48
|
-
function showExpiredAnnualGraceLicenseKeyError({
|
|
36
|
+
export function showExpiredAnnualGraceLicenseKeyError({
|
|
49
37
|
plan,
|
|
50
38
|
licenseKey,
|
|
51
39
|
expiryTimestamp
|
|
52
40
|
}) {
|
|
53
41
|
showError(['MUI X: Expired license key.', '', `Your annual license key to use MUI X ${plan} in non-production environments has 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}`, '']);
|
|
54
42
|
}
|
|
55
|
-
function showExpiredAnnualLicenseKeyError({
|
|
43
|
+
export function showExpiredAnnualLicenseKeyError({
|
|
56
44
|
plan,
|
|
57
45
|
licenseKey,
|
|
58
46
|
expiryTimestamp
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore - do not document.
|
|
3
|
+
*/
|
|
4
|
+
export interface MuiLicenseInfo {
|
|
5
|
+
key: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare class LicenseInfo {
|
|
8
|
+
private static getLicenseInfo;
|
|
9
|
+
static getLicenseKey(): MuiLicenseInfo['key'];
|
|
10
|
+
static setLicenseKey(key: string): void;
|
|
11
|
+
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LicenseInfo = void 0;
|
|
7
|
-
var _utils = require("@mui/utils");
|
|
8
3
|
/**
|
|
9
4
|
* @ignore - do not document.
|
|
10
5
|
*/
|
|
@@ -14,13 +9,13 @@ var _utils = require("@mui/utils");
|
|
|
14
9
|
// if using multiple version of MUI X at the same time of the bundler
|
|
15
10
|
// decide to duplicate to improve the size of the chunks.
|
|
16
11
|
// eslint-disable-next-line no-underscore-dangle
|
|
17
|
-
|
|
12
|
+
ponyfillGlobal.__MUI_LICENSE_INFO__ = ponyfillGlobal.__MUI_LICENSE_INFO__ || {
|
|
18
13
|
key: undefined
|
|
19
14
|
};
|
|
20
|
-
class LicenseInfo {
|
|
15
|
+
export class LicenseInfo {
|
|
21
16
|
static getLicenseInfo() {
|
|
22
17
|
// eslint-disable-next-line no-underscore-dangle
|
|
23
|
-
return
|
|
18
|
+
return ponyfillGlobal.__MUI_LICENSE_INFO__;
|
|
24
19
|
}
|
|
25
20
|
static getLicenseKey() {
|
|
26
21
|
return LicenseInfo.getLicenseInfo().key;
|
|
@@ -29,5 +24,4 @@ class LicenseInfo {
|
|
|
29
24
|
const licenseInfo = LicenseInfo.getLicenseInfo();
|
|
30
25
|
licenseInfo.key = key;
|
|
31
26
|
}
|
|
32
|
-
}
|
|
33
|
-
exports.LicenseInfo = LicenseInfo;
|
|
27
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LICENSE_MODELS = void 0;
|
|
7
|
-
const LICENSE_MODELS = exports.LICENSE_MODELS = [
|
|
1
|
+
export const LICENSE_MODELS = [
|
|
8
2
|
/**
|
|
9
3
|
* A license is outdated if the current version of the software was released after the expiry date of the license.
|
|
10
4
|
* But the license can be used indefinitely with an older version of the software.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum LICENSE_STATUS {
|
|
2
|
+
NotFound = "NotFound",
|
|
3
|
+
Invalid = "Invalid",
|
|
4
|
+
ExpiredAnnual = "ExpiredAnnual",
|
|
5
|
+
ExpiredAnnualGrace = "ExpiredAnnualGrace",
|
|
6
|
+
ExpiredVersion = "ExpiredVersion",
|
|
7
|
+
Valid = "Valid",
|
|
8
|
+
OutOfScope = "OutOfScope",
|
|
9
|
+
NotAvailableInInitialProPlan = "NotAvailableInInitialProPlan",
|
|
10
|
+
}
|
|
11
|
+
export type LicenseStatus = keyof typeof LICENSE_STATUS;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LICENSE_STATUS = void 0;
|
|
7
1
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8
|
-
let LICENSE_STATUS =
|
|
2
|
+
export let LICENSE_STATUS = /*#__PURE__*/function (LICENSE_STATUS) {
|
|
9
3
|
LICENSE_STATUS["NotFound"] = "NotFound";
|
|
10
4
|
LICENSE_STATUS["Invalid"] = "Invalid";
|
|
11
5
|
LICENSE_STATUS["ExpiredAnnual"] = "ExpiredAnnual";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./verifyLicense.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./verifyLicense.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LicenseStatus } from "../utils/licenseStatus.js";
|
|
2
|
+
import { MuiCommercialPackageName } from "../utils/commercialPackages.js";
|
|
3
|
+
export declare function generateReleaseInfo(releaseDate?: Date): string;
|
|
4
|
+
export declare function verifyLicense({
|
|
5
|
+
releaseInfo,
|
|
6
|
+
licenseKey,
|
|
7
|
+
packageName
|
|
8
|
+
}: {
|
|
9
|
+
releaseInfo: string;
|
|
10
|
+
licenseKey?: string;
|
|
11
|
+
packageName: MuiCommercialPackageName;
|
|
12
|
+
}): {
|
|
13
|
+
status: LicenseStatus;
|
|
14
|
+
meta?: any;
|
|
15
|
+
};
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
exports.generateReleaseInfo = generateReleaseInfo;
|
|
7
|
-
exports.verifyLicense = verifyLicense;
|
|
8
|
-
var _base = require("../encoding/base64");
|
|
9
|
-
var _md = require("../encoding/md5");
|
|
10
|
-
var _licenseStatus = require("../utils/licenseStatus");
|
|
11
|
-
var _plan = require("../utils/plan");
|
|
12
|
-
var _licenseModel = require("../utils/licenseModel");
|
|
1
|
+
import { base64Decode, base64Encode } from "../encoding/base64.js";
|
|
2
|
+
import { md5 } from "../encoding/md5.js";
|
|
3
|
+
import { LICENSE_STATUS } from "../utils/licenseStatus.js";
|
|
4
|
+
import { PLAN_SCOPES } from "../utils/plan.js";
|
|
5
|
+
import { LICENSE_MODELS } from "../utils/licenseModel.js";
|
|
13
6
|
const getDefaultReleaseDate = () => {
|
|
14
7
|
const today = new Date();
|
|
15
8
|
today.setHours(0, 0, 0, 0);
|
|
16
9
|
return today;
|
|
17
10
|
};
|
|
18
|
-
function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
19
|
-
return
|
|
11
|
+
export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
12
|
+
return base64Encode(releaseDate.getTime().toString());
|
|
20
13
|
}
|
|
21
14
|
function isPlanScopeSufficient(packageName, planScope) {
|
|
22
15
|
let acceptedScopes;
|
|
@@ -87,7 +80,7 @@ const decodeLicenseVersion2 = license => {
|
|
|
87
80
|
* Decode the license based on its key version and return a version-agnostic `MuiLicense` object.
|
|
88
81
|
*/
|
|
89
82
|
const decodeLicense = encodedLicense => {
|
|
90
|
-
const license =
|
|
83
|
+
const license = base64Decode(encodedLicense);
|
|
91
84
|
if (license.includes('KEYVERSION=1')) {
|
|
92
85
|
return decodeLicenseVersion1(license);
|
|
93
86
|
}
|
|
@@ -96,7 +89,7 @@ const decodeLicense = encodedLicense => {
|
|
|
96
89
|
}
|
|
97
90
|
return null;
|
|
98
91
|
};
|
|
99
|
-
function verifyLicense({
|
|
92
|
+
export function verifyLicense({
|
|
100
93
|
releaseInfo,
|
|
101
94
|
licenseKey,
|
|
102
95
|
packageName
|
|
@@ -106,43 +99,43 @@ function verifyLicense({
|
|
|
106
99
|
}
|
|
107
100
|
if (!licenseKey) {
|
|
108
101
|
return {
|
|
109
|
-
status:
|
|
102
|
+
status: LICENSE_STATUS.NotFound
|
|
110
103
|
};
|
|
111
104
|
}
|
|
112
105
|
const hash = licenseKey.substr(0, 32);
|
|
113
106
|
const encoded = licenseKey.substr(32);
|
|
114
|
-
if (hash !==
|
|
107
|
+
if (hash !== md5(encoded)) {
|
|
115
108
|
return {
|
|
116
|
-
status:
|
|
109
|
+
status: LICENSE_STATUS.Invalid
|
|
117
110
|
};
|
|
118
111
|
}
|
|
119
112
|
const license = decodeLicense(encoded);
|
|
120
113
|
if (license == null) {
|
|
121
114
|
console.error('MUI X: Error checking license. Key version not found!');
|
|
122
115
|
return {
|
|
123
|
-
status:
|
|
116
|
+
status: LICENSE_STATUS.Invalid
|
|
124
117
|
};
|
|
125
118
|
}
|
|
126
|
-
if (license.licenseModel == null || !
|
|
119
|
+
if (license.licenseModel == null || !LICENSE_MODELS.includes(license.licenseModel)) {
|
|
127
120
|
console.error('MUI X: Error checking license. Licensing model not found or invalid!');
|
|
128
121
|
return {
|
|
129
|
-
status:
|
|
122
|
+
status: LICENSE_STATUS.Invalid
|
|
130
123
|
};
|
|
131
124
|
}
|
|
132
125
|
if (license.expiryTimestamp == null) {
|
|
133
126
|
console.error('MUI X: Error checking license. Expiry timestamp not found or invalid!');
|
|
134
127
|
return {
|
|
135
|
-
status:
|
|
128
|
+
status: LICENSE_STATUS.Invalid
|
|
136
129
|
};
|
|
137
130
|
}
|
|
138
131
|
if (license.licenseModel === 'perpetual' || process.env.NODE_ENV === 'production') {
|
|
139
|
-
const pkgTimestamp = parseInt(
|
|
132
|
+
const pkgTimestamp = parseInt(base64Decode(releaseInfo), 10);
|
|
140
133
|
if (Number.isNaN(pkgTimestamp)) {
|
|
141
134
|
throw new Error('MUI X: The release information is invalid. Not able to validate license.');
|
|
142
135
|
}
|
|
143
136
|
if (license.expiryTimestamp < pkgTimestamp) {
|
|
144
137
|
return {
|
|
145
|
-
status:
|
|
138
|
+
status: LICENSE_STATUS.ExpiredVersion
|
|
146
139
|
};
|
|
147
140
|
}
|
|
148
141
|
} else if (license.licenseModel === 'subscription' || license.licenseModel === 'annual') {
|
|
@@ -151,7 +144,7 @@ function verifyLicense({
|
|
|
151
144
|
// 30 days grace
|
|
152
145
|
new Date().getTime() < license.expiryTimestamp + 1000 * 3600 * 24 * 30 || process.env.NODE_ENV !== 'development') {
|
|
153
146
|
return {
|
|
154
|
-
status:
|
|
147
|
+
status: LICENSE_STATUS.ExpiredAnnualGrace,
|
|
155
148
|
meta: {
|
|
156
149
|
expiryTimestamp: license.expiryTimestamp,
|
|
157
150
|
licenseKey
|
|
@@ -159,7 +152,7 @@ function verifyLicense({
|
|
|
159
152
|
};
|
|
160
153
|
}
|
|
161
154
|
return {
|
|
162
|
-
status:
|
|
155
|
+
status: LICENSE_STATUS.ExpiredAnnual,
|
|
163
156
|
meta: {
|
|
164
157
|
expiryTimestamp: license.expiryTimestamp,
|
|
165
158
|
licenseKey
|
|
@@ -167,25 +160,25 @@ function verifyLicense({
|
|
|
167
160
|
};
|
|
168
161
|
}
|
|
169
162
|
}
|
|
170
|
-
if (license.planScope == null || !
|
|
163
|
+
if (license.planScope == null || !PLAN_SCOPES.includes(license.planScope)) {
|
|
171
164
|
console.error('MUI X: Error checking license. planScope not found or invalid!');
|
|
172
165
|
return {
|
|
173
|
-
status:
|
|
166
|
+
status: LICENSE_STATUS.Invalid
|
|
174
167
|
};
|
|
175
168
|
}
|
|
176
169
|
if (!isPlanScopeSufficient(packageName, license.planScope)) {
|
|
177
170
|
return {
|
|
178
|
-
status:
|
|
171
|
+
status: LICENSE_STATUS.OutOfScope
|
|
179
172
|
};
|
|
180
173
|
}
|
|
181
174
|
|
|
182
175
|
// 'charts-pro' or 'tree-view-pro' can only be used with a newer Pro license
|
|
183
176
|
if (license.planVersion === 'initial' && license.planScope === 'pro' && !PRO_PACKAGES_AVAILABLE_IN_INITIAL_PRO_PLAN.includes(packageName)) {
|
|
184
177
|
return {
|
|
185
|
-
status:
|
|
178
|
+
status: LICENSE_STATUS.NotAvailableInInitialProPlan
|
|
186
179
|
};
|
|
187
180
|
}
|
|
188
181
|
return {
|
|
189
|
-
status:
|
|
182
|
+
status: LICENSE_STATUS.Valid
|
|
190
183
|
};
|
|
191
184
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PlanScope, PlanVersion } from
|
|
2
|
-
import { LicenseModel } from
|
|
1
|
+
import { PlanScope, PlanVersion } from "../utils/plan.js";
|
|
2
|
+
import { LicenseModel } from "../utils/licenseModel.js";
|
|
3
3
|
export interface LicenseDetails {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
expiryDate: Date;
|
|
5
|
+
licenseModel?: LicenseModel;
|
|
6
|
+
orderNumber: string;
|
|
7
|
+
planScope?: PlanScope;
|
|
8
|
+
planVersion: PlanVersion;
|
|
9
9
|
}
|
|
10
|
-
export declare function generateLicense(details: LicenseDetails): string;
|
|
10
|
+
export declare function generateLicense(details: LicenseDetails): string;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.generateLicense = generateLicense;
|
|
7
|
+
var _md = require("../encoding/md5");
|
|
8
|
+
var _base = require("../encoding/base64");
|
|
9
|
+
var _plan = require("../utils/plan");
|
|
10
|
+
var _licenseModel = require("../utils/licenseModel");
|
|
5
11
|
const licenseVersion = '2';
|
|
6
12
|
function getClearLicenseString(details) {
|
|
7
|
-
if (details.planScope && !PLAN_SCOPES.includes(details.planScope)) {
|
|
13
|
+
if (details.planScope && !_plan.PLAN_SCOPES.includes(details.planScope)) {
|
|
8
14
|
throw new Error('MUI X: Invalid scope');
|
|
9
15
|
}
|
|
10
|
-
if (details.licenseModel && !LICENSE_MODELS.includes(details.licenseModel)) {
|
|
16
|
+
if (details.licenseModel && !_licenseModel.LICENSE_MODELS.includes(details.licenseModel)) {
|
|
11
17
|
throw new Error('MUI X: Invalid licensing model');
|
|
12
18
|
}
|
|
13
19
|
const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.planScope}`, `LM=${details.licenseModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
|
|
14
20
|
return keyParts.join(',');
|
|
15
21
|
}
|
|
16
|
-
|
|
22
|
+
function generateLicense(details) {
|
|
17
23
|
const licenseStr = getClearLicenseString(details);
|
|
18
|
-
return `${md5(base64Encode(licenseStr))}${base64Encode(licenseStr)}`;
|
|
24
|
+
return `${(0, _md.md5)((0, _base.base64Encode)(licenseStr))}${(0, _base.base64Encode)(licenseStr)}`;
|
|
19
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./generateLicense.js";
|
package/generateLicense/index.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _generateLicense = require("./generateLicense");
|
|
7
|
+
Object.keys(_generateLicense).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _generateLicense[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _generateLicense[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from "./generateLicense/index.js";
|
|
2
|
+
export * from "./utils/index.js";
|
|
3
|
+
export * from "./verifyLicense/index.js";
|
|
4
|
+
export * from "./useLicenseVerifier/index.js";
|
|
5
|
+
export * from "./Watermark/index.js";
|
|
6
|
+
export * from "./Unstable_LicenseInfoProvider/index.js";
|