@mui/x-license 8.26.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +591 -3
  2. package/{esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.d.ts → Unstable_LicenseInfoProvider/LicenseInfoProvider.d.mts} +1 -1
  3. package/{esm/Unstable_LicenseInfoProvider/LicenseInfoProvider.js → Unstable_LicenseInfoProvider/LicenseInfoProvider.mjs} +1 -1
  4. package/{esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.ts → Unstable_LicenseInfoProvider/MuiLicenseInfoContext.d.mts} +1 -1
  5. package/{esm/Unstable_LicenseInfoProvider/index.d.ts → Unstable_LicenseInfoProvider/index.d.mts} +2 -2
  6. package/{esm/Unstable_LicenseInfoProvider/index.js → Unstable_LicenseInfoProvider/index.mjs} +1 -1
  7. package/{esm/Watermark/Watermark.d.ts → Watermark/Watermark.d.mts} +1 -1
  8. package/Watermark/Watermark.js +3 -1
  9. package/{esm/Watermark/Watermark.js → Watermark/Watermark.mjs} +4 -3
  10. package/Watermark/index.d.mts +1 -0
  11. package/Watermark/index.mjs +1 -0
  12. package/encoding/base64.js +3 -1
  13. package/{esm/encoding/base64.js → encoding/base64.mjs} +2 -1
  14. package/encoding/index.d.mts +2 -0
  15. package/encoding/index.mjs +2 -0
  16. package/index.d.mts +4 -0
  17. package/index.d.ts +3 -6
  18. package/index.js +14 -75
  19. package/index.mjs +10 -0
  20. package/license-env.d.mts +6 -0
  21. package/license-env.d.ts +6 -0
  22. package/package.json +107 -16
  23. package/test-keys.d.mts +92 -0
  24. package/test-keys.d.ts +92 -0
  25. package/test-keys.js +135 -0
  26. package/test-keys.mjs +129 -0
  27. package/{esm/useLicenseVerifier/index.d.ts → useLicenseVerifier/index.d.mts} +1 -1
  28. package/{esm/useLicenseVerifier/index.js → useLicenseVerifier/index.mjs} +1 -1
  29. package/{esm/useLicenseVerifier/useLicenseVerifier.d.ts → useLicenseVerifier/useLicenseVerifier.d.mts} +2 -2
  30. package/useLicenseVerifier/useLicenseVerifier.js +2 -1
  31. package/{esm/useLicenseVerifier/useLicenseVerifier.js → useLicenseVerifier/useLicenseVerifier.mjs} +7 -6
  32. package/{esm/utils/commercialPackages.d.ts → utils/commercialPackages.d.mts} +1 -1
  33. package/utils/commercialPackages.d.ts +1 -1
  34. package/utils/index.d.mts +8 -0
  35. package/utils/index.d.ts +3 -1
  36. package/utils/index.mjs +4 -0
  37. package/utils/licenseAppType.d.mts +8 -0
  38. package/utils/licenseAppType.d.ts +8 -0
  39. package/utils/licenseAppType.js +16 -0
  40. package/utils/licenseAppType.mjs +10 -0
  41. package/utils/licenseDetails.d.mts +60 -0
  42. package/utils/licenseDetails.d.ts +60 -0
  43. package/utils/licenseDetails.js +5 -0
  44. package/utils/licenseDetails.mjs +1 -0
  45. package/utils/licenseErrorMessageUtils.js +15 -1
  46. package/{esm/utils/licenseErrorMessageUtils.js → utils/licenseErrorMessageUtils.mjs} +14 -1
  47. package/{esm/utils/plan.d.ts → utils/licensePlan.d.mts} +1 -1
  48. package/utils/{plan.d.ts → licensePlan.d.ts} +1 -1
  49. package/utils/{plan.js → licensePlan.js} +1 -1
  50. package/utils/licensePlan.mjs +2 -0
  51. package/verifyLicense/index.d.mts +1 -0
  52. package/verifyLicense/index.mjs +1 -0
  53. package/verifyLicense/verifyLicense.d.mts +32 -0
  54. package/verifyLicense/verifyLicense.d.ts +18 -1
  55. package/verifyLicense/verifyLicense.js +86 -36
  56. package/{esm/verifyLicense/verifyLicense.js → verifyLicense/verifyLicense.mjs} +85 -39
  57. package/esm/Watermark/index.d.ts +0 -1
  58. package/esm/Watermark/index.js +0 -1
  59. package/esm/encoding/index.d.ts +0 -2
  60. package/esm/encoding/index.js +0 -2
  61. package/esm/generateLicense/generateLicense.d.ts +0 -10
  62. package/esm/generateLicense/generateLicense.js +0 -19
  63. package/esm/generateLicense/index.d.ts +0 -1
  64. package/esm/generateLicense/index.js +0 -1
  65. package/esm/index.d.ts +0 -7
  66. package/esm/index.js +0 -14
  67. package/esm/package.json +0 -1
  68. package/esm/utils/index.d.ts +0 -6
  69. package/esm/utils/index.js +0 -4
  70. package/esm/utils/plan.js +0 -2
  71. package/esm/verifyLicense/index.d.ts +0 -1
  72. package/esm/verifyLicense/index.js +0 -1
  73. package/esm/verifyLicense/verifyLicense.d.ts +0 -15
  74. package/generateLicense/generateLicense.d.ts +0 -10
  75. package/generateLicense/generateLicense.js +0 -25
  76. package/generateLicense/index.d.ts +0 -1
  77. package/generateLicense/index.js +0 -16
  78. /package/{esm/Unstable_LicenseInfoProvider/MuiLicenseInfoContext.js → Unstable_LicenseInfoProvider/MuiLicenseInfoContext.mjs} +0 -0
  79. /package/{esm/encoding/base64.d.ts → encoding/base64.d.mts} +0 -0
  80. /package/{esm/encoding/md5.d.ts → encoding/md5.d.mts} +0 -0
  81. /package/{esm/encoding/md5.js → encoding/md5.mjs} +0 -0
  82. /package/{esm/utils/commercialPackages.js → utils/commercialPackages.mjs} +0 -0
  83. /package/{esm/utils/licenseErrorMessageUtils.d.ts → utils/licenseErrorMessageUtils.d.mts} +0 -0
  84. /package/{esm/utils/licenseInfo.d.ts → utils/licenseInfo.d.mts} +0 -0
  85. /package/{esm/utils/licenseInfo.js → utils/licenseInfo.mjs} +0 -0
  86. /package/{esm/utils/licenseModel.d.ts → utils/licenseModel.d.mts} +0 -0
  87. /package/{esm/utils/licenseModel.js → utils/licenseModel.mjs} +0 -0
  88. /package/{esm/utils/licenseStatus.d.ts → utils/licenseStatus.d.mts} +0 -0
  89. /package/{esm/utils/licenseStatus.js → utils/licenseStatus.mjs} +0 -0
@@ -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
- export declare function generateReleaseInfo(releaseDate?: Date): string;
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.generateReleaseInfo = generateReleaseInfo;
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 _plan = require("../utils/plan");
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
- version: 1,
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
- * Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2`;
67
+ * Parse a comma-separated key=value license string into a NullableLicenseDetails object.
68
+ * Shared by v2 and v3 decoders.
68
69
  */
69
- function decodeLicenseVersion2(license) {
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 `MuiLicense` object.
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. Not able to validate license.');
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.substr(0, 32);
140
- const encoded = licenseKey.substr(32);
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. Not able to validate license.');
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 || !_plan.PLAN_SCOPES.includes(license.planScope)) {
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
@@ -1,16 +1,9 @@
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";
6
- const getDefaultReleaseDate = () => {
7
- const today = new Date();
8
- today.setHours(0, 0, 0, 0);
9
- return today;
10
- };
11
- export function generateReleaseInfo(releaseDate = getDefaultReleaseDate()) {
12
- return base64Encode(releaseDate.getTime().toString());
13
- }
1
+ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
+ import { base64Decode } from "../encoding/base64.mjs";
3
+ import { md5 } from "../encoding/md5.mjs";
4
+ import { LICENSE_STATUS } from "../utils/licenseStatus.mjs";
5
+ import { PLAN_SCOPES } from "../utils/licensePlan.mjs";
6
+ import { LICENSE_MODELS } from "../utils/licenseModel.mjs";
14
7
  function isPlanScopeSufficient(packageName, planScope) {
15
8
  let acceptedScopes;
16
9
  if (packageName.includes('-pro')) {
@@ -46,29 +39,24 @@ function decodeLicenseVersion1(license) {
46
39
  orderId = null;
47
40
  }
48
41
  return {
49
- version: 1,
42
+ keyVersion: 1,
50
43
  licenseModel: 'perpetual',
51
44
  planScope: 'pro',
52
45
  planVersion: 'initial',
53
46
  expiryTimestamp,
54
47
  expiryDate: expiryTimestamp ? new Date(expiryTimestamp) : null,
55
- orderId
48
+ orderId,
49
+ appType: 'multi',
50
+ quantity: null,
51
+ isTestKey: license.includes('T=true')
56
52
  };
57
53
  }
58
54
 
59
55
  /**
60
- * Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2`;
56
+ * Parse a comma-separated key=value license string into a NullableLicenseDetails object.
57
+ * Shared by v2 and v3 decoders.
61
58
  */
62
- function decodeLicenseVersion2(license) {
63
- const licenseInfo = {
64
- version: 2,
65
- licenseModel: null,
66
- planScope: null,
67
- planVersion: 'initial',
68
- expiryTimestamp: null,
69
- expiryDate: null,
70
- orderId: null
71
- };
59
+ export function parseLicenseTokens(license, licenseInfo) {
72
60
  license.split(',').map(token => token.split('=')).filter(el => el.length === 2).forEach(([key, value]) => {
73
61
  if (key === 'S') {
74
62
  licenseInfo.planScope = value;
@@ -92,14 +80,65 @@ function decodeLicenseVersion2(license) {
92
80
  licenseInfo.orderId = orderNum;
93
81
  }
94
82
  }
83
+ if (key === 'Q') {
84
+ const qty = parseInt(value, 10);
85
+ if (qty && !Number.isNaN(qty)) {
86
+ licenseInfo.quantity = qty;
87
+ }
88
+ }
89
+ if (key === 'AT') {
90
+ licenseInfo.appType = value;
91
+ }
92
+ if (key === 'T') {
93
+ licenseInfo.isTestKey = value === 'true';
94
+ }
95
95
  });
96
+ }
97
+
98
+ /**
99
+ * Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},KV=2
100
+ */
101
+ export function decodeLicenseVersion2(license) {
102
+ const licenseInfo = {
103
+ keyVersion: 2,
104
+ licenseModel: null,
105
+ planScope: null,
106
+ planVersion: 'initial',
107
+ expiryTimestamp: null,
108
+ expiryDate: null,
109
+ orderId: null,
110
+ appType: 'multi',
111
+ quantity: null,
112
+ isTestKey: false
113
+ };
114
+ parseLicenseTokens(license, licenseInfo);
96
115
  return licenseInfo;
97
116
  }
98
117
 
99
118
  /**
100
- * Decode the license based on its key version and return a version-agnostic `MuiLicense` object.
119
+ * Format: O=${orderNumber},E=${expiryTimestamp},S=${planScope},LM=${licenseModel},PV=${planVersion},Q=${quantity},AT=${appType},KV=3
101
120
  */
102
- function decodeLicense(encodedLicense) {
121
+ export function decodeLicenseVersion3(license) {
122
+ const licenseInfo = {
123
+ keyVersion: 3,
124
+ licenseModel: null,
125
+ planScope: null,
126
+ planVersion: 'initial',
127
+ expiryTimestamp: null,
128
+ expiryDate: null,
129
+ orderId: null,
130
+ appType: null,
131
+ quantity: null,
132
+ isTestKey: false
133
+ };
134
+ parseLicenseTokens(license, licenseInfo);
135
+ return licenseInfo;
136
+ }
137
+
138
+ /**
139
+ * Decode the license based on its key version and return a version-agnostic `NullableLicenseDetails` object.
140
+ */
141
+ export function decodeLicense(encodedLicense) {
103
142
  const license = base64Decode(encodedLicense);
104
143
  if (license.includes('KEYVERSION=1')) {
105
144
  return decodeLicenseVersion1(license);
@@ -107,6 +146,9 @@ function decodeLicense(encodedLicense) {
107
146
  if (license.includes('KV=2')) {
108
147
  return decodeLicenseVersion2(license);
109
148
  }
149
+ if (license.includes('KV=3')) {
150
+ return decodeLicenseVersion3(license);
151
+ }
110
152
  return null;
111
153
  }
112
154
  export function verifyLicense({
@@ -114,23 +156,16 @@ export function verifyLicense({
114
156
  licenseKey,
115
157
  packageName
116
158
  }) {
117
- // Gets replaced at build time
118
- // @ts-ignore
119
- if (false) {
120
- return {
121
- status: LICENSE_STATUS.Valid
122
- };
123
- }
124
159
  if (!releaseInfo) {
125
- throw new Error('MUI X: The release information is missing. Not able to validate license.');
160
+ 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.' : _formatErrorMessage(188));
126
161
  }
127
162
  if (!licenseKey) {
128
163
  return {
129
164
  status: LICENSE_STATUS.NotFound
130
165
  };
131
166
  }
132
- const hash = licenseKey.substr(0, 32);
133
- const encoded = licenseKey.substr(32);
167
+ const hash = licenseKey.slice(0, 32);
168
+ const encoded = licenseKey.slice(32);
134
169
  if (hash !== md5(encoded)) {
135
170
  return {
136
171
  status: LICENSE_STATUS.Invalid
@@ -143,6 +178,17 @@ export function verifyLicense({
143
178
  status: LICENSE_STATUS.Invalid
144
179
  };
145
180
  }
181
+
182
+ // Reject test license keys outside of test environments.
183
+ // Gets replaced with `false` during production builds, making it impossible
184
+ // for users of published packages to use test licenses.
185
+ // @ts-ignore
186
+ if (license.isTestKey && !false) {
187
+ console.error('MUI X: Error checking license. Test license key used in a non-test environment!');
188
+ return {
189
+ status: LICENSE_STATUS.Invalid
190
+ };
191
+ }
146
192
  if (license.licenseModel == null || !LICENSE_MODELS.includes(license.licenseModel)) {
147
193
  console.error('MUI X: Error checking license. License model not found or invalid!');
148
194
  return {
@@ -158,7 +204,7 @@ export function verifyLicense({
158
204
  if (license.licenseModel === 'perpetual' || process.env.NODE_ENV === 'production') {
159
205
  const pkgTimestamp = parseInt(base64Decode(releaseInfo), 10);
160
206
  if (Number.isNaN(pkgTimestamp)) {
161
- throw new Error('MUI X: The release information is invalid. Not able to validate license.');
207
+ 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.' : _formatErrorMessage(189));
162
208
  }
163
209
  if (license.expiryTimestamp < pkgTimestamp) {
164
210
  return {
@@ -1 +0,0 @@
1
- export * from "./Watermark.js";
@@ -1 +0,0 @@
1
- export * from "./Watermark.js";
@@ -1,2 +0,0 @@
1
- export * from "./base64.js";
2
- export * from "./md5.js";
@@ -1,2 +0,0 @@
1
- export * from "./base64.js";
2
- export * from "./md5.js";
@@ -1,10 +0,0 @@
1
- import { PlanScope, PlanVersion } from "../utils/plan.js";
2
- import { LicenseModel } from "../utils/licenseModel.js";
3
- export interface LicenseDetails {
4
- expiryDate: Date;
5
- licenseModel?: LicenseModel;
6
- orderNumber: string;
7
- planScope?: PlanScope;
8
- planVersion: PlanVersion;
9
- }
10
- export declare function generateLicense(details: LicenseDetails): string;
@@ -1,19 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export * from "./generateLicense.js";
@@ -1 +0,0 @@
1
- export * from "./generateLicense.js";
package/esm/index.d.ts DELETED
@@ -1,7 +0,0 @@
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";
7
- export { muiXTelemetrySettings } from '@mui/x-telemetry';
package/esm/index.js DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * @mui/x-license v8.26.0
3
- *
4
- * @license SEE LICENSE IN LICENSE
5
- * This source code is licensed under the SEE LICENSE IN LICENSE 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";
14
- export { muiXTelemetrySettings } from '@mui/x-telemetry';
package/esm/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"module","sideEffects":["./utils/licenseInfo.js","./esm/utils/licenseInfo.js"]}
@@ -1,6 +0,0 @@
1
- export * from "./licenseErrorMessageUtils.js";
2
- export * from "./licenseInfo.js";
3
- export * from "./licenseStatus.js";
4
- export type { PlanScope } from "./plan.js";
5
- export type { LicenseModel } from "./licenseModel.js";
6
- export type { MuiCommercialPackageName } from "./commercialPackages.js";
@@ -1,4 +0,0 @@
1
- export * from "./licenseErrorMessageUtils.js";
2
- export * from "./licenseInfo.js";
3
- export * from "./licenseStatus.js";
4
- export {};
package/esm/utils/plan.js DELETED
@@ -1,2 +0,0 @@
1
- export const PLAN_SCOPES = ['pro', 'premium'];
2
- export const PLAN_VERSIONS = ['initial', 'Q3-2024'];
@@ -1 +0,0 @@
1
- export * from "./verifyLicense.js";
@@ -1 +0,0 @@
1
- export * from "./verifyLicense.js";
@@ -1,15 +0,0 @@
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,10 +0,0 @@
1
- import { PlanScope, PlanVersion } from "../utils/plan.js";
2
- import { LicenseModel } from "../utils/licenseModel.js";
3
- export interface LicenseDetails {
4
- expiryDate: Date;
5
- licenseModel?: LicenseModel;
6
- orderNumber: string;
7
- planScope?: PlanScope;
8
- planVersion: PlanVersion;
9
- }
10
- export declare function generateLicense(details: LicenseDetails): string;
@@ -1,25 +0,0 @@
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");
11
- const licenseVersion = '2';
12
- function getClearLicenseString(details) {
13
- if (details.planScope && !_plan.PLAN_SCOPES.includes(details.planScope)) {
14
- throw new Error('MUI X: Invalid scope');
15
- }
16
- if (details.licenseModel && !_licenseModel.LICENSE_MODELS.includes(details.licenseModel)) {
17
- throw new Error('MUI X: Invalid licensing model');
18
- }
19
- const keyParts = [`O=${details.orderNumber}`, `E=${details.expiryDate.getTime()}`, `S=${details.planScope}`, `LM=${details.licenseModel}`, `PV=${details.planVersion}`, `KV=${licenseVersion}`];
20
- return keyParts.join(',');
21
- }
22
- function generateLicense(details) {
23
- const licenseStr = getClearLicenseString(details);
24
- return `${(0, _md.md5)((0, _base.base64Encode)(licenseStr))}${(0, _base.base64Encode)(licenseStr)}`;
25
- }
@@ -1 +0,0 @@
1
- export * from "./generateLicense.js";
@@ -1,16 +0,0 @@
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
- });
File without changes
File without changes