Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Update the logic of the check. #17651

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/getting-started/licensing/license-key-and-activation.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ This key grants access to your subscription features. It does not consume editor

* **Features**: Grants access to subscription features.
* **Functionality**:
* Similar to the trial license, the editor is limited functionally, including session time and the number of changes allowed.
* Additionally, there are limitations on development domains. The editor can be used in the following domains: `localhost`, `*.test`, `*.localhost`, `*.local`, and IP addresses: `127.0.0.1`, `192.168.*.*`, `10.*.*.*`, `172.*.*.*`.
* Limitations on development domains apply on usage-based plans. The editor can be used in the following domains: `localhost`, `*.test`, `*.localhost`, `*.local`, and IP addresses: `127.0.0.1`, `192.168.*.*`, `10.*.*.*`, `172.*.*.*`.
* The editor will show a banner informing it was launched for development purposes.
* **Intended use**: Designed for development environments such as local work, continuous integration (CI), and end-to-end (E2E) tests.
* **Usage limitation**: Must not be used for production environments.
Expand Down
23 changes: 9 additions & 14 deletions packages/ckeditor5-core/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
return;
}

if ( [ 'evaluation', 'trial', 'development' ].includes( licensePayload.licenseType ) ) {
const licenseType: 'evaluation' | 'trial' | 'development' = licensePayload.licenseType;
if ( [ 'evaluation', 'trial' ].includes( licensePayload.licenseType ) ) {
const licenseType: 'evaluation' | 'trial' = licensePayload.licenseType;

console.info(
`You are using the ${ licenseType } version of CKEditor 5 with limited usage. ` +
Expand All @@ -542,6 +542,13 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
} );
}

if ( licensePayload.licenseType === 'development' ) {
console.info(
'You are using the development version of CKEditor 5. ' +
'Make sure you will not use it in the production environment.'
);
}
arkflpc marked this conversation as resolved.
Show resolved Hide resolved

if ( licensePayload.usageEndpoint ) {
editor.once<EditorReadyEvent>( 'ready', () => {
const request = {
Expand Down Expand Up @@ -986,17 +993,6 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
throw new CKEditorError( 'license-key-trial-limit' );
}

if ( reason == 'developmentLimit' ) {
/**
* You have exceeded the operation limit for your development license key within the editor.
* Please restart the editor to continue using it.
* {@glink getting-started/licensing/license-key-and-activation#license-key-types Read more about license key types}.
*
* @error license-key-development-limit
*/
throw new CKEditorError( 'license-key-development-limit' );
}

if ( reason == 'usageLimit' ) {
/**
* You have reached the usage limit of your license key. This can occur in the following situations:
Expand Down Expand Up @@ -1103,7 +1099,6 @@ type LicenseErrorReason =
'featureNotAllowed' |
'evaluationLimit' |
'trialLimit' |
'developmentLimit' |
'usageLimit' |
'distributionChannel';

Expand Down
15 changes: 7 additions & 8 deletions packages/ckeditor5-core/tests/editor/licensecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ describe( 'Editor - license check', () => {

expect( editor.isReadOnly ).to.be.false;
sinon.assert.calledOnce( consoleInfoStub );
sinon.assert.calledWith( consoleInfoStub, 'You are using the development version of CKEditor 5 with ' +
'limited usage. Make sure you will not use it in the production environment.' );
sinon.assert.calledWith( consoleInfoStub, 'You are using the development version of CKEditor 5. ' +
'Make sure you will not use it in the production environment.' );
} );

it( 'should not block the editor if 10 minutes have not passed (development license)', () => {
Expand All @@ -466,7 +466,7 @@ describe( 'Editor - license check', () => {
dateNow.restore();
} );

it( 'should block editor after 10 minutes (development license)', () => {
it( 'also should not block editor after 10 minutes (development license)', () => {
gorzelinski marked this conversation as resolved.
Show resolved Hide resolved
const { licenseKey, todayTimestamp } = generateKey( {
licenseType: 'development'
} );
Expand All @@ -480,13 +480,13 @@ describe( 'Editor - license check', () => {

sinon.clock.tick( 600100 );

sinon.assert.calledWithMatch( showErrorStub, 'developmentLimit' );
expect( editor.isReadOnly ).to.be.true;
sinon.assert.notCalled( showErrorStub );
expect( editor.isReadOnly ).to.be.false;

dateNow.restore();
} );

it( 'should clear timer on editor destroy', done => {
it( 'should not interact with timers', done => {
const { licenseKey, todayTimestamp } = generateKey( {
licenseType: 'development'
} );
Expand All @@ -497,7 +497,7 @@ describe( 'Editor - license check', () => {

editor.fire( 'ready' );
editor.on( 'destroy', () => {
sinon.assert.calledOnce( clearTimeoutSpy );
sinon.assert.notCalled( clearTimeoutSpy );
done();
} );

Expand Down Expand Up @@ -688,7 +688,6 @@ describe( 'Editor - license check', () => {
{ reason: 'featureNotAllowed', error: 'license-key-plugin-not-allowed', pluginName: 'PluginABC' },
{ reason: 'evaluationLimit', error: 'license-key-evaluation-limit' },
{ reason: 'trialLimit', error: 'license-key-trial-limit' },
{ reason: 'developmentLimit', error: 'license-key-development-limit' },
{ reason: 'usageLimit', error: 'license-key-usage-limit' },
{ reason: 'distributionChannel', error: 'license-key-invalid-distribution-channel' }
];
Expand Down
Loading