@ckeditor/ckeditor5-utils 40.0.0 → 40.2.0
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 +26 -26
- package/LICENSE.md +3 -3
- package/package.json +1 -1
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/areconnectedthroughproperties.d.ts +11 -11
- package/src/areconnectedthroughproperties.js +73 -73
- package/src/ckeditorerror.d.ts +123 -123
- package/src/ckeditorerror.js +176 -176
- package/src/collection.d.ts +433 -427
- package/src/collection.js +583 -575
- package/src/comparearrays.d.ts +30 -30
- package/src/comparearrays.js +47 -47
- package/src/config.d.ts +163 -163
- package/src/config.js +163 -162
- package/src/count.d.ts +18 -18
- package/src/count.js +24 -24
- package/src/delay.d.ts +19 -19
- package/src/delay.js +26 -26
- package/src/diff.d.ts +31 -31
- package/src/diff.js +115 -115
- package/src/difftochanges.d.ts +59 -59
- package/src/difftochanges.js +79 -79
- package/src/dom/createelement.d.ts +57 -57
- package/src/dom/createelement.js +40 -40
- package/src/dom/emittermixin.d.ts +142 -142
- package/src/dom/emittermixin.js +239 -239
- package/src/dom/findclosestscrollableancestor.d.ts +11 -11
- package/src/dom/findclosestscrollableancestor.js +31 -31
- package/src/dom/getancestors.d.ts +17 -17
- package/src/dom/getancestors.js +27 -27
- package/src/dom/getborderwidths.d.ts +24 -24
- package/src/dom/getborderwidths.js +24 -24
- package/src/dom/getcommonancestor.d.ts +12 -12
- package/src/dom/getcommonancestor.js +25 -25
- package/src/dom/getdatafromelement.d.ts +14 -14
- package/src/dom/getdatafromelement.js +20 -20
- package/src/dom/getpositionedancestor.d.ts +10 -10
- package/src/dom/getpositionedancestor.js +22 -22
- package/src/dom/global.d.ts +32 -32
- package/src/dom/global.js +35 -35
- package/src/dom/indexof.d.ts +14 -14
- package/src/dom/indexof.js +21 -21
- package/src/dom/insertat.d.ts +15 -15
- package/src/dom/insertat.js +17 -17
- package/src/dom/iscomment.d.ts +11 -11
- package/src/dom/iscomment.js +14 -14
- package/src/dom/isnode.d.ts +11 -11
- package/src/dom/isnode.js +21 -21
- package/src/dom/isrange.d.ts +11 -11
- package/src/dom/isrange.js +13 -13
- package/src/dom/istext.d.ts +11 -11
- package/src/dom/istext.js +13 -13
- package/src/dom/isvalidattributename.d.ts +10 -10
- package/src/dom/isvalidattributename.js +22 -22
- package/src/dom/isvisible.d.ts +18 -18
- package/src/dom/isvisible.js +20 -20
- package/src/dom/iswindow.d.ts +11 -11
- package/src/dom/iswindow.js +22 -22
- package/src/dom/position.d.ts +211 -211
- package/src/dom/position.js +313 -313
- package/src/dom/rect.d.ts +195 -195
- package/src/dom/rect.js +474 -474
- package/src/dom/remove.d.ts +13 -13
- package/src/dom/remove.js +18 -18
- package/src/dom/resizeobserver.d.ts +74 -74
- package/src/dom/resizeobserver.js +126 -126
- package/src/dom/scroll.d.ts +73 -73
- package/src/dom/scroll.js +383 -383
- package/src/dom/setdatainelement.d.ts +14 -14
- package/src/dom/setdatainelement.js +20 -20
- package/src/dom/tounit.d.ts +22 -22
- package/src/dom/tounit.js +16 -16
- package/src/elementreplacer.d.ts +31 -31
- package/src/elementreplacer.js +43 -43
- package/src/emittermixin.d.ts +312 -312
- package/src/emittermixin.js +453 -453
- package/src/env.d.ts +117 -117
- package/src/env.js +122 -122
- package/src/eventinfo.d.ts +58 -58
- package/src/eventinfo.js +26 -26
- package/src/fastdiff.d.ts +112 -112
- package/src/fastdiff.js +248 -248
- package/src/first.d.ts +11 -11
- package/src/first.js +17 -17
- package/src/focustracker.d.ts +75 -75
- package/src/focustracker.js +95 -95
- package/src/index.d.ts +64 -61
- package/src/index.js +63 -60
- package/src/inserttopriorityarray.d.ts +30 -30
- package/src/inserttopriorityarray.js +21 -21
- package/src/isiterable.d.ts +14 -14
- package/src/isiterable.js +16 -16
- package/src/keyboard.d.ts +126 -126
- package/src/keyboard.js +221 -221
- package/src/keystrokehandler.d.ts +87 -87
- package/src/keystrokehandler.js +122 -122
- package/src/language.d.ts +17 -17
- package/src/language.js +19 -19
- package/src/locale.d.ts +120 -120
- package/src/locale.js +76 -76
- package/src/mapsequal.d.ts +15 -15
- package/src/mapsequal.js +27 -27
- package/src/mix.d.ts +85 -85
- package/src/mix.js +50 -50
- package/src/nth.d.ts +16 -16
- package/src/nth.js +24 -24
- package/src/objecttomap.d.ts +23 -23
- package/src/objecttomap.js +27 -27
- package/src/observablemixin.d.ts +560 -560
- package/src/observablemixin.js +580 -580
- package/src/priorities.d.ts +33 -33
- package/src/priorities.js +23 -23
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/splicearray.d.ts +26 -26
- package/src/splicearray.js +40 -40
- package/src/spy.d.ts +21 -21
- package/src/spy.js +22 -22
- package/src/toarray.d.ts +25 -25
- package/src/toarray.js +7 -7
- package/src/tomap.d.ts +19 -19
- package/src/tomap.js +29 -29
- package/src/translation-service.d.ts +168 -168
- package/src/translation-service.js +198 -198
- package/src/uid.d.ts +15 -15
- package/src/uid.js +57 -57
- package/src/unicode.d.ts +54 -54
- package/src/unicode.js +85 -85
- package/src/verifylicense.d.ts +15 -15
- package/src/verifylicense.js +87 -87
- package/src/version.d.ts +10 -10
- package/src/version.js +153 -153
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
package/src/unicode.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Set of utils to handle unicode characters.
|
|
7
|
-
*
|
|
8
|
-
* @module utils/unicode
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Checks whether given `character` is a combining mark.
|
|
12
|
-
*
|
|
13
|
-
* @param character Character to check.
|
|
14
|
-
*/
|
|
15
|
-
export function isCombiningMark(character) {
|
|
16
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
17
|
-
return !!character && character.length == 1 && /[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(character);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Checks whether given `character` is a high half of surrogate pair.
|
|
21
|
-
*
|
|
22
|
-
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
23
|
-
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
24
|
-
*
|
|
25
|
-
* @param character Character to check.
|
|
26
|
-
*/
|
|
27
|
-
export function isHighSurrogateHalf(character) {
|
|
28
|
-
return !!character && character.length == 1 && /[\ud800-\udbff]/.test(character);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Checks whether given `character` is a low half of surrogate pair.
|
|
32
|
-
*
|
|
33
|
-
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
34
|
-
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
35
|
-
*
|
|
36
|
-
* @param character Character to check.
|
|
37
|
-
*/
|
|
38
|
-
export function isLowSurrogateHalf(character) {
|
|
39
|
-
return !!character && character.length == 1 && /[\udc00-\udfff]/.test(character);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Checks whether given offset in a string is inside a surrogate pair (between two surrogate halves).
|
|
43
|
-
*
|
|
44
|
-
* @param string String to check.
|
|
45
|
-
* @param offset Offset to check.
|
|
46
|
-
*/
|
|
47
|
-
export function isInsideSurrogatePair(string, offset) {
|
|
48
|
-
return isHighSurrogateHalf(string.charAt(offset - 1)) && isLowSurrogateHalf(string.charAt(offset));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Checks whether given offset in a string is between base character and combining mark or between two combining marks.
|
|
52
|
-
*
|
|
53
|
-
* @param string String to check.
|
|
54
|
-
* @param offset Offset to check.
|
|
55
|
-
*/
|
|
56
|
-
export function isInsideCombinedSymbol(string, offset) {
|
|
57
|
-
return isCombiningMark(string.charAt(offset));
|
|
58
|
-
}
|
|
59
|
-
const EMOJI_PATTERN = buildEmojiRegexp();
|
|
60
|
-
/**
|
|
61
|
-
* Checks whether given offset in a string is inside multi-character emoji sequence.
|
|
62
|
-
*
|
|
63
|
-
* @param string String to check.
|
|
64
|
-
* @param offset Offset to check.
|
|
65
|
-
*/
|
|
66
|
-
export function isInsideEmojiSequence(string, offset) {
|
|
67
|
-
const matches = String(string).matchAll(EMOJI_PATTERN);
|
|
68
|
-
return Array.from(matches).some(match => match.index < offset && offset < match.index + match[0].length);
|
|
69
|
-
}
|
|
70
|
-
function buildEmojiRegexp() {
|
|
71
|
-
const parts = [
|
|
72
|
-
// Emoji Tag Sequence (ETS)
|
|
73
|
-
/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,
|
|
74
|
-
// Emoji Keycap Sequence
|
|
75
|
-
/\p{Emoji}\u{FE0F}?\u{20E3}/u,
|
|
76
|
-
// Emoji Presentation Sequence
|
|
77
|
-
/\p{Emoji}\u{FE0F}/u,
|
|
78
|
-
// Single-Character Emoji / Emoji Modifier Sequence
|
|
79
|
-
/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u
|
|
80
|
-
];
|
|
81
|
-
const flagSequence = /\p{Regional_Indicator}{2}/u.source;
|
|
82
|
-
const emoji = '(?:' + parts.map(part => part.source).join('|') + ')';
|
|
83
|
-
const sequence = `${flagSequence}|${emoji}(?:\u{200D}${emoji})*`;
|
|
84
|
-
return new RegExp(sequence, 'ug');
|
|
85
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Set of utils to handle unicode characters.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/unicode
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether given `character` is a combining mark.
|
|
12
|
+
*
|
|
13
|
+
* @param character Character to check.
|
|
14
|
+
*/
|
|
15
|
+
export function isCombiningMark(character) {
|
|
16
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
17
|
+
return !!character && character.length == 1 && /[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(character);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether given `character` is a high half of surrogate pair.
|
|
21
|
+
*
|
|
22
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
23
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
24
|
+
*
|
|
25
|
+
* @param character Character to check.
|
|
26
|
+
*/
|
|
27
|
+
export function isHighSurrogateHalf(character) {
|
|
28
|
+
return !!character && character.length == 1 && /[\ud800-\udbff]/.test(character);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether given `character` is a low half of surrogate pair.
|
|
32
|
+
*
|
|
33
|
+
* Using UTF-16 terminology, a surrogate pair denotes UTF-16 character using two UTF-8 characters. The surrogate pair
|
|
34
|
+
* consist of high surrogate pair character followed by low surrogate pair character.
|
|
35
|
+
*
|
|
36
|
+
* @param character Character to check.
|
|
37
|
+
*/
|
|
38
|
+
export function isLowSurrogateHalf(character) {
|
|
39
|
+
return !!character && character.length == 1 && /[\udc00-\udfff]/.test(character);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks whether given offset in a string is inside a surrogate pair (between two surrogate halves).
|
|
43
|
+
*
|
|
44
|
+
* @param string String to check.
|
|
45
|
+
* @param offset Offset to check.
|
|
46
|
+
*/
|
|
47
|
+
export function isInsideSurrogatePair(string, offset) {
|
|
48
|
+
return isHighSurrogateHalf(string.charAt(offset - 1)) && isLowSurrogateHalf(string.charAt(offset));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether given offset in a string is between base character and combining mark or between two combining marks.
|
|
52
|
+
*
|
|
53
|
+
* @param string String to check.
|
|
54
|
+
* @param offset Offset to check.
|
|
55
|
+
*/
|
|
56
|
+
export function isInsideCombinedSymbol(string, offset) {
|
|
57
|
+
return isCombiningMark(string.charAt(offset));
|
|
58
|
+
}
|
|
59
|
+
const EMOJI_PATTERN = buildEmojiRegexp();
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether given offset in a string is inside multi-character emoji sequence.
|
|
62
|
+
*
|
|
63
|
+
* @param string String to check.
|
|
64
|
+
* @param offset Offset to check.
|
|
65
|
+
*/
|
|
66
|
+
export function isInsideEmojiSequence(string, offset) {
|
|
67
|
+
const matches = String(string).matchAll(EMOJI_PATTERN);
|
|
68
|
+
return Array.from(matches).some(match => match.index < offset && offset < match.index + match[0].length);
|
|
69
|
+
}
|
|
70
|
+
function buildEmojiRegexp() {
|
|
71
|
+
const parts = [
|
|
72
|
+
// Emoji Tag Sequence (ETS)
|
|
73
|
+
/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,
|
|
74
|
+
// Emoji Keycap Sequence
|
|
75
|
+
/\p{Emoji}\u{FE0F}?\u{20E3}/u,
|
|
76
|
+
// Emoji Presentation Sequence
|
|
77
|
+
/\p{Emoji}\u{FE0F}/u,
|
|
78
|
+
// Single-Character Emoji / Emoji Modifier Sequence
|
|
79
|
+
/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u
|
|
80
|
+
];
|
|
81
|
+
const flagSequence = /\p{Regional_Indicator}{2}/u.source;
|
|
82
|
+
const emoji = '(?:' + parts.map(part => part.source).join('|') + ')';
|
|
83
|
+
const sequence = `${flagSequence}|${emoji}(?:\u{200D}${emoji})*`;
|
|
84
|
+
return new RegExp(sequence, 'ug');
|
|
85
|
+
}
|
package/src/verifylicense.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Possible states of the key after verification.
|
|
7
|
-
*/
|
|
8
|
-
export type VerifiedKeyStatus = 'VALID' | 'INVALID';
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether the given string contains information that allows you to verify the license status.
|
|
11
|
-
*
|
|
12
|
-
* @param token The string to check.
|
|
13
|
-
* @returns String that represents the state of given `token` parameter.
|
|
14
|
-
*/
|
|
15
|
-
export default function verifyLicense(token: string | undefined): VerifiedKeyStatus;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Possible states of the key after verification.
|
|
7
|
+
*/
|
|
8
|
+
export type VerifiedKeyStatus = 'VALID' | 'INVALID';
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether the given string contains information that allows you to verify the license status.
|
|
11
|
+
*
|
|
12
|
+
* @param token The string to check.
|
|
13
|
+
* @returns String that represents the state of given `token` parameter.
|
|
14
|
+
*/
|
|
15
|
+
export default function verifyLicense(token: string | undefined): VerifiedKeyStatus;
|
package/src/verifylicense.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/verifylicense
|
|
7
|
-
*/
|
|
8
|
-
import { releaseDate } from './version';
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether the given string contains information that allows you to verify the license status.
|
|
11
|
-
*
|
|
12
|
-
* @param token The string to check.
|
|
13
|
-
* @returns String that represents the state of given `token` parameter.
|
|
14
|
-
*/
|
|
15
|
-
export default function verifyLicense(token) {
|
|
16
|
-
// This function implements naive and partial license key check mechanism,
|
|
17
|
-
// used only to decide whether to show or hide the "Powered by CKEditor" logo.
|
|
18
|
-
//
|
|
19
|
-
// You can read the reasoning behind showing the logo to unlicensed (GPL) users
|
|
20
|
-
// in this thread: https://github.com/ckeditor/ckeditor5/issues/14082.
|
|
21
|
-
//
|
|
22
|
-
// We firmly believe in the values behind creating open-source software, even when that
|
|
23
|
-
// means keeping the license verification logic open for everyone to see.
|
|
24
|
-
//
|
|
25
|
-
// Please keep this code intact. Thank you for your understanding.
|
|
26
|
-
function oldTokenCheck(token) {
|
|
27
|
-
if (token.length >= 40 && token.length <= 255) {
|
|
28
|
-
return 'VALID';
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return 'INVALID';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// TODO: issue ci#3175
|
|
35
|
-
if (!token) {
|
|
36
|
-
return 'INVALID';
|
|
37
|
-
}
|
|
38
|
-
let decryptedData = '';
|
|
39
|
-
try {
|
|
40
|
-
decryptedData = atob(token);
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
return 'INVALID';
|
|
44
|
-
}
|
|
45
|
-
const splittedDecryptedData = decryptedData.split('-');
|
|
46
|
-
const firstElement = splittedDecryptedData[0];
|
|
47
|
-
const secondElement = splittedDecryptedData[1];
|
|
48
|
-
if (!secondElement) {
|
|
49
|
-
return oldTokenCheck(token);
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
atob(secondElement);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
try {
|
|
56
|
-
atob(firstElement);
|
|
57
|
-
if (!atob(firstElement).length) {
|
|
58
|
-
return oldTokenCheck(token);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
return oldTokenCheck(token);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (firstElement.length < 40 || firstElement.length > 255) {
|
|
66
|
-
return 'INVALID';
|
|
67
|
-
}
|
|
68
|
-
let decryptedSecondElement = '';
|
|
69
|
-
try {
|
|
70
|
-
atob(firstElement);
|
|
71
|
-
decryptedSecondElement = atob(secondElement);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
return 'INVALID';
|
|
75
|
-
}
|
|
76
|
-
if (decryptedSecondElement.length !== 8) {
|
|
77
|
-
return 'INVALID';
|
|
78
|
-
}
|
|
79
|
-
const year = Number(decryptedSecondElement.substring(0, 4));
|
|
80
|
-
const monthIndex = Number(decryptedSecondElement.substring(4, 6)) - 1;
|
|
81
|
-
const day = Number(decryptedSecondElement.substring(6, 8));
|
|
82
|
-
const date = new Date(year, monthIndex, day);
|
|
83
|
-
if (date < releaseDate || isNaN(Number(date))) {
|
|
84
|
-
return 'INVALID';
|
|
85
|
-
}
|
|
86
|
-
return 'VALID';
|
|
87
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/verifylicense
|
|
7
|
+
*/
|
|
8
|
+
import { releaseDate } from './version';
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether the given string contains information that allows you to verify the license status.
|
|
11
|
+
*
|
|
12
|
+
* @param token The string to check.
|
|
13
|
+
* @returns String that represents the state of given `token` parameter.
|
|
14
|
+
*/
|
|
15
|
+
export default function verifyLicense(token) {
|
|
16
|
+
// This function implements naive and partial license key check mechanism,
|
|
17
|
+
// used only to decide whether to show or hide the "Powered by CKEditor" logo.
|
|
18
|
+
//
|
|
19
|
+
// You can read the reasoning behind showing the logo to unlicensed (GPL) users
|
|
20
|
+
// in this thread: https://github.com/ckeditor/ckeditor5/issues/14082.
|
|
21
|
+
//
|
|
22
|
+
// We firmly believe in the values behind creating open-source software, even when that
|
|
23
|
+
// means keeping the license verification logic open for everyone to see.
|
|
24
|
+
//
|
|
25
|
+
// Please keep this code intact. Thank you for your understanding.
|
|
26
|
+
function oldTokenCheck(token) {
|
|
27
|
+
if (token.length >= 40 && token.length <= 255) {
|
|
28
|
+
return 'VALID';
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return 'INVALID';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// TODO: issue ci#3175
|
|
35
|
+
if (!token) {
|
|
36
|
+
return 'INVALID';
|
|
37
|
+
}
|
|
38
|
+
let decryptedData = '';
|
|
39
|
+
try {
|
|
40
|
+
decryptedData = atob(token);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return 'INVALID';
|
|
44
|
+
}
|
|
45
|
+
const splittedDecryptedData = decryptedData.split('-');
|
|
46
|
+
const firstElement = splittedDecryptedData[0];
|
|
47
|
+
const secondElement = splittedDecryptedData[1];
|
|
48
|
+
if (!secondElement) {
|
|
49
|
+
return oldTokenCheck(token);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
atob(secondElement);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
try {
|
|
56
|
+
atob(firstElement);
|
|
57
|
+
if (!atob(firstElement).length) {
|
|
58
|
+
return oldTokenCheck(token);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return oldTokenCheck(token);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (firstElement.length < 40 || firstElement.length > 255) {
|
|
66
|
+
return 'INVALID';
|
|
67
|
+
}
|
|
68
|
+
let decryptedSecondElement = '';
|
|
69
|
+
try {
|
|
70
|
+
atob(firstElement);
|
|
71
|
+
decryptedSecondElement = atob(secondElement);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return 'INVALID';
|
|
75
|
+
}
|
|
76
|
+
if (decryptedSecondElement.length !== 8) {
|
|
77
|
+
return 'INVALID';
|
|
78
|
+
}
|
|
79
|
+
const year = Number(decryptedSecondElement.substring(0, 4));
|
|
80
|
+
const monthIndex = Number(decryptedSecondElement.substring(4, 6)) - 1;
|
|
81
|
+
const day = Number(decryptedSecondElement.substring(6, 8));
|
|
82
|
+
const date = new Date(year, monthIndex, day);
|
|
83
|
+
if (date < releaseDate || isNaN(Number(date))) {
|
|
84
|
+
return 'INVALID';
|
|
85
|
+
}
|
|
86
|
+
return 'VALID';
|
|
87
|
+
}
|
package/src/version.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
declare const version = "40.
|
|
6
|
-
export default version;
|
|
7
|
-
export declare const releaseDate: Date;
|
|
8
|
-
declare global {
|
|
9
|
-
var CKEDITOR_VERSION: string;
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
declare const version = "40.2.0";
|
|
6
|
+
export default version;
|
|
7
|
+
export declare const releaseDate: Date;
|
|
8
|
+
declare global {
|
|
9
|
+
var CKEDITOR_VERSION: string;
|
|
10
|
+
}
|