From 869600ab7875512a50dd149dd19a770cc7f8ca7a Mon Sep 17 00:00:00 2001 From: Arman Jivanyan Date: Thu, 9 Apr 2026 12:59:16 +0400 Subject: [PATCH] remove old key validation code and add warnings --- .../js/__internal/core/license/key.ts | 2 - .../core/license/license_validation.ts | 103 ++---------------- .../license/license_validation_internal.ts | 3 - .../devextreme/license/devextreme-license.js | 10 +- packages/devextreme/license/messages.js | 2 +- 5 files changed, 18 insertions(+), 102 deletions(-) diff --git a/packages/devextreme/js/__internal/core/license/key.ts b/packages/devextreme/js/__internal/core/license/key.ts index e85eb6ae5aaf..e93a65ecdca7 100644 --- a/packages/devextreme/js/__internal/core/license/key.ts +++ b/packages/devextreme/js/__internal/core/license/key.ts @@ -13,5 +13,3 @@ export const PUBLIC_KEY: PublicKey = { 230, 44, 247, 200, 253, 170, 192, 246, 30, 12, 96, 205, 100, 249, 181, 93, 0, 231, ]), }; - -export const INTERNAL_USAGE_ID = 'GbnwUNpOUPaHhM47HM4Sxw'; diff --git a/packages/devextreme/js/__internal/core/license/license_validation.ts b/packages/devextreme/js/__internal/core/license/license_validation.ts index 062edfa001e1..64798112b2b0 100644 --- a/packages/devextreme/js/__internal/core/license/license_validation.ts +++ b/packages/devextreme/js/__internal/core/license/license_validation.ts @@ -8,52 +8,24 @@ import { getPreviousMajorVersion, parseVersion, } from '../../utils/version'; -import { base64ToBytes } from './byte_utils'; import { - BUY_NOW_LINK, FORMAT, KEY_SPLITTER, LICENSE_KEY_PLACEHOLDER, + BUY_NOW_LINK, LICENSE_KEY_PLACEHOLDER, LICENSING_DOC_LINK, RTM_MIN_PATCH_VERSION, SUBSCRIPTION_NAMES, } from './const'; -import { INTERNAL_USAGE_ID, PUBLIC_KEY } from './key'; import { isProductOnlyLicense, parseDevExpressProductKey } from './lcp_key_validation/lcp_key_validator'; import { logLicenseWarning } from './license_warnings'; -import { pad } from './pkcs1'; -import { compareSignatures } from './rsa_bigint'; -import { sha1 } from './sha1'; import { showTrialPanel } from './trial_panel'; import type { - License, LicenseCheckParams, Token, } from './types'; import { - DECODING_ERROR, - DESERIALIZATION_ERROR, GENERAL_ERROR, - PAYLOAD_ERROR, TokenKind, - VERIFICATION_ERROR, - VERSION_ERROR, } from './types'; -interface Payload extends Partial { - readonly format?: number; - readonly internalUsageId?: string; -} - let validationPerformed = false; -// verifies RSASSA-PKCS1-v1.5 signature -function verifySignature({ text, signature: encodedSignature }: { - text: string; - signature: string; -}): boolean { - return compareSignatures({ - key: PUBLIC_KEY, - signature: base64ToBytes(encodedSignature), - actual: pad(sha1(text)), - }); -} - export function parseLicenseKey(encodedKey: string | undefined): Token { if (encodedKey === undefined) { return GENERAL_ERROR; @@ -63,57 +35,7 @@ export function parseLicenseKey(encodedKey: string | undefined): Token { return parseDevExpressProductKey(encodedKey); } - const parts = encodedKey.split(KEY_SPLITTER); - - if (parts.length !== 2 || parts[0].length === 0 || parts[1].length === 0) { - return GENERAL_ERROR; - } - - if (!verifySignature({ text: parts[0], signature: parts[1] })) { - return VERIFICATION_ERROR; - } - - let decodedPayload = ''; - try { - decodedPayload = atob(parts[0]); - } catch { - return DECODING_ERROR; - } - - let payload: Payload = {}; - try { - payload = JSON.parse(decodedPayload); - } catch { - return DESERIALIZATION_ERROR; - } - - const { - customerId, maxVersionAllowed, format, internalUsageId, ...rest - } = payload; - - if (internalUsageId !== undefined) { - return { - kind: TokenKind.internal, - internalUsageId, - }; - } - - if (customerId === undefined || maxVersionAllowed === undefined || format === undefined) { - return PAYLOAD_ERROR; - } - - if (format !== FORMAT) { - return VERSION_ERROR; - } - - return { - kind: TokenKind.verified, - payload: { - customerId, - maxVersionAllowed, - ...rest, - }, - }; + return GENERAL_ERROR; } function isPreview(patch: number): boolean { @@ -124,19 +46,6 @@ function hasLicensePrefix(licenseKey: string, prefix: string): boolean { return licenseKey.trim().startsWith(prefix); } -export function isUnsupportedKeyFormat(licenseKey: string | undefined): boolean { - if (!licenseKey) { - return false; - } - - if (hasLicensePrefix(licenseKey, 'LCXv1')) { - errors.log('W0000', 'config', 'licenseKey', 'LCXv1 is specified in the license key'); - return true; - } - - return false; -} - function displayTrialPanel(): void { const buyNowLink = config().buyNowLink ?? BUY_NOW_LINK; const licensingDocLink = config().licensingDocLink ?? LICENSING_DOC_LINK; @@ -165,6 +74,10 @@ function getLicenseCheckParams({ return { preview, error: 'W0021', warningType: 'lcx-used' }; } + if (hasLicensePrefix(licenseKey, 'ewog')) { + return { preview, error: 'W0021', warningType: 'old-devextreme-key' }; + } + const license = parseLicenseKey(licenseKey); if (license.kind === TokenKind.corrupted) { @@ -177,8 +90,8 @@ function getLicenseCheckParams({ return { preview, error: 'W0021', warningType: 'invalid-key' }; } - if (license.kind === TokenKind.internal) { - return { preview, internal: true, error: license.internalUsageId === INTERNAL_USAGE_ID ? undefined : 'W0020' }; + if (license.kind !== TokenKind.verified) { + return { preview, error: 'W0021', warningType: 'invalid-key' }; } if (!(major && minor)) { diff --git a/packages/devextreme/js/__internal/core/license/license_validation_internal.ts b/packages/devextreme/js/__internal/core/license/license_validation_internal.ts index a61f9cc003d5..df552c7a8878 100644 --- a/packages/devextreme/js/__internal/core/license/license_validation_internal.ts +++ b/packages/devextreme/js/__internal/core/license/license_validation_internal.ts @@ -4,9 +4,6 @@ import type { Token } from './types'; // @ts-expect-error - only for internal usage export function parseLicenseKey(encodedKey: string | undefined): Token {} -// @ts-expect-error - only for internal usage -export function isUnsupportedKeyFormat(licenseKey: string | undefined): boolean {} - export function validateLicense(licenseKey: string, version?: string): void {} // @ts-expect-error - only for internal usage diff --git a/packages/devextreme/license/devextreme-license.js b/packages/devextreme/license/devextreme-license.js index b727dd84dbfb..db29c6aa7aa8 100644 --- a/packages/devextreme/license/devextreme-license.js +++ b/packages/devextreme/license/devextreme-license.js @@ -167,7 +167,15 @@ function main() { let lcp = TRIAL_VALUE; let licenseId = null; - if(lcx) { + if(lcx && lcx.trimStart().startsWith('ewog')) { + logStderr( + prefixed(`${TEMPLATES.warningPrefix(1000)} ${TEMPLATES.purchaseLicense}`), + TEMPLATES.keyVerificationFailed(), + TEMPLATES.oldDevExtremeKey(currentVersion), + TEMPLATES.keyWasFound(source.type, source.path), + prefixed(`${TEMPLATES.warningPrefix(1001)} ${TEMPLATES.installationInstructions}`), + ); + } else if(lcx) { lcp = tryConvertLCXtoLCP(lcx) || TRIAL_VALUE; const { warning, licenseId: id } = getLCPInfo(lcp); licenseId = id; diff --git a/packages/devextreme/license/messages.js b/packages/devextreme/license/messages.js index cff0a8efaca2..9bf082cad13d 100644 --- a/packages/devextreme/license/messages.js +++ b/packages/devextreme/license/messages.js @@ -81,7 +81,7 @@ const TEMPLATES = Object.freeze({ ].join(' '), oldDevExtremeKey: (version) => - `A DevExtreme key (v25_1 or earlier) has been detected. Use DevExpress license key (v${version}+) instead.`, + `A DevExtreme key (v25_2 or earlier) has been detected. Use DevExpress license key (v${version}+) instead.`, licenseId: (id) => `License ID: ${id}`, });