@mui/x-license 9.0.0-alpha.0 → 9.0.0-alpha.2
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 +236 -0
- package/{esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts → Unstable_LicenseInfoProvider/LicenseInfoProvider.d.mts} +1 -1
- package/{esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.js → Unstable_LicenseInfoProvider/LicenseInfoProvider.mjs} +1 -1
- package/{esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts → Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.mts} +1 -1
- package/{esm/Unstable_LicenseInfoProvider/index.d.ts → Unstable_LicenseInfoProvider/index.d.mts} +2 -2
- package/{esm/Unstable_LicenseInfoProvider/index.js → Unstable_LicenseInfoProvider/index.mjs} +1 -1
- package/{esm/Watermark/Watermark.d.ts → Watermark/Watermark.d.mts} +1 -1
- package/Watermark/Watermark.js +3 -1
- package/{esm/Watermark/Watermark.js → Watermark/Watermark.mjs} +4 -3
- package/Watermark/index.d.mts +1 -0
- package/Watermark/index.mjs +1 -0
- package/encoding/base64.js +3 -1
- package/{esm/encoding/base64.js → encoding/base64.mjs} +2 -1
- package/encoding/index.d.mts +2 -0
- package/encoding/index.mjs +2 -0
- package/index.d.mts +4 -0
- package/index.d.ts +3 -6
- package/index.js +14 -75
- package/index.mjs +10 -0
- package/license-env.d.mts +6 -0
- package/license-env.d.ts +6 -0
- package/package.json +105 -14
- package/test-keys.d.mts +92 -0
- package/test-keys.d.ts +92 -0
- package/test-keys.js +135 -0
- package/test-keys.mjs +129 -0
- package/{esm/useLicenseVerifier/index.d.ts → useLicenseVerifier/index.d.mts} +1 -1
- package/{esm/useLicenseVerifier/index.js → useLicenseVerifier/index.mjs} +1 -1
- package/{esm/useLicenseVerifier/useLicenseVerifier.d.ts → useLicenseVerifier/useLicenseVerifier.d.mts} +2 -2
- package/useLicenseVerifier/useLicenseVerifier.js +2 -1
- package/{esm/useLicenseVerifier/useLicenseVerifier.js → useLicenseVerifier/useLicenseVerifier.mjs} +7 -6
- package/{esm/utils/commercialPackages.d.ts → utils/commercialPackages.d.mts} +1 -1
- package/utils/commercialPackages.d.ts +1 -1
- package/utils/index.d.mts +8 -0
- package/utils/index.d.ts +3 -1
- package/utils/index.mjs +4 -0
- package/utils/licenseAppType.d.mts +8 -0
- package/utils/licenseAppType.d.ts +8 -0
- package/utils/licenseAppType.js +16 -0
- package/utils/licenseAppType.mjs +10 -0
- package/utils/licenseDetails.d.mts +60 -0
- package/utils/licenseDetails.d.ts +60 -0
- package/utils/licenseDetails.js +5 -0
- package/utils/licenseDetails.mjs +1 -0
- package/utils/licenseErrorMessageUtils.js +15 -1
- package/{esm/utils/licenseErrorMessageUtils.js → utils/licenseErrorMessageUtils.mjs} +14 -1
- package/{esm/utils/plan.d.ts → utils/licensePlan.d.mts} +1 -1
- package/utils/{plan.d.ts → licensePlan.d.ts} +1 -1
- package/utils/{plan.js → licensePlan.js} +1 -1
- package/utils/licensePlan.mjs +2 -0
- package/verifyLicense/index.d.mts +1 -0
- package/verifyLicense/index.mjs +1 -0
- package/verifyLicense/verifyLicense.d.mts +32 -0
- package/verifyLicense/verifyLicense.d.ts +18 -1
- package/verifyLicense/verifyLicense.js +86 -36
- package/{esm/verifyLicense/verifyLicense.js → verifyLicense/verifyLicense.mjs} +85 -39
- package/esm/Watermark/index.d.ts +0 -1
- package/esm/Watermark/index.js +0 -1
- package/esm/encoding/index.d.ts +0 -2
- package/esm/encoding/index.js +0 -2
- package/esm/generateLicense/generateLicense.d.ts +0 -10
- package/esm/generateLicense/generateLicense.js +0 -19
- package/esm/generateLicense/index.d.ts +0 -1
- package/esm/generateLicense/index.js +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -14
- package/esm/package.json +0 -1
- package/esm/utils/index.d.ts +0 -6
- package/esm/utils/index.js +0 -4
- package/esm/utils/plan.js +0 -2
- package/esm/verifyLicense/index.d.ts +0 -1
- package/esm/verifyLicense/index.js +0 -1
- package/esm/verifyLicense/verifyLicense.d.ts +0 -15
- package/generateLicense/generateLicense.d.ts +0 -10
- package/generateLicense/generateLicense.js +0 -25
- package/generateLicense/index.d.ts +0 -1
- package/generateLicense/index.js +0 -16
- /package/{esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js → Unstable_LicenseInfoProvider/MuiLicenseInfoContext.mjs} +0 -0
- /package/{esm/encoding/base64.d.ts → encoding/base64.d.mts} +0 -0
- /package/{esm/encoding/md5.d.ts → encoding/md5.d.mts} +0 -0
- /package/{esm/encoding/md5.js → encoding/md5.mjs} +0 -0
- /package/{esm/utils/commercialPackages.js → utils/commercialPackages.mjs} +0 -0
- /package/{esm/utils/licenseErrorMessageUtils.d.ts → utils/licenseErrorMessageUtils.d.mts} +0 -0
- /package/{esm/utils/licenseInfo.d.ts → utils/licenseInfo.d.mts} +0 -0
- /package/{esm/utils/licenseInfo.js → utils/licenseInfo.mjs} +0 -0
- /package/{esm/utils/licenseModel.d.ts → utils/licenseModel.d.mts} +0 -0
- /package/{esm/utils/licenseModel.js → utils/licenseModel.mjs} +0 -0
- /package/{esm/utils/licenseStatus.d.ts → utils/licenseStatus.d.mts} +0 -0
- /package/{esm/utils/licenseStatus.js → utils/licenseStatus.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export type MuiCommercialPackageName = 'x-data-grid-pro' | 'x-data-grid-premium' | 'x-date-pickers-pro' | 'x-tree-view-pro' | 'x-charts-pro' | 'x-charts-premium';
|
|
1
|
+
export type MuiCommercialPackageName = 'x-data-grid-pro' | 'x-data-grid-premium' | 'x-date-pickers-pro' | 'x-tree-view-pro' | 'x-charts-pro' | 'x-charts-premium' | 'x-scheduler-premium';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./licenseErrorMessageUtils.mjs";
|
|
2
|
+
export * from "./licenseInfo.mjs";
|
|
3
|
+
export * from "./licenseStatus.mjs";
|
|
4
|
+
export type { AppType } from "./licenseAppType.mjs";
|
|
5
|
+
export type { PlanScope } from "./licensePlan.mjs";
|
|
6
|
+
export type { LicenseModel } from "./licenseModel.mjs";
|
|
7
|
+
export type { KeyVersion, LicenseDetails, NullableLicenseDetails } from "./licenseDetails.mjs";
|
|
8
|
+
export type { MuiCommercialPackageName } from "./commercialPackages.mjs";
|
package/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./licenseErrorMessageUtils.js";
|
|
2
2
|
export * from "./licenseInfo.js";
|
|
3
3
|
export * from "./licenseStatus.js";
|
|
4
|
-
export type {
|
|
4
|
+
export type { AppType } from "./licenseAppType.js";
|
|
5
|
+
export type { PlanScope } from "./licensePlan.js";
|
|
5
6
|
export type { LicenseModel } from "./licenseModel.js";
|
|
7
|
+
export type { KeyVersion, LicenseDetails, NullableLicenseDetails } from "./licenseDetails.js";
|
|
6
8
|
export type { MuiCommercialPackageName } from "./commercialPackages.js";
|
package/utils/index.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.APP_TYPES = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The supported application types for a MUI X license.
|
|
9
|
+
*/
|
|
10
|
+
const APP_TYPES = exports.APP_TYPES = [/** A single application. */
|
|
11
|
+
'single', /** Multiple applications. */
|
|
12
|
+
'multi'];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The type of application the license covers.
|
|
16
|
+
*/
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AppType } from "./licenseAppType.mjs";
|
|
2
|
+
import { LicenseModel } from "./licenseModel.mjs";
|
|
3
|
+
import { PlanScope, PlanVersion } from "./licensePlan.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* The version of the license key encoding format.
|
|
6
|
+
* - `1`: Legacy format.
|
|
7
|
+
* - `2`: Adds plan scope and license model.
|
|
8
|
+
* - `3`: Adds quantity and app type.
|
|
9
|
+
*/
|
|
10
|
+
export type KeyVersion = 1 | 2 | 3;
|
|
11
|
+
/**
|
|
12
|
+
* The details of a MUI X license.
|
|
13
|
+
*/
|
|
14
|
+
export interface LicenseDetails {
|
|
15
|
+
/**
|
|
16
|
+
* The type of application the license covers.
|
|
17
|
+
* - `'single'`: A single application.
|
|
18
|
+
* - `'multi'`: Multiple applications.
|
|
19
|
+
* Only available in key version 3+.
|
|
20
|
+
*/
|
|
21
|
+
appType?: AppType;
|
|
22
|
+
/**
|
|
23
|
+
* The date when the license expires.
|
|
24
|
+
*/
|
|
25
|
+
expiryDate: Date;
|
|
26
|
+
/**
|
|
27
|
+
* The timestamp (in milliseconds) when the license expires.
|
|
28
|
+
*/
|
|
29
|
+
expiryTimestamp: number;
|
|
30
|
+
/**
|
|
31
|
+
* The license model.
|
|
32
|
+
* Only available in key version 2+.
|
|
33
|
+
*/
|
|
34
|
+
licenseModel?: LicenseModel;
|
|
35
|
+
/**
|
|
36
|
+
* The order id associated with the license.
|
|
37
|
+
*/
|
|
38
|
+
orderId: number;
|
|
39
|
+
/**
|
|
40
|
+
* The plan scope (e.g., 'pro' or 'premium').
|
|
41
|
+
* Only available in key version 2+.
|
|
42
|
+
*/
|
|
43
|
+
planScope?: PlanScope;
|
|
44
|
+
/**
|
|
45
|
+
* The plan version (e.g., 'initial', 'Q3-2024').
|
|
46
|
+
*/
|
|
47
|
+
planVersion: PlanVersion;
|
|
48
|
+
/**
|
|
49
|
+
* The number of developer seats covered by the license.
|
|
50
|
+
* Only available in key version 3+.
|
|
51
|
+
*/
|
|
52
|
+
quantity?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The version of the license key encoding format.
|
|
55
|
+
*/
|
|
56
|
+
keyVersion: KeyVersion;
|
|
57
|
+
}
|
|
58
|
+
export type NullableLicenseDetails = { [K in keyof LicenseDetails]: LicenseDetails[K] | null } & {
|
|
59
|
+
isTestKey: boolean;
|
|
60
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AppType } from "./licenseAppType.js";
|
|
2
|
+
import { LicenseModel } from "./licenseModel.js";
|
|
3
|
+
import { PlanScope, PlanVersion } from "./licensePlan.js";
|
|
4
|
+
/**
|
|
5
|
+
* The version of the license key encoding format.
|
|
6
|
+
* - `1`: Legacy format.
|
|
7
|
+
* - `2`: Adds plan scope and license model.
|
|
8
|
+
* - `3`: Adds quantity and app type.
|
|
9
|
+
*/
|
|
10
|
+
export type KeyVersion = 1 | 2 | 3;
|
|
11
|
+
/**
|
|
12
|
+
* The details of a MUI X license.
|
|
13
|
+
*/
|
|
14
|
+
export interface LicenseDetails {
|
|
15
|
+
/**
|
|
16
|
+
* The type of application the license covers.
|
|
17
|
+
* - `'single'`: A single application.
|
|
18
|
+
* - `'multi'`: Multiple applications.
|
|
19
|
+
* Only available in key version 3+.
|
|
20
|
+
*/
|
|
21
|
+
appType?: AppType;
|
|
22
|
+
/**
|
|
23
|
+
* The date when the license expires.
|
|
24
|
+
*/
|
|
25
|
+
expiryDate: Date;
|
|
26
|
+
/**
|
|
27
|
+
* The timestamp (in milliseconds) when the license expires.
|
|
28
|
+
*/
|
|
29
|
+
expiryTimestamp: number;
|
|
30
|
+
/**
|
|
31
|
+
* The license model.
|
|
32
|
+
* Only available in key version 2+.
|
|
33
|
+
*/
|
|
34
|
+
licenseModel?: LicenseModel;
|
|
35
|
+
/**
|
|
36
|
+
* The order id associated with the license.
|
|
37
|
+
*/
|
|
38
|
+
orderId: number;
|
|
39
|
+
/**
|
|
40
|
+
* The plan scope (e.g., 'pro' or 'premium').
|
|
41
|
+
* Only available in key version 2+.
|
|
42
|
+
*/
|
|
43
|
+
planScope?: PlanScope;
|
|
44
|
+
/**
|
|
45
|
+
* The plan version (e.g., 'initial', 'Q3-2024').
|
|
46
|
+
*/
|
|
47
|
+
planVersion: PlanVersion;
|
|
48
|
+
/**
|
|
49
|
+
* The number of developer seats covered by the license.
|
|
50
|
+
* Only available in key version 3+.
|
|
51
|
+
*/
|
|
52
|
+
quantity?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The version of the license key encoding format.
|
|
55
|
+
*/
|
|
56
|
+
keyVersion: KeyVersion;
|
|
57
|
+
}
|
|
58
|
+
export type NullableLicenseDetails = { [K in keyof LicenseDetails]: LicenseDetails[K] | null } & {
|
|
59
|
+
isTestKey: boolean;
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -10,6 +11,7 @@ exports.showInvalidLicenseKeyError = showInvalidLicenseKeyError;
|
|
|
10
11
|
exports.showLicenseKeyPlanMismatchError = showLicenseKeyPlanMismatchError;
|
|
11
12
|
exports.showMissingLicenseKeyError = showMissingLicenseKeyError;
|
|
12
13
|
exports.showNotAvailableInInitialProPlanError = showNotAvailableInInitialProPlanError;
|
|
14
|
+
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
13
15
|
/**
|
|
14
16
|
* Workaround for the codesadbox preview error.
|
|
15
17
|
*
|
|
@@ -60,5 +62,17 @@ function showExpiredAnnualLicenseKeyError({
|
|
|
60
62
|
licenseKey,
|
|
61
63
|
expiryTimestamp
|
|
62
64
|
}) {
|
|
63
|
-
throw new Error(
|
|
65
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Expired license key.
|
|
66
|
+
|
|
67
|
+
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).
|
|
68
|
+
|
|
69
|
+
To solve the problem you can either:
|
|
70
|
+
|
|
71
|
+
- Renew your license https://mui.com/r/x-get-license and use the new key
|
|
72
|
+
- Stop making changes to code depending directly or indirectly on MUI X ${plan}'s APIs
|
|
73
|
+
|
|
74
|
+
Note that your license is perpetual in production environments with any version released before your license term ends.
|
|
75
|
+
|
|
76
|
+
- License key expiry timestamp: ${new Date(expiryTimestamp)}
|
|
77
|
+
- Installed license key: ${licenseKey}` : (0, _formatErrorMessage2.default)(187, plan, plan, plan, new Date(expiryTimestamp), licenseKey));
|
|
64
78
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
1
2
|
/**
|
|
2
3
|
* Workaround for the codesadbox preview error.
|
|
3
4
|
*
|
|
@@ -48,5 +49,17 @@ export function showExpiredAnnualLicenseKeyError({
|
|
|
48
49
|
licenseKey,
|
|
49
50
|
expiryTimestamp
|
|
50
51
|
}) {
|
|
51
|
-
throw new Error(
|
|
52
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Expired license key.
|
|
53
|
+
|
|
54
|
+
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).
|
|
55
|
+
|
|
56
|
+
To solve the problem you can either:
|
|
57
|
+
|
|
58
|
+
- Renew your license https://mui.com/r/x-get-license and use the new key
|
|
59
|
+
- Stop making changes to code depending directly or indirectly on MUI X ${plan}'s APIs
|
|
60
|
+
|
|
61
|
+
Note that your license is perpetual in production environments with any version released before your license term ends.
|
|
62
|
+
|
|
63
|
+
- License key expiry timestamp: ${new Date(expiryTimestamp)}
|
|
64
|
+
- Installed license key: ${licenseKey}` : _formatErrorMessage(187, plan, plan, plan, new Date(expiryTimestamp), licenseKey));
|
|
52
65
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const PLAN_SCOPES: readonly ["pro", "premium"];
|
|
2
|
-
export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024"];
|
|
2
|
+
export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024", "Q1-2026"];
|
|
3
3
|
export type PlanScope = (typeof PLAN_SCOPES)[number];
|
|
4
4
|
export type PlanVersion = (typeof PLAN_VERSIONS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const PLAN_SCOPES: readonly ["pro", "premium"];
|
|
2
|
-
export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024"];
|
|
2
|
+
export declare const PLAN_VERSIONS: readonly ["initial", "Q3-2024", "Q1-2026"];
|
|
3
3
|
export type PlanScope = (typeof PLAN_SCOPES)[number];
|
|
4
4
|
export type PlanVersion = (typeof PLAN_VERSIONS)[number];
|
|
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.PLAN_VERSIONS = exports.PLAN_SCOPES = void 0;
|
|
7
7
|
const PLAN_SCOPES = exports.PLAN_SCOPES = ['pro', 'premium'];
|
|
8
|
-
const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024'];
|
|
8
|
+
const PLAN_VERSIONS = exports.PLAN_VERSIONS = ['initial', 'Q3-2024', 'Q1-2026'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./verifyLicense.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./verifyLicense.mjs";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LicenseStatus } from "../utils/licenseStatus.mjs";
|
|
2
|
+
import type { NullableLicenseDetails } from "../utils/licenseDetails.mjs";
|
|
3
|
+
import { MuiCommercialPackageName } from "../utils/commercialPackages.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Parse a comma-separated key=value license string into a NullableLicenseDetails object.
|
|
6
|
+
* Shared by v2 and v3 decoders.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseLicenseTokens(license: string, licenseInfo: NullableLicenseDetails): void;
|
|
9
|
+
/**
|
|
10
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2
|
|
11
|
+
*/
|
|
12
|
+
export declare function decodeLicenseVersion2(license: string): NullableLicenseDetails;
|
|
13
|
+
/**
|
|
14
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},Q=${quantity},AT=${appType},KV=3
|
|
15
|
+
*/
|
|
16
|
+
export declare function decodeLicenseVersion3(license: string): NullableLicenseDetails;
|
|
17
|
+
/**
|
|
18
|
+
* Decode the license based on its key version and return a version-agnostic `NullableLicenseDetails` object.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeLicense(encodedLicense: string): NullableLicenseDetails | null;
|
|
21
|
+
export declare function verifyLicense({
|
|
22
|
+
releaseInfo,
|
|
23
|
+
licenseKey,
|
|
24
|
+
packageName
|
|
25
|
+
}: {
|
|
26
|
+
releaseInfo: string;
|
|
27
|
+
licenseKey?: string;
|
|
28
|
+
packageName: MuiCommercialPackageName;
|
|
29
|
+
}): {
|
|
30
|
+
status: LicenseStatus;
|
|
31
|
+
meta?: any;
|
|
32
|
+
};
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { LicenseStatus } from "../utils/licenseStatus.js";
|
|
2
|
+
import type { NullableLicenseDetails } from "../utils/licenseDetails.js";
|
|
2
3
|
import { MuiCommercialPackageName } from "../utils/commercialPackages.js";
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Parse a comma-separated key=value license string into a NullableLicenseDetails object.
|
|
6
|
+
* Shared by v2 and v3 decoders.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseLicenseTokens(license: string, licenseInfo: NullableLicenseDetails): void;
|
|
9
|
+
/**
|
|
10
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2
|
|
11
|
+
*/
|
|
12
|
+
export declare function decodeLicenseVersion2(license: string): NullableLicenseDetails;
|
|
13
|
+
/**
|
|
14
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},Q=${quantity},AT=${appType},KV=3
|
|
15
|
+
*/
|
|
16
|
+
export declare function decodeLicenseVersion3(license: string): NullableLicenseDetails;
|
|
17
|
+
/**
|
|
18
|
+
* Decode the license based on its key version and return a version-agnostic `NullableLicenseDetails` object.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeLicense(encodedLicense: string): NullableLicenseDetails | null;
|
|
4
21
|
export declare function verifyLicense({
|
|
5
22
|
releaseInfo,
|
|
6
23
|
licenseKey,
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.decodeLicense = decodeLicense;
|
|
8
|
+
exports.decodeLicenseVersion2 = decodeLicenseVersion2;
|
|
9
|
+
exports.decodeLicenseVersion3 = decodeLicenseVersion3;
|
|
10
|
+
exports.parseLicenseTokens = parseLicenseTokens;
|
|
7
11
|
exports.verifyLicense = verifyLicense;
|
|
12
|
+
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
8
13
|
var _base = require("../encoding/base64");
|
|
9
14
|
var _md = require("../encoding/md5");
|
|
10
15
|
var _licenseStatus = require("../utils/licenseStatus");
|
|
11
|
-
var
|
|
16
|
+
var _licensePlan = require("../utils/licensePlan");
|
|
12
17
|
var _licenseModel = require("../utils/licenseModel");
|
|
13
|
-
const getDefaultReleaseDate = () => {
|
|
14
|
-
const today = new Date();
|
|
15
|
-
today.setHours(0, 0, 0, 0);
|
|
16
|
-
return today;
|
|
17
|
-
};
|
|
18
|
-
function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
|
|
19
|
-
return (0, _base.base64Encode)(releaseDate.getTime().toString());
|
|
20
|
-
}
|
|
21
18
|
function isPlanScopeSufficient(packageName, planScope) {
|
|
22
19
|
let acceptedScopes;
|
|
23
20
|
if (packageName.includes('-pro')) {
|
|
@@ -53,29 +50,24 @@ function decodeLicenseVersion1(license) {
|
|
|
53
50
|
orderId = null;
|
|
54
51
|
}
|
|
55
52
|
return {
|
|
56
|
-
|
|
53
|
+
keyVersion: 1,
|
|
57
54
|
licenseModel: 'perpetual',
|
|
58
55
|
planScope: 'pro',
|
|
59
56
|
planVersion: 'initial',
|
|
60
57
|
expiryTimestamp,
|
|
61
58
|
expiryDate: expiryTimestamp ? new Date(expiryTimestamp) : null,
|
|
62
|
-
orderId
|
|
59
|
+
orderId,
|
|
60
|
+
appType: 'multi',
|
|
61
|
+
quantity: null,
|
|
62
|
+
isTestKey: license.includes('T=true')
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Parse a comma-separated key=value license string into a NullableLicenseDetails object.
|
|
68
|
+
* Shared by v2 and v3 decoders.
|
|
68
69
|
*/
|
|
69
|
-
function
|
|
70
|
-
const licenseInfo = {
|
|
71
|
-
version: 2,
|
|
72
|
-
licenseModel: null,
|
|
73
|
-
planScope: null,
|
|
74
|
-
planVersion: 'initial',
|
|
75
|
-
expiryTimestamp: null,
|
|
76
|
-
expiryDate: null,
|
|
77
|
-
orderId: null
|
|
78
|
-
};
|
|
70
|
+
function parseLicenseTokens(license, licenseInfo) {
|
|
79
71
|
license.split(',').map(token => token.split('=')).filter(el => el.length === 2).forEach(([key, value]) => {
|
|
80
72
|
if (key === 'S') {
|
|
81
73
|
licenseInfo.planScope = value;
|
|
@@ -99,12 +91,63 @@ function decodeLicenseVersion2(license) {
|
|
|
99
91
|
licenseInfo.orderId = orderNum;
|
|
100
92
|
}
|
|
101
93
|
}
|
|
94
|
+
if (key === 'Q') {
|
|
95
|
+
const qty = parseInt(value, 10);
|
|
96
|
+
if (qty && !Number.isNaN(qty)) {
|
|
97
|
+
licenseInfo.quantity = qty;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (key === 'AT') {
|
|
101
|
+
licenseInfo.appType = value;
|
|
102
|
+
}
|
|
103
|
+
if (key === 'T') {
|
|
104
|
+
licenseInfo.isTestKey = value === 'true';
|
|
105
|
+
}
|
|
102
106
|
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2
|
|
111
|
+
*/
|
|
112
|
+
function decodeLicenseVersion2(license) {
|
|
113
|
+
const licenseInfo = {
|
|
114
|
+
keyVersion: 2,
|
|
115
|
+
licenseModel: null,
|
|
116
|
+
planScope: null,
|
|
117
|
+
planVersion: 'initial',
|
|
118
|
+
expiryTimestamp: null,
|
|
119
|
+
expiryDate: null,
|
|
120
|
+
orderId: null,
|
|
121
|
+
appType: 'multi',
|
|
122
|
+
quantity: null,
|
|
123
|
+
isTestKey: false
|
|
124
|
+
};
|
|
125
|
+
parseLicenseTokens(license, licenseInfo);
|
|
126
|
+
return licenseInfo;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},Q=${quantity},AT=${appType},KV=3
|
|
131
|
+
*/
|
|
132
|
+
function decodeLicenseVersion3(license) {
|
|
133
|
+
const licenseInfo = {
|
|
134
|
+
keyVersion: 3,
|
|
135
|
+
licenseModel: null,
|
|
136
|
+
planScope: null,
|
|
137
|
+
planVersion: 'initial',
|
|
138
|
+
expiryTimestamp: null,
|
|
139
|
+
expiryDate: null,
|
|
140
|
+
orderId: null,
|
|
141
|
+
appType: null,
|
|
142
|
+
quantity: null,
|
|
143
|
+
isTestKey: false
|
|
144
|
+
};
|
|
145
|
+
parseLicenseTokens(license, licenseInfo);
|
|
103
146
|
return licenseInfo;
|
|
104
147
|
}
|
|
105
148
|
|
|
106
149
|
/**
|
|
107
|
-
* Decode the license based on its key version and return a version-agnostic `
|
|
150
|
+
* Decode the license based on its key version and return a version-agnostic `NullableLicenseDetails` object.
|
|
108
151
|
*/
|
|
109
152
|
function decodeLicense(encodedLicense) {
|
|
110
153
|
const license = (0, _base.base64Decode)(encodedLicense);
|
|
@@ -114,6 +157,9 @@ function decodeLicense(encodedLicense) {
|
|
|
114
157
|
if (license.includes('KV=2')) {
|
|
115
158
|
return decodeLicenseVersion2(license);
|
|
116
159
|
}
|
|
160
|
+
if (license.includes('KV=3')) {
|
|
161
|
+
return decodeLicenseVersion3(license);
|
|
162
|
+
}
|
|
117
163
|
return null;
|
|
118
164
|
}
|
|
119
165
|
function verifyLicense({
|
|
@@ -121,23 +167,16 @@ function verifyLicense({
|
|
|
121
167
|
licenseKey,
|
|
122
168
|
packageName
|
|
123
169
|
}) {
|
|
124
|
-
// Gets replaced at build time
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
if (false) {
|
|
127
|
-
return {
|
|
128
|
-
status: _licenseStatus.LICENSE_STATUS.Valid
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
170
|
if (!releaseInfo) {
|
|
132
|
-
throw new Error('MUI X: The release information is missing.
|
|
171
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: The release information is missing and license validation cannot proceed. ' + 'This is an internal error that should not occur in normal usage. ' + 'Please report this issue if you encounter it.' : (0, _formatErrorMessage2.default)(188));
|
|
133
172
|
}
|
|
134
173
|
if (!licenseKey) {
|
|
135
174
|
return {
|
|
136
175
|
status: _licenseStatus.LICENSE_STATUS.NotFound
|
|
137
176
|
};
|
|
138
177
|
}
|
|
139
|
-
const hash = licenseKey.
|
|
140
|
-
const encoded = licenseKey.
|
|
178
|
+
const hash = licenseKey.slice(0, 32);
|
|
179
|
+
const encoded = licenseKey.slice(32);
|
|
141
180
|
if (hash !== (0, _md.md5)(encoded)) {
|
|
142
181
|
return {
|
|
143
182
|
status: _licenseStatus.LICENSE_STATUS.Invalid
|
|
@@ -150,6 +189,17 @@ function verifyLicense({
|
|
|
150
189
|
status: _licenseStatus.LICENSE_STATUS.Invalid
|
|
151
190
|
};
|
|
152
191
|
}
|
|
192
|
+
|
|
193
|
+
// Reject test license keys outside of test environments.
|
|
194
|
+
// Gets replaced with `false` during production builds, making it impossible
|
|
195
|
+
// for users of published packages to use test licenses.
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
if (license.isTestKey && !false) {
|
|
198
|
+
console.error('MUI X: Error checking license. Test license key used in a non-test environment!');
|
|
199
|
+
return {
|
|
200
|
+
status: _licenseStatus.LICENSE_STATUS.Invalid
|
|
201
|
+
};
|
|
202
|
+
}
|
|
153
203
|
if (license.licenseModel == null || !_licenseModel.LICENSE_MODELS.includes(license.licenseModel)) {
|
|
154
204
|
console.error('MUI X: Error checking license. License model not found or invalid!');
|
|
155
205
|
return {
|
|
@@ -165,7 +215,7 @@ function verifyLicense({
|
|
|
165
215
|
if (license.licenseModel === 'perpetual' || process.env.NODE_ENV === 'production') {
|
|
166
216
|
const pkgTimestamp = parseInt((0, _base.base64Decode)(releaseInfo), 10);
|
|
167
217
|
if (Number.isNaN(pkgTimestamp)) {
|
|
168
|
-
throw new Error('MUI X: The release information is invalid.
|
|
218
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: The release information is invalid and license validation cannot proceed. ' + 'The package release timestamp could not be parsed. ' + 'This may indicate a corrupted package. Try reinstalling the MUI X packages.' : (0, _formatErrorMessage2.default)(189));
|
|
169
219
|
}
|
|
170
220
|
if (license.expiryTimestamp < pkgTimestamp) {
|
|
171
221
|
return {
|
|
@@ -194,7 +244,7 @@ function verifyLicense({
|
|
|
194
244
|
};
|
|
195
245
|
}
|
|
196
246
|
}
|
|
197
|
-
if (license.planScope == null || !
|
|
247
|
+
if (license.planScope == null || !_licensePlan.PLAN_SCOPES.includes(license.planScope)) {
|
|
198
248
|
console.error('MUI X: Error checking license. planScope not found or invalid!');
|
|
199
249
|
return {
|
|
200
250
|
status: _licenseStatus.LICENSE_STATUS.Invalid
|