@ckeditor/ckeditor5-adapter-ckfinder 0.0.0-internal-20241017.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 ADDED
@@ -0,0 +1,4 @@
1
+ Changelog
2
+ =========
3
+
4
+ All changes in the package are documented in https://github.com/ckeditor/ckeditor5/blob/master/CHANGELOG.md.
package/LICENSE.md ADDED
@@ -0,0 +1,17 @@
1
+ Software License Agreement
2
+ ==========================
3
+
4
+ **CKEditor&nbsp;5 CKFinder adapter** – https://github.com/ckeditor/ckeditor5-adapter-ckfinder <br>
5
+ Copyright (c) 2003–2024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
+
7
+ Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
+
9
+ Sources of Intellectual Property Included in CKEditor
10
+ -----------------------------------------------------
11
+
12
+ Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
13
+
14
+ Trademarks
15
+ ----------
16
+
17
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ CKEditor&nbsp;5 CKFinder adapter
2
+ ========================================
3
+
4
+ [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-adapter-ckfinder.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-adapter-ckfinder)
5
+ [![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
6
+ [![Build Status](https://travis-ci.com/ckeditor/ckeditor5.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5)
7
+
8
+ This package implements a CKEditor&nbsp;5 upload adapter compatible with the [CKFinder file manager and uploader](https://ckeditor.com/ckfinder/)'s server–side connector.
9
+
10
+ ## Documentation
11
+
12
+ See the ["CKFinder integration" guide](https://ckeditor.com/docs/ckeditor5/latest/features/ckfinder.html) and the [plugin documentation](https://ckeditor.com/docs/ckeditor5/latest/api/adapter-ckfinder.html) to learn how to configure the adapter.
13
+
14
+ Check out the {@link features/image-upload/image-upload comprehensive "Image upload overview"} to learn about other ways to upload images into CKEditor&nbsp;5.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install ckeditor5
20
+ ```
21
+
22
+ ## License
23
+
24
+ Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */(()=>{var e={782:(e,t,r)=>{e.exports=r(237)("./src/core.js")},260:(e,t,r)=>{e.exports=r(237)("./src/upload.js")},237:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{CKFinderUploadAdapter:()=>a});var e=r(782),t=r(260);const n="ckCsrfToken",s="abcdefghijklmnopqrstuvwxyz0123456789";function i(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const r of t){const t=r.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(n);var t,r;return e&&40==e.length||(e=function(e){let t="";const r=new Uint8Array(e);window.crypto.getRandomValues(r);for(let e=0;e<r.length;e++){const o=s.charAt(r[e]%36);t+=Math.random()>.5?o.toUpperCase():o}return t}(40),t=n,r=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(r)+";path=/"),e}class a extends e.Plugin{static get requires(){return[t.FileRepository]}static get pluginName(){return"CKFinderUploadAdapter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(t.FileRepository).createUploadAdapter=t=>new d(t,e,this.editor.t))}}class d{constructor(e,t,r){this.loader=e,this.url=t,this.t=r}upload(){return this.loader.file.then((e=>new Promise(((t,r)=>{this._initRequest(),this._initListeners(t,r,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,r){const o=this.xhr,n=this.loader,s=(0,this.t)("Cannot upload file:")+` ${r.name}.`;o.addEventListener("error",(()=>t(s))),o.addEventListener("abort",(()=>t())),o.addEventListener("load",(()=>{const r=o.response;if(!r||!r.uploaded)return t(r&&r.error&&r.error.message?r.error.message:s);e({default:r.url})})),o.upload&&o.upload.addEventListener("progress",(e=>{e.lengthComputable&&(n.uploadTotal=e.total,n.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",i()),this.xhr.send(t)}}})(),(window.CKEditor5=window.CKEditor5||{}).adapterCkfinder=o})();
@@ -0,0 +1,11 @@
1
+ {
2
+ "plugins": [
3
+ {
4
+ "name": "CKFinder upload adapter",
5
+ "className": "CKFinderUploadAdapter",
6
+ "path": "src/uploadadapter.js",
7
+ "description": "Implements the CKEditor 5 upload adapter compatible with the CKFinder file manager and uploader's server–side connector.",
8
+ "docs": "features/images/image-upload/image-upload.html#ckfinder"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import type { CKFinderUploadAdapter } from './index.js';
10
+ declare module '@ckeditor/ckeditor5-core' {
11
+ interface PluginsMap {
12
+ [CKFinderUploadAdapter.pluginName]: CKFinderUploadAdapter;
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
package/dist/index.css ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module adapter-ckfinder
11
+ */
12
+ export { default as CKFinderUploadAdapter } from './uploadadapter.js';
13
+ import './augmentation.js';
package/dist/index.js ADDED
@@ -0,0 +1,194 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
6
+ import { FileRepository } from '@ckeditor/ckeditor5-upload/dist/index.js';
7
+
8
+ /**
9
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
10
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
11
+ */ /* globals window, document */ /**
12
+ * @module adapter-ckfinder/utils
13
+ */ const TOKEN_COOKIE_NAME = 'ckCsrfToken';
14
+ const TOKEN_LENGTH = 40;
15
+ const tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';
16
+ /**
17
+ * Returns the CSRF token value. The value is a hash stored in `document.cookie`
18
+ * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
19
+ * between the web browser and the CKFinder server.
20
+ */ function getCsrfToken() {
21
+ let token = getCookie(TOKEN_COOKIE_NAME);
22
+ if (!token || token.length != TOKEN_LENGTH) {
23
+ token = generateToken(TOKEN_LENGTH);
24
+ setCookie(TOKEN_COOKIE_NAME, token);
25
+ }
26
+ return token;
27
+ }
28
+ /**
29
+ * Returns the value of the cookie with a given name or `null` if the cookie is not found.
30
+ */ function getCookie(name) {
31
+ name = name.toLowerCase();
32
+ const parts = document.cookie.split(';');
33
+ for (const part of parts){
34
+ const pair = part.split('=');
35
+ const key = decodeURIComponent(pair[0].trim().toLowerCase());
36
+ if (key === name) {
37
+ return decodeURIComponent(pair[1]);
38
+ }
39
+ }
40
+ return null;
41
+ }
42
+ /**
43
+ * Sets the value of the cookie with a given name.
44
+ */ function setCookie(name, value) {
45
+ document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';path=/';
46
+ }
47
+ /**
48
+ * Generates the CSRF token with the given length.
49
+ */ function generateToken(length) {
50
+ let result = '';
51
+ const randValues = new Uint8Array(length);
52
+ window.crypto.getRandomValues(randValues);
53
+ for(let j = 0; j < randValues.length; j++){
54
+ const character = tokenCharset.charAt(randValues[j] % tokenCharset.length);
55
+ result += Math.random() > 0.5 ? character.toUpperCase() : character;
56
+ }
57
+ return result;
58
+ }
59
+
60
+ /**
61
+ * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
62
+ *
63
+ * See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
64
+ * and use this feature as well as find out more about the full integration with the file manager
65
+ * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
66
+ *
67
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
68
+ * about other ways to upload images into CKEditor 5.
69
+ */ class CKFinderUploadAdapter extends Plugin {
70
+ /**
71
+ * @inheritDoc
72
+ */ static get requires() {
73
+ return [
74
+ FileRepository
75
+ ];
76
+ }
77
+ /**
78
+ * @inheritDoc
79
+ */ static get pluginName() {
80
+ return 'CKFinderUploadAdapter';
81
+ }
82
+ /**
83
+ * @inheritDoc
84
+ */ static get isOfficialPlugin() {
85
+ return true;
86
+ }
87
+ /**
88
+ * @inheritDoc
89
+ */ init() {
90
+ const url = this.editor.config.get('ckfinder.uploadUrl');
91
+ if (!url) {
92
+ return;
93
+ }
94
+ // Register CKFinderAdapter
95
+ this.editor.plugins.get(FileRepository).createUploadAdapter = (loader)=>new UploadAdapter(loader, url, this.editor.t);
96
+ }
97
+ }
98
+ /**
99
+ * Upload adapter for CKFinder.
100
+ */ class UploadAdapter {
101
+ /**
102
+ * FileLoader instance to use during the upload.
103
+ */ loader;
104
+ /**
105
+ * Upload URL.
106
+ */ url;
107
+ /**
108
+ * Locale translation method.
109
+ */ t;
110
+ xhr;
111
+ /**
112
+ * Creates a new adapter instance.
113
+ */ constructor(loader, url, t){
114
+ this.loader = loader;
115
+ this.url = url;
116
+ this.t = t;
117
+ }
118
+ /**
119
+ * Starts the upload process.
120
+ *
121
+ * @see module:upload/filerepository~UploadAdapter#upload
122
+ */ upload() {
123
+ return this.loader.file.then((file)=>{
124
+ return new Promise((resolve, reject)=>{
125
+ this._initRequest();
126
+ this._initListeners(resolve, reject, file);
127
+ this._sendRequest(file);
128
+ });
129
+ });
130
+ }
131
+ /**
132
+ * Aborts the upload process.
133
+ *
134
+ * @see module:upload/filerepository~UploadAdapter#abort
135
+ */ abort() {
136
+ if (this.xhr) {
137
+ this.xhr.abort();
138
+ }
139
+ }
140
+ /**
141
+ * Initializes the XMLHttpRequest object.
142
+ */ _initRequest() {
143
+ const xhr = this.xhr = new XMLHttpRequest();
144
+ xhr.open('POST', this.url, true);
145
+ xhr.responseType = 'json';
146
+ }
147
+ /**
148
+ * Initializes XMLHttpRequest listeners.
149
+ *
150
+ * @param resolve Callback function to be called when the request is successful.
151
+ * @param reject Callback function to be called when the request cannot be completed.
152
+ * @param file File instance to be uploaded.
153
+ */ _initListeners(resolve, reject, file) {
154
+ const xhr = this.xhr;
155
+ const loader = this.loader;
156
+ const t = this.t;
157
+ const genericError = t('Cannot upload file:') + ` ${file.name}.`;
158
+ xhr.addEventListener('error', ()=>reject(genericError));
159
+ xhr.addEventListener('abort', ()=>reject());
160
+ xhr.addEventListener('load', ()=>{
161
+ const response = xhr.response;
162
+ if (!response || !response.uploaded) {
163
+ return reject(response && response.error && response.error.message ? response.error.message : genericError);
164
+ }
165
+ resolve({
166
+ default: response.url
167
+ });
168
+ });
169
+ // Upload progress when it's supported.
170
+ /* istanbul ignore else -- @preserve */ if (xhr.upload) {
171
+ xhr.upload.addEventListener('progress', (evt)=>{
172
+ if (evt.lengthComputable) {
173
+ loader.uploadTotal = evt.total;
174
+ loader.uploaded = evt.loaded;
175
+ }
176
+ });
177
+ }
178
+ }
179
+ /**
180
+ * Prepares the data and sends the request.
181
+ *
182
+ * @param file File instance to be uploaded.
183
+ */ _sendRequest(file) {
184
+ // Prepare form data.
185
+ const data = new FormData();
186
+ data.append('upload', file);
187
+ data.append('ckCsrfToken', getCsrfToken());
188
+ // Send request.
189
+ this.xhr.send(data);
190
+ }
191
+ }
192
+
193
+ export { CKFinderUploadAdapter };
194
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js","../src/utils.ts","../src/uploadadapter.ts"],"names":["TOKEN_COOKIE_NAME","TOKEN_LENGTH","tokenCharset","getCsrfToken","token","getCookie","length","generateToken","setCookie","name","toLowerCase","parts","document","cookie","split","part","pair","key","decodeURIComponent","trim","value","encodeURIComponent","result","randValues","Uint8Array","window","crypto","getRandomValues","j","character","charAt","Math","random","toUpperCase","CKFinderUploadAdapter","Plugin","requires","FileRepository","pluginName","isOfficialPlugin","url","editor","config","get","plugins","createUploadAdapter","loader","UploadAdapter","t","xhr","constructor","file","then","Promise","resolve","reject","_initRequest","_initListeners","_sendRequest","abort","XMLHttpRequest","open","responseType","genericError","addEventListener","response","uploaded","error","message","default","upload","evt","lengthComputable","uploadTotal","total","loaded","data","FormData","append","send"],"mappings":";;;;AAAA,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;AAC/D,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;;ACDzE,CAAA,CAAA;ADIA,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ;AACpF,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAI,CAAC8C,GAAG,CAAE8B,IAAI,CAAEH,IAAAA,CAAAA;AACjB,CAAA,CAAA,CAAA,CAAA;AACD;;AFJA,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC","file":"index.js.map","sourcesContent":["import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';\nimport { FileRepository } from '@ckeditor/ckeditor5-upload/dist/index.js';\n\n/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */ /* globals window, document */ /**\n * @module adapter-ckfinder/utils\n */ const TOKEN_COOKIE_NAME = 'ckCsrfToken';\nconst TOKEN_LENGTH = 40;\nconst tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';\n/**\n * Returns the CSRF token value. The value is a hash stored in `document.cookie`\n * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication\n * between the web browser and the CKFinder server.\n */ function getCsrfToken() {\n let token = getCookie(TOKEN_COOKIE_NAME);\n if (!token || token.length != TOKEN_LENGTH) {\n token = generateToken(TOKEN_LENGTH);\n setCookie(TOKEN_COOKIE_NAME, token);\n }\n return token;\n}\n/**\n * Returns the value of the cookie with a given name or `null` if the cookie is not found.\n */ function getCookie(name) {\n name = name.toLowerCase();\n const parts = document.cookie.split(';');\n for (const part of parts){\n const pair = part.split('=');\n const key = decodeURIComponent(pair[0].trim().toLowerCase());\n if (key === name) {\n return decodeURIComponent(pair[1]);\n }\n }\n return null;\n}\n/**\n * Sets the value of the cookie with a given name.\n */ function setCookie(name, value) {\n document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';path=/';\n}\n/**\n * Generates the CSRF token with the given length.\n */ function generateToken(length) {\n let result = '';\n const randValues = new Uint8Array(length);\n window.crypto.getRandomValues(randValues);\n for(let j = 0; j < randValues.length; j++){\n const character = tokenCharset.charAt(randValues[j] % tokenCharset.length);\n result += Math.random() > 0.5 ? character.toUpperCase() : character;\n }\n return result;\n}\n\n/**\n * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.\n *\n * See the {@glink features/file-management/ckfinder \"CKFinder file manager integration\"} guide to learn how to configure\n * and use this feature as well as find out more about the full integration with the file manager\n * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.\n *\n * Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} guide to learn\n * about other ways to upload images into CKEditor 5.\n */ class CKFinderUploadAdapter extends Plugin {\n /**\n\t * @inheritDoc\n\t */ static get requires() {\n return [\n FileRepository\n ];\n }\n /**\n\t * @inheritDoc\n\t */ static get pluginName() {\n return 'CKFinderUploadAdapter';\n }\n /**\n\t * @inheritDoc\n\t */ static get isOfficialPlugin() {\n return true;\n }\n /**\n\t * @inheritDoc\n\t */ init() {\n const url = this.editor.config.get('ckfinder.uploadUrl');\n if (!url) {\n return;\n }\n // Register CKFinderAdapter\n this.editor.plugins.get(FileRepository).createUploadAdapter = (loader)=>new UploadAdapter(loader, url, this.editor.t);\n }\n}\n/**\n * Upload adapter for CKFinder.\n */ class UploadAdapter {\n /**\n\t * FileLoader instance to use during the upload.\n\t */ loader;\n /**\n\t * Upload URL.\n\t */ url;\n /**\n\t * Locale translation method.\n\t */ t;\n xhr;\n /**\n\t * Creates a new adapter instance.\n\t */ constructor(loader, url, t){\n this.loader = loader;\n this.url = url;\n this.t = t;\n }\n /**\n\t * Starts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#upload\n\t */ upload() {\n return this.loader.file.then((file)=>{\n return new Promise((resolve, reject)=>{\n this._initRequest();\n this._initListeners(resolve, reject, file);\n this._sendRequest(file);\n });\n });\n }\n /**\n\t * Aborts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#abort\n\t */ abort() {\n if (this.xhr) {\n this.xhr.abort();\n }\n }\n /**\n\t * Initializes the XMLHttpRequest object.\n\t */ _initRequest() {\n const xhr = this.xhr = new XMLHttpRequest();\n xhr.open('POST', this.url, true);\n xhr.responseType = 'json';\n }\n /**\n\t * Initializes XMLHttpRequest listeners.\n\t *\n\t * @param resolve Callback function to be called when the request is successful.\n\t * @param reject Callback function to be called when the request cannot be completed.\n\t * @param file File instance to be uploaded.\n\t */ _initListeners(resolve, reject, file) {\n const xhr = this.xhr;\n const loader = this.loader;\n const t = this.t;\n const genericError = t('Cannot upload file:') + ` ${file.name}.`;\n xhr.addEventListener('error', ()=>reject(genericError));\n xhr.addEventListener('abort', ()=>reject());\n xhr.addEventListener('load', ()=>{\n const response = xhr.response;\n if (!response || !response.uploaded) {\n return reject(response && response.error && response.error.message ? response.error.message : genericError);\n }\n resolve({\n default: response.url\n });\n });\n // Upload progress when it's supported.\n /* istanbul ignore else -- @preserve */ if (xhr.upload) {\n xhr.upload.addEventListener('progress', (evt)=>{\n if (evt.lengthComputable) {\n loader.uploadTotal = evt.total;\n loader.uploaded = evt.loaded;\n }\n });\n }\n }\n /**\n\t * Prepares the data and sends the request.\n\t *\n\t * @param file File instance to be uploaded.\n\t */ _sendRequest(file) {\n // Prepare form data.\n const data = new FormData();\n data.append('upload', file);\n data.append('ckCsrfToken', getCsrfToken());\n // Send request.\n this.xhr.send(data);\n }\n}\n\nexport { CKFinderUploadAdapter };\n//# sourceMappingURL=index.js.map\n","/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* globals window, document */\n\n/**\n * @module adapter-ckfinder/utils\n */\n\nconst TOKEN_COOKIE_NAME = 'ckCsrfToken';\nconst TOKEN_LENGTH = 40;\nconst tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';\n\n/**\n * Returns the CSRF token value. The value is a hash stored in `document.cookie`\n * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication\n * between the web browser and the CKFinder server.\n */\nexport function getCsrfToken(): string {\n\tlet token = getCookie( TOKEN_COOKIE_NAME );\n\n\tif ( !token || token.length != TOKEN_LENGTH ) {\n\t\ttoken = generateToken( TOKEN_LENGTH );\n\t\tsetCookie( TOKEN_COOKIE_NAME, token );\n\t}\n\n\treturn token;\n}\n\n/**\n * Returns the value of the cookie with a given name or `null` if the cookie is not found.\n */\nexport function getCookie( name: string ): string | null {\n\tname = name.toLowerCase();\n\tconst parts = document.cookie.split( ';' );\n\n\tfor ( const part of parts ) {\n\t\tconst pair = part.split( '=' );\n\t\tconst key = decodeURIComponent( pair[ 0 ].trim().toLowerCase() );\n\n\t\tif ( key === name ) {\n\t\t\treturn decodeURIComponent( pair[ 1 ] );\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Sets the value of the cookie with a given name.\n */\nexport function setCookie( name: string, value: string ): void {\n\tdocument.cookie = encodeURIComponent( name ) + '=' + encodeURIComponent( value ) + ';path=/';\n}\n\n/**\n * Generates the CSRF token with the given length.\n */\nfunction generateToken( length: number ): string {\n\tlet result = '';\n\tconst randValues = new Uint8Array( length );\n\n\twindow.crypto.getRandomValues( randValues );\n\n\tfor ( let j = 0; j < randValues.length; j++ ) {\n\t\tconst character = tokenCharset.charAt( randValues[ j ] % tokenCharset.length );\n\t\tresult += Math.random() > 0.5 ? character.toUpperCase() : character;\n\t}\n\n\treturn result;\n}\n","/**\n * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/* globals XMLHttpRequest, FormData */\n\n/**\n * @module adapter-ckfinder/uploadadapter\n */\n\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport {\n\tFileRepository,\n\ttype UploadAdapter as UploadAdapterInterface,\n\ttype FileLoader,\n\ttype UploadResponse\n} from 'ckeditor5/src/upload.js';\nimport type { LocaleTranslate } from 'ckeditor5/src/utils.js';\n\nimport { getCsrfToken } from './utils.js';\n\n/**\n * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.\n *\n * See the {@glink features/file-management/ckfinder \"CKFinder file manager integration\"} guide to learn how to configure\n * and use this feature as well as find out more about the full integration with the file manager\n * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.\n *\n * Check out the {@glink features/images/image-upload/image-upload comprehensive \"Image upload overview\"} guide to learn\n * about other ways to upload images into CKEditor 5.\n */\nexport default class CKFinderUploadAdapter extends Plugin {\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get requires() {\n\t\treturn [ FileRepository ] as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static get pluginName() {\n\t\treturn 'CKFinderUploadAdapter' as const;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic static override get isOfficialPlugin(): true {\n\t\treturn true;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tpublic init(): void {\n\t\tconst url = this.editor.config.get( 'ckfinder.uploadUrl' )! as string;\n\n\t\tif ( !url ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Register CKFinderAdapter\n\t\tthis.editor.plugins.get( FileRepository ).createUploadAdapter = loader => new UploadAdapter( loader, url, this.editor.t );\n\t}\n}\n\n/**\n * Upload adapter for CKFinder.\n */\nclass UploadAdapter implements UploadAdapterInterface {\n\t/**\n\t * FileLoader instance to use during the upload.\n\t */\n\tpublic loader: FileLoader;\n\n\t/**\n\t * Upload URL.\n\t */\n\tpublic url: string;\n\n\t/**\n\t * Locale translation method.\n\t */\n\tpublic t: LocaleTranslate;\n\n\tprivate xhr?: XMLHttpRequest;\n\n\t/**\n\t * Creates a new adapter instance.\n\t */\n\tconstructor( loader: FileLoader, url: string, t: LocaleTranslate ) {\n\t\tthis.loader = loader;\n\t\tthis.url = url;\n\t\tthis.t = t;\n\t}\n\n\t/**\n\t * Starts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#upload\n\t */\n\tpublic upload() {\n\t\treturn this.loader.file.then( file => {\n\t\t\treturn new Promise<UploadResponse>( ( resolve, reject ) => {\n\t\t\t\tthis._initRequest();\n\t\t\t\tthis._initListeners( resolve, reject, file! );\n\t\t\t\tthis._sendRequest( file! );\n\t\t\t} );\n\t\t} );\n\t}\n\n\t/**\n\t * Aborts the upload process.\n\t *\n\t * @see module:upload/filerepository~UploadAdapter#abort\n\t */\n\tpublic abort() {\n\t\tif ( this.xhr ) {\n\t\t\tthis.xhr.abort();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the XMLHttpRequest object.\n\t */\n\tprivate _initRequest() {\n\t\tconst xhr = this.xhr = new XMLHttpRequest();\n\n\t\txhr.open( 'POST', this.url, true );\n\t\txhr.responseType = 'json';\n\t}\n\n\t/**\n\t * Initializes XMLHttpRequest listeners.\n\t *\n\t * @param resolve Callback function to be called when the request is successful.\n\t * @param reject Callback function to be called when the request cannot be completed.\n\t * @param file File instance to be uploaded.\n\t */\n\tprivate _initListeners(\n\t\tresolve: ( value: UploadResponse ) => void,\n\t\treject: ( reason?: unknown ) => void,\n\t\tfile: File\n\t) {\n\t\tconst xhr = this.xhr!;\n\t\tconst loader = this.loader;\n\t\tconst t = this.t;\n\t\tconst genericError = t( 'Cannot upload file:' ) + ` ${ file.name }.`;\n\n\t\txhr.addEventListener( 'error', () => reject( genericError ) );\n\t\txhr.addEventListener( 'abort', () => reject() );\n\t\txhr.addEventListener( 'load', () => {\n\t\t\tconst response = xhr.response;\n\n\t\t\tif ( !response || !response.uploaded ) {\n\t\t\t\treturn reject( response && response.error && response.error.message ? response.error.message : genericError );\n\t\t\t}\n\n\t\t\tresolve( {\n\t\t\t\tdefault: response.url\n\t\t\t} );\n\t\t} );\n\n\t\t// Upload progress when it's supported.\n\t\t/* istanbul ignore else -- @preserve */\n\t\tif ( xhr.upload ) {\n\t\t\txhr.upload.addEventListener( 'progress', evt => {\n\t\t\t\tif ( evt.lengthComputable ) {\n\t\t\t\t\tloader.uploadTotal = evt.total;\n\t\t\t\t\tloader.uploaded = evt.loaded;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Prepares the data and sends the request.\n\t *\n\t * @param file File instance to be uploaded.\n\t */\n\tprivate _sendRequest( file: File ) {\n\t\t// Prepare form data.\n\t\tconst data = new FormData();\n\t\tdata.append( 'upload', file );\n\t\tdata.append( 'ckCsrfToken', getCsrfToken() );\n\n\t\t// Send request.\n\t\tthis.xhr!.send( data );\n\t}\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module adapter-ckfinder/uploadadapter
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import { FileRepository } from 'ckeditor5/src/upload.js';
14
+ /**
15
+ * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
16
+ *
17
+ * See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
18
+ * and use this feature as well as find out more about the full integration with the file manager
19
+ * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
20
+ *
21
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
22
+ * about other ways to upload images into CKEditor 5.
23
+ */
24
+ export default class CKFinderUploadAdapter extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get requires(): readonly [typeof FileRepository];
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get pluginName(): "CKFinderUploadAdapter";
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get isOfficialPlugin(): true;
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ init(): void;
41
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * Returns the CSRF token value. The value is a hash stored in `document.cookie`
11
+ * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
12
+ * between the web browser and the CKFinder server.
13
+ */
14
+ export declare function getCsrfToken(): string;
15
+ /**
16
+ * Returns the value of the cookie with a given name or `null` if the cookie is not found.
17
+ */
18
+ export declare function getCookie(name: string): string | null;
19
+ /**
20
+ * Sets the value of the cookie with a given name.
21
+ */
22
+ export declare function setCookie(name: string, value: string): void;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@ckeditor/ckeditor5-adapter-ckfinder",
3
+ "version": "0.0.0-internal-20241017.0",
4
+ "description": "CKFinder adapter for CKEditor 5.",
5
+ "keywords": [
6
+ "ckeditor",
7
+ "ckeditor5",
8
+ "ckeditor 5",
9
+ "ckeditor5-feature",
10
+ "ckeditor5-plugin",
11
+ "ckeditor5-dll"
12
+ ],
13
+ "type": "module",
14
+ "main": "src/index.js",
15
+ "dependencies": {
16
+ "@ckeditor/ckeditor5-core": "0.0.0-internal-20241017.0",
17
+ "@ckeditor/ckeditor5-upload": "0.0.0-internal-20241017.0",
18
+ "ckeditor5": "0.0.0-internal-20241017.0"
19
+ },
20
+ "author": "CKSource (http://cksource.com/)",
21
+ "license": "GPL-2.0-or-later",
22
+ "homepage": "https://ckeditor.com/ckeditor-5",
23
+ "bugs": "https://github.com/ckeditor/ckeditor5/issues",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/ckeditor/ckeditor5.git",
27
+ "directory": "packages/ckeditor5-adapter-ckfinder"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "lang",
32
+ "src/**/*.js",
33
+ "src/**/*.d.ts",
34
+ "theme",
35
+ "build",
36
+ "ckeditor5-metadata.json",
37
+ "CHANGELOG.md"
38
+ ],
39
+ "types": "src/index.d.ts"
40
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ import type { CKFinderUploadAdapter } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface PluginsMap {
8
+ [CKFinderUploadAdapter.pluginName]: CKFinderUploadAdapter;
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ export {};
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 adapter-ckfinder
7
+ */
8
+ export { default as CKFinderUploadAdapter } from './uploadadapter.js';
9
+ import './augmentation.js';
package/src/index.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 adapter-ckfinder
7
+ */
8
+ export { default as CKFinderUploadAdapter } from './uploadadapter.js';
9
+ import './augmentation.js';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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 adapter-ckfinder/uploadadapter
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import { FileRepository } from 'ckeditor5/src/upload.js';
10
+ /**
11
+ * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
12
+ *
13
+ * See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
14
+ * and use this feature as well as find out more about the full integration with the file manager
15
+ * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
16
+ *
17
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
18
+ * about other ways to upload images into CKEditor 5.
19
+ */
20
+ export default class CKFinderUploadAdapter extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires(): readonly [typeof FileRepository];
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName(): "CKFinderUploadAdapter";
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get isOfficialPlugin(): true;
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init(): void;
37
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /* globals XMLHttpRequest, FormData */
6
+ /**
7
+ * @module adapter-ckfinder/uploadadapter
8
+ */
9
+ import { Plugin } from 'ckeditor5/src/core.js';
10
+ import { FileRepository } from 'ckeditor5/src/upload.js';
11
+ import { getCsrfToken } from './utils.js';
12
+ /**
13
+ * A plugin that enables file uploads in CKEditor 5 using the CKFinder server–side connector.
14
+ *
15
+ * See the {@glink features/file-management/ckfinder "CKFinder file manager integration"} guide to learn how to configure
16
+ * and use this feature as well as find out more about the full integration with the file manager
17
+ * provided by the {@link module:ckfinder/ckfinder~CKFinder} plugin.
18
+ *
19
+ * Check out the {@glink features/images/image-upload/image-upload comprehensive "Image upload overview"} guide to learn
20
+ * about other ways to upload images into CKEditor 5.
21
+ */
22
+ export default class CKFinderUploadAdapter extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires() {
27
+ return [FileRepository];
28
+ }
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get pluginName() {
33
+ return 'CKFinderUploadAdapter';
34
+ }
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ static get isOfficialPlugin() {
39
+ return true;
40
+ }
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ init() {
45
+ const url = this.editor.config.get('ckfinder.uploadUrl');
46
+ if (!url) {
47
+ return;
48
+ }
49
+ // Register CKFinderAdapter
50
+ this.editor.plugins.get(FileRepository).createUploadAdapter = loader => new UploadAdapter(loader, url, this.editor.t);
51
+ }
52
+ }
53
+ /**
54
+ * Upload adapter for CKFinder.
55
+ */
56
+ class UploadAdapter {
57
+ /**
58
+ * Creates a new adapter instance.
59
+ */
60
+ constructor(loader, url, t) {
61
+ this.loader = loader;
62
+ this.url = url;
63
+ this.t = t;
64
+ }
65
+ /**
66
+ * Starts the upload process.
67
+ *
68
+ * @see module:upload/filerepository~UploadAdapter#upload
69
+ */
70
+ upload() {
71
+ return this.loader.file.then(file => {
72
+ return new Promise((resolve, reject) => {
73
+ this._initRequest();
74
+ this._initListeners(resolve, reject, file);
75
+ this._sendRequest(file);
76
+ });
77
+ });
78
+ }
79
+ /**
80
+ * Aborts the upload process.
81
+ *
82
+ * @see module:upload/filerepository~UploadAdapter#abort
83
+ */
84
+ abort() {
85
+ if (this.xhr) {
86
+ this.xhr.abort();
87
+ }
88
+ }
89
+ /**
90
+ * Initializes the XMLHttpRequest object.
91
+ */
92
+ _initRequest() {
93
+ const xhr = this.xhr = new XMLHttpRequest();
94
+ xhr.open('POST', this.url, true);
95
+ xhr.responseType = 'json';
96
+ }
97
+ /**
98
+ * Initializes XMLHttpRequest listeners.
99
+ *
100
+ * @param resolve Callback function to be called when the request is successful.
101
+ * @param reject Callback function to be called when the request cannot be completed.
102
+ * @param file File instance to be uploaded.
103
+ */
104
+ _initListeners(resolve, reject, file) {
105
+ const xhr = this.xhr;
106
+ const loader = this.loader;
107
+ const t = this.t;
108
+ const genericError = t('Cannot upload file:') + ` ${file.name}.`;
109
+ xhr.addEventListener('error', () => reject(genericError));
110
+ xhr.addEventListener('abort', () => reject());
111
+ xhr.addEventListener('load', () => {
112
+ const response = xhr.response;
113
+ if (!response || !response.uploaded) {
114
+ return reject(response && response.error && response.error.message ? response.error.message : genericError);
115
+ }
116
+ resolve({
117
+ default: response.url
118
+ });
119
+ });
120
+ // Upload progress when it's supported.
121
+ /* istanbul ignore else -- @preserve */
122
+ if (xhr.upload) {
123
+ xhr.upload.addEventListener('progress', evt => {
124
+ if (evt.lengthComputable) {
125
+ loader.uploadTotal = evt.total;
126
+ loader.uploaded = evt.loaded;
127
+ }
128
+ });
129
+ }
130
+ }
131
+ /**
132
+ * Prepares the data and sends the request.
133
+ *
134
+ * @param file File instance to be uploaded.
135
+ */
136
+ _sendRequest(file) {
137
+ // Prepare form data.
138
+ const data = new FormData();
139
+ data.append('upload', file);
140
+ data.append('ckCsrfToken', getCsrfToken());
141
+ // Send request.
142
+ this.xhr.send(data);
143
+ }
144
+ }
package/src/utils.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ * Returns the CSRF token value. The value is a hash stored in `document.cookie`
7
+ * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
8
+ * between the web browser and the CKFinder server.
9
+ */
10
+ export declare function getCsrfToken(): string;
11
+ /**
12
+ * Returns the value of the cookie with a given name or `null` if the cookie is not found.
13
+ */
14
+ export declare function getCookie(name: string): string | null;
15
+ /**
16
+ * Sets the value of the cookie with a given name.
17
+ */
18
+ export declare function setCookie(name: string, value: string): void;
package/src/utils.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ /* globals window, document */
6
+ /**
7
+ * @module adapter-ckfinder/utils
8
+ */
9
+ const TOKEN_COOKIE_NAME = 'ckCsrfToken';
10
+ const TOKEN_LENGTH = 40;
11
+ const tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';
12
+ /**
13
+ * Returns the CSRF token value. The value is a hash stored in `document.cookie`
14
+ * under the `ckCsrfToken` key. The CSRF token can be used to secure the communication
15
+ * between the web browser and the CKFinder server.
16
+ */
17
+ export function getCsrfToken() {
18
+ let token = getCookie(TOKEN_COOKIE_NAME);
19
+ if (!token || token.length != TOKEN_LENGTH) {
20
+ token = generateToken(TOKEN_LENGTH);
21
+ setCookie(TOKEN_COOKIE_NAME, token);
22
+ }
23
+ return token;
24
+ }
25
+ /**
26
+ * Returns the value of the cookie with a given name or `null` if the cookie is not found.
27
+ */
28
+ export function getCookie(name) {
29
+ name = name.toLowerCase();
30
+ const parts = document.cookie.split(';');
31
+ for (const part of parts) {
32
+ const pair = part.split('=');
33
+ const key = decodeURIComponent(pair[0].trim().toLowerCase());
34
+ if (key === name) {
35
+ return decodeURIComponent(pair[1]);
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ /**
41
+ * Sets the value of the cookie with a given name.
42
+ */
43
+ export function setCookie(name, value) {
44
+ document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';path=/';
45
+ }
46
+ /**
47
+ * Generates the CSRF token with the given length.
48
+ */
49
+ function generateToken(length) {
50
+ let result = '';
51
+ const randValues = new Uint8Array(length);
52
+ window.crypto.getRandomValues(randValues);
53
+ for (let j = 0; j < randValues.length; j++) {
54
+ const character = tokenCharset.charAt(randValues[j] % tokenCharset.length);
55
+ result += Math.random() > 0.5 ? character.toUpperCase() : character;
56
+ }
57
+ return result;
58
+ }