@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.
Files changed (89) hide show
  1. package/CHANGELOG.md +236 -0
  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 +105 -14
  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
@@ -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 v9.0.0-alpha.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